]> O.S.I.I.S - jp/vke.net.git/commitdiff
first working triangle (rdna2, mesa-trunk, VK_EXT_mesh_shader
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 31 Oct 2022 17:24:20 +0000 (18:24 +0100)
committerj-p <jp_bruyere@hotmail.com>
Tue, 1 Nov 2022 20:53:51 +0000 (21:53 +0100)
14 files changed:
.vscode/launch.json
.vscode/tasks.json
Directory.Build.props
SpirVTasks/spirv.xml
samples/Directory.Build.props
samples/MeshShader/MeshShader.csproj [new file with mode: 0644]
samples/MeshShader/main.cs [new file with mode: 0644]
samples/MeshShader/shaders/main.frag [new file with mode: 0644]
samples/MeshShader/shaders/main.mesh [new file with mode: 0644]
samples/common/SampleBase.cs
vke.net.sln
vke/src/VkWindow.cs
vke/src/base/PhysicalDevice.cs
vke/vke.csproj

index 541a0b7f5eea2d219b1ae8dad20f6cbcd244f79c..038b2cd2a852ecb71eb1edf75dbac3acf3cc5fba 100644 (file)
                        "stopAtEntry": false,
                        "console": "internalConsole"
                },
+               {
+                       "name": ".NET Core Launch (MeshShader)",
+                       "type": "coreclr",
+                       "request": "launch",
+                       "preLaunchTask": "build MeshShader",
+                       "program": "${workspaceFolder}/build/Debug/netcoreapp3.1/MeshShader",
+                       "args": [],
+                       "cwd": "${workspaceFolder}/build/Debug/netcoreapp3.1/",
+                       "stopAtEntry": false,
+                       "console": "internalConsole",
+                       "env": {
+                               "VK_ICD_FILENAMES": "/usr/local/share/vulkan/icd.d/radeon_icd.x86_64.json",
+                               "RADV_PERFTEST": "rt,ext_ms"
+                       }
+               },
                {
                        "name": ".NET Core Launch (Compute)",
                        "type": "coreclr",
index 504ba80d816cb7fd7bae22590ee51a8cd632bc0c..e1657dd6488e071cfaa745847f4ddc9e487ea87e 100644 (file)
@@ -1,6 +1,20 @@
 {
        "version": "2.0.0",
        "tasks": [
+               {
+                       "label": "build SpirVTasks",
+                       "command": "dotnet",
+                       "type": "process",
+                       "args": [
+                               "build",
+                               "${workspaceFolder}/SpirVTasks/SpirVTasks.csproj",
+                               "/property:GenerateFullPaths=true",
+                               "/property:SolutionDir=${workspaceFolder}/",
+                               "/property:Configuration=Debug",
+                               "/consoleloggerparameters:NoSummary"
+                       ],
+                       "problemMatcher": "$msCompile"
+               },
                {
                        "label": "build ExternalMemmories",
                        "command": "dotnet",
                        ],
                        "problemMatcher": "$msCompile"
                },
+               {
+                       "label": "build MeshShader",
+                       "command": "dotnet",
+                       "type": "process",
+                       "args": [
+                               "build",
+                               "${workspaceFolder}/samples/MeshShader/MeshShader.csproj",
+                               "/property:GenerateFullPaths=true",
+                               "/property:SolutionDir=${workspaceFolder}/",
+                               "/property:Configuration=Debug",
+                               "/consoleloggerparameters:NoSummary"
+                       ],
+                       "problemMatcher": "$msCompile"
+               },
                {
                        "label": "build Compute",
                        "command": "dotnet",
index 022e6eae566c8e51a5f3dafda2911e83e7776221..7efe3e336bc98634f542d8319be7dc9a2affb9c2 100644 (file)
@@ -2,9 +2,9 @@
        <PropertyGroup>
                <RootDirectory>$(MSBuildThisFileDirectory)</RootDirectory>
                <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
-               <SpirVTasksReleaseVersion>0.1.45</SpirVTasksReleaseVersion>
+               <SpirVTasksReleaseVersion>0.2.0</SpirVTasksReleaseVersion>
                <SpirVTasksPackageVersion>$(SpirVTasksReleaseVersion)</SpirVTasksPackageVersion>
-               <VkeReleaseVersion>0.2.7</VkeReleaseVersion>
+               <VkeReleaseVersion>0.3.0</VkeReleaseVersion>
                <VkePackageVersion>$(VkeReleaseVersion)-beta</VkePackageVersion>
                <UseStbSharp>true</UseStbSharp>
                <UseMemoryPools>false</UseMemoryPools>
index d22b7a80e2d02fe1a1bfd2e0dd8675438278f2c4..7f89d71ef3e62aa53f3185d6117ade32b3d570fc 100644 (file)
@@ -8,4 +8,6 @@
   <FileExtension Name=".vert" ContentType="GLSLShader" />
        <FileExtension Name=".tesc" ContentType="GLSLShader" />
        <FileExtension Name=".tese" ContentType="GLSLShader" />
+       <FileExtension Name=".mesh" ContentType="GLSLShader" />
+  <FileExtension Name=".task" ContentType="GLSLShader" />
 </ProjectSchemaDefinitions>
index c2598c2b838dcbfaf4755680090c7b87a636b179..87424d224bb832465f5df444b0daadb3512a42d8 100644 (file)
@@ -33,7 +33,7 @@
 
        <ItemGroup>
                <Compile Include="$(MSBuildThisFileDirectory)common\Utils.cs;$(MSBuildThisFileDirectory)common\SampleBase.cs"/>
-               <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">
+               <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom;shaders\**\*.mesh;shaders\**\*.task">
                        <LogicalName>shaders.%(Filename)%(Extension).spv</LogicalName>
                </GLSLShader>
                <EmbeddedResource Include="ui\**\*.*">
diff --git a/samples/MeshShader/MeshShader.csproj b/samples/MeshShader/MeshShader.csproj
new file mode 100644 (file)
index 0000000..672fb5a
--- /dev/null
@@ -0,0 +1,5 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>
+  </PropertyGroup>
+</Project>
diff --git a/samples/MeshShader/main.cs b/samples/MeshShader/main.cs
new file mode 100644 (file)
index 0000000..5406f85
--- /dev/null
@@ -0,0 +1,211 @@
+// Copyright (c) 2019  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.Numerics;
+using System.Runtime.InteropServices;
+using vke;
+using Vulkan;
+using Glfw;
+using System.Linq;
+using System.Collections.Generic;
+
+namespace MeshShader {
+       class Program : SampleBase {
+#if DEBUG
+               /*public override string[] EnabledLayers  =>
+                       new string[] {
+                               "VK_LAYER_KHRONOS_validation"
+                       };*/
+
+#endif
+               public override string[] EnabledInstanceExtensions => new string[] {
+                       Ext.I.VK_KHR_get_physical_device_properties2,
+                       Ext.I.VK_EXT_debug_utils,
+               };
+               public override string[] EnabledDeviceExtensions => new string[] {
+                       Ext.D.VK_KHR_swapchain,
+                       Ext.D.VK_KHR_spirv_1_4,
+                       Ext.D.VK_EXT_mesh_shader
+                       //"VK_NV_mesh_shader"
+               };
+               protected override void configureEnabledFeatures(VkPhysicalDeviceFeatures available_features, ref VkPhysicalDeviceFeatures enabled_features)
+               {
+                       base.configureEnabledFeatures(available_features, ref enabled_features);
+                       
+                       
+               }
+               vke.DebugUtils.Messenger dbgmsg;
+               protected override void selectPhysicalDevice () {
+                       PhysicalDeviceCollection phys = instance.GetAvailablePhysicalDevice ();
+                       phy = instance.GetAvailablePhysicalDevice ().FirstOrDefault (p => p.Properties.deviceType == VkPhysicalDeviceType.DiscreteGpu && p.HasSwapChainSupport);
+                       Console.WriteLine($"Using gpu: {phy.Properties.deviceName}");
+                       
+                       dbgmsg = new vke.DebugUtils.Messenger (instance,
+                               VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT | VkDebugUtilsMessageTypeFlagsEXT.ValidationEXT | VkDebugUtilsMessageTypeFlagsEXT.GeneralEXT,
+                               VkDebugUtilsMessageSeverityFlagsEXT.InfoEXT |
+                               VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT |
+                               VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT |
+                               VkDebugUtilsMessageSeverityFlagsEXT.VerboseEXT);
+
+                       VkPhysicalDeviceFeatures2 phyFeat2 = VkPhysicalDeviceFeatures2.New;
+                       VkPhysicalDeviceMeshShaderFeaturesEXT meshFeat = VkPhysicalDeviceMeshShaderFeaturesEXT.New;
+                       
+                       IntPtr pPhyFeat2 = Marshal.AllocHGlobal(Marshal.SizeOf<VkPhysicalDeviceFeatures2>());
+                       IntPtr pMeshFeat = Marshal.AllocHGlobal(Marshal.SizeOf<VkPhysicalDeviceMeshShaderFeaturesEXT>());
+                       
+                       Marshal.StructureToPtr<VkPhysicalDeviceMeshShaderFeaturesEXT>(meshFeat, pMeshFeat,false);
+                       phyFeat2.pNext = pMeshFeat;
+                       Marshal.StructureToPtr<VkPhysicalDeviceFeatures2>(phyFeat2, pPhyFeat2,false);
+
+                       Vk.vkGetPhysicalDeviceFeatures2(phy.Handle, pPhyFeat2);
+
+                       phyFeat2 = Marshal.PtrToStructure<VkPhysicalDeviceFeatures2>(pPhyFeat2);
+                       meshFeat = Marshal.PtrToStructure<VkPhysicalDeviceMeshShaderFeaturesEXT>(pMeshFeat);
+                       Marshal.FreeHGlobal(pPhyFeat2);
+                       Marshal.FreeHGlobal(pMeshFeat);
+                       
+                       Console.WriteLine($"Mesh Shader Support:\t{meshFeat.meshShader}");
+                       Console.WriteLine($"Task Shader Support:\t{meshFeat.taskShader}");
+
+                       if (!(meshFeat.meshShader && meshFeat.taskShader)) {
+                               phy = null;                             
+                       }
+               }               
+               
+               static void Main (string[] args) {
+                       Instance.VK_MINOR = 3;
+                       using (Program vke = new Program ()) {
+                               vke.Run ();
+                       }
+               }
+
+               const float rotSpeed = 0.01f, zoomSpeed = 0.01f;
+               float rotX, rotY, zoom = 1f;
+
+               HostBuffer<Matrix4x4> uboMVPmatrix; //a host mappable buffer for mvp matrice.
+
+               DescriptorPool descriptorPool;
+               DescriptorSet descriptorSet;//descriptor set for the mvp matrice.
+
+               FrameBuffers frameBuffers;      //the frame buffer collection coupled to the swapchain images
+               GraphicPipeline pipeline;
+
+               protected override void initVulkan () {
+                       base.initVulkan ();
+
+                       
+                       descriptorPool = new DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer));
+                       using (GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1, false)) {
+                               //Create the pipeline layout, it will be automatically activated on pipeline creation, so that sharing layout among different pipelines will benefit
+                               //from the reference counting to automatically dispose unused layout on pipeline clean up. It's the same for DescriptorSetLayout.
+                               /*cfg.Layout = new PipelineLayout (dev,
+                                       new DescriptorSetLayout (dev, new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex, VkDescriptorType.UniformBuffer)));*/
+                               cfg.Layout = new PipelineLayout (dev);
+                               //create a default renderpass with just a color attachment for the swapchain image, a default subpass is automatically created and the renderpass activation
+                               //will follow the pipeline life cicle and will be automatically disposed when no longuer used.
+                               cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, cfg.Samples);
+                               //configuration of vertex bindings and attributes
+
+                               //shader are automatically compiled by SpirVTasks if added to the project. The resulting shaders are automatically embedded in the assembly.
+                               //To specifiy that the shader path is a resource name, put the '#' prefix. Else the path will be search on disk.
+                               cfg.AddShaders (
+                                       new ShaderInfo (dev, VkShaderStageFlags.MeshEXT, "#shaders.main.mesh.spv"),
+                                       new ShaderInfo (dev, VkShaderStageFlags.Fragment, "#shaders.main.frag.spv")
+                               );
+
+                               //create and activate the pipeline with the configuration we've just done.
+                               pipeline = new GraphicPipeline (cfg);
+                       }
+
+                       //because descriptor layout used for a pipeline are only activated on pipeline activation, descriptor set must not be allocated before, except if the layout has been manually activated,
+                       //but in this case, layout will need also to be explicitly disposed.
+                       //descriptorSet = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]);
+
+                       //Write the content of the descriptor, the mvp matrice.
+                       //DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, pipeline.Layout.DescriptorSetLayouts[0]);
+                       //Descriptor property of the mvp buffer will return a default descriptor with no offset of the full size of the buffer.
+                       //uboUpdate.Write (dev, uboMVPmatrix.Descriptor);
+
+                       //allocate the default VkWindow buffers, one per swapchain image. Their will be only reset when rebuilding and not reallocated.
+                       cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount);
+               }
+
+               //view update override, see base method for more informations.
+               public override void UpdateView () {
+                       /*uboMVPmatrix.AsSpan()[0] =
+                               Matrix4x4.CreateFromAxisAngle (Vector3.UnitY, rotY) *
+                               Matrix4x4.CreateFromAxisAngle (Vector3.UnitX, rotX) *
+                               Matrix4x4.CreateTranslation (0, 0, -3f * zoom) *
+                               Helpers.CreatePerspectiveFieldOfView (Helpers.DegreesToRadians (45f), (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f);
+
+                       base.UpdateView ();*/
+               }
+               protected override void onMouseMove (double xPos, double yPos) {
+                       double diffX = lastMouseX - xPos;
+                       double diffY = lastMouseY - yPos;
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
+                               rotY -= rotSpeed * (float)diffX;
+                               rotX += rotSpeed * (float)diffY;
+                               updateViewRequested = true;
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
+                               zoom += zoomSpeed * (float)diffY;
+                               updateViewRequested = true;
+                       }
+               }
+
+               void buildCommandBuffers() {
+                       cmdPool.Reset (VkCommandPoolResetFlags.ReleaseResources);
+
+                       for (int i = 0; i < swapChain.ImageCount; ++i) {
+                               FrameBuffer fb = frameBuffers[i];
+                               cmds[i].Start ();
+
+                               pipeline.RenderPass.Begin (cmds[i], fb);
+
+                               cmds[i].SetViewport (swapChain.Width, swapChain.Height);
+                               cmds[i].SetScissor (swapChain.Width, swapChain.Height);
+
+                               //cmds[i].BindDescriptorSet (pipeline.Layout, descriptorSet);
+
+                               cmds[i].BindPipeline (pipeline);
+
+                               Vk.vkCmdDrawMeshTasksEXT(cmds[i].Handle, 1, 1, 1);
+
+                               pipeline.RenderPass.End (cmds[i]);
+
+                               cmds[i].End ();
+                       }
+               }
+
+               protected override void OnResize () {
+                       base.OnResize ();
+
+                       updateViewRequested = true;
+
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
+
+                       buildCommandBuffers ();
+               }
+               //clean up
+               protected override void Dispose (bool disposing) {
+                       dev.WaitIdle ();
+                       if (disposing) {
+                               if (!isDisposed) {
+                                       //pipeline clean up will dispose PipelineLayout, DescriptorSet layouts and render pass automatically. If their reference count is zero, their handles will be destroyed.
+                                       pipeline.Dispose ();
+                                       //frame buffers are automatically activated on creation as for resources, so it requests an explicit call to dispose.
+                                       frameBuffers?.Dispose();
+                                       //the descriptor pool
+                                       descriptorPool.Dispose ();
+                                       //resources have to be explicityly disposed.
+                                       //uboMVPmatrix.Dispose ();
+                                       dbgmsg?.Dispose ();
+                               }
+                       }
+
+                       base.Dispose (disposing);
+               }
+       }
+}
diff --git a/samples/MeshShader/shaders/main.frag b/samples/MeshShader/shaders/main.frag
new file mode 100644 (file)
index 0000000..9f807c4
--- /dev/null
@@ -0,0 +1,13 @@
+#version 450
+layout (location = 0) in PerVertexData
+{
+  vec4 color;
+} fragIn;
+layout (location = 0) out vec4 FragColor;
+void main()
+{
+  FragColor = fragIn.color;
+}
\ No newline at end of file
diff --git a/samples/MeshShader/shaders/main.mesh b/samples/MeshShader/shaders/main.mesh
new file mode 100644 (file)
index 0000000..ebe1be2
--- /dev/null
@@ -0,0 +1,47 @@
+
+#extension GL_EXT_mesh_shader : require
+layout(local_size_x = 1) in;
+layout(triangles, max_vertices = 3, max_primitives = 1) out;
+// Custom vertex output block
+layout (location = 0) out PerVertexData
+{
+  vec4 color;
+} v_out[];   // [max_vertices]
+float scale = 0.95;
+const vec3 vertices[3] = {vec3(-1,-1,0), vec3(0,1,0), vec3(1,-1,0)};
+const vec3 colors[3] = {vec3(1.0,0.0,0.0), vec3(0.0,1.0,0.0), vec3(0.0,0.0,1.0)};
+void main()
+{
+  vec4 pos = vec4(vertices[0] * scale, 1.0);
+  // GL->VK conventions...
+  pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0;
+  gl_MeshVerticesEXT[0].gl_Position = pos; 
+  pos = vec4(vertices[1] * scale, 1.0);
+  pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0;
+  gl_MeshVerticesEXT[1].gl_Position = pos; 
+  pos = vec4(vertices[2] * scale, 1.0);
+  pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0;
+  gl_MeshVerticesEXT[2].gl_Position = pos; 
+  v_out[0].color = vec4(colors[0], 1.0);
+  v_out[1].color = vec4(colors[1], 1.0);
+  v_out[2].color = vec4(colors[2], 1.0);
+  gl_PrimitiveIndicesEXT[0] = 0;
+  gl_PrimitiveIndicesEXT[1] = 1;
+  gl_PrimitiveIndicesEXT[2] = 2;
+  gl_PrimitiveCountEXT = 1;
+  
+  SetMeshOutputsEXT(3,1);
+}
\ No newline at end of file
index 2104a6984682beab6af65f2ee1cc7fea5e7b778f..d6a3a641b3d3e755bb7c99f08f3bb48aedb81eaf 100644 (file)
@@ -10,7 +10,7 @@ namespace vke
                {
                        base.initVulkan();
 #if DEBUG
-                       foreach (VkPhysicalDeviceToolPropertiesEXT toolProp in phy.GetToolProperties()) {
+                       foreach (VkPhysicalDeviceToolProperties toolProp in phy.GetToolProperties()) {
                                Console.ForegroundColor = ConsoleColor.DarkYellow;
                                Console.WriteLine ($"Enabled Tool: {toolProp.name}({toolProp.version})");
                                Console.ResetColor ();
index 0e5ac9853eecdf016e5cd52d31c6c70ac78fac53..a366bbab9d214e3b31a7463a6581167d9ca63350 100644 (file)
@@ -44,9 +44,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "deferred", "samples\deferre
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "pbr", "samples\pbr\pbr.csproj", "{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalMemmories", "samples\ExternalMemmories\ExternalMemmories.csproj", "{85CD9813-E182-4ED1-8D2C-38467657BEF3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExternalMemmories", "samples\ExternalMemmories\ExternalMemmories.csproj", "{85CD9813-E182-4ED1-8D2C-38467657BEF3}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VulkanContext", "samples\VulkanContext\VulkanContext.csproj", "{CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VulkanContext", "samples\VulkanContext\VulkanContext.csproj", "{CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeshShader", "samples\MeshShader\MeshShader.csproj", "{5787D082-7E4E-4B18-9C69-529CBC4F105E}"
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -70,93 +72,68 @@ Global
                {642726F4-0592-4846-8EAF-A5D1964C85A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {642726F4-0592-4846-8EAF-A5D1964C85A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {642726F4-0592-4846-8EAF-A5D1964C85A7}.Release|Any CPU.Build.0 = Release|Any CPU
-               {642726F4-0592-4846-8EAF-A5D1964C85A7}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Release|Any CPU.Build.0 = Release|Any CPU
-               {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.Release|Any CPU.Build.0 = Release|Any CPU
-               {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.Release|Any CPU.Build.0 = Release|Any CPU
-               {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
-               {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
                {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.Release|Any CPU.Build.0 = Release|Any CPU
-               {1D2A1968-8F04-4BE0-B03A-573F1F68AB66}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU
-               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Release|Any CPU.Build.0 = Release|Any CPU
-               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {1B2DF710-E500-49E5-8802-EBA71A05E827}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.Release|Any CPU.Build.0 = Release|Any CPU
-               {1B2DF710-E500-49E5-8802-EBA71A05E827}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Release|Any CPU.Build.0 = Release|Any CPU
-               {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {77437C6D-28B5-4798-96CA-68F987770D65}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.Release|Any CPU.Build.0 = Release|Any CPU
-               {77437C6D-28B5-4798-96CA-68F987770D65}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {8185163E-A67C-4C0E-8548-67E2A9F16309}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.Release|Any CPU.Build.0 = Release|Any CPU
-               {8185163E-A67C-4C0E-8548-67E2A9F16309}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Release|Any CPU.Build.0 = Release|Any CPU
-               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Release|Any CPU.Build.0 = Release|Any CPU
-               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
-               {85CD9813-E182-4ED1-8D2C-38467657BEF3}.BuildPackages|Any CPU.ActiveCfg = Debug|Any CPU
-               {85CD9813-E182-4ED1-8D2C-38467657BEF3}.BuildPackages|Any CPU.Build.0 = Debug|Any CPU
                {85CD9813-E182-4ED1-8D2C-38467657BEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {85CD9813-E182-4ED1-8D2C-38467657BEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {85CD9813-E182-4ED1-8D2C-38467657BEF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {85CD9813-E182-4ED1-8D2C-38467657BEF3}.Release|Any CPU.Build.0 = Release|Any CPU
-               {85CD9813-E182-4ED1-8D2C-38467657BEF3}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU
-               {85CD9813-E182-4ED1-8D2C-38467657BEF3}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU
-               {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.BuildPackages|Any CPU.ActiveCfg = Debug|Any CPU
-               {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.BuildPackages|Any CPU.Build.0 = Debug|Any CPU
                {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.Release|Any CPU.Build.0 = Release|Any CPU
-               {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU
-               {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU
+               {5787D082-7E4E-4B18-9C69-529CBC4F105E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {5787D082-7E4E-4B18-9C69-529CBC4F105E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {5787D082-7E4E-4B18-9C69-529CBC4F105E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {5787D082-7E4E-4B18-9C69-529CBC4F105E}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -175,6 +152,7 @@ Global
                {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {85CD9813-E182-4ED1-8D2C-38467657BEF3} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {CF8755E1-9E8B-4AD2-A7D1-D66D797004AD} = {16439374-B8DB-4643-8116-EB3358B49A12}
+               {5787D082-7E4E-4B18-9C69-529CBC4F105E} = {16439374-B8DB-4643-8116-EB3358B49A12}
        EndGlobalSection
        GlobalSection(ExtensibilityGlobals) = postSolution
                SolutionGuid = {1360F94D-CF3C-4121-A8D7-E227F41668F1}
index e208a33a701b1b12be695c4388257d9b01377b13..d527880ead96acc840b8017dedb45db26bfc040f 100644 (file)
@@ -153,10 +153,16 @@ namespace vke {
 
                        instance = new Instance (EnabledLayers, instExts.ToArray());
 
-                       hSurf = instance.CreateSurface (hWin);
-
                        selectPhysicalDevice ();
 
+                       if (phy == null) {
+                               instance.Dispose();
+                               terminateGLFW();
+                               throw new Exception("Required physical device not found.");
+                       }
+
+                       hSurf = instance.CreateSurface (hWin);
+
                        VkPhysicalDeviceFeatures enabledFeatures = default;
                        configureEnabledFeatures (phy.Features, ref enabledFeatures);
 
@@ -392,6 +398,15 @@ namespace vke {
 
                #region IDisposable Support
                protected bool isDisposed;
+               void terminateGLFW() {
+                               if (currentCursor != IntPtr.Zero)
+                                       Glfw3.DestroyCursor (currentCursor);
+                               if (hWin != IntPtr.Zero) {
+                                       windows.Remove (hWin);
+                                       Glfw3.DestroyWindow (hWin);
+                               }
+                               Glfw3.Terminate ();                     
+               }
 
                protected virtual void Dispose (bool disposing) {
                        if (!isDisposed) {
@@ -413,15 +428,7 @@ namespace vke {
                                } else
                                        Debug.WriteLine ("a VkWindow has not been correctly disposed");
 
-                               if (currentCursor != IntPtr.Zero)
-                                       Glfw3.DestroyCursor (currentCursor);
-
-                               windows.Remove (hWin);
-
-                               Glfw3.DestroyWindow (hWin);
-                               Glfw3.Terminate ();
-
-
+                               terminateGLFW();
                                isDisposed = true;
                        }
                }
index 859f129411d1a31e61225cc0f83d8024b0ea328c..3ef8269c6750c8bc30cebd181560c48302f1a46b 100644 (file)
@@ -166,16 +166,16 @@ namespace vke {
                                tiling, usage, flags, out properties);
                        return result == VkResult.Success;
                }
-               public VkPhysicalDeviceToolPropertiesEXT[] GetToolProperties () {
-                       CheckResult (vkGetPhysicalDeviceToolPropertiesEXT (phy , out uint count, IntPtr.Zero));
-                       int sizeStruct = Marshal.SizeOf<VkPhysicalDeviceToolPropertiesEXT> ();
+               public VkPhysicalDeviceToolProperties[] GetToolProperties () {
+                       CheckResult (vkGetPhysicalDeviceToolProperties (phy , out uint count, IntPtr.Zero));
+                       int sizeStruct = Marshal.SizeOf<VkPhysicalDeviceToolProperties> ();
                        IntPtr ptrTools = Marshal.AllocHGlobal (sizeStruct * (int)count);
-                       CheckResult (vkGetPhysicalDeviceToolPropertiesEXT (phy , out count, ptrTools));
+                       CheckResult (vkGetPhysicalDeviceToolProperties (phy , out count, ptrTools));
 
-                       VkPhysicalDeviceToolPropertiesEXT[] result = new VkPhysicalDeviceToolPropertiesEXT[count];
+                       VkPhysicalDeviceToolProperties[] result = new VkPhysicalDeviceToolProperties[count];
                        IntPtr tmp = ptrTools;
                        for (int i = 0; i < count; i++) {
-                               result[i] = Marshal.PtrToStructure<VkPhysicalDeviceToolPropertiesEXT> (tmp);
+                               result[i] = Marshal.PtrToStructure<VkPhysicalDeviceToolProperties> (tmp);
                                tmp += sizeStruct;
                        }
 
index d1d163c7c1500b7a662b66e10998316d7ff965d3..9ecb0ab2c9a6fea95fbdb7aafd39c93936b4c3b1 100644 (file)
@@ -48,7 +48,7 @@
 
        <ItemGroup>
                <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
-               <PackageReference Include="Vulkan" Version="0.4.1-beta" />
+               <PackageReference Include="Vulkan" Version="0.4.2" />
                <PackageReference Include="shaderc.net" Version="0.1.0" />
                <PackageReference Include="glfw-sharp" Version="0.2.14" />
        </ItemGroup>