vk loader rework

This commit is contained in:
maik klein 2016-11-28 21:16:35 +01:00
parent f7e53f97f5
commit 170aa92a03
14 changed files with 435 additions and 950 deletions

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View file

@ -1,3 +0,0 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ClientPropertiesManager">
<properties class="javax.swing.AbstractButton">
<property name="hideActionText" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JComponent">
<property name="html.disable" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JEditorPane">
<property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
<property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
<property name="charset" class="java.lang.String" />
</properties>
<properties class="javax.swing.JList">
<property name="List.isFileList" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JPasswordField">
<property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JSlider">
<property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
<property name="JSlider.isFilled" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTable">
<property name="Table.isFileList" class="java.lang.Boolean" />
<property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
<property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JToolBar">
<property name="JToolBar.isRollover" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTree">
<property name="JTree.lineStyle" class="java.lang.String" />
</properties>
<properties class="javax.swing.text.JTextComponent">
<property name="caretAspectRatio" class="java.lang.Double" />
<property name="caretWidth" class="java.lang.Integer" />
</properties>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" default="true" assert-keyword="false" jdk-15="false" />
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ashlib.iml" filepath="$PROJECT_DIR$/.idea/ashlib.iml" />
</modules>
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,499 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="3bfba5c3-3712-4c12-bd49-0c72a2c4b6a5" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/Cargo.lock" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/Cargo.toml" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ash/src/device.rs" afterPath="$PROJECT_DIR$/ash/src/device.rs" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ash/src/feature.rs" afterPath="$PROJECT_DIR$/ash/src/feature.rs" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ash/src/surface.rs" afterPath="$PROJECT_DIR$/ash/src/surface.rs" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/examples/src/main.rs" afterPath="$PROJECT_DIR$/examples/src/main.rs" />
</list>
<ignored path="ashlib.iws" />
<ignored path=".idea/workspace.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="ashlib" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="main.rs" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/examples/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" column="29" selection-start-line="25" selection-start-column="29" selection-end-line="25" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="surface.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ash/src/surface.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/ash/src/surface.rs" />
<option value="$PROJECT_DIR$/examples/src/main.rs" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="Bundled (Maven 3)" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="-16" />
<option name="width" value="1920" />
<option name="height" value="1096" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes />
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/examples" />
<property name="SearchEverywhereHistoryKey" value="surface.&#9;FILE&#9;file:///home/maik/projects/ashlib/ash/src/surface.rs&#10;main.&#9;FILE&#9;file:///home/maik/projects/ashlib/examples/src/main.rs" />
<property name="org.rust.alreadyTriedToolchainAutoDiscovery" value="true" />
<property name="settings.editor.selected.configurable" value="org.rust.cargo.project.configurable.RustProjectConfigurable" />
<property name="settings.editor.splitter.proportion" value="0.2" />
</component>
<component name="RunManager">
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<method />
</configuration>
<configuration default="true" type="AndroidRunConfigurationType" factoryName="Android Application">
<module name="" />
<option name="DEPLOY" value="true" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="DEBUGGER_TYPE" value="Java" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<Java />
<Profilers>
<option name="GAPID_DISABLE_PCS" value="false" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method />
</configuration>
<configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
<module name="" />
<option name="TESTING_TYPE" value="0" />
<option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
<option name="METHOD_NAME" value="" />
<option name="CLASS_NAME" value="" />
<option name="PACKAGE_NAME" value="" />
<option name="EXTRA_OPTIONS" value="" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="DEBUGGER_TYPE" value="Java" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<Java />
<Profilers>
<option name="GAPID_DISABLE_PCS" value="false" />
</Profilers>
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<module />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="CargoCommandRunConfiguration" factoryName="Cargo Command" show_console_on_std_err="false" show_console_on_std_out="false">
<option name="additionalArguments" value="" />
<option name="command" value="run" />
<option name="environmentVariables">
<map />
</option>
<option name="printBacktrace" value="false" />
<module name="ashlib" />
<method />
</configuration>
<configuration default="true" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list />
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="JUnitTestDiscovery" factoryName="JUnit Test Discovery" changeList="All">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="JarApplication" factoryName="JAR Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<envs />
<method />
</configuration>
<configuration default="true" type="Java Scratch" factoryName="Java Scratch">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="SCRATCH_FILE_ID" value="0" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="ashlib" />
<envs />
<method />
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType" factoryName="Kotlin script">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="filePath" />
<option name="vmParameters" />
<option name="alternativeJrePath" />
<option name="programParameters" />
<option name="passParentEnvs" value="true" />
<option name="workingDirectory" />
<option name="isAlternativeJrePathEnabled" value="false" />
<envs />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="TestNGTestDiscovery" factoryName="TestNG Test Discovery" changeList="All">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="3bfba5c3-3712-4c12-bd49-0c72a2c4b6a5" name="Default" comment="" />
<created>1471359564698</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1471359564698</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="-16" width="1920" height="1096" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32935324" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="antWorkspaceConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/examples/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ash/src/surface.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ash/src/surface.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="810">
<caret line="45" column="0" selection-start-line="45" selection-start-column="0" selection-end-line="45" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396">
<caret line="22" column="25" selection-start-line="22" selection-start-column="25" selection-end-line="22" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ash/src/surface.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ash/src/surface.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" column="29" selection-start-line="25" selection-start-column="29" selection-end-line="25" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

View file

@ -10,3 +10,4 @@ glfw = "0.9.1"
bitflags = "0.7.0"
vk_loader = { version = "0.1.0", path = "../vk_loader"}
vk_loader2 = { version = "0.1.0", path = "../vk_loader2"}

View file

@ -6,219 +6,337 @@ use std::error;
use std::fmt;
use std::mem;
use std::sync::Arc;
use vk_loader as vk;
use feature;
use load;
use fence;
use extensions::*;
use std::os::raw::*;
use std::cell::Cell;
use surface;
use device::*;
use vk_loader2 as vk;
// use feature;
use load;
// use fence;
// use extensions::*;
// use surface;
// use device::*;
pub struct DebugCallback {
handle: vk::DebugReportCallbackEXT,
f: *mut Fn(String),
}
#[derive(Clone)]
#[derive(Debug)]
pub struct Instance {
pub inner: Arc<InstanceImpl>,
handle: vk::Instance,
instance_fn: vk::InstanceFn,
}
pub struct InstanceImpl {
pub instance: vk::Instance,
pub ip: vk::InstancePointers,
callback: Option<DebugCallback>,
}
impl Instance{
pub fn handle(&self) -> usize{
self.inner.instance
}
pub fn ip(&self) -> &vk::InstancePointers {
&self.inner.ip
}
}
unsafe impl Send for Instance {}
unsafe impl Sync for Instance {}
impl Drop for InstanceImpl {
fn drop(&mut self) {
unsafe {
if let Some(ref callback) = self.callback {
self.ip.DestroyDebugReportCallbackEXT(self.instance, callback.handle, ptr::null());
Box::from_raw(callback.f);
macro_rules! vk_error(
($err_name: ident, $($raw_name: ident => $name: ident,)*) => {
#[derive(Debug)]
pub enum $err_name {
$(
$name,
)*
}
impl From<vk::Result> for $err_name {
fn from(r: vk::Result) -> $err_name {
match r {
$(
vk::Result::$raw_name => $err_name::$name,
)*
_ => panic!("Missing error case for '{}', please open an issue.", stringify!($err_name)),
}
}
self.ip.DestroyInstance(self.instance, ptr::null());
}
}
}
);
pub struct ApplicationInfo {
pub name: String,
}
vk_error!(
InstanceError,
ErrorOutOfHostMemory => OutOfHostMemory,
ErrorOutOfDeviceMemory => OutOfDeviceMemory,
ErrorInitializationFailed => InitializationFailed,
ErrorIncompatibleDriver => IncompatibleDriver,
);
vk_error!(
EnumerateDeviceError,
ErrorOutOfHostMemory => OutOfHostMemory,
ErrorOutOfDeviceMemory => OutOfDeviceMemory,
ErrorInitializationFailed => InitializationFailed,
);
impl Instance {
pub fn create_surface<S: surface::VulkanSurface>(&self, s: &S) -> surface::Surface {
surface::Surface {
instance: self.clone(),
handle: s.create_surface(self),
// FIX: Add loading error
pub fn create_instance<I: Into<vk::InstanceCreateInfo>>(i: I) -> Result<Instance, vk::Result> {
let create_info = i.into();
let static_fn = load::static_fn().unwrap();
let entry = load::entry_fn(&static_fn);
unsafe {
let mut instance: vk::Instance = mem::uninitialized();
let err_code = entry.create_instance(&create_info, ptr::null(), &mut instance);
if err_code != vk::Result::Success {
return Err(err_code);
}
let instance_fn = vk::InstanceFn::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})
.unwrap();
Ok(Instance {
handle: instance,
instance_fn: instance_fn,
})
}
}
pub fn extenstion_properties() -> InstanceExtension {
let entry_points = load::entry_points().unwrap();
let extension_props = unsafe {
let mut num = 0;
entry_points.EnumerateInstanceExtensionProperties(ptr::null(), &mut num, ptr::null_mut());
let mut data = Vec::with_capacity(num as usize);
entry_points.EnumerateInstanceExtensionProperties(ptr::null(), &mut num, data.as_mut_ptr());
data.set_len(num as usize);
InstanceExtensionProperties { ext_props: data }
};
extension_props.into()
pub fn enumerate_physical_devices(&self) -> Result<Vec<vk::PhysicalDevice>, vk::Result> {
unsafe {
let mut num = mem::uninitialized();
self.instance_fn
.enumerate_physical_devices(self.handle, &mut num, ptr::null_mut());
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
let err_code = self.instance_fn
.enumerate_physical_devices(self.handle, &mut num, physical_devices.as_mut_ptr());
physical_devices.set_len(num as usize);
match err_code {
vk::Result::Success => Ok(physical_devices),
_ => Err(err_code),
}
}
}
pub fn device_extension_properties(&self, device: vk::PhysicalDevice) -> DeviceExtension {
let extension_props = unsafe {
pub fn enumerate_instance_layer_properties() -> Vec<vk::LayerProperties> {
let static_fn = load::static_fn().unwrap();
let entry = load::entry_fn(&static_fn);
unsafe {
let mut num = 0;
self.inner.ip
.EnumerateDeviceExtensionProperties(device, ptr::null(), &mut num, ptr::null_mut());
entry.enumerate_instance_layer_properties(&mut num, ptr::null_mut());
let mut v = Vec::with_capacity(num as usize);
entry.enumerate_instance_layer_properties(&mut num, v.as_mut_ptr());
v.set_len(num as usize);
v
}
}
pub fn enumerate_device_extension_properties
(&self,
device: vk::PhysicalDevice)
-> Result<Vec<vk::ExtensionProperties>, vk::Result> {
unsafe {
let mut num = 0;
self.instance_fn
.enumerate_device_extension_properties(device,
ptr::null(),
&mut num,
ptr::null_mut());
let mut data = Vec::with_capacity(num as usize);
self.inner.ip.EnumerateDeviceExtensionProperties(device,
let err_code = self.instance_fn
.enumerate_device_extension_properties(device,
ptr::null(),
&mut num,
data.as_mut_ptr());
data.set_len(num as usize);
DeviceExtensionProperties { ext_props: data }
};
extension_props.into()
}
pub fn new<F: Fn(String) + 'static>(app_info: &ApplicationInfo,
extensions: &InstanceExtension,
f: F)
-> Instance {
let entry_points = load::entry_points().unwrap();
unsafe {
let mut num = 0;
entry_points.EnumerateInstanceLayerProperties(&mut num, ptr::null_mut());
let mut v = Vec::with_capacity(num as usize);
entry_points.EnumerateInstanceLayerProperties(&mut num, v.as_mut_ptr());
v.set_len(num as usize);
for p in v {
// println!("layer {}", CStr::from_ptr(p.layerName.as_ptr()).to_str().unwrap());
match err_code {
vk::Result::Success => Ok(data),
_ => Err(err_code),
}
}
let layername = CString::new("VK_LAYER_LUNARG_standard_validation").unwrap();
let layer = [layername.as_ptr()];
let c = CString::new(app_info.name.clone()).unwrap();
let raw_name = c.as_ptr();
let appinfo = vk::ApplicationInfo {
pApplicationName: raw_name,
sType: vk::STRUCTURE_TYPE_APPLICATION_INFO,
pNext: ptr::null(),
applicationVersion: 0,
pEngineName: raw_name,
engineVersion: 0,
apiVersion: 0,
};
let extension_list = extensions.extension_list();
let extension_list_raw =
extension_list.iter().map(|extension| extension.as_ptr()).collect::<Vec<_>>();
let create_info = vk::InstanceCreateInfo {
sType: vk::STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
pApplicationInfo: &appinfo,
pNext: ptr::null(),
ppEnabledLayerNames: layer.as_ptr(),
enabledLayerCount: layer.len() as u32,
ppEnabledExtensionNames: extension_list_raw.as_ptr(),
enabledExtensionCount: extension_list_raw.len() as u32,
flags: 0,
};
let mut instance: vk::Instance = unsafe { mem::uninitialized() };
unsafe {
entry_points.CreateInstance(&create_info, ptr::null(), &mut instance);
}
let vk: vk::InstancePointers = {
let f = load::static_functions().unwrap();
vk::InstancePointers::load(|name| unsafe {
mem::transmute(f.GetInstanceProcAddr(instance, name.as_ptr()))
})
};
extern "system" fn debug_callback<F: Fn(String)>(flags: vk::DebugReportFlagsEXT,
obj: vk::DebugReportObjectTypeEXT,
u: u64,
u1: usize,
i: i32,
chars: *const c_char,
chars1: *const c_char,
data: *mut c_void)
-> u32 {
unsafe {
let f = &*(data as *mut F);
f(CStr::from_ptr(chars).to_str().unwrap().to_owned());
f(CStr::from_ptr(chars1).to_str().unwrap().to_owned());
}
1
}
let raw_boxed_f = Box::into_raw(Box::new(f));
let debug = vk::DebugReportCallbackCreateInfoEXT {
sType: 1000011000,
pNext: ptr::null(),
flags: vk::DEBUG_REPORT_ERROR_BIT_EXT | vk::DEBUG_REPORT_WARNING_BIT_EXT,
pfnCallback: debug_callback::<F>,
pUserData: raw_boxed_f as *mut c_void,
};
let callback = unsafe {
let mut callback: vk::DebugReportCallbackEXT = mem::uninitialized();
assert!(vk.CreateDebugReportCallbackEXT(instance,
&debug,
ptr::null(),
&mut callback) == 0,
"Debug");
DebugCallback {
f: raw_boxed_f,
handle: callback,
}
};
Instance {
inner: Arc::new(InstanceImpl {
ip: vk,
instance: instance,
callback: Some(callback),
}),
}
}
pub fn get_pysical_devices(&self) -> Vec<PhysicalDevice> {
unsafe {
let mut num = 0;
self.inner.ip
.EnumeratePhysicalDevices(self.inner.instance, &mut num, ptr::null_mut());
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
self.inner.ip
.EnumeratePhysicalDevices(self.inner.instance, &mut num, physical_devices.as_mut_ptr());
physical_devices.set_len(num as usize);
physical_devices.into_iter()
.map(|handle| {
PhysicalDevice {
instance: self.clone(),
handle: handle,
}
})
.collect()
}
}
}
// pub struct DebugCallback {
// handle: vk::DebugReportCallbackEXT,
// f: *mut Fn(String),
// }
//
// #[derive(Clone)]
// pub struct Instance {
// pub inner: Arc<InstanceImpl>,
// }
//
// pub struct InstanceImpl {
// pub instance: vk::Instance,
// pub ip: vk::InstancePointers,
// callback: Option<DebugCallback>,
// }
//
// impl Instance{
// pub fn handle(&self) -> usize{
// self.inner.instance
// }
//
// pub fn ip(&self) -> &vk::InstancePointers {
// &self.inner.ip
// }
// }
//
// unsafe impl Send for Instance {}
// unsafe impl Sync for Instance {}
//
// impl Drop for InstanceImpl {
// fn drop(&mut self) {
// unsafe {
// if let Some(ref callback) = self.callback {
// self.ip.DestroyDebugReportCallbackEXT(self.instance, callback.handle, ptr::null());
// Box::from_raw(callback.f);
// }
// self.ip.DestroyInstance(self.instance, ptr::null());
// }
// }
// }
//
// pub struct ApplicationInfo {
// pub name: String,
// }
//
// impl Instance {
// pub fn create_surface<S: surface::VulkanSurface>(&self, s: &S) -> surface::Surface {
// surface::Surface {
// instance: self.clone(),
// handle: s.create_surface(self),
// }
// }
//
// pub fn extenstion_properties() -> InstanceExtension {
// let entry_points = load::entry_points().unwrap();
// let extension_props = unsafe {
// let mut num = 0;
// entry_points.EnumerateInstanceExtensionProperties(ptr::null(), &mut num, ptr::null_mut());
// let mut data = Vec::with_capacity(num as usize);
// entry_points.EnumerateInstanceExtensionProperties(ptr::null(), &mut num, data.as_mut_ptr());
// data.set_len(num as usize);
// InstanceExtensionProperties { ext_props: data }
// };
// extension_props.into()
// }
// pub fn device_extension_properties(&self, device: vk::PhysicalDevice) -> DeviceExtension {
// let extension_props = unsafe {
// let mut num = 0;
// self.inner.ip
// .EnumerateDeviceExtensionProperties(device, ptr::null(), &mut num, ptr::null_mut());
// let mut data = Vec::with_capacity(num as usize);
// self.inner.ip.EnumerateDeviceExtensionProperties(device,
// ptr::null(),
// &mut num,
// data.as_mut_ptr());
// data.set_len(num as usize);
// DeviceExtensionProperties { ext_props: data }
// };
// extension_props.into()
// }
//
// pub fn new<F: Fn(String) + 'static>(app_info: &ApplicationInfo,
// extensions: &InstanceExtension,
// f: F)
// -> Instance {
// let entry_points = load::entry_points().unwrap();
//
// unsafe {
// let mut num = 0;
// entry_points.EnumerateInstanceLayerProperties(&mut num, ptr::null_mut());
//
// let mut v = Vec::with_capacity(num as usize);
// entry_points.EnumerateInstanceLayerProperties(&mut num, v.as_mut_ptr());
// v.set_len(num as usize);
//
// for p in v {
// // println!("layer {}", CStr::from_ptr(p.layerName.as_ptr()).to_str().unwrap());
// }
// }
// let layername = CString::new("VK_LAYER_LUNARG_standard_validation").unwrap();
// let layer = [layername.as_ptr()];
//
// let c = CString::new(app_info.name.clone()).unwrap();
// let raw_name = c.as_ptr();
// let appinfo = vk::ApplicationInfo {
// pApplicationName: raw_name,
// sType: vk::STRUCTURE_TYPE_APPLICATION_INFO,
// pNext: ptr::null(),
// applicationVersion: 0,
// pEngineName: raw_name,
// engineVersion: 0,
// apiVersion: 0,
// };
//
// let extension_list = extensions.extension_list();
// let extension_list_raw =
// extension_list.iter().map(|extension| extension.as_ptr()).collect::<Vec<_>>();
// let create_info = vk::InstanceCreateInfo {
// sType: vk::STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
// pApplicationInfo: &appinfo,
// pNext: ptr::null(),
// ppEnabledLayerNames: layer.as_ptr(),
// enabledLayerCount: layer.len() as u32,
// ppEnabledExtensionNames: extension_list_raw.as_ptr(),
// enabledExtensionCount: extension_list_raw.len() as u32,
// flags: 0,
// };
//
// let mut instance: vk::Instance = unsafe { mem::uninitialized() };
// unsafe {
// entry_points.CreateInstance(&create_info, ptr::null(), &mut instance);
// }
// let vk: vk::InstancePointers = {
// let f = load::static_functions().unwrap();
// vk::InstancePointers::load(|name| unsafe {
// mem::transmute(f.GetInstanceProcAddr(instance, name.as_ptr()))
// })
// };
// extern "system" fn debug_callback<F: Fn(String)>(flags: vk::DebugReportFlagsEXT,
// obj: vk::DebugReportObjectTypeEXT,
// u: u64,
// u1: usize,
// i: i32,
// chars: *const c_char,
// chars1: *const c_char,
// data: *mut c_void)
// -> u32 {
// unsafe {
// let f = &*(data as *mut F);
// f(CStr::from_ptr(chars).to_str().unwrap().to_owned());
// f(CStr::from_ptr(chars1).to_str().unwrap().to_owned());
// }
// 1
// }
// let raw_boxed_f = Box::into_raw(Box::new(f));
// let debug = vk::DebugReportCallbackCreateInfoEXT {
// sType: 1000011000,
// pNext: ptr::null(),
// flags: vk::DEBUG_REPORT_ERROR_BIT_EXT | vk::DEBUG_REPORT_WARNING_BIT_EXT,
// pfnCallback: debug_callback::<F>,
// pUserData: raw_boxed_f as *mut c_void,
// };
// let callback = unsafe {
// let mut callback: vk::DebugReportCallbackEXT = mem::uninitialized();
//
// assert!(vk.CreateDebugReportCallbackEXT(instance,
// &debug,
// ptr::null(),
// &mut callback) == 0,
// "Debug");
//
// DebugCallback {
// f: raw_boxed_f,
// handle: callback,
// }
// };
// Instance {
// inner: Arc::new(InstanceImpl {
// ip: vk,
// instance: instance,
// callback: Some(callback),
// }),
// }
// }
//
// pub fn get_pysical_devices(&self) -> Vec<PhysicalDevice> {
// unsafe {
// let mut num = 0;
// self.inner.ip
// .EnumeratePhysicalDevices(self.inner.instance, &mut num, ptr::null_mut());
// let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
// self.inner.ip
// .EnumeratePhysicalDevices(self.inner.instance, &mut num, physical_devices.as_mut_ptr());
// physical_devices.set_len(num as usize);
// physical_devices.into_iter()
// .map(|handle| {
// PhysicalDevice {
// instance: self.clone(),
// handle: handle,
// }
// })
// .collect()
// }
// }
// }

View file

@ -2,16 +2,17 @@
extern crate lazy_static;
extern crate shared_library;
extern crate vk_loader;
extern crate vk_loader2;
extern crate glfw;
#[macro_use]
extern crate bitflags;
pub mod load;
pub mod extensions;
pub mod surface;
//pub mod extensions;
//pub mod surface;
pub mod instance;
pub mod feature;
pub mod device;
pub mod commandpool;
pub mod fence;
pub mod buffer;
//pub mod feature;
//pub mod device;
//pub mod commandpool;
//pub mod fence;
//pub mod buffer;

View file

@ -14,7 +14,7 @@ use std::path::Path;
use std::ptr;
use shared_library;
use vk_loader as vk;
use vk_loader2 as vk;
lazy_static! {
pub static ref VK_LIB: Result<shared_library::dynamic_library::DynamicLibrary, LoadingError> = {
@ -26,59 +26,81 @@ lazy_static! {
.map_err(|err| LoadingError::LibraryLoadFailure(err))
};
static ref VK_STATIC: Result<vk::Static, LoadingError> = {
match *VK_LIB {
Ok(ref lib) => {
let mut err = None;
let result = vk::Static::load(|name| unsafe {
let name = name.to_str().unwrap();
match lib.symbol(name) {
Ok(s) => s,
Err(_) => { // TODO: return error?
err = Some(LoadingError::MissingEntryPoint(name.to_owned()));
ptr::null()
}
}
});
if let Some(err) = err {
Err(err)
} else {
Ok(result)
}
},
Err(ref err) => Err(err.clone()),
}
};
static ref VK_ENTRY: Result<vk::EntryPoints, LoadingError> = {
match *VK_STATIC {
Ok(ref lib) => {
// At this point we assume that if one of the functions fails to load, it is an
// implementation bug and not a real-life situation that could be handled by
// an error.
Ok(vk::EntryPoints::load(|name| unsafe {
mem::transmute(lib.GetInstanceProcAddr(0, name.as_ptr()))
}))
},
Err(ref err) => Err(err.clone()),
}
};
// static ref VK_STATIC: Result<vk::Static, LoadingError> = {
// match *VK_LIB {
// Ok(ref lib) => {
// let mut err = None;
// let result = vk::Static::load(|name| unsafe {
// let name = name.to_str().unwrap();
// match lib.symbol(name) {
// Ok(s) => s,
// Err(_) => { // TODO: return error?
// err = Some(LoadingError::MissingEntryPoint(name.to_owned()));
// ptr::null()
// }
// }
// });
//
// if let Some(err) = err {
// Err(err)
// } else {
// Ok(result)
// }
// },
// Err(ref err) => Err(err.clone()),
// }
// };
//
// static ref VK_ENTRY: Result<vk::EntryPoints, LoadingError> = {
// match *VK_STATIC {
// Ok(ref lib) => {
// // At this point we assume that if one of the functions fails to load, it is an
// // implementation bug and not a real-life situation that could be handled by
// // an error.
// Ok(vk::EntryPoints::load(|name| unsafe {
// mem::transmute(lib.GetInstanceProcAddr(0, name.as_ptr()))
// }))
// },
// Err(ref err) => Err(err.clone()),
// }
// };
}
/// Returns the collection of static functions from the Vulkan loader, or an error if failed to
/// open the loader.
pub fn static_functions() -> Result<&'static vk::Static, LoadingError> {
VK_STATIC.as_ref().map_err(|err| err.clone())
// pub fn static_functions() -> Result<&'static vk::Static, LoadingError> {
// VK_STATIC.as_ref().map_err(|err| err.clone())
// }
pub fn static_fn() -> Result<vk::Static, String> {
let r = match *VK_LIB {
Ok(ref lib) => {
vk::Static::load(|name| unsafe {
let name = name.to_str().unwrap();
match lib.symbol(name) {
Ok(s) => s,
Err(_) => ptr::null(),
}
})
}
Err(ref err) => return Err("Foo".to_string()),
};
Ok(r.unwrap())
}
pub fn entry_fn(static_fn: &vk::Static) -> vk::EntryFn {
let entry = vk::EntryFn::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(ptr::null_mut(), name.as_ptr()))
});
entry.unwrap()
}
/// Returns the collection of Vulkan entry points from the Vulkan loader, or an error if failed to
/// open the loader.
pub fn entry_points() -> Result<&'static vk::EntryPoints, LoadingError> {
VK_ENTRY.as_ref().map_err(|err| err.clone())
}
/// Error that can happen when loading the Vulkan loader.
/// // Returns the collection of Vulkan entry points from the Vulkan loader, or an error if failed to
/// // open the loader.
/// pub fn entry_points() -> Result<&'static vk::EntryPoints, LoadingError> {
/// VK_ENTRY.as_ref().map_err(|err| err.clone())
/// }
///
/// // Error that can happen when loading the Vulkan loader.
#[derive(Debug, Clone)]
pub enum LoadingError {
/// Failed to load the Vulkan shared library.

1
examples/Cargo.lock generated
View file

@ -19,6 +19,7 @@ dependencies = [
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vk_loader 0.1.0",
"vk_loader2 0.1.0",
]
[[package]]

View file

@ -5,42 +5,16 @@ extern crate ash;
extern crate vk_loader2 as vk;
extern crate glfw;
use ash::instance::Instance;
use std::ptr;
use std::ffi::{CStr, CString};
use std::mem;
fn main(){
let vkstatic = match *ash::load::VK_LIB {
Ok(ref lib) => {
let mut err = None;
let result = vk::Static::load(|name| unsafe {
let name = name.to_str().unwrap();
match lib.symbol(name) {
Ok(s) => s,
Err(_) => { // TODO: return error?
err = Some(ash::load::LoadingError::MissingEntryPoint("".to_owned()));
ptr::null()
}
}
});
if let Some(err) = err {
Err(err)
} else {
Ok(result)
}
},
Err(ref err) => Err(err.clone()),
}.unwrap();
let entry = vk::EntryFn::load(|name| unsafe {
mem::transmute(vkstatic.get_instance_proc_addr(ptr::null_mut(), name.as_ptr()))
});
println!("{:?}", entry);
fn main() {
let app_name = CString::new("TEST").unwrap();
let raw_name = app_name.as_ptr();
let lunarg_layer = CString::new("VK_LAYER_LUNARG_standard_validation").unwrap();
let layers = [lunarg_layer.as_ptr()];
let appinfo = vk::ApplicationInfo {
p_application_name: raw_name,
s_type: vk::StructureType::ApplicationInfo,
@ -51,87 +25,44 @@ fn main(){
api_version: 0,
};
let create_info = vk::InstanceCreateInfo {
s_type: vk::StructureType::ApplicationInfo,
s_type: vk::StructureType::InstanceCreateInfo,
p_application_info: &appinfo,
p_next: ptr::null(),
pp_enabled_layer_names: ptr::null(),
enabled_layer_count: 0,
pp_enabled_layer_names: layers.as_ptr(),
enabled_layer_count: layers.len() as u32,
pp_enabled_extension_names: ptr::null(),
enabled_extension_count: 0,
flags: 0,
};
let mut instance: vk::Instance = unsafe { mem::uninitialized() };
let instance = Instance::create_instance(create_info).expect("Instance creation error");
println!("{:?}", instance);
unsafe {
let i = entry.create_instance(&create_info, ptr::null(), &mut instance);
println!("{:?}", i);
}
// let r1 = vk::load_with(|name| unsafe {
// let cs = CString::new(name).unwrap();
// mem::transmute(vk::get_instance_proc_addr(ptr::null_mut(), cs.as_ptr()))
// });
// let app_name = CString::new("TEST").unwrap();
// let raw_name = app_name.as_ptr();
// let appinfo = vk::ApplicationInfo {
// p_application_name: raw_name,
// s_type: vk::StructureType::ApplicationInfo,
// p_next: ptr::null(),
// application_version: 0,
// p_engine_name: raw_name,
// engine_version: 0,
// api_version: 0,
// };
// let create_info = vk::InstanceCreateInfo {
// s_type: vk::StructureType::ApplicationInfo,
// p_application_info: &appinfo,
// p_next: ptr::null(),
// pp_enabled_layer_names: ptr::null(),
// enabled_layer_count: 0,
// pp_enabled_extension_names: ptr::null(),
// enabled_extension_count: 0,
// flags: 0,
// };
// let mut instance: vk::Instance = unsafe { mem::uninitialized() };
// println!("{:?}", instance);
// unsafe {
// let i = vk::create_instance(&create_info, ptr::null(), &mut instance);
// println!("{:?}", i);
//
// }
// println!("{:?}", instance);
// let r2 = vk::load_with(|name| unsafe {
// let cs = CString::new(name).unwrap();
// mem::transmute(vk::get_instance_proc_addr(instance, cs.as_ptr()))
// });
// println!("{:?}", r2);
// let r3 = vk::load_with(|name| unsafe {
// let cs = CString::new(name).unwrap();
// mem::transmute(vk::get_instance_proc_addr(ptr::null_mut(), cs.as_ptr()))
// });
// println!("{:?}", r3);
let pdevices = instance.enumerate_physical_devices().expect("Physical device error");
println!("{:?}", pdevices);
let ext_props = instance.enumerate_device_extension_properties(pdevices[0])
.expect("Enumerate device error");
println!("{:?}", ext_props);
}
//use ash::instance::*;
//use vk_loader as vk;
//use ash::extensions::*;
//use glfw::*;
//use std::sync::Arc;
//use std::thread;
//use ash::device::*;
//use ash::surface;
//use ash::commandpool;
//use std::cell::RefCell;
//use std::marker;
//use std::ptr;
//use ash::device;
//fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
// use ash::instance::*;
// use vk_loader as vk;
// use ash::extensions::*;
// use glfw::*;
// use std::sync::Arc;
// use std::thread;
// use ash::device::*;
// use ash::surface;
// use ash::commandpool;
// use std::cell::RefCell;
// use std::marker;
// use std::ptr;
// use ash::device;
// fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
// match event {
// glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => window.set_should_close(true),
// _ => {}
// }
//}
// }
//
//fn main() {
// fn main() {
// let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
//
// let (mut window, events) = glfw.create_window(1920,
@ -347,4 +278,4 @@ fn main(){
// // handle_window_event(&mut window, event);
// // }
// // }
//}
// }

View file

@ -3109,6 +3109,7 @@ pub type PFN_vkVoidFunction = unsafe extern "system" fn(
);
}
//FIX: Need better error handling for extensions
macro_rules! vk_functions {
($struct_name: ident, $($raw_name: expr, $name: ident ($($param_name: ident: $param: ty),*,) -> $ret: ty;)+) => {
pub struct $struct_name{
@ -3116,27 +3117,37 @@ macro_rules! vk_functions {
$name: extern "system" fn ($($param_name: $param),*) -> $ret,
)+
}
unsafe impl Send for $struct_name {}
unsafe impl Sync for $struct_name {}
impl $struct_name {
pub fn load<F>(mut f: F) -> $struct_name
pub fn load<F>(mut f: F) -> ::std::result::Result<$struct_name, String>
where F: FnMut(&::std::ffi::CStr) -> *const c_void
{
use std::ffi::{CString, CStr};
use std::mem;
$struct_name {
let s = $struct_name {
$(
$name: unsafe {
extern "system" fn $name($(_: $param),*) { panic!("function pointer `{}` not loaded", stringify!($name)) }
let cname = CString::new($raw_name).unwrap();
let val = f(&cname);
if val.is_null() { mem::transmute($name as *const ()) } else { mem::transmute(val) }
//if val.is_null() { mem::transmute($name as *const ()) } else { mem::transmute(val) }
//if val.is_null(){
// return ::std::result::Result::Err($raw_name.to_string());
//}
mem::transmute(val)
},
)+
}
};
::std::result::Result::Ok(s)
}
$(
#[inline]
pub unsafe fn $name(&self $(, $param_name: $param)*) -> $ret {
let fp = self.$name;
assert!(!(self.$name as *const c_void).is_null(), "{} not loaded!.", stringify!($raw_name));
fp($($param_name),*)
}
)+
@ -3147,6 +3158,7 @@ macro_rules! vk_functions {
writeln!(fmt, stringify!($struct_name));
$(
write!(fmt, $raw_name);
write!(fmt," is loaded = {:?}", !(self.$name as *const c_void).is_null());
writeln!(fmt, ", ");
)+
write!(fmt, "")
@ -3235,6 +3247,7 @@ vk_functions!{
vk_functions!{
InstanceFn,
"vkDestroyInstance", destroy_instance(
instance: Instance,
p_allocator: *const AllocationCallbacks,