]> O.S.I.I.S - jp/vke.net.git/commitdiff
debug, wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 17 Jan 2020 02:06:38 +0000 (03:06 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 17 Jan 2020 02:06:38 +0000 (03:06 +0100)
52 files changed:
SpirVTasks/CompileGLSLTask.cs
SpirVTasks/README.md
SpirVTasks/SpirVTasks.csproj
SpirVTasks/SpirVTasks.targets
addons/Directory.Build.props
addons/EnvironmentPipeline/EnvironmentPipeline.cs
addons/EnvironmentPipeline/EnvironmentPipeline.csproj
addons/gltfLoader/gltfLoader.csproj
samples/Directory.Build.props
samples/DistanceFieldFontTest/Program.cs
samples/Model/main.cs
samples/Textured/main.cs
samples/TexturedCube/main.cs
samples/Triangle/main.cs
samples/compute/delaunay.cs
samples/deferred/DeferredPbrRenderer.cs
samples/deferred/deferred.csproj
samples/deferred/main.cs
samples/deferred/shaders/compose_with_shadows.frag
samples/deferred/shaders/tone_mapping.frag
samples/deferred/shadowMapRenderer.cs
samples/pbr/PbrPipeline.cs
samples/pbr/main.cs
samples/pbr/pbr.csproj
vke.net.sln
vke/shaders/debug.frag [new file with mode: 0644]
vke/shaders/debug.vert [new file with mode: 0644]
vke/src/Camera.cs
vke/src/ExtensionMethods.cs
vke/src/Utils.cs
vke/src/VkWindow.cs
vke/src/base/Activable.cs
vke/src/base/Buffer.cs
vke/src/base/CommandBuffer.cs
vke/src/base/CommandPool.cs
vke/src/base/DebuDrawPipeline.cs
vke/src/base/DebugUtilsMessenger.cs
vke/src/base/DescriptorPool.cs
vke/src/base/DescriptorSetLayout.cs
vke/src/base/Device.cs
vke/src/base/FrameBuffer.cs
vke/src/base/GraphicPipeline.cs
vke/src/base/GraphicPipelineConfig.cs
vke/src/base/Image.cs
vke/src/base/Instance.cs
vke/src/base/Pipeline.cs
vke/src/base/PipelineCache.cs
vke/src/base/PipelineLayout.cs
vke/src/base/QueryPool.cs
vke/src/base/RenderPass.cs
vke/src/base/SwapChain.cs
vke/vke.csproj

index 80765bc1ba61fa16533f852fdc7d45bdabcc1f32..e6774a65df4ac64d94de71fc93badc425ea92187 100644 (file)
@@ -61,7 +61,10 @@ namespace SpirVTasks {
                        get;
                        set;
                }
-               public ITaskItem Optimisation {
+               /// <summary>
+               /// Optional, set optimization flag. Accepted values are NONE, PERF and SIZE. By default PERF is selected.
+               /// </summary>
+               public ITaskItem Optimization {
                        get;
                        set;
                }
@@ -205,12 +208,12 @@ namespace SpirVTasks {
                                }
                        }
                        string optimisationStr = "";
-                       if (!string.IsNullOrEmpty (Optimisation?.ItemSpec)) {
-                               if (string.Equals (Optimisation.ItemSpec, "perf", StringComparison.OrdinalIgnoreCase))
+                       if (!string.IsNullOrEmpty (Optimization?.ItemSpec)) {
+                               if (string.Equals (Optimization.ItemSpec, "perf", StringComparison.OrdinalIgnoreCase))
                                        optimisationStr = "-O";
-                               else if (string.Equals (Optimisation.ItemSpec, "size", StringComparison.OrdinalIgnoreCase))
+                               else if (string.Equals (Optimization.ItemSpec, "size", StringComparison.OrdinalIgnoreCase))
                                        optimisationStr = "-Os";
-                               else if (string.Equals (Optimisation.ItemSpec, "none", StringComparison.OrdinalIgnoreCase))
+                               else if (string.Equals (Optimization.ItemSpec, "none", StringComparison.OrdinalIgnoreCase))
                                        optimisationStr = "-O0";
                        }else
                                optimisationStr = "-O";
@@ -229,7 +232,7 @@ namespace SpirVTasks {
                        glslc.OutputDataReceived += Glslc_OutputDataReceived;
                        glslc.ErrorDataReceived += Glslc_ErrorDataReceived;
 
-                       Log.LogMessage (MessageImportance.High, $"-> glslc {glslc.StartInfo.Arguments}");
+                       Log.LogMessage (MessageImportance.Normal, $"-> glslc {glslc.StartInfo.Arguments}");
 
                        glslc.Start ();
 
@@ -252,9 +255,9 @@ namespace SpirVTasks {
 
                        string[] tmp = e.Data.Split (':');
 
-                       Log.LogMessage (MessageImportance.High, $"glslc: {e.Data}");
+                       //Log.LogMessage (MessageImportance.High, $"glslc: {e.Data}");
 
-                       if (tmp.Length == 5) {
+                       if (tmp.Length > 4) {
                                string srcFile = SourceFile.ItemSpec;
                                int line = Math.Max (0, int.Parse (tmp[1]));
 
@@ -271,7 +274,13 @@ namespace SpirVTasks {
                                //}
                                //Log.LogMessage (MessageImportance.High, $"====================================");
 
-                               BuildErrorEventArgs err = new BuildErrorEventArgs ("compile", tmp[2], srcFile, line, 0, 0, 0, $"{tmp[3]} {tmp[4]}", "no help", "SpirVTasks");
+
+                               string msg = tmp[4];
+
+                               if (tmp.Length > 5) 
+                                       msg += tmp.Skip(5).Aggregate ((i, j) => i + ", " + j);
+
+                               BuildErrorEventArgs err = new BuildErrorEventArgs ("compile", tmp[2], srcFile, line, 0, 0, 0, $"{tmp[3]} {msg}", "no help", "SpirVTasks");
                                BuildEngine.LogErrorEvent (err);
                                success = false;
                        } else {
index e3659cdcf583e65eb2ac6d636847762ae79ad91b..7e720845d2e3a85c3b845655b6d8218319d8176d 100644 (file)
 </p>
 </h1>
 
-`SpirVTasks` package add `SpirV` compilation support to msbuild project. Error and warning
-are routed to the `IDE`.
+**SpirVTasks** package add **SpirV** compilation support to msbuild project. Error and warning are routed to the `IDE`.
 
-
-#### Usage
+## Usage
 ```xml
+<ItemGroup>
+  <PackageReference Include="SpirVTasks" Version="0.1.15-beta" />              
+</ItemGroup>
 <ItemGroup>    
   <GLSLShader Include="shaders\*.frag;shaders\*.vert;shaders\*.comp;shaders\*.geom" />
 </ItemGroup> 
 ```
-Resulting `.spv` files are embedded with resource ID = `ProjectName.file.ext.spv`. You can override the default resource id by adding a custom LogicalName.
+Resulting `.spv` files are embedded with resource ID = `ProjectName.file.ext.spv`. You can override the default resource id by adding a custom **LogicalName**.
 ```xml
 <ItemGroup>    
   <GLSLShader Include="shaders\skybox.vert">
@@ -29,14 +30,15 @@ Resulting `.spv` files are embedded with resource ID = `ProjectName.file.ext.spv
   </GLSLShader>
 </ItemGroup> 
 ```
-`VULKAN_SDK`/bin then `PATH` are searched for the `glslc` executable. You can also use the `SpirVglslcPath` property.
+
+`VULKAN_SDK/bin` then `PATH` are searched for the `glslc` executable. You can also use the `SpirVglslcPath` property.
 ```xml
 <PropertyGroup>
   <SpirVglslcPath>bin\glslc.exe</SpirVglslcPath>
 </PropertyGroup>
 ```
 
-#### Include in glsl
+## Include in glsl
 ```glsl
 #include <preamble.inc>
 
@@ -55,6 +57,20 @@ Included files are searched from the location of the current parsed file, then i
 </PropertyGroup>
 ```
 
-#### todo
+## Additional attributes
+
+**Optimisation** attribute will set compiler flag for resulting code optimizations.
+```
+<GLSLShader Include="shaders\skybox.vert" Optimization="size"/>
+```
+Default optimization if this attribute is not present is **PERF**, accepted values are:
+- NONE: no optimization.
+- PERF: spirv will be optimized for performances.
+- SIZE: resulting code size will be minimized.
+
+**DefineConstants** attribute may contains a semicolon separated list of implicit **MACRO** to define for compilation.
+
+```
+<GLSLShader Include="shaders\skybox.vert" DefineConstants="DEBUG;SHADOW_FACTOR=0.15"/>
+```
 
-- Error source file and line with included files.
index 96571899a3c5ca14b4600174a411ac42711a670b..2636b86929be29cabf401b85701fa79bec0a373b 100644 (file)
@@ -1,41 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
 <Project Sdk="Microsoft.NET.Sdk">
-    <PropertyGroup>
-        <TargetFrameworks>netstandard2.0</TargetFrameworks>
-        <ReleaseVersion>0.1.32</ReleaseVersion>
-        <SynchReleaseVersion>false</SynchReleaseVersion>
-        <AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
-        <Description>MSBuild addon to compile and embed spirV shaders</Description>
-
-        <PackageId>SpirVTasks</PackageId>
-        <PackageTags>vulkan msbuild spirv glsl addons</PackageTags>    
-        <PackageVersion>$(ReleaseVersion)-beta</PackageVersion>
-        <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-        <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
-        <PackageProjectUrl>https://github.com/jpbruyere/vk.net/blob/master/SpirVTasks/README.md</PackageProjectUrl>
-        <License>MIT</License>
-        <Authors>Jean-Philippe Bruyère</Authors>        
-        <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
-        
-        <IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>               
+       <PropertyGroup>
+               <TargetFrameworks>netstandard2.0</TargetFrameworks>
+               
+               <ReleaseVersion>0.1.37</ReleaseVersion>
+               
+               <SynchReleaseVersion>false</SynchReleaseVersion>
+               <AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
+               <Description>MSBuild addon to compile and embed spirV shaders</Description>
+               <PackageId>SpirVTasks</PackageId>
+               <PackageTags>vulkan msbuild spirv glsl addons</PackageTags>
+               <PackageVersion>$(ReleaseVersion)-beta</PackageVersion>
+               <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+               <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
+               <PackageProjectUrl>https://github.com/jpbruyere/vk.net/blob/master/SpirVTasks/README.md</PackageProjectUrl>
+               <License>MIT</License>
+               <Authors>Jean-Philippe Bruyère</Authors>
+               <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
+               <IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>
                <EnableDefaultContentItems>false</EnableDefaultContentItems>
                <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
                <EnableDefaultCompileItems>true</EnableDefaultCompileItems>
-        
                <AssemblyName>SpirVTasks_$(TargetFramework)</AssemblyName>
-    </PropertyGroup>
-    <ItemGroup>        
-        <PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
-    </ItemGroup>
-    <ItemGroup>
-      <Content Include="SpirVTasks.targets">
-        <Pack>true</Pack>
-        <IncludeInPackage>true</IncludeInPackage>
-        <PackagePath>build\</PackagePath>
-      </Content>
-      <Content Include="spirv.xml">        
-        <Pack>true</Pack>
-        <IncludeInPackage>true</IncludeInPackage>
-        <PackagePath>build</PackagePath>
-      </Content>
-    </ItemGroup>
-</Project>
+       </PropertyGroup>
+       <ItemGroup>
+               <PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
+       </ItemGroup>
+       <ItemGroup>
+               <Content Include="SpirVTasks.targets">
+                       <Pack>true</Pack>
+                       <IncludeInPackage>true</IncludeInPackage>
+                       <PackagePath>build\</PackagePath>
+               </Content>
+               <Content Include="spirv.xml">
+                       <Pack>true</Pack>
+                       <IncludeInPackage>true</IncludeInPackage>
+                       <PackagePath>build</PackagePath>
+               </Content>
+       </ItemGroup>
+</Project>
\ No newline at end of file
index 6da971e98b422b82e5316abb9d98c6798d663d8b..c1176e65a416e7ae90555734e1695e7131af9d96 100644 (file)
@@ -26,6 +26,6 @@
                                        TaskParameter="Include"                 
                                        ItemName="EmbeddedResource"/>       
     </CreateItem>              
-               <Message Importance="High" Text="%(GLSLShader.Identity) -> $(AssemblyName).%(Filename)%(Extension).spv (Embedded Resource)" />
+               <Message Importance="High" Text="%(GLSLShader.Identity) -> %(GLSLShader.LogicalName) (Embedded Resource)" />
   </Target>
 </Project>
index 29b7f6f21f946af295706c8332a71b75ff05d34c..9f566b4e546c6d06fbf4fdd518796e40a05db932 100644 (file)
@@ -3,7 +3,7 @@
                <RootDirectory>$(MSBuildThisFileDirectory)../</RootDirectory>
                <Deterministic>true</Deterministic>
 
-               <TargetFrameworks>netstandard2.0</TargetFrameworks>
+               <TargetFrameworks>netstandard2.0</TargetFrameworks>             
 
                <RepositoryUrl>https://github.com/jpbruyere/vke.net</RepositoryUrl>
                <License>MIT</License>
                <DefineConstants>NETSTANDARD;NETSTANDARD2_0;WITH_SHADOWS;_WITH_VKVG</DefineConstants>    
        </PropertyGroup>        
 
-       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">    
+       <ItemGroup Condition=" '$(Configuration)|$(Platform)' != 'BuildPackages|AnyCPU' ">
                <ProjectReference Include="..\..\vke\vke.csproj" />
        </ItemGroup>
-       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-               <PackageReference Include="vke" Version="0.1.8-beta" />
-       </ItemGroup>    
+       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'BuildPackages|AnyCPU' ">
+               <PackageReference Include="vke" Version="0.1.11-beta" />
+       </ItemGroup>
        
        <ItemGroup>
-               <PackageReference Include="SpirVTasks" Version="0.1.15-beta" />         
+               <PackageReference Include="SpirVTasks" Version="0.1.37-beta" /> 
+               <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />                  
        </ItemGroup>    
-
+       
        <ItemGroup>
                <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom" />
        </ItemGroup>
index cab3f3092a3519b93a9dcd1cc1fa7c52793428bb..fcb4c2c08b64e660f8666c1894af8807aed33f96 100644 (file)
@@ -5,6 +5,7 @@ using Vulkan;
 
 namespace vke.Environment {
        public class EnvironmentCube : GraphicPipeline {
+               public static string STR_FRAG_PATH = "#EnvironmentPipeline.skybox.frag.spv";
 
                GPUBuffer vboSkybox;
 
@@ -13,7 +14,7 @@ namespace vke.Environment {
                public Image irradianceCube { get; private set; }
                public Image prefilterCube { get; set; }
 
-               public EnvironmentCube (string cubemapPath, DescriptorSet dsSkybox, PipelineLayout plLayout, Queue staggingQ, RenderPass renderPass, PipelineCache cache = null)
+               public EnvironmentCube (string cubemapPath, PipelineLayout plLayout, Queue staggingQ, RenderPass renderPass, PipelineCache cache = null)
                : base (renderPass, cache, "EnvCube pipeline") {
 
                        using (CommandPool cmdPool = new CommandPool (staggingQ.Dev, staggingQ.index)) {
@@ -33,7 +34,7 @@ namespace vke.Environment {
                                cfg.AddVertexBinding (0, 3 * sizeof (float));
                                cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat);
                                cfg.AddShader (VkShaderStageFlags.Vertex, "#EnvironmentPipeline.skybox.vert.spv");
-                               cfg.AddShader (VkShaderStageFlags.Fragment, "#EnvironmentPipeline.skybox.frag.spv");
+                               cfg.AddShader (VkShaderStageFlags.Fragment, STR_FRAG_PATH);
                                cfg.multisampleState.rasterizationSamples = Samples;
 
                                layout = cfg.Layout;
index ef6f39c384ce8651782580657157101de97f4466..1344f296b62d204a307591c8e2e7ef6b9de90cd4 100644 (file)
@@ -3,7 +3,7 @@
   <PropertyGroup>
     <AssemblyName>EnvironmentPipeline</AssemblyName>
     <PackageId>vke.EnvironmentPipeline</PackageId>
-    <AssemblyVersion>0.1.0</AssemblyVersion>
+    <AssemblyVersion>0.1.2</AssemblyVersion>
     <Description>vke.net Environment cube pipeline</Description>
     <PackageTags>vulkan c# vke.net</PackageTags>    
     <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
index 0e9ebb40ad6d80a3b087e5df7404558dd6add06b..a9474c46e0d42bbc5fc00c3161d14f7a4823f7a3 100644 (file)
@@ -3,7 +3,7 @@
   <PropertyGroup>
     <AssemblyName>vke.gltfLoader</AssemblyName>
     <PackageId>vke.gltfLoader</PackageId>
-    <AssemblyVersion>0.1.7</AssemblyVersion>
+    <AssemblyVersion>0.1.8</AssemblyVersion>
     <Description>vke.net gltf addons</Description>
     <PackageTags>C# vulkan CVKL gltf</PackageTags>    
     <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
index f96af28181c5b685b5972dde4816b8fdcc09fbc4..f6d84427767019e0423c3d2cc622d52933ae4f9a 100644 (file)
        </PropertyGroup>
     
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">    
-               <DefineConstants>TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;WITH_VKVG</DefineConstants>    
+               <DefineConstants>TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;WITH_SHADOWS;WITH_VKVG</DefineConstants>    
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
                <DefineConstants>NETSTANDARD;NETSTANDARD2_0;WITH_SHADOWS;_WITH_VKVG</DefineConstants>    
        </PropertyGroup>
                
-       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">    
+       <ItemGroup Condition=" '$(Configuration)|$(Platform)' != 'BuildPackages|AnyCPU' ">
                <ProjectReference Include="..\..\vke\vke.csproj" />
        </ItemGroup>
-       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-               <PackageReference Include="vke" Version="0.1.8-beta" />
+       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'BuildPackages|AnyCPU' ">
+               <PackageReference Include="vke" Version="0.1.11-beta" />
        </ItemGroup>
                        
        <ItemGroup>
-               <PackageReference Include="SpirVTasks" Version="0.1.15-beta" />         
+               <PackageReference Include="SpirVTasks" Version="0.1.37-beta" />         
        </ItemGroup>    
 
        <ItemGroup>    
-               <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom" />
+               <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">
+                       <LogicalName>shaders.%(Filename)%(Extension).spv</LogicalName>
+               </GLSLShader>           
+    <EmbeddedResource Include="ui\**\*.*">
+      <LogicalName>ui.%(Filename)%(Extension)</LogicalName>
+    </EmbeddedResource>                
        </ItemGroup>     
-       
 </Project>
index 666a1d1b30a3303250095c591a6b05bae51983b0..7e0d330a61fbfbcb3997b27b3bbf2be1e3d98ad2 100644 (file)
@@ -92,8 +92,8 @@ namespace DistanceFieldFontTest {
                        cfg.AddVertexBinding (0, 5 * sizeof (float));
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#DistanceFieldFontTest.main.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#DistanceFieldFontTest.main.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.main.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.main.frag.spv");
 
                        pipeline = new GraphicPipeline (cfg);
 
index d4ce8648313d78155a3629953c30f1d5fbe85004..e93019dd2b84106a54e6269ea9cc28dd3ef0ced4 100644 (file)
@@ -26,10 +26,6 @@ namespace ModelSample
                        public Matrix4x4 model;
                }
 
-               public struct PushConstants {
-                       public Matrix4x4 matrix;
-               }
-
                Matrices matrices;
 
                HostBuffer uboMats;
@@ -66,13 +62,7 @@ namespace ModelSample
                                new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                new VkDescriptorSetLayoutBinding (2, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                        );
-
-                       VkPushConstantRange pushConstantRange = new VkPushConstantRange { 
-                               stageFlags = VkShaderStageFlags.Vertex,
-                               size = (uint)Marshal.SizeOf<PushConstants>(),
-                               offset = 0
-                       };
-
+                               
                        GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, NUM_SAMPLES);
                        cfg.rasterizationState.cullMode = VkCullModeFlags.Back;
                        if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1) {
@@ -80,13 +70,13 @@ namespace ModelSample
                                cfg.multisampleState.minSampleShading = 0.5f;
                        }
 
-                       cfg.Layout = new PipelineLayout (dev, pushConstantRange, descLayoutMatrix, descLayoutTextures);
+                       cfg.Layout = new PipelineLayout (dev, new VkPushConstantRange(VkShaderStageFlags.Vertex, (uint)Marshal.SizeOf<Matrix4x4> ()), descLayoutMatrix, descLayoutTextures);
                        cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat (), cfg.Samples);
                        cfg.AddVertexBinding<Model.Vertex> (0);
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#Model.model.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#Model.model.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.model.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.model.frag.spv");
 
                        pipeline = new GraphicPipeline (cfg);
 
@@ -110,8 +100,8 @@ namespace ModelSample
                }
 
                public override void UpdateView () {
-                       matrices.projection = Matrix4x4.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (45f),
-                               (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f) * Camera.VKProjectionCorrection;
+                       matrices.projection = Utils.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (45f),
+                               (float)swapChain.Width / (float)swapChain.Height, 0.1f, 16.0f);
                        matrices.view =
                                Matrix4x4.CreateFromAxisAngle (Vector3.UnitZ, rotZ) *
                                Matrix4x4.CreateFromAxisAngle (Vector3.UnitY, rotY) *
@@ -148,8 +138,8 @@ namespace ModelSample
                                cmds[i].BindDescriptorSet (pipeline.Layout, dsMatrices);
                                cmds[i].BindDescriptorSet (pipeline.Layout, dsTextures, 1);
 
-                               PushConstants pc = new PushConstants { matrix = Matrix4x4.Identity };
-                               cmds[i].PushConstant (pipeline.Layout, VkShaderStageFlags.Vertex, pc, (uint)Marshal.SizeOf<Matrix4x4> ());
+                               Matrix4x4 matrix = Matrix4x4.Identity;
+                               cmds[i].PushConstant (pipeline.Layout, VkShaderStageFlags.Vertex, matrix);
 
                                cmds[i].BindPipeline (pipeline);
 
index e78dea0cc1feec8b4906af763318575c7503ff94..b14dd459ba056c28f7840c9df8dfd905bdd13f47 100644 (file)
@@ -60,13 +60,11 @@ namespace Textured {
                ushort[] indices = { 0, 1, 2, 2, 0, 3 };
                int currentImgIndex = 0;
                string[] imgPathes = {
-                       "/mnt/devel/vulkan/VulkanExamples/data/models/voyager/voyager_rgba_unorm.ktx",
-                       "/mnt/devel/vulkan/vulkanExUpstream/data/models/voyager/voyager_astc_8x8_unorm.ktx",
-                       Utils.DataDirectory + "font.ktx",
-                       "/mnt/devel/vulkan/vulkanExUpstream/data/textures/trail_astc_8x8_unorm.ktx",
+                       Utils.DataDirectory + "models/Bricks16_col.jpg",
                        Utils.DataDirectory + "textures/texturearray_rocks_bc3_unorm.ktx",
                        Utils.DataDirectory + "textures/texture.jpg",
                        Utils.DataDirectory + "textures/tex256.jpg",
+                       Utils.DataDirectory + "font.ktx",
                };
 
                Program () : base () {
@@ -94,8 +92,8 @@ namespace Textured {
                        cfg.AddVertexBinding (0, 5 * sizeof(float));
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#Textured.main.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#Textured.main.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.main.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.main.frag.spv");
 
                        pipeline = new GraphicPipeline (cfg);
 
@@ -112,6 +110,7 @@ namespace Textured {
                }
 
                void buildCommandBuffers () {
+                       dev.WaitIdle ();
                        cmdPool.Reset();
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
                                cmds[i].Start();
@@ -161,6 +160,8 @@ namespace Textured {
                        nextTexture.CreateSampler ();
                        nextTexture.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
 
+                       dev.WaitIdle ();
+
                        DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, dsLayout.Bindings[1]);
                        uboUpdate.Write (dev, nextTexture.Descriptor);
 
index 186817a57b66c48ef2148906affd4235ba0ae7e3..d15a0292ad241a782dd28223cbd6e2b267e7eeca 100644 (file)
@@ -131,8 +131,8 @@ namespace TextureCube {
                        cfg.AddVertexBinding (0, 5 * sizeof (float));
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#TexturedCube.skybox.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#TexturedCube.skybox.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.skybox.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.skybox.frag.spv");
 
                        pipeline = new GraphicPipeline (cfg);
 
index 3524a2d42e287e16773704f39931f72871bdbb62..d49856205c6c1ec705c08dc9b5f0a435d427d295 100644 (file)
@@ -2,12 +2,18 @@
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
+using System.IO;
 using System.Numerics;
 using System.Runtime.InteropServices;
+using System.Xml.Serialization;
 using vke;
 using Vulkan;
 
 namespace Triangle {
+       public class Renderer {
+               public DescriptorPool descriptorPool;
+               [XmlIgnore] public DescriptorSetLayout dsLayout;
+       }
        class Program : VkWindow {
                static void Main (string[] args) {
 #if DEBUG
@@ -44,8 +50,6 @@ namespace Triangle {
                HostBuffer vbo;
                HostBuffer uboMats;
 
-               DescriptorPool descriptorPool;
-               DescriptorSetLayout dsLayout;
                DescriptorSet descriptorSet;
 
                FrameBuffers frameBuffers;
@@ -58,6 +62,10 @@ namespace Triangle {
                };
                ushort[] indices = new ushort[] { 0, 1, 2 };
 
+
+
+               public Renderer r = new Renderer ();
+
                Program () : base () {
                        cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
 
@@ -65,27 +73,36 @@ namespace Triangle {
                        ibo = new HostBuffer<ushort> (dev, VkBufferUsageFlags.IndexBuffer, indices);
                        uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices);
 
-                       descriptorPool = new DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer));
-                       dsLayout = new DescriptorSetLayout (dev,
-                               new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer));
+                       r.descriptorPool = new DescriptorPool (dev, 1,
+                               new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer),
+                               new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler));                              
+
+                       XmlSerializer serializer = new XmlSerializer (typeof(Renderer), Utils.GetXmlOverrides());
+                       using (Stream s = new FileStream ("/home/jp/test.xml", FileMode.Create)) {
+                               serializer.Serialize (s, r);
+                       }
+
+
+                       r.dsLayout = new DescriptorSetLayout (dev,
+                                       new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer));
 
                        GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1,false);
 
-                       cfg.Layout = new PipelineLayout (dev, dsLayout);
+                       cfg.Layout = new PipelineLayout (dev, r.dsLayout);
                        cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, cfg.Samples);
                        cfg.AddVertexBinding<Vertex> (0);
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#Triangle.main.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#Triangle.main.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.main.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.main.frag.spv");
 
                        pipeline = new GraphicPipeline (cfg);
 
                        //note that descriptor set is allocated after the pipeline creation that use this layout, layout is activated
                        //automaticaly on pipeline creation, and will be disposed automatically when no longuer in use.
-                       descriptorSet = descriptorPool.Allocate (dsLayout);
+                       descriptorSet = r.descriptorPool.Allocate (r.dsLayout);
 
-                       DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, dsLayout);
+                       DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, r.dsLayout);
                        uboUpdate.Write (dev, uboMats.Descriptor);
 
                        uboMats.Map ();
@@ -159,7 +176,7 @@ namespace Triangle {
                                        pipeline.Dispose ();
 
                                        frameBuffers?.Dispose();
-                                       descriptorPool.Dispose ();
+                                       r.descriptorPool.Dispose ();
                                        vbo.Dispose ();
                                        ibo.Dispose ();
                                        uboMats.Dispose ();
index 52a3b494f67c5185d25369bdc9aaa8181d09272b..4a36790da472a8066f988ea17dad4bf7eeaa0af7 100644 (file)
@@ -89,7 +89,7 @@ namespace delaunay {
 
                        cfg.ResetShadersAndVerticesInfos ();
                        cfg.AddShader (VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#compute.simpletexture.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.simpletexture.frag.spv");
 
                        cfg.blendAttachments[0] = new VkPipelineColorBlendAttachmentState (true);
 
@@ -97,10 +97,10 @@ namespace delaunay {
 
                        plCompute = new ComputePipeline (
                                new PipelineLayout (dev, new VkPushConstantRange (VkShaderStageFlags.Compute, 2 * sizeof (int)), dslCompute),
-                               "#compute.computeTest.comp.spv");
+                               "#shaders.computeTest.comp.spv");
                        plNormalize = new ComputePipeline (
                                plCompute.Layout,
-                               "#compute.normalize.comp.spv");
+                               "#shaders.normalize.comp.spv");
 
                        dsImage = dsPool.Allocate (dslImage);
                        dsetPing = dsPool.Allocate (dslCompute);
index 3ccc4c064cebadea7a768a8f9ba618511e02f544..a17e5b5dac3028e3cdb6412f3214fc6f19546f27 100644 (file)
@@ -54,21 +54,21 @@ namespace deferred {
                }
 
                public Matrices matrices = new Matrices {
-                       scaleIBLAmbient = 0.5f,
+                       scaleIBLAmbient = 1.0f,
                };
                public Light[] lights = {
                        new Light {
-                               position = new Vector4(2.5f,5.5f,2,0f),
-                               color = new Vector4(1,0.8f,0.8f,1)
+                               position = new Vector4(1.5f,2.5f,1.5f,0f),
+                               color = new Vector4(1,1.0f,1.0f,1)
                        },
-                       /*new Light {
-                               position = new Vector4(-2.5f,5.5f,2,0f),
+                       new Light {
+                               position = new Vector4(-1.5f,2.5f,1.5f,0f),
                                color = new Vector4(0.8f,0.8f,1,1)
-                       }*/
+                       }
                };
 
                FrameBuffer frameBuffer;
-               public Image gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgResolved, hdrImgMS;
+               public Image gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgResolved;
 
                DescriptorPool descriptorPool;
                DescriptorSetLayout descLayoutMain, descLayoutTextures, descLayoutGBuff;
@@ -132,14 +132,12 @@ namespace deferred {
                void init_renderpass () {
                        renderPass = new RenderPass (dev, NUM_SAMPLES);
 
-                       renderPass.AddAttachment (HDR_FORMAT, VkImageLayout.ColorAttachmentOptimal, VkSampleCountFlags.SampleCount1);//final outpout
+                       renderPass.AddAttachment (HDR_FORMAT, VkImageLayout.ShaderReadOnlyOptimal, NUM_SAMPLES);//final outpout
                        renderPass.AddAttachment (dev.GetSuitableDepthFormat (), VkImageLayout.DepthStencilAttachmentOptimal, NUM_SAMPLES);
                        renderPass.AddAttachment (VkFormat.R8g8b8a8Unorm, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff0 (color + roughness) and final color before resolve
                        renderPass.AddAttachment (VkFormat.R8g8b8a8Unorm, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff1 (emit + metal)
                        renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff2 (normals + AO)
                        renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff3 (Pos + depth)
-                       if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
-                               renderPass.AddAttachment (HDR_FORMAT, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES);//hdr color multisampled
 
                        renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) });
                        renderPass.ClearValues.Add (new VkClearValue { depthStencil = new VkClearDepthStencilValue (1.0f, 0) });
@@ -147,30 +145,24 @@ namespace deferred {
                        renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) });
                        renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) });
                        renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) });
-                       if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
-                                       renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) });
-
-                       uint mainHdr = NUM_SAMPLES == VkSampleCountFlags.SampleCount1 ? 0u : 6u;
 
                        SubPass[] subpass = { new SubPass (), new SubPass (), new SubPass ()};
                        //skybox
-                       subpass[SP_SKYBOX].AddColorReference (mainHdr, VkImageLayout.ColorAttachmentOptimal);
+                       subpass[SP_SKYBOX].AddColorReference (0, VkImageLayout.ColorAttachmentOptimal);
                        //models
                        subpass[SP_MODELS].AddColorReference (new VkAttachmentReference (2, VkImageLayout.ColorAttachmentOptimal),
                                                                        new VkAttachmentReference (3, VkImageLayout.ColorAttachmentOptimal),
                                                                        new VkAttachmentReference (4, VkImageLayout.ColorAttachmentOptimal),
                                                                        new VkAttachmentReference (5, VkImageLayout.ColorAttachmentOptimal));
                        subpass[SP_MODELS].SetDepthReference (1, VkImageLayout.DepthStencilAttachmentOptimal);
-                       subpass[SP_MODELS].AddPreservedReference (mainHdr);
+                       subpass[SP_MODELS].AddPreservedReference (0);
 
                        //compose
-                       subpass[SP_COMPOSE].AddColorReference (mainHdr, VkImageLayout.ColorAttachmentOptimal);
+                       subpass[SP_COMPOSE].AddColorReference (0, VkImageLayout.ColorAttachmentOptimal);
                        subpass[SP_COMPOSE].AddInputReference (new VkAttachmentReference (2, VkImageLayout.ShaderReadOnlyOptimal),
                                                                        new VkAttachmentReference (3, VkImageLayout.ShaderReadOnlyOptimal),
                                                                        new VkAttachmentReference (4, VkImageLayout.ShaderReadOnlyOptimal),
                                                                        new VkAttachmentReference (5, VkImageLayout.ShaderReadOnlyOptimal));
-                       if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
-                               subpass[SP_COMPOSE].AddResolveReference (0, VkImageLayout.ColorAttachmentOptimal);
                        //tone mapping
                        //subpass[SP_TONE_MAPPING].AddColorReference ((NUM_SAMPLES == VkSampleCountFlags.SampleCount1) ? 0u : 2u, VkImageLayout.ColorAttachmentOptimal);
                        //subpass[SP_TONE_MAPPING].AddInputReference (new VkAttachmentReference (6, VkImageLayout.ShaderReadOnlyOptimal));
@@ -273,11 +265,11 @@ namespace deferred {
                                                new SpecializationConstant<float> (1, farPlane),
                                                new SpecializationConstant<float> (2, MAX_MATERIAL_COUNT))) {
 
-                               cfg.AddShader (VkShaderStageFlags.Vertex, "#deferred.GBuffPbr.vert.spv");
+                               cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.GBuffPbr.vert.spv");
                                if (TEXTURE_ARRAY) 
-                                       cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.GBuffPbrTexArray.frag.spv", constants);
+                                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.GBuffPbrTexArray.frag.spv", constants);
                                else
-                                       cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.GBuffPbr.frag.spv", constants);
+                                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.GBuffPbr.frag.spv", constants);
 
                                gBuffPipeline = new GraphicPipeline (cfg);
                        }
@@ -294,25 +286,25 @@ namespace deferred {
                                new SpecializationConstant<uint> (0, (uint)lights.Length))) {
                                cfg.AddShader (VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv");
 #if WITH_SHADOWS
-                               cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.compose_with_shadows.frag.spv", constants);
+                               cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.compose_with_shadows.frag.spv", constants);
 #else
-                               cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.compose.frag.spv", constants);
+                               cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.compose.frag.spv", constants);
 #endif
                                composePipeline = new GraphicPipeline (cfg);
                        }
                        //DEBUG DRAW use subpass of compose
-                       cfg.shaders[1] = new ShaderInfo (VkShaderStageFlags.Fragment, "#deferred.show_gbuff.frag.spv");
+                       cfg.shaders[1] = new ShaderInfo (VkShaderStageFlags.Fragment, "#shaders.show_gbuff.frag.spv");
                        cfg.SubpassIndex = SP_COMPOSE;
                        debugPipeline = new GraphicPipeline (cfg);
                        ////TONE MAPPING
-                       //cfg.shaders[1] = new ShaderInfo (VkShaderStageFlags.Fragment, "#deferred.tone_mapping.frag.spv");
+                       //cfg.shaders[1] = new ShaderInfo (VkShaderStageFlags.Fragment, "#shaders.tone_mapping.frag.spv");
                        //cfg.SubpassIndex = SP_TONE_MAPPING;
                        //toneMappingPipeline = new GraphicPipeline (cfg);
 
                        dsMain = descriptorPool.Allocate (descLayoutMain);
                        dsGBuff = descriptorPool.Allocate (descLayoutGBuff);
 
-                       envCube = new EnvironmentCube (cubemapPath, dsMain, gBuffPipeline.Layout, gQueue, renderPass);
+                       envCube = new EnvironmentCube (cubemapPath, gBuffPipeline.Layout, gQueue, renderPass);
 
                        matrices.prefilteredCubeMipLevels = envCube.prefilterCube.CreateInfo.mipLevels;
 
@@ -380,6 +372,7 @@ namespace deferred {
 
                        renderPass.BeginSubPass (cmd);
 
+                       //cmd.BindDescriptorSet (composePipeline.Layout, dsMain);
                        cmd.BindDescriptorSet (composePipeline.Layout, dsGBuff, 1);
 
                        if (currentDebugView == DebugView.none)
@@ -415,15 +408,13 @@ namespace deferred {
                        camera.AspectRatio = (float)width / height;
 
                        matrices.projection = camera.Projection;
+                       //matrices.projection = Utils.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (60), 1, 0.1f, 16f);
                        matrices.view = camera.View;
+                       //matrices.view = Matrix4x4.CreateLookAt (lights[0].position.ToVector3 (), Vector3.Zero, Vector3.UnitY);
                        matrices.model = camera.Model;
 
-                       matrices.camPos = new Vector4 (
-                               -camera.Position.Z * (float)Math.Sin (camera.Rotation.Y) * (float)Math.Cos (camera.Rotation.X),
-                                camera.Position.Z * (float)Math.Sin (camera.Rotation.X),
-                                camera.Position.Z * (float)Math.Cos (camera.Rotation.Y) * (float)Math.Cos (camera.Rotation.X),
-                                0
-                       );
+                       Matrix4x4.Invert (camera.View, out Matrix4x4 inv);
+                       matrices.camPos = new Vector4 (inv.M41, inv.M42, inv.M43, 0);
 
                        uboMatrices.Update (matrices, (uint)Marshal.SizeOf<Matrices> ());
                }
@@ -437,16 +428,13 @@ namespace deferred {
                        gbN_AO?.Dispose ();
                        gbPos?.Dispose ();
                        hdrImgResolved?.Dispose ();
-                       hdrImgMS?.Dispose ();
 
 
-                       hdrImgResolved = new Image (dev, HDR_FORMAT, VkImageUsageFlags.Sampled | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransferSrc, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, VkSampleCountFlags.SampleCount1);
+                       hdrImgResolved = new Image (dev, HDR_FORMAT, VkImageUsageFlags.Sampled | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransferSrc, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
                        gbColorRough = new Image (dev, VkFormat.R8g8b8a8Unorm, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
                        gbEmitMetal = new Image (dev, VkFormat.R8g8b8a8Unorm, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
                        gbN_AO = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
                        gbPos = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
-                       if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
-                               hdrImgMS = new Image (dev, HDR_FORMAT, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, width, height, VkImageType.Image2D, NUM_SAMPLES);
 
 
                        gbColorRough.CreateView (); gbColorRough.CreateSampler ();
@@ -460,9 +448,6 @@ namespace deferred {
                        hdrImgResolved.CreateView (); hdrImgResolved.CreateSampler ();
                        hdrImgResolved.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
 
-                       hdrImgMS?.CreateView ();
-
-
                        DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descLayoutGBuff);
                        uboUpdate.Write (dev, dsGBuff,  gbColorRough.Descriptor,
                                                                                gbEmitMetal.Descriptor,
@@ -474,7 +459,6 @@ namespace deferred {
                        gbN_AO.SetName ("GBuffN");
                        gbPos.SetName ("GBuffPos");
                        hdrImgResolved.SetName ("HDRimg resolved");
-                       hdrImgMS?.SetName ("HDRimg resolved");
                }
 
                public void Resize (uint width, uint height) {
@@ -484,11 +468,8 @@ namespace deferred {
                        frameBuffer?.Dispose ();
                        createGBuff ();
 
-                       frameBuffer = (NUM_SAMPLES == VkSampleCountFlags.SampleCount1) ?
-                               new FrameBuffer (renderPass, width, height, new Image[] {
-                                       hdrImgResolved, null, gbColorRough, gbEmitMetal, gbN_AO, gbPos}) :
-                               new FrameBuffer (renderPass, width, height, new Image[] {
-                                       hdrImgResolved, null, gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgMS});
+                       frameBuffer = new FrameBuffer (renderPass, width, height, new Image[] {
+                                       hdrImgResolved, null, gbColorRough, gbEmitMetal, gbN_AO, gbPos});
                }
 
                public void Dispose () {
@@ -500,7 +481,6 @@ namespace deferred {
                        gbEmitMetal.Dispose ();
                        gbN_AO.Dispose ();
                        gbPos.Dispose ();
-                       hdrImgMS?.Dispose ();
                        hdrImgResolved.Dispose ();
 
                        gBuffPipeline.Dispose ();
index 2db814fab733ada7ce7e82c4c679a295a365dec1..06dbc9e3ff0bdd279354dbf7c11ccb487f37e882 100644 (file)
@@ -1,42 +1,26 @@
-<Project Sdk="Microsoft.NET.Sdk">  
-  <PropertyGroup>    
-    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>        
-<!--    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>     -->
-  </PropertyGroup>
-        
-    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">    
-        <DefineConstants>TRACE;NETSTANDARD;NETSTANDARD2_0;MEMORY_POOLS;WITH_SHADOWS;_WITH_VKVG;DEBUG;NETFRAMEWORK;NET472</DefineConstants>    
-    </PropertyGroup>
-    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugCrow|AnyCPU' ">    
-        <DefineConstants>TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;MEMORY_POOLS;WITH_SHADOWS;_WITH_VKVG</DefineConstants>    
-    </PropertyGroup>
-    
-  <ItemGroup>    
-    <Compile Include="DeferredPbrRenderer.cs;shadowMapRenderer.cs" />
-  </ItemGroup>     
-
-
-  <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugCrow|AnyCPU' ">    
-    <Compile Include="main-crow.cs" />
-    <EmbeddedResource Include="ui\**\*.*">
-      <LogicalName>deferred.%(Filename)%(Extension)</LogicalName>
-    </EmbeddedResource>                
-  </ItemGroup>  
-    
-  <ItemGroup Condition="$(Configuration) != 'DebugCrow' ">
-    <Compile Include="main.cs" />
-  </ItemGroup>    
-    
-    
-  <ItemGroup>
-<!--    <PackageReference Include="Crow.VK" Version="0.9.0-beta" />-->
-  </ItemGroup>
-    
-  <ItemGroup>
-    <Folder Include="shaders\" />
-  </ItemGroup>    
-  <ItemGroup>
-    <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+       <PropertyGroup>
+               <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
+               <!--    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>     -->
+       </PropertyGroup>
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+               <DefineConstants>TRACE;NETSTANDARD;NETSTANDARD2_0;MEMORY_POOLS;WITH_SHADOWS;_WITH_VKVG;DEBUG;NETFRAMEWORK;NET472</DefineConstants>
+       </PropertyGroup>
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugCrow|AnyCPU' ">
+               <DefineConstants>TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;MEMORY_POOLS;WITH_SHADOWS;_WITH_VKVG</DefineConstants>
+       </PropertyGroup>
+       <ItemGroup>
+               <Compile Include="DeferredPbrRenderer.cs;shadowMapRenderer.cs" />
+       </ItemGroup>
+       <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugCrow|AnyCPU' ">
+               <Compile Include="main-crow.cs" />
+       </ItemGroup>
+       <ItemGroup Condition="$(Configuration) != 'DebugCrow' ">
+               <Compile Include="main.cs" />
+       </ItemGroup>
+       <ItemGroup>
+               <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
                <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
-  </ItemGroup>
+       </ItemGroup>
 </Project>
\ No newline at end of file
index a6073123ea660b93fe05fe81a565382ce1be7542..85e81aab9f4f89801786f79f8f1a3ace70f4572e 100644 (file)
@@ -11,13 +11,13 @@ namespace deferred {
                static void Main (string[] args) {
 #if DEBUG
                        Instance.VALIDATION = true;
-                       //Instance.RENDER_DOC_CAPTURE = false;
+                       Instance.RENDER_DOC_CAPTURE = true;
 #endif
                        SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Srgb;
                        DeferredPbrRenderer.TEXTURE_ARRAY = true;
                        DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount1;
                        DeferredPbrRenderer.HDR_FORMAT = VkFormat.R16g16b16a16Sfloat;
-                       DeferredPbrRenderer.MRT_FORMAT = VkFormat.R32g32b32a32Sfloat;
+                       DeferredPbrRenderer.MRT_FORMAT = VkFormat.R16g16b16a16Sfloat;
 
                        PbrModelTexArray.TEXTURE_DIM = 1024;
 
@@ -27,12 +27,11 @@ namespace deferred {
                }
 
                public override string[] EnabledInstanceExtensions => new string[] {
-                       Ext.I.VK_EXT_debug_utils
+                       Ext.I.VK_EXT_debug_utils,
                };
 
                public override string[] EnabledDeviceExtensions => new string[] {
                        Ext.D.VK_KHR_swapchain,
-                       Ext.D.VK_EXT_debug_marker
                };
 
                protected override void configureEnabledFeatures (VkPhysicalDeviceFeatures available_features, ref VkPhysicalDeviceFeatures enabled_features) {
@@ -58,14 +57,15 @@ namespace deferred {
                        Utils.DataDirectory + "textures/uffizi_cube.ktx",
                };
                string[] modelPathes = {
+                               "/mnt/devel/vkPinball/data/models/pinball.gltf",
                                Utils.DataDirectory + "models/DamagedHelmet/glTF/DamagedHelmet.gltf",
-                               Utils.DataDirectory + "models/shadow.glb",
+                               //Utils.DataDirectory + "models/shadow.glb",
                                Utils.DataDirectory + "models/Hubble.glb",
                                Utils.DataDirectory + "models/MER_static.glb",
                                Utils.DataDirectory + "models/ISS_stationary.glb",
                        };
 
-               int curModelIndex = 0;
+               int curModelIndex = 1;
                bool reloadModel;
                bool rebuildBuffers;
 
@@ -89,7 +89,7 @@ namespace deferred {
 
 
                        camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 16f);
-                       camera.SetPosition (0, 0, 2);
+                       camera.SetPosition (0, 0, -2);
 
                        //renderer = new DeferredPbrRenderer (presentQueue, cubemapPathes[2], swapChain.Width, swapChain.Height, camera.NearPlane, camera.FarPlane);
                        renderer = new DeferredPbrRenderer (presentQueue, cubemapPathes[2], swapChain.Width, swapChain.Height, camera.NearPlane, camera.FarPlane);
@@ -106,139 +106,33 @@ namespace deferred {
                        );
 
                        GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, DeferredPbrRenderer.NUM_SAMPLES);
-
+                       if (DeferredPbrRenderer.NUM_SAMPLES != VkSampleCountFlags.SampleCount1) {
+                               cfg.multisampleState.sampleShadingEnable = true;
+                               cfg.multisampleState.minSampleShading = 0.5f;
+                       }
                        cfg.Layout = new PipelineLayout (dev,
                                new VkPushConstantRange (VkShaderStageFlags.Fragment, 2 * sizeof (float)),
                                new DescriptorSetLayout (dev, 0,
-                                       new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
-                                       new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
+                                       new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                                        ));
 
                        cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, DeferredPbrRenderer.NUM_SAMPLES);
 
                        cfg.AddShader (VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.tone_mapping.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.tone_mapping.frag.spv");
 
                        plToneMap = new GraphicPipeline (cfg);
 
                        descriptorSet = descriptorPool.Allocate (cfg.Layout.DescriptorSetLayouts[0]);
 
-                       init_blur ();
-               }
-
-               ComputePipeline plBlur;
-               DescriptorSetLayout dsLayoutBlur;
-               DescriptorSet dsetBlurPing, dsetBlurPong;
-               Image downSamp, downSamp2;
-               CommandPool computeCmdPool;
-
-               struct BlurPushCsts {
-                       public Vector2 texSize;
-                       public int dir;
-                       public float scale;
-                       public float strength;
-               };
-               BlurPushCsts pcBloom = new BlurPushCsts () { strength = 1.3f, scale = 0.4f };
-
-               void init_blur () {
-                       computeCmdPool = new CommandPool (computeQ);
-
-                       blurComplete = dev.CreateSemaphore ();
-
-                       dsLayoutBlur = new DescriptorSetLayout (dev,
-                               new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Compute, VkDescriptorType.StorageImage),
-                               new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Compute, VkDescriptorType.StorageImage)
-                       );
-                       plBlur = new ComputePipeline (
-                               new PipelineLayout (dev, new VkPushConstantRange (VkShaderStageFlags.Compute, (uint)Marshal.SizeOf<BlurPushCsts> ()), dsLayoutBlur),
-                               "#deferred.bloom.comp.spv");
-
-                       dsetBlurPing = descriptorPool.Allocate (dsLayoutBlur);
-                       dsetBlurPong = descriptorPool.Allocate (dsLayoutBlur);
-               }
-
-               void buildBlurCmd (CommandBuffer cmd) {
-                       renderer.hdrImgResolved.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkAccessFlags.ColorAttachmentWrite, VkAccessFlags.TransferRead,
-                               VkImageLayout.ColorAttachmentOptimal, VkImageLayout.TransferSrcOptimal,
-                               VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.Transfer);
-                       downSamp.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkAccessFlags.ShaderRead, VkAccessFlags.TransferWrite,
-                               VkImageLayout.ShaderReadOnlyOptimal, VkImageLayout.TransferDstOptimal,
-                               VkPipelineStageFlags.FragmentShader, VkPipelineStageFlags.Transfer);
-
-
-                       renderer.hdrImgResolved.BlitTo (cmd, downSamp);
-
-                       renderer.hdrImgResolved.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkImageLayout.TransferSrcOptimal, VkImageLayout.ShaderReadOnlyOptimal,
-                               VkPipelineStageFlags.Transfer, VkPipelineStageFlags.FragmentShader);
-
-                       downSamp2.SetLayout (cmd, VkImageAspectFlags.Color,
-                               0, VkAccessFlags.MemoryWrite,
-                               VkImageLayout.Undefined, VkImageLayout.General,
-                               VkPipelineStageFlags.AllCommands, VkPipelineStageFlags.ComputeShader);
-
-                       downSamp.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkAccessFlags.TransferWrite, VkAccessFlags.MemoryRead,
-                               VkImageLayout.TransferDstOptimal, VkImageLayout.General,
-                               VkPipelineStageFlags.Transfer, VkPipelineStageFlags.ComputeShader);
-
-                       plBlur.Bind (cmd);
-
-                       pcBloom.dir = 0;
-                       /*
-                       plBlur.BindDescriptorSet (cmd, dsetBlurPing);
-                       cmd.PushConstant (plBlur.Layout, VkShaderStageFlags.Compute, pcBloom);
-                       cmd.Dispatch (downSamp.Width / 16, downSamp.Height / 16);
-
-                       cmd.SetMemoryBarrier (VkPipelineStageFlags.ComputeShader, VkPipelineStageFlags.ComputeShader,
-                                                                       VkAccessFlags.ShaderWrite, VkAccessFlags.ShaderRead);
-                               
-                       plBlur.BindDescriptorSet (cmd, dsetBlurPong);
-                       cmd.PushConstant (plBlur.Layout, VkShaderStageFlags.Compute, 1, (uint)Marshal.SizeOf<Vector2> ());
-                       cmd.Dispatch (downSamp.Width / 16, downSamp.Height / 16);
-
-                       downSamp.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkAccessFlags.MemoryWrite, VkAccessFlags.ShaderRead,
-                               VkImageLayout.General, VkImageLayout.ShaderReadOnlyOptimal,
-                               VkPipelineStageFlags.ComputeShader, VkPipelineStageFlags.FragmentShader);*/
-
-                       downSamp.SetLayout (cmd, VkImageAspectFlags.Color,
-                               VkAccessFlags.TransferWrite, VkAccessFlags.ShaderRead,
-                               VkImageLayout.TransferDstOptimal, VkImageLayout.ShaderReadOnlyOptimal,
-                               VkPipelineStageFlags.Transfer, VkPipelineStageFlags.FragmentShader);
-                               
-                       cmd.End ();
                }
 
-
-               //CommandBuffer cmdPbr;
-               //CommandBuffer cmdBlur;
-               VkSemaphore blurComplete;
-               const uint downSizing = 1;
-               float finalDebug = -1.0f;
-
                void buildCommandBuffers () {
-                       //cmdPbr?.Free ();
-                       //cmdPbr = cmdPool.AllocateAndStart ();
-                       //renderer.buildCommandBuffers (cmdPbr);
-                       //cmdPbr.End ();
-
-                       //cmdBlur?.Free ();
-                       //cmdBlur = computeCmdPool.AllocateAndStart ();
-                       //buildBlurCmd (cmdBlur);
-
-
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
                                cmds[i]?.Free ();
                                cmds[i] = cmdPool.AllocateAndStart ();
 
                                renderer.buildCommandBuffers (cmds[i]);
-                               //renderer.hdrImgResolved.SetLayout (cmds[i], VkImageAspectFlags.Color,
-                               //VkAccessFlags.TransferRead, VkAccessFlags.ShaderRead,
-                               //VkImageLayout.TransferSrcOptimal, VkImageLayout.ShaderReadOnlyOptimal,
-                               //VkPipelineStageFlags.Transfer, VkPipelineStageFlags.FragmentShader);
 
                                plToneMap.RenderPass.Begin (cmds[i], frameBuffers[i]);
 
@@ -248,17 +142,12 @@ namespace deferred {
                                plToneMap.Bind (cmds[i]);
                                plToneMap.BindDescriptorSet (cmds[i], descriptorSet);
 
-                               cmds[i].PushConstant (plToneMap.Layout, VkShaderStageFlags.Fragment, 12, new float[] { renderer.exposure, renderer.gamma, finalDebug }, 0);
+                               cmds[i].PushConstant (plToneMap.Layout, VkShaderStageFlags.Fragment, 8, new float[] { renderer.exposure, renderer.gamma }, 0);
 
                                cmds[i].Draw (3, 1, 0, 0);
 
                                plToneMap.RenderPass.End (cmds[i]);
 
-                               renderer.hdrImgResolved.SetLayout (cmds[i], VkImageAspectFlags.Color,
-                                       VkAccessFlags.ShaderRead, VkAccessFlags.ColorAttachmentWrite,
-                                       VkImageLayout.ShaderReadOnlyOptimal, VkImageLayout.ColorAttachmentOptimal,
-                                       VkPipelineStageFlags.FragmentShader, VkPipelineStageFlags.ColorAttachmentOutput);
-
                                cmds[i].End ();
                        }
                }
@@ -291,21 +180,6 @@ namespace deferred {
 
                }
 
-
-               protected override void render () {
-                       int idx = swapChain.GetNextImage ();
-                       if (idx < 0) {
-                               OnResize ();
-                               return;
-                       }
-
-                       if (cmds[idx] == null)
-                               return;                         
-
-                       presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx]);
-                       presentQueue.Present (swapChain, drawComplete[idx]);
-               }
-
                protected override void OnResize () {
                        base.OnResize ();
 
@@ -315,33 +189,12 @@ namespace deferred {
 
                        UpdateView ();
 
-                       downSamp?.Dispose ();
-                       downSamp2?.Dispose ();
-                       downSamp = new Image (dev, VkFormat.R16g16b16a16Sfloat, VkImageUsageFlags.TransferDst | VkImageUsageFlags.Storage | VkImageUsageFlags.Sampled,
-                               VkMemoryPropertyFlags.DeviceLocal, renderer.Width / downSizing, renderer.Height / downSizing, VkImageType.Image2D);
-                       downSamp2 = new Image (dev, VkFormat.R16g16b16a16Sfloat, VkImageUsageFlags.Storage,
-                               VkMemoryPropertyFlags.DeviceLocal, renderer.Width / downSizing, renderer.Height/ downSizing, VkImageType.Image2D);
-                       downSamp.CreateView (); downSamp.CreateSampler ();
-                       downSamp.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
-                       downSamp2.CreateView (); downSamp2.CreateSampler ();
-                       downSamp2.Descriptor.imageLayout = VkImageLayout.General;
-
-                       downSamp.SetName ("HDRimgDownScaled");
-                       downSamp2.SetName ("HDRimgDownScaled2");
-
-                       pcBloom.texSize.X = downSamp.Width;
-                       pcBloom.texSize.Y = downSamp.Height;
 
                        frameBuffers?.Dispose();
                        frameBuffers = plToneMap.RenderPass.CreateFrameBuffers(swapChain);
 
-                       DescriptorSetWrites dsUpdate = new DescriptorSetWrites (plToneMap.Layout.DescriptorSetLayouts[0]);
-                       dsUpdate.Write (dev, descriptorSet, renderer.hdrImgResolved.Descriptor, downSamp.Descriptor);
-
-                       dsUpdate = new DescriptorSetWrites (dsLayoutBlur);
-                       downSamp.Descriptor.imageLayout = VkImageLayout.General;
-                       dsUpdate.Write (dev, dsetBlurPong, downSamp2.Descriptor, downSamp.Descriptor);
-                       dsUpdate.Write (dev, dsetBlurPing, downSamp.Descriptor, downSamp2.Descriptor);
+                       DescriptorSetWrites dsUpdate = new DescriptorSetWrites (plToneMap.Layout.DescriptorSetLayouts[0].Bindings[0]);
+                       dsUpdate.Write (dev, descriptorSet, renderer.hdrImgResolved.Descriptor);
 
                        buildCommandBuffers ();
 
@@ -477,30 +330,6 @@ namespace deferred {
                                                renderer.gamma += 0.1f;
                                        rebuildBuffers = true;
                                        break;
-                               case Key.D:
-                                       finalDebug = -finalDebug;
-                                       rebuildBuffers = true;
-                                       break;
-                               case Key.B:
-                                       if (modifiers.HasFlag (Modifier.Control)) {
-                                               if (modifiers.HasFlag (Modifier.Shift))
-                                                       pcBloom.strength -= 0.1f;
-                                               else
-                                                       pcBloom.strength += 0.1f;
-                                       } else {
-                                               if (modifiers.HasFlag (Modifier.Shift))
-                                                       pcBloom.scale *= 1.1f;
-                                               else
-                                                       pcBloom.scale *= 0.9f;
-                                       }
-                                       Console.WriteLine ($"Bloom: scale = {pcBloom.scale}, strength = {pcBloom.strength}");
-                                       rebuildBuffers = true;
-                                       //if (camera.Type == Camera.CamType.FirstPerson)
-                                       //      camera.Type = Camera.CamType.LookAt;
-                                       //else
-                                       //      camera.Type = Camera.CamType.FirstPerson;
-                                       //Console.WriteLine ($"camera type = {camera.Type}");
-                                       break;
                                case Key.KeypadAdd:
                                        curModelIndex++;
                                        if (curModelIndex >= modelPathes.Length)
@@ -525,17 +354,12 @@ namespace deferred {
                        dev.WaitIdle ();
                        if (disposing) {
                                if (!isDisposed) {
-                                       computeCmdPool.Dispose ();
-                                       downSamp?.Dispose ();
-                                       downSamp2?.Dispose ();
                                        frameBuffers?.Dispose();
                                        renderer.Dispose ();
-                                       plBlur.Dispose ();
                                        plToneMap.Dispose ();
                                        descriptorPool.Dispose ();
                                        dbgmsg.Dispose ();
                                }
-                               dev.DestroySemaphore (blurComplete);
                        }
                        base.Dispose (disposing);
                }
index 68fc8bf25fb21ade696376661a33b577c3e7b705..95d49409bc9bc7c4c726269dcbcba63585c67b3f 100644 (file)
@@ -181,7 +181,7 @@ void main()
         // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
         vec3 color = NdotL * lights[i].color.rgb * (diffuseContrib + specContrib);
         
-        #if SHADOW
+        #ifdef WITH_SHADOWS
         vec4 shadowClip = lights[i].mvp * vec4(pos, 1);
         float shadowFactor = filterPCF(shadowClip, i);
         // Calculate lighting contribution from image based lighting source (IBL)
index 138bea8949f21a7950878f5fa542f766eb199cdf..98f4a692a5a02815a5c5a73be05c244f6df978e3 100644 (file)
@@ -2,31 +2,27 @@
 
 layout(push_constant) uniform PushConsts {
        float exposure;
-       float gamma;
-       float debug;
+       float gamma;    
 };
 
 #include "tonemap.inc"
 
-layout (set = 0, binding = 0) uniform sampler2D samplerHDR;
-layout (set = 0, binding = 1) uniform sampler2D bloom;
+layout (set = 0, binding = 0) uniform sampler2DMS samplerHDR;
 
 layout (location = 0) in vec2 inUV;
 layout (location = 0) out vec4 outColor;
                                                                                                          
 void main() 
 {
-       if (debug < 0.0f) {    
-           //vec4 hdrColor = texelFetch (samplerHDR, ivec2(inUV), gl_SampleID);    
-           vec4 hdrColor = texture (samplerHDR, inUV);    
+               ivec2 ts = textureSize(samplerHDR);
+           vec4 hdrColor = texelFetch (samplerHDR, ivec2(gl_FragCoord.xy), gl_SampleID);
+           //vec4 hdrColor = texelFetch (samplerHDR, inUV);    
            //vec4 c = texture (bloom, inUV);
            //float lum = (0.299*c.r + 0.587*c.g + 0.114*c.b);
            //if (lum>1.0)
            //    hdrColor.rgb += c.rgb * 0.05;
            //outColor = SRGBtoLINEAR(tonemap(hdrColor, exposure, gamma));          
-           outColor = tonemap(hdrColor, exposure, gamma);          
-    }else
-       outColor = texture (bloom, inUV);
+           outColor = tonemap(hdrColor, exposure, gamma);              
     
     
     /*
index 41bc1200a643cd80f67ba0fcdab73128f7672447..68ca47961a090b84d45cef22dcacdff122e36df5 100644 (file)
@@ -84,11 +84,11 @@ namespace deferred {
                                new VkPushConstantRange (VkShaderStageFlags.Vertex|VkShaderStageFlags.Geometry, (uint)Marshal.SizeOf<Matrix4x4> ())
                        );
 
-                       cfg.AddVertexBinding<PbrModel.Vertex> (0);
+                       cfg.AddVertexBinding<PbrModelTexArray.Vertex> (0);
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#deferred.shadow.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Geometry, "#deferred.shadow.geom.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.shadow.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Geometry, "#shaders.shadow.geom.spv");
 
                        shadowPipeline = new GraphicPipeline (cfg);
 
@@ -110,7 +110,7 @@ namespace deferred {
                }
 
                public void update_light_matrices () {
-                       Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView (lightFOV, 1, 0.1f, lightFarPlane);
+                       Matrix4x4 proj = Utils.CreatePerspectiveFieldOfView (lightFOV, 1, 0.1f, lightFarPlane);
                        for (int i = 0; i < renderer.lights.Length; i++) {
                                Matrix4x4 view = Matrix4x4.CreateLookAt (renderer.lights[i].position.ToVector3 (), Vector3.Zero, Vector3.UnitY);
                                renderer.lights[i].mvp = view * proj;
index 8061ae72054438be2fe699493c044a80e918a4bb..737626626cb3cf67765c0fa5492496be99e8aa13 100644 (file)
@@ -26,9 +26,9 @@ namespace vke {
 
                public Matrices matrices = new Matrices {
                        lightDir = Vector4.Normalize (new Vector4 (0.7f, 0.6f, 0.2f, 0.0f)),
-                       gamma = 2.2f,
-                       exposure = 4.5f,
-                       scaleIBLAmbient = 1f,
+                       gamma = 1.2f,
+                       exposure = 2.5f,
+                       scaleIBLAmbient = 0.9f,
                        debugViewInputs = 0,
                        debugViewEquation = 0
                };
@@ -84,8 +84,8 @@ namespace vke {
                        cfg.AddVertexBinding<PbrModel2.Vertex> (0);
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat, VkFormat.R32g32Sfloat);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#pbr.pbr.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#pbr.pbr_khr.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.pbr.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.pbr_khr.frag.spv");
 
                        layout = cfg.Layout;
 
@@ -93,46 +93,31 @@ namespace vke {
 
                        dsMain = descriptorPool.Allocate (descLayoutMain);
 
-                       envCube = new Environment.EnvironmentCube (cubemapPathes[0], dsMain, layout, staggingQ, RenderPass);
+                       envCube = new Environment.EnvironmentCube (cubemapPathes[0], layout, staggingQ, RenderPass);
 
                        matrices.prefilteredCubeMipLevels = envCube.prefilterCube.CreateInfo.mipLevels;
                        uboMats = new HostBuffer (Dev, VkBufferUsageFlags.UniformBuffer, matrices, true);
 
-                       string[] modelPathes = {
-                               Utils.DataDirectory + "models/DamagedHelmet/glTF/DamagedHelmet.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Avocado/glTF/Avocado.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BarramundiFish/glTF/BarramundiFish.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BoomBoxWithAxes/glTF/BoomBoxWithAxes.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Box/glTF/Box.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/EnvironmentTest/glTF/EnvironmentTest.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/MetalRoughSpheres/glTF/MetalRoughSpheres.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/OrientationTest/glTF/OrientationTest.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Buggy/glTF/Buggy.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/2CylinderEngine/glTF-Embedded/2CylinderEngine.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/FlightHelmet/glTF/FlightHelmet.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/GearboxAssy/glTF/GearboxAssy.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Lantern/glTF/Lantern.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf",
-                               "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Sponza/glTF/Sponza.gltf",
-                               "/mnt/devel/vkChess/data/chess.gltf"
-                       };
-
-
-                       model = new PbrModel2 (staggingQ, modelPathes[0], descLayoutTextures,
+                       DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descLayoutMain.Bindings.GetRange(0,4).ToArray());
+                       uboUpdate.Write (Dev, dsMain,
+                               uboMats.Descriptor,
+                               envCube.irradianceCube.Descriptor,
+                               envCube.prefilterCube.Descriptor,
+                               envCube.lutBrdf.Descriptor);
+               }
+
+               public void LoadModel (Queue staggingQ, string path) {
+                       model?.Dispose ();
+
+                       model = new PbrModel2 (staggingQ, path, descLayoutTextures,
                                AttachmentType.Color,
                                AttachmentType.PhysicalProps,
                                AttachmentType.Normal,
                                AttachmentType.AmbientOcclusion,
                                AttachmentType.Emissive);
-                       //model = new Model (Dev, presentQueue, Utils.DataDirectory + "models/icosphere.gltf");
-                       //model = new Model (Dev, presentQueue, cmdPool, Utils.DataDirectory + "models/cube.gltf");
-                       DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descLayoutMain.Bindings.GetRange(0,5).ToArray());
-                       uboUpdate.Write (Dev, dsMain,
-                               uboMats.Descriptor,
-                               envCube.irradianceCube.Descriptor,
-                               envCube.prefilterCube.Descriptor,
-                               envCube.lutBrdf.Descriptor,
-                               model.materialUBO.Descriptor);
+
+                       DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descLayoutMain.Bindings[4]);
+                       uboUpdate.Write (Dev, dsMain, model.materialUBO.Descriptor);
                }
 
                public void RecordDraw (CommandBuffer cmd) {
index 94d41850e63b5339f49a0852d161acf9931c4f8c..7bc30ea10bea85298910887136905cacfed025e0 100644 (file)
@@ -20,7 +20,7 @@ namespace pbrSample {
                        Instance.VALIDATION = true;
                        Instance.RENDER_DOC_CAPTURE = false;
 #endif
-                       SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Unorm;
+                       SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Srgb;
 
                        using (Program vke = new Program ()) {
                                vke.Run ();
@@ -49,6 +49,30 @@ namespace pbrSample {
                        roughness
                }
 
+               string[] modelPathes = {
+                       Utils.DataDirectory + "models/DamagedHelmet/glTF/DamagedHelmet.gltf",
+                       Utils.DataDirectory + "models/Hubble.glb",
+                       Utils.DataDirectory + "models/ISS_stationary.glb",
+                       Utils.DataDirectory + "models/MER_static.glb",
+                       Utils.DataDirectory + "models/Box.gltf",
+
+                       /*"/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Avocado/glTF/Avocado.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BarramundiFish/glTF/BarramundiFish.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BoomBoxWithAxes/glTF/BoomBoxWithAxes.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Box/glTF/Box.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/EnvironmentTest/glTF/EnvironmentTest.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/MetalRoughSpheres/glTF/MetalRoughSpheres.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/OrientationTest/glTF/OrientationTest.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Buggy/glTF/Buggy.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/2CylinderEngine/glTF-Embedded/2CylinderEngine.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/FlightHelmet/glTF/FlightHelmet.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/GearboxAssy/glTF/GearboxAssy.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Lantern/glTF/Lantern.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf",
+                       "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Sponza/glTF/Sponza.gltf",
+                       "/mnt/devel/vkChess/data/chess.gltf"*/
+               };
+
                DebugView currentDebugView = DebugView.none;
 
 #if PIPELINE_STATS
@@ -141,23 +165,18 @@ namespace pbrSample {
 
 
                Vector4 lightPos = new Vector4 (1, 0, 0, 0);
-               BoundingBox modelAABB;
+               uint curModelIndex = 0;
 
                Program () : base() {
 
                        //UpdateFrequency = 20;
-
-                       camera.SetPosition (0, 0, 5);
-
+                       camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 64f);
+                       camera.SetPosition (0, 0, -2);
 
                        pbrPipeline = new PBRPipeline(presentQueue,
                                new RenderPass (dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat (), samples));
 
-
-
-                       modelAABB = pbrPipeline.model.DefaultScene.AABB;
-
-                       //camera.Model = Matrix4x4.CreateScale (1f/ Math.Max (Math.Max (modelAABB.max.X, modelAABB.max.Y), modelAABB.max.Z));
+                       loadCurrentModel ();
 
 #if PIPELINE_STATS
                        statPool = new PipelineStatisticsQueryPool (dev,
@@ -175,7 +194,7 @@ namespace pbrSample {
 #endif
                }
 
-               bool rebuildBuffers;
+               bool rebuildBuffers, reloadModel;
 
                void buildCommandBuffers () {
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
@@ -206,8 +225,15 @@ namespace pbrSample {
                        pbrPipeline.RenderPass.End (cmd);
                }
 
+               void loadCurrentModel () {
+                       dev.WaitIdle ();
+                       pbrPipeline.LoadModel (presentQueue, modelPathes[curModelIndex]);
+                       BoundingBox modelAABB = pbrPipeline.model.DefaultScene.AABB;
+                       camera.Model = Matrix4x4.CreateScale (1f / Math.Max (Math.Max (modelAABB.max.X, modelAABB.max.Y), modelAABB.max.Z));
+                       updateViewRequested = true;
+               }
 
-#region update
+               #region update
                public override void UpdateView () {
                        camera.AspectRatio = (float)swapChain.Width / swapChain.Height;
 
@@ -217,12 +243,8 @@ namespace pbrSample {
                        pbrPipeline.matrices.model = camera.Model;
 
 
-                       pbrPipeline.matrices.camPos = new Vector4 (
-                               -camera.Position.Z * (float)Math.Sin (camera.Rotation.Y) * (float)Math.Cos (camera.Rotation.X),
-                                camera.Position.Z * (float)Math.Sin (camera.Rotation.X),
-                                camera.Position.Z * (float)Math.Cos (camera.Rotation.Y) * (float)Math.Cos (camera.Rotation.X),
-                                0
-                       );
+                       Matrix4x4.Invert (camera.View, out Matrix4x4 inv);
+                       pbrPipeline.matrices.camPos = new Vector4 (inv.M41, inv.M42, inv.M43, 0);
                        pbrPipeline.matrices.debugViewInputs = (float)currentDebugView;
 
                        pbrPipeline.uboMats.Update (pbrPipeline.matrices, (uint)Marshal.SizeOf<PBRPipeline.Matrices> ());
@@ -231,6 +253,11 @@ namespace pbrSample {
                }
 
                public override void Update () {
+                       if (reloadModel) {
+                               loadCurrentModel ();
+                               reloadModel = false;
+                               rebuildBuffers = true;
+                       }
 #if PIPELINE_STATS
                        results = statPool.GetResults ();
 #endif
@@ -279,6 +306,13 @@ namespace pbrSample {
 
                protected override void onKeyDown (Key key, int scanCode, Modifier modifiers) {
                        switch (key) {
+                       case Key.Space:
+                               if (modifiers.HasFlag (Modifier.Shift))
+                                       curModelIndex = curModelIndex == 0 ? (uint)modelPathes.Length - 1 : curModelIndex-1;
+                               else
+                                       curModelIndex = curModelIndex < (uint)modelPathes.Length - 1 ? curModelIndex + 1 : 0;
+                               reloadModel = true;
+                               break;
                        /*
                                case Key.F:
                                        if (modifiers.HasFlag (Modifier.Shift)) {
index 46f34680b1544b1e934dafa5f5b6240825a282ed..c0a4e2ce92030cbc7c2d8c2727cb9d2ee87b7c03 100644 (file)
@@ -1,7 +1,5 @@
 <Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>    
-    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>    
-  </PropertyGroup>
+
                 
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DefineConstants>NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;WITH_VKVG;TRACE;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
                <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
   </ItemGroup>    
   
-  <ItemGroup>    
-    <EmbeddedResource Include="ui\**\*.*">
-      <LogicalName>deferred.%(Filename)%(Extension)</LogicalName>
-    </EmbeddedResource> 
-               <None Include="shaders\**\*.*" />
-  </ItemGroup>     
-
 </Project>
index 498c316e4829f6bb592832b2d15cdb4375453dbb..4d856a02a8af47a46b288ae0c3faa1b6e313cb3b 100644 (file)
@@ -15,122 +15,151 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{1643
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "compute", "samples\compute\compute.csproj", "{5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "deferred", "samples\deferred\deferred.csproj", "{7E10A906-8633-48E5-8FEF-94F84CD8844C}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DistanceFieldFontTest", "samples\DistanceFieldFontTest\DistanceFieldFontTest.csproj", "{77437C6D-28B5-4798-96CA-68F987770D65}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "samples\Model\Model.csproj", "{A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pbr", "samples\pbr\pbr.csproj", "{96921211-C5A8-41FC-9F3D-F35A696203F7}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Textured", "samples\Textured\Textured.csproj", "{1B2DF710-E500-49E5-8802-EBA71A05E827}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "samples\TexturedCube\TexturedCube.csproj", "{8185163E-A67C-4C0E-8548-67E2A9F16309}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Triangle", "samples\Triangle\Triangle.csproj", "{A30AEC45-54A3-4120-B341-B3299CC1B00E}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpirVTasks", "SpirVTasks\SpirVTasks.csproj", "{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnvironmentPipeline", "addons\EnvironmentPipeline\EnvironmentPipeline.csproj", "{F04C3F79-2E08-4D35-A804-43039DCB7F5E}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "deferred", "samples\deferred\deferred.csproj", "{D9A41382-444E-44ED-B638-3D8F06F2FBC2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Triangle", "samples\Triangle\Triangle.csproj", "{124152F8-FAE6-4D4B-87B9-6074DD365E9B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pbr", "samples\pbr\pbr.csproj", "{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
                Release|Any CPU = Release|Any CPU
                DebugCrow|Any CPU = DebugCrow|Any CPU
+               ReleaseSpirVTasks|Any CPU = ReleaseSpirVTasks|Any CPU
+               BuildPackages|Any CPU = BuildPackages|Any CPU
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
                {642726F4-0592-4846-8EAF-A5D1964C85A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {642726F4-0592-4846-8EAF-A5D1964C85A7}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {642726F4-0592-4846-8EAF-A5D1964C85A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {642726F4-0592-4846-8EAF-A5D1964C85A7}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
+               {642726F4-0592-4846-8EAF-A5D1964C85A7}.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}.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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E}.Debug|Any CPU.Build.0 = Debug|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
                {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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {F3BBF67D-7E63-48F3-8156-ADC014D268BB}.Debug|Any CPU.Build.0 = Debug|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
                {611541A0-CE88-4A83-A6FF-3917971841C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {611541A0-CE88-4A83-A6FF-3917971841C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {611541A0-CE88-4A83-A6FF-3917971841C9}.Release|Any CPU.Build.0 = Release|Any CPU
                {611541A0-CE88-4A83-A6FF-3917971841C9}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {611541A0-CE88-4A83-A6FF-3917971841C9}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
                {611541A0-CE88-4A83-A6FF-3917971841C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {611541A0-CE88-4A83-A6FF-3917971841C9}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
+               {611541A0-CE88-4A83-A6FF-3917971841C9}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Debug|Any CPU.ActiveCfg = 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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.Release|Any CPU.Build.0 = Release|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.DebugCrow|Any CPU.ActiveCfg = DebugCrow|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.DebugCrow|Any CPU.Build.0 = DebugCrow|Any CPU
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.Release|Any CPU.Build.0 = Release|Any CPU
+               {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.Debug|Any CPU.ActiveCfg = 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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {77437C6D-28B5-4798-96CA-68F987770D65}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {77437C6D-28B5-4798-96CA-68F987770D65}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {77437C6D-28B5-4798-96CA-68F987770D65}.Release|Any CPU.Build.0 = Release|Any CPU
+               {77437C6D-28B5-4798-96CA-68F987770D65}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.Release|Any CPU.Build.0 = Release|Any CPU
                {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.Release|Any CPU.Build.0 = Release|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
-               {96921211-C5A8-41FC-9F3D-F35A696203F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.Release|Any CPU.Build.0 = Release|Any CPU
+               {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.Debug|Any CPU.ActiveCfg = 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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {1B2DF710-E500-49E5-8802-EBA71A05E827}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {1B2DF710-E500-49E5-8802-EBA71A05E827}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {1B2DF710-E500-49E5-8802-EBA71A05E827}.Release|Any CPU.Build.0 = Release|Any CPU
+               {1B2DF710-E500-49E5-8802-EBA71A05E827}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.Debug|Any CPU.ActiveCfg = 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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {8185163E-A67C-4C0E-8548-67E2A9F16309}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.Release|Any CPU.Build.0 = Release|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {8185163E-A67C-4C0E-8548-67E2A9F16309}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {8185163E-A67C-4C0E-8548-67E2A9F16309}.Release|Any CPU.Build.0 = Release|Any CPU
+               {8185163E-A67C-4C0E-8548-67E2A9F16309}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
                {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Release|Any CPU.Build.0 = Release|Any CPU
                {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
+               {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Debug|Any CPU.Build.0 = Debug|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
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.DebugCrow|Any CPU.ActiveCfg = DebugCrow|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.DebugCrow|Any CPU.Build.0 = DebugCrow|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.Release|Any CPU.Build.0 = Release|Any CPU
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.Release|Any CPU.Build.0 = Release|Any CPU
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B}.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}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
+               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Release|Any CPU.Build.0 = Release|Any CPU
+               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
        EndGlobalSection
        GlobalSection(NestedProjects) = preSolution
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
                {F3BBF67D-7E63-48F3-8156-ADC014D268BB} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
                {611541A0-CE88-4A83-A6FF-3917971841C9} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
                {5000CDE2-99B9-47EA-B4D9-EA1631F0E14A} = {16439374-B8DB-4643-8116-EB3358B49A12}
-               {7E10A906-8633-48E5-8FEF-94F84CD8844C} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {77437C6D-28B5-4798-96CA-68F987770D65} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {A7D3FB7F-769B-4F36-9E3E-3FB71F24D306} = {16439374-B8DB-4643-8116-EB3358B49A12}
-               {96921211-C5A8-41FC-9F3D-F35A696203F7} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {1B2DF710-E500-49E5-8802-EBA71A05E827} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {8185163E-A67C-4C0E-8548-67E2A9F16309} = {16439374-B8DB-4643-8116-EB3358B49A12}
-               {A30AEC45-54A3-4120-B341-B3299CC1B00E} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {F04C3F79-2E08-4D35-A804-43039DCB7F5E} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
+               {D9A41382-444E-44ED-B638-3D8F06F2FBC2} = {16439374-B8DB-4643-8116-EB3358B49A12}
+               {124152F8-FAE6-4D4B-87B9-6074DD365E9B} = {16439374-B8DB-4643-8116-EB3358B49A12}
+               {7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5} = {16439374-B8DB-4643-8116-EB3358B49A12}
        EndGlobalSection
        GlobalSection(MonoDevelopProperties) = preSolution
                Policies = $0
diff --git a/vke/shaders/debug.frag b/vke/shaders/debug.frag
new file mode 100644 (file)
index 0000000..fd419ff
--- /dev/null
@@ -0,0 +1,12 @@
+#version 450
+
+#extension GL_ARB_separate_shader_objects : enable
+#extension GL_ARB_shading_language_420pack : enable
+
+layout (location = 0) in vec3 inColor;
+layout (location = 0) out vec4 outFragColor;
+
+void main() 
+{
+  outFragColor = vec4(inColor, 1.0);
+}
\ No newline at end of file
diff --git a/vke/shaders/debug.vert b/vke/shaders/debug.vert
new file mode 100644 (file)
index 0000000..b3967f7
--- /dev/null
@@ -0,0 +1,26 @@
+#version 450
+
+#extension GL_ARB_separate_shader_objects : enable
+#extension GL_ARB_shading_language_420pack : enable
+
+layout (location = 0) in vec3 inPos;
+layout (location = 1) in vec3 inColor;
+
+layout (location = 0) out vec3 outColor;
+
+layout(push_constant) uniform PushConsts {
+    mat4 projection;
+    mat4 view;
+};
+
+out gl_PerVertex 
+{
+    vec4 gl_Position;   
+};
+
+void main() 
+{
+    outColor = inColor;    
+       //gl_Position = projection * vec4 ((view * vec4(inPos.xyz, 0.0)).xyz, 1);
+       gl_Position = projection * view * vec4(inPos.xyz, 1);
+}
index c897cf2b68f1041ada53ca83cde216eddce745de..5adf968a8776dbeb553579d61bfb560ac263fe4e 100644 (file)
@@ -48,7 +48,7 @@ namespace vke {
                        get { return Matrix4x4.CreatePerspectiveFieldOfView (fov, aspectRatio, zNear, zFar); }
                }
 
-               public Camera (float fieldOfView, float aspectRatio, float nearPlane = 0.1f, float farPlane = 256f) {
+               public Camera (float fieldOfView, float aspectRatio, float nearPlane = 0.1f, float farPlane = 16f) {
                        fov = fieldOfView;
                        this.aspectRatio = aspectRatio;
                        zNear = nearPlane;
@@ -111,8 +111,9 @@ namespace vke {
                }
 
                public void Update () {
-                       Projection = Matrix4x4.CreatePerspectiveFieldOfView (fov, aspectRatio, zNear, zFar) * VKProjectionCorrection;
-                       Matrix4x4 translation = Matrix4x4.CreateTranslation (position * zoom * new Vector3(1,1,-1)) ;
+                       Projection =  Vulkan.Utils.CreatePerspectiveFieldOfView (fov, aspectRatio, zNear, zFar);
+
+                       Matrix4x4 translation = Matrix4x4.CreateTranslation (position * zoom);// * new Vector3(1,1,-1)) ;
                        if (Type == CamType.LookAt) {
                                View = 
                                                Matrix4x4.CreateFromAxisAngle (Vector3.UnitZ, rotation.Z) *
index afefdd9db8d0f1da6041acef267e7a9200615eae..cbdc7414e13ec8b7d0112bd4e891435b5fd86286 100644 (file)
@@ -110,59 +110,59 @@ namespace vke {
 
                #region DebugMarkers
                public static void SetDebugMarkerName (this VkCommandBuffer obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.CommandBufferEXT,
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.CommandBuffer,
                                (ulong)obj.Handle.ToInt64 ()) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkImageView obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.ImageViewEXT,
-                               obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.ImageView,
+                               (ulong)obj.Handle) { pObjectName = name.Pin () };
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkSampler obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.SamplerEXT,
-                               obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Sampler,
+                               (ulong)obj.Handle) { pObjectName = name.Pin () };
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkPipeline obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.PipelineEXT,
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Pipeline,
                                obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkDescriptorSet obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.DescriptorSetEXT,
-                               obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.DescriptorSet,
+                               (ulong)obj.Handle) { pObjectName = name.Pin () };
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkSemaphore obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.SemaphoreEXT,
-                               obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Semaphore,
+                               (ulong)obj.Handle) { pObjectName = name.Pin () };
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                public static void SetDebugMarkerName (this VkFence obj, Device dev, string name) {
-                       if (!dev.debugMarkersEnabled)
+                       if (!dev.debugUtilsEnabled)
                                return;
-                       VkDebugMarkerObjectNameInfoEXT dmo = new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.FenceEXT,
-                               obj.Handle) { pObjectName = name.Pin () };
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (dev.VkDev, ref dmo));
+                       VkDebugUtilsObjectNameInfoEXT dmo = new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Fence,
+                               (ulong)obj.Handle) { pObjectName = name.Pin () };
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (dev.VkDev, ref dmo));
                        name.Unpin ();
                }
                #endregion
index 3a8d34e92aa19f264488a735eb9eb0fe7f263e71..0e4db152330fbf535705e07f29482ee51d2778ad 100644 (file)
@@ -6,6 +6,7 @@ using System.IO;
 using System.Linq;
 using System.Numerics;
 using System.Reflection;
+using System.Xml.Serialization;
 
 namespace Vulkan {
        public static partial class Utils {
@@ -15,6 +16,18 @@ namespace Vulkan {
             if (result != VkResult.Success)
                 throw new InvalidOperationException (errorString + ": " + result.ToString ());
         }
+               static void xmlMakeTypeFieldsAsAttributes (Type t, ref XmlAttributeOverrides overrides)
+               {
+                       foreach (FieldInfo fi in t.GetFields (BindingFlags.Public | BindingFlags.Instance))
+                               overrides.Add (t, fi.Name, new XmlAttributes { XmlAttribute = new XmlAttributeAttribute () });
+               }
+               public static XmlAttributeOverrides GetXmlOverrides ()
+               {
+                       XmlAttributeOverrides xmlAttributeOverrides = new XmlAttributeOverrides ();
+                       //Assembly avk = Assembly.GetAssembly (typeof (VkInstance));
+                       xmlMakeTypeFieldsAsAttributes (typeof (VkDescriptorPoolSize), ref xmlAttributeOverrides);
+                       return xmlAttributeOverrides;
+               }
                /// <summary>
                /// Return a file or embedded resource stream.
                /// </summary>
@@ -377,5 +390,14 @@ namespace Vulkan {
                                return VkPipelineStageFlags.AllCommands;
                        }
                }
+               public static Matrix4x4 CreatePerspectiveFieldOfView (float fov, float aspectRatio, float zNear, float zFar) {
+                       float f = (float)(1.0 / System.Math.Tan (0.5 * fov));
+                       return new Matrix4x4 (
+                               f / aspectRatio, 0, 0, 0,
+                               0, -f, 0, 0,
+                               0, 0, zFar / (zNear - zFar), -1,
+                               0, 0, zNear * zFar / (zNear - zFar), 0
+                       );
+               }
        }
 }
index 40aa3a8610d312d6c232c50825fc36c9875a7cbb..fab1325a0c274851360eb0360ed27ae888f2ba07 100644 (file)
@@ -31,6 +31,7 @@ namespace vke {
                protected CommandPool cmdPool;
                protected CommandBuffer[] cmds;
                protected VkSemaphore[] drawComplete;
+               protected VkFence drawFence;
 
                protected uint fps;
                protected bool updateViewRequested = true;
@@ -125,6 +126,8 @@ namespace vke {
 
                        //First create the c# device class
                        dev = new Device (phy);
+                       dev.debugUtilsEnabled = instance.debugUtilsEnabled;
+
                        //create queue class
                        createQueues ();
 
@@ -142,6 +145,7 @@ namespace vke {
 
                        cmds = new CommandBuffer[swapChain.ImageCount];
                        drawComplete = new VkSemaphore[swapChain.ImageCount];
+                       drawFence = dev.CreateFence (true);
 
                        for (int i = 0; i < swapChain.ImageCount; i++) {
                                drawComplete[i] = dev.CreateSemaphore ();
@@ -179,10 +183,13 @@ namespace vke {
                        if (cmds[idx] == null)
                                return;
 
-                       presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx]);
+                       dev.WaitForFence (drawFence);
+                       dev.ResetFence (drawFence);
+
+                       presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx], drawFence);
                        presentQueue.Present (swapChain, drawComplete[idx]);
 
-                       presentQueue.WaitIdle ();
+                       //presentQueue.WaitIdle ();
                }
 
                protected virtual void onScroll (double xOffset, double yOffset) { }
@@ -339,6 +346,7 @@ namespace vke {
                                        dev.DestroySemaphore (drawComplete[i]);
                                        cmds[i].Free ();
                                }
+                               dev.DestroyFence (drawFence);
 
                                swapChain.Dispose ();
 
index 13ca491e9938d3eee2ef9c40f6a227ee751b13e1..6e60f8de76ffc89060c5b08a68f06e4b489f67a5 100644 (file)
@@ -2,6 +2,7 @@
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
+using System.Xml.Serialization;
 using Vulkan;
 using static Vulkan.Vk;
 
@@ -34,7 +35,7 @@ namespace vke {
        /// </remarks>
        public abstract class Activable : IDisposable {
                //count number of activation, only the first one will create a handle 
-               protected uint references;
+               [XmlIgnore] protected uint references;
                //keep track of the current state of activation.
                protected ActivableState state;
                //With the debug marker extension, setting name to vulkan's object ease the debugging.
@@ -43,11 +44,11 @@ namespace vke {
                /// This property has to be implemented in every vulkan object. It should return the correct debug marker info.
                /// </summary>
                /// <value>The debug marker info.</value>
-               protected abstract VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo { get; }
+               protected abstract VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo { get; }
                /// <summary>
                /// Vulkan logical device this activable is bound to.
                /// </summary>
-               public Device Dev { get; private set; }
+               [XmlIgnore] public Device Dev { get; private set; }
 
                #region CTOR
                protected Activable (Device dev) {
@@ -66,12 +67,12 @@ namespace vke {
                public void SetName (string name) {
                        this.name = name;
 
-                       if (!Dev.debugMarkersEnabled)
+                       if (!Dev.debugUtilsEnabled)
                                return;
 
-                       VkDebugMarkerObjectNameInfoEXT dmo = DebugMarkerInfo;
+                       VkDebugUtilsObjectNameInfoEXT dmo = DebugUtilsInfo;
                        dmo.pObjectName = name.Pin();
-                       Utils.CheckResult (vkDebugMarkerSetObjectNameEXT (Dev.VkDev, ref dmo));
+                       Utils.CheckResult (vkSetDebugUtilsObjectNameEXT (Dev.VkDev, ref dmo));
                        name.Unpin ();                  
                }
                /// <summary>
index 837a9d7f2e19ca27e5ab2381465a63e5c2fdeac1..9a86f14fa9f75746604079b3c8b607f7ff02fb0b 100644 (file)
@@ -19,9 +19,8 @@ namespace vke {
                public VkBufferCreateInfo Infos => createInfo;
                public override bool IsLinar => true;
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.BufferEXT, handle.Handle);
-
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Buffer, handle.Handle);
                #region CTORS
                public Buffer (Device device, VkBufferUsageFlags usage, VkMemoryPropertyFlags _memoryPropertyFlags, UInt64 size)
         : base (device, _memoryPropertyFlags) {
index 126137b476053d193b6a8a1b1388702c9b028d59..9c65dc1b27ef87566ee05161dac3db2809c1203d 100644 (file)
@@ -153,7 +153,7 @@ namespace vke {
                                dependencyFlags, 1, ref memoryBarrier, 0, IntPtr.Zero, 0, IntPtr.Zero);
                }
                public void BeginRegion (string name, float r = 1f, float g = 0.1f, float b=0.1f, float a = 1f) {
-                       if (!Device.debugMarkersEnabled)
+                       if (!Device.debugUtilsEnabled)
                                return;
                        VkDebugMarkerMarkerInfoEXT info = VkDebugMarkerMarkerInfoEXT.New();
                        info.pMarkerName = name.Pin ();
@@ -167,7 +167,7 @@ namespace vke {
                        name.Unpin ();
                }
                public void InsertDebugMarker (string name, float r = 1f, float g = 0.1f, float b=0.1f, float a = 1f) {
-                       if (!Device.debugMarkersEnabled)
+                       if (!Device.debugUtilsEnabled)
                                return;
                        VkDebugMarkerMarkerInfoEXT info = VkDebugMarkerMarkerInfoEXT.New();
                        info.pMarkerName = name.Pin ();
@@ -181,7 +181,7 @@ namespace vke {
                        name.Unpin ();
                }
                public void EndRegion () {
-                       if (Device.debugMarkersEnabled)
+                       if (Device.debugUtilsEnabled)
                                vkCmdDebugMarkerEndEXT (Handle);
                }
 
index 01888e6a1fd8eb4f12104e0a54eafe3bdd709030..ead3ec153c5c5ca7ca905fd369efd5df87588480 100644 (file)
@@ -34,8 +34,8 @@ namespace vke {
                public CommandPool (Queue queue) : this(queue.dev, queue.qFamIndex) {}
                #endregion
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.CommandPoolEXT, handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.CommandPool, handle.Handle);
 
                public override void Activate () {
                        if (state != ActivableState.Activated) {            
index 3ebc71a6f15081d792db989f355bdcb694777bb3..20398cc04276cbf2613a32b4a1a2101bccc9d35c 100644 (file)
@@ -26,8 +26,8 @@ namespace vke {
                        cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat);
                        cfg.blendAttachments[0] = new VkPipelineColorBlendAttachmentState (true);
 
-                       cfg.AddShader (VkShaderStageFlags.Vertex, "#CVKL.debug.vert.spv");
-                       cfg.AddShader (VkShaderStageFlags.Fragment, "#CVKL.debug.frag.spv");
+                       cfg.AddShader (VkShaderStageFlags.Vertex, "#vke.debug.vert.spv");
+                       cfg.AddShader (VkShaderStageFlags.Fragment, "#vke.debug.frag.spv");
 
                        layout = cfg.Layout;
 
index eb042d1acaa0fd458957dd6d13e13b4421769cd5..4c4786764c2b8ce01847b9096a3d365ac7bf8bfd 100644 (file)
@@ -3,6 +3,7 @@
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
 using System.Runtime.InteropServices;
+using System.Text;
 using Vulkan;
 using static Vulkan.Vk;
 
@@ -43,8 +44,19 @@ namespace vke.DebugUtils {
                                break;                  
                        }
 
-                       Console.WriteLine (Marshal.PtrToStringAnsi (data.pMessage));
-                       Console.ForegroundColor = curColor;
+                       byte [] tmp = new byte [1024];
+
+                       if (data.pMessage != IntPtr.Zero) {
+                               byte b = Marshal.ReadByte (data.pMessage);
+                               int i = 1;
+                               while (b != 0) {
+                                       tmp [i] = b;
+                                       b = Marshal.ReadByte (data.pMessage, i);
+                                       i++;
+                               }
+                               Console.WriteLine (Encoding.UTF8.GetString(tmp));
+                               Console.ForegroundColor = curColor;
+                       }
                        return false;
                }
                /// <summary>
index 38fba546f51ce21b3c619fab4ece2f9b5fdd01c6..26339f58a4bd6ce829c823be57f5693723504d05 100644 (file)
@@ -3,20 +3,25 @@
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
 using System.Collections.Generic;
+using System.Xml.Serialization;
 using Vulkan;
 using static Vulkan.Vk;
 
 namespace vke {
-    public sealed class DescriptorPool : Activable {
-        internal VkDescriptorPool handle;        
-        public readonly uint MaxSets;
+       [Serializable]
+    public sealed class DescriptorPool : Activable {        
+        internal VkDescriptorPool handle;
+               [XmlAttribute]
+               public uint MaxSets;
+               [XmlArrayItem("PoolSize")]
 
-        public List<VkDescriptorPoolSize> PoolSizes = new List<VkDescriptorPoolSize> ();
-        
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.DescriptorPoolEXT, handle.Handle);
+               public List<VkDescriptorPoolSize> PoolSizes = new List<VkDescriptorPoolSize> ();
+
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.DescriptorPool, handle.Handle);
 
                #region CTORS
+               DescriptorPool () : base (null) {}
                public DescriptorPool (Device device, uint maxSets = 1) : base (device) {            
             MaxSets = maxSets;
         }
index 6df04fbb321659ce1b5ac35f3e37b462fcd457b2..d09c4c40335a7819274a3c9d869fc5ebf9ca60d5 100644 (file)
@@ -16,11 +16,12 @@ namespace vke {
         
                public VkDescriptorSetLayoutCreateFlags Flags { get; private set; } = 0;
         public List<VkDescriptorSetLayoutBinding> Bindings { get; private set; } = new List<VkDescriptorSetLayoutBinding> ();
-        
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo 
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.DescriptorSetLayoutEXT, handle.Handle);
+
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.DescriptorSetLayout, handle.Handle);
 
                #region CTORS
+               DescriptorSetLayout () : base (null) { }
                public DescriptorSetLayout (Device device, VkDescriptorSetLayoutCreateFlags flags) : base (device) {            
                        Flags = flags;
         }
index 2e287e4c5a1f3beae5fa5fa43d3c075dac08bffe..56e38feb7eec3851639904f5d739b86951f94d3f 100644 (file)
@@ -24,7 +24,7 @@ namespace vke {
 
 
                internal List<Queue> queues = new List<Queue> ();
-               internal bool debugMarkersEnabled;
+               internal bool debugUtilsEnabled;
 
 #if MEMORY_POOLS
                public ResourceManager resourceManager;
@@ -66,12 +66,8 @@ namespace vke {
                        //enable only supported exceptions
                        List<IntPtr> deviceExtensions = new List<IntPtr> ();
                        for (int i = 0; i < extensions.Length; i++) {
-                               if (phy.GetDeviceExtensionSupported (extensions[i])) {
-                                       deviceExtensions.Add (new FixedUtf8String (extensions[i]));
-                                       //store in a bool to prevent frequent string test for debug marker ext presence
-                                       if (extensions[i] == Ext.D.VK_EXT_debug_marker)
-                                               debugMarkersEnabled = true;
-                               }
+                               if (phy.GetDeviceExtensionSupported (extensions[i])) 
+                                       deviceExtensions.Add (new FixedUtf8String (extensions[i]));                             
                        }
 
                        VkDeviceCreateInfo deviceCreateInfo = VkDeviceCreateInfo.New ();
index 7ba3d004b8a6d09151f64f7ec829580b249caaa6..94a69b95b4d834e6965e1f45ca6303d67503377f 100644 (file)
@@ -21,9 +21,8 @@ namespace vke {
         public uint Height => createInfo.height;
         public uint Layers => createInfo.layers;
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo 
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.FramebufferEXT, handle.Handle);
-
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Framebuffer, handle.Handle);
                #region CTORS
                public FrameBuffer (RenderPass _renderPass, uint _width, uint _height, uint _layers = 1) : base(_renderPass.Dev) {
             renderPass = _renderPass;
@@ -45,13 +44,13 @@ namespace vke {
                                Image v = views[i];
                                if (v == null) {
                                        //automatically create attachment if not in unused state in the renderpass
-                                       VkAttachmentDescription ad = renderPass.attachments[i];
+                                       VkAttachmentDescription ad = renderPass.Attachments[i];
                                        VkImageUsageFlags usage = 0;
                                        VkImageAspectFlags aspectFlags = 0;
 
                                        Utils.QueryLayoutRequirements (ad.initialLayout, ref usage, ref aspectFlags);
                                        Utils.QueryLayoutRequirements (ad.finalLayout, ref usage, ref aspectFlags);
-                                       foreach (SubPass sp in renderPass.subpasses) {
+                                       foreach (SubPass sp in renderPass.SubPasses) {
                                                //TODO:check subpass usage
                                        }
 
index 46f2b86815e94aebd7b65a30a850bf0443467c92..b0c1e67c37c51c1ce5f7b6aad517a51ffa10e9f7 100644 (file)
@@ -15,7 +15,6 @@ namespace vke {
                #region CTORS
                protected GraphicPipeline (RenderPass renderPass, PipelineCache cache = null, string name = "graphic pipeline") : base(renderPass.Dev, cache, name) { 
                        RenderPass = renderPass;
-                       handle.SetDebugMarkerName (Dev, name);
                }
                /// <summary>
                /// Create a new Pipeline with supplied RenderPass
index bca8ee6b4c72d70119f8d3c65ce3aa86562a2e6f..e96756e065d49a1dc41854f320df4c350ec810e7 100644 (file)
@@ -10,11 +10,30 @@ using Vulkan;
 using static Vulkan.Vk;
 
 namespace vke {
+       /// <summary>
+       /// Graphic pipeline config is a helper class used to construct configurations to create pipelines.
+       /// This class has some facilities for chaining multiple pipelines creations that have small differencies
+       /// in their configurations.
+       /// </summary>
        public class GraphicPipelineConfig {
                public uint SubpassIndex;
+               /// <summary>
+               /// Pipeline layout. Note that layout will not be activated (handle creation) until
+               /// the creation of a new pipeline with this 'GraphicPipelineConfig'.
+               /// It is valid to use an already activated layout for a new config.
+               /// </summary>
                public PipelineLayout Layout;
+               /// <summary>
+               /// See note for the 'Layout' field.
+               /// </summary>
                public RenderPass RenderPass;
+               /// <summary>
+               /// VkPipelineCache to use for the pipeline creation.
+               /// </summary>
                public PipelineCache Cache;
+               /// <summary>
+               /// VkPipelineBindPoint.Graphics is set by default,
+               /// </summary>
                public VkPipelineBindPoint bindPoint = VkPipelineBindPoint.Graphics;
                public VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = VkPipelineInputAssemblyStateCreateInfo.New ();
                public VkPipelineRasterizationStateCreateInfo rasterizationState = VkPipelineRasterizationStateCreateInfo.New ();
@@ -34,7 +53,10 @@ namespace vke {
                public VkSampleCountFlags Samples {
                        get { return multisampleState.rasterizationSamples; }
                }
-
+               /// <summary>
+               /// Default constructor. Prefer the static 'CreateDefault' method to start with
+               /// a classic default configuration for rendering.
+               /// </summary>
                public GraphicPipelineConfig () {
 
                }
@@ -116,13 +138,20 @@ namespace vke {
                public void AddShader (VkShaderStageFlags _stageFlags, string _spirvPath, SpecializationInfo specializationInfo = null, string _entryPoint = "main") {
                        shaders.Add (new ShaderInfo (_stageFlags, _spirvPath, specializationInfo, _entryPoint));
                }
-
+               /// <summary>
+               /// Resets shaders and vertices in current configuration to ease reuse of
+               /// current 'GraphicPipelineConfig' for creating another pipeline.
+               /// </summary>
                public void ResetShadersAndVerticesInfos () {
                        currentAttributeIndex = 0;
                        vertexBindings.Clear ();
                        vertexAttributes.Clear ();
                        ResetShaders ();
                }
+               /// <summary>
+               /// Resets shaders in current config to ease reause of current 'GraphicPipelineConfig
+               /// for creating another similar pipeline with different shaders.
+               /// </summary>
                public void ResetShaders () {
                        foreach (ShaderInfo shader in shaders)
                                shader.Dispose ();
index aa5eb440a789cd0735a3d69c7cbc6f079f289c6c..9c1cb8e653ee71ad7fed7c28767409d6982774ba 100644 (file)
@@ -35,11 +35,11 @@ namespace vke {
 
                public VkImageLayout lastKnownLayout { get; private set; }
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.ImageEXT, handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Image, handle.Handle);
 
                #region CTORS
-        public Image (Device device, VkFormat format, VkImageUsageFlags usage, VkMemoryPropertyFlags _memoryPropertyFlags,
+               public Image (Device device, VkFormat format, VkImageUsageFlags usage, VkMemoryPropertyFlags _memoryPropertyFlags,
             uint width, uint height,
             VkImageType type = VkImageType.Image2D, VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1,
             VkImageTiling tiling = VkImageTiling.Optimal, uint mipsLevels = 1, uint layers = 1, uint depth = 1,
@@ -414,14 +414,18 @@ namespace vke {
                        VkImageLayout oldImageLayout,
                        VkImageLayout newImageLayout,
                        VkPipelineStageFlags srcStageMask = VkPipelineStageFlags.AllCommands,
-                       VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands) {
+                       VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands,
+                       uint srcQueueFamilyIndex = Vk.QueueFamilyIgnored,
+                       uint dstQueueFamilyIndex = Vk.QueueFamilyIgnored)
+               {
                        VkImageSubresourceRange subresourceRange = new VkImageSubresourceRange {
                                aspectMask = aspectMask,
                                baseMipLevel = 0,
                                levelCount = CreateInfo.mipLevels,
                                layerCount = CreateInfo.arrayLayers,
                        };
-                       SetLayout (cmdbuffer, srcAccessMask, dstAccessMask, oldImageLayout, newImageLayout, subresourceRange, srcStageMask, dstStageMask);
+                       SetLayout (cmdbuffer, srcAccessMask, dstAccessMask, oldImageLayout, newImageLayout, subresourceRange, srcStageMask, dstStageMask,
+                               srcQueueFamilyIndex, dstQueueFamilyIndex);
                }
                public void SetLayout (
                        CommandBuffer cmdbuffer,
@@ -431,11 +435,14 @@ namespace vke {
                        VkImageLayout newImageLayout,
                        VkImageSubresourceRange subresourceRange,
                        VkPipelineStageFlags srcStageMask = VkPipelineStageFlags.AllCommands,
-                       VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands) {
+                       VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands,
+                       uint srcQueueFamilyIndex = Vk.QueueFamilyIgnored,
+                       uint dstQueueFamilyIndex = Vk.QueueFamilyIgnored)
+               {
 
                        VkImageMemoryBarrier imageMemoryBarrier = VkImageMemoryBarrier.New ();
-                       imageMemoryBarrier.srcQueueFamilyIndex = Vk.QueueFamilyIgnored;
-                       imageMemoryBarrier.dstQueueFamilyIndex = Vk.QueueFamilyIgnored;
+                       imageMemoryBarrier.srcQueueFamilyIndex = srcQueueFamilyIndex;
+                       imageMemoryBarrier.dstQueueFamilyIndex = dstQueueFamilyIndex;
                        imageMemoryBarrier.oldLayout = oldImageLayout;
                        imageMemoryBarrier.newLayout = newImageLayout;
                        imageMemoryBarrier.image = handle;
@@ -462,11 +469,13 @@ namespace vke {
             VkImageLayout newImageLayout,
             VkImageSubresourceRange subresourceRange,
             VkPipelineStageFlags srcStageMask = VkPipelineStageFlags.AllCommands,
-            VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands) {
+            VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands,
+                       uint srcQueueFamilyIndex = Vk.QueueFamilyIgnored,
+                       uint dstQueueFamilyIndex = Vk.QueueFamilyIgnored) {
             // Create an image barrier object
             VkImageMemoryBarrier imageMemoryBarrier = VkImageMemoryBarrier.New();
-            imageMemoryBarrier.srcQueueFamilyIndex = Vk.QueueFamilyIgnored;
-            imageMemoryBarrier.dstQueueFamilyIndex = Vk.QueueFamilyIgnored;
+            imageMemoryBarrier.srcQueueFamilyIndex = srcQueueFamilyIndex;
+            imageMemoryBarrier.dstQueueFamilyIndex = dstQueueFamilyIndex;
             imageMemoryBarrier.oldLayout = oldImageLayout;
             imageMemoryBarrier.newLayout = newImageLayout;
             imageMemoryBarrier.image = handle;
index dbc9673af7f539fc971fd3f46bb9819679d5acef..beb415a1dc471079db4b91424f51a37fd24e85be 100644 (file)
@@ -29,7 +29,6 @@ namespace vke {
                public IntPtr Handle => inst.Handle;
                public VkInstance VkInstance => inst;
 
-
                static class Strings {
 
                        public static FixedUtf8String main = "main";
@@ -37,6 +36,8 @@ namespace vke {
                const string strValidationLayer = "VK_LAYER_KHRONOS_validation";
                const string strRenderDocLayer = "VK_LAYER_RENDERDOC_Capture";
 
+               internal bool debugUtilsEnabled;
+
                /// <summary>
                /// Create a new vulkan instance with enabled extensions given as argument.
                /// </summary>
@@ -49,10 +50,12 @@ namespace vke {
 
                        using (PinnedObjects pctx = new PinnedObjects ()) {
                                for (int i = 0; i < extensions.Length; i++) {
-                                       if (supportedExts.Contains (extensions[i]))
-                                               instanceExtensions.Add (extensions[i].Pin (pctx));
-                                       else
-                                               Console.WriteLine ($"Vulkan initialisation: Unsupported extension: {extensions[i]}");
+                                       if (supportedExts.Contains (extensions [i])) {
+                                               instanceExtensions.Add (extensions [i].Pin (pctx));
+                                               if (extensions [i] == Ext.I.VK_EXT_debug_utils)
+                                                       debugUtilsEnabled = true;
+                                       } else
+                                               Console.WriteLine ($"Vulkan initialisation: Unsupported extension: {extensions [i]}");
                                }
 
 
index 329e555ec9584d010b8332feb84aa5680ab774a0..8b34025b0d964e292bd90af675f5b90effeeac6c 100644 (file)
@@ -22,8 +22,8 @@ namespace vke {
                }
                #endregion
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.PipelineEXT, handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.Pipeline, handle.Handle);
 
                public abstract void Bind (CommandBuffer cmd);
                public abstract void BindDescriptorSet (CommandBuffer cmd, DescriptorSet dset, uint firstSet = 0);
index f38764dd5dcd60b4556c03cb34de722b76dd23bc..51545c17efbca4af0f46cc2b9d063b869f401f9a 100644 (file)
@@ -72,9 +72,8 @@ namespace vke {
                        base.Activate ();
                }
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.PipelineCacheEXT, handle.Handle);
-
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.PipelineCache, handle.Handle);
 
                public void Delete () {
                        string path = Path.Combine (globalConfigPath, cacheFile);
index 2f932e7f84f6aa3330d5aa6efd668f706f633962..0b68a63071edfeda4f0a9bcd45f9864bd5f36f49 100644 (file)
@@ -15,8 +15,8 @@ namespace vke {
                public List<DescriptorSetLayout> DescriptorSetLayouts = new List<DescriptorSetLayout> ();
                public List<VkPushConstantRange> PushConstantRanges = new List<VkPushConstantRange> ();
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.PipelineLayoutEXT, handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.PipelineLayout, handle.Handle);
 
                #region CTORS
                public PipelineLayout (Device device) : base (device) { }
index 7a5edd35b182b27493f9fde183f278ff62d7f2a0..9fa6f4ca8c4603e87eae08bdc53ef1c168bd4cbe 100644 (file)
@@ -104,8 +104,8 @@ namespace vke {
 
                #endregion
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.QueryPoolEXT, handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.QueryPool, handle.Handle);
 
                public override void Activate () {
                        if (state != ActivableState.Activated) {
index ae5e60366f46f6e21f876284f69ac3bf5d01e8ea..57ceddbd709de11ee89d63b2087eb0ce2593f3bd 100644 (file)
@@ -21,11 +21,13 @@ namespace vke {
                public VkAttachmentDescription [] Attachments => attachments.ToArray ();
                public SubPass [] SubPasses => subpasses.ToArray ();
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.RenderPassEXT, handle.Handle);
-
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.RenderPass, handle.Handle);
                #region CTORS
 
+               /// <summary>
+               /// Create empty render pass with no attachment
+               /// </summary>
                public RenderPass (Device device, VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1) : base(device) {
                        Samples = samples;
                }
index c752696614a11a112a8bcd47492a3870a9e0533d..eba607dc117bde9d649e9e82a38fe6ebc4263fff 100644 (file)
@@ -26,8 +26,8 @@ namespace vke {
                public VkSemaphore presentComplete;
         public Image[] images;
 
-               protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
-                       => new VkDebugMarkerObjectNameInfoEXT (VkDebugReportObjectTypeEXT.SwapchainKhrEXT, Handle.Handle);
+               protected override VkDebugUtilsObjectNameInfoEXT DebugUtilsInfo
+                                       => new VkDebugUtilsObjectNameInfoEXT (VkObjectType.SwapchainKHR, Handle.Handle);
 
                /// <summary>Swapchain images count.</summary>
                public uint ImageCount => (uint)images?.Length;
@@ -84,8 +84,6 @@ namespace vke {
                /// Create swapchain and populate images array
                /// </summary>
                public void Create () {
-                       if (state != ActivableState.Activated)
-                               Activate ();
 
                        Dev.WaitIdle ();
 
@@ -113,7 +111,10 @@ namespace vke {
                 _destroy ();
             Handle = newSwapChain;
 
-            VkImage[] tmp = Dev.GetSwapChainImages (Handle);
+                       if (state != ActivableState.Activated)
+                               Activate ();
+
+                       VkImage[] tmp = Dev.GetSwapChainImages (Handle);
             images = new Image[tmp.Length];
             for (int i = 0; i < tmp.Length; i++) {
                 images[i] = new Image (Dev, tmp[i], ColorFormat, ImageUsage, Width, Height);
index 2d7aab679d1fe4cdf1f0562e9790dceabd5b9aba..b11e08721dd11d89d91a699ab13f5c7c9877578a 100644 (file)
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>netstandard2.0</TargetFramework>          
+               
+               <ReleaseVersion>0.1.11</ReleaseVersion>         
                
-               <ReleaseVersion>0.1.8</ReleaseVersion>          
                <AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
                <Description>C# vulkan library with IDispose model and references counting</Description>                
                <RepositoryUrl>https://github.com/jpbruyere/vke.net</RepositoryUrl>
@@ -48,8 +49,8 @@
        </ItemGroup>
                
        <ItemGroup>
-               <PackageReference Include="SpirVTasks" Version="0.1.15-beta" />
-               <PackageReference Include="Vulkan" Version="0.1.8-beta" />
+               <PackageReference Include="SpirVTasks" Version="0.1.37-beta" />
+               <PackageReference Include="Vulkan" Version="0.1.9-beta" />
        </ItemGroup>
        <ItemGroup>
                <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">