From: j-p Date: Sun, 26 Jan 2020 02:18:04 +0000 (+0100) Subject: Test ci (#1) X-Git-Tag: v0.1.21~17 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=92f0298f811871455adabd96b3e361416f13d1cd;p=jp%2Fvke.net.git Test ci (#1) * update samples with initVulkan() override, update CI files * build spirvtasks first * use dist xenial for travis, update vulkan apt source --- diff --git a/.travis.yml b/.travis.yml index 408fa8a..4956f1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,20 @@ + language: csharp -dist: bionic - -dotnet: 2.2.401-1 -mono: latest + +dist: xenial + +dotnet: 3.1 + +env: + - FrameworkPathOverride=/usr/lib/mono/4.5/ before_install: - wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - - - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.1.121-bionic.list http://packages.lunarg.com/vulkan/1.1.121/lunarg-vulkan-1.1.121-bionic.list - - sudo apt update + - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-xenial.list https://packages.lunarg.com/vulkan/lunarg-vulkan-xenial.list + - sudo apt -qq update - sudo apt install vulkan-sdk script: - - msbuild /t:restore - - msbuild + - dotnet build /p:Configuration=ReleaseSpirVTasks + - dotnet build /p:Configuration=Release diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..999299b --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,8 @@ + + + $(MSBuildThisFileDirectory) + $(SolutionDir)build\$(Configuration)\ + 0.1.41 + $(SpirVTasksReleaseVersion)-beta + + diff --git a/README.md b/README.md index 94bb90f..74ebeb7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@

-vke.net -
+ vke.net +
+ Vulkan Engine for .NET +

- + @@ -22,7 +24,9 @@ vke.net
adaptation of the gltf PBR sample from Sacha Willems

-**vke.net** (_vulkan engine for .net_) is composed of high level classes encapsulating vulkan objects with `IDispose` model and **reference counting**. [GLFW](https://www.glfw.org/) handles the windowing system. +**vke.net** (_vulkan engine for .net_) is composed of high level classes encapsulating [vulkan]() objects with `IDispose` model and **reference counting**. [GLFW](https://www.glfw.org/) handles the windowing system. + + Use the 'download_datas.sh' script for downloading sample's datas. diff --git a/SpirVTasks/CompileGLSLTask.cs b/SpirVTasks/CompileGLSLTask.cs index 5c65dd5..1b98bc8 100644 --- a/SpirVTasks/CompileGLSLTask.cs +++ b/SpirVTasks/CompileGLSLTask.cs @@ -136,6 +136,7 @@ namespace SpirVTasks { /// Use the SpirVCompilerPath element if present. if not search 'VULKAN_SDK' environment, then PATH env variable. /// bool tryFindGlslcExecutable (out string glslcPath) { + glslcPath = ""; if (!string.IsNullOrEmpty (SpirVCompilerPath?.ItemSpec)) { glslcPath = SpirVCompilerPath.ItemSpec; if (!File.Exists (glslcPath)) @@ -146,14 +147,17 @@ namespace SpirVTasks { if (Environment.OSVersion.Platform.ToString ().StartsWith ("Win", StringComparison.Ordinal)) glslcExec = glslcExec + ".exe"; - glslcPath = Path.Combine (Environment.GetEnvironmentVariable ("VULKAN_SDK"), "bin"); - glslcPath = Path.Combine (glslcPath, glslcExec); - if (File.Exists (glslcPath)) - return true; + string vkSdk = Environment.GetEnvironmentVariable ("VULKAN_SDK"); + if (!string.IsNullOrEmpty (vkSdk)) { + glslcPath = Path.Combine (vkSdk, "bin"); + glslcPath = Path.Combine (glslcPath, glslcExec); + if (File.Exists (glslcPath)) + return true; + } string envStrPathes = Environment.GetEnvironmentVariable ("PATH"); if (!string.IsNullOrEmpty (envStrPathes)) { - foreach (string path in envStrPathes.Split (';')) { + foreach (string path in envStrPathes.Split (':')) { glslcPath = Path.Combine (path, glslcExec); if (File.Exists (glslcPath)) return true; diff --git a/SpirVTasks/SpirVTasks.csproj b/SpirVTasks/SpirVTasks.csproj index bb9bb63..54286d3 100644 --- a/SpirVTasks/SpirVTasks.csproj +++ b/SpirVTasks/SpirVTasks.csproj @@ -1,16 +1,16 @@ - + netstandard2.0 - 0.1.38 + $(SpirVTasksReleaseVersion) false $(ReleaseVersion) MSBuild addon to compile and embed spirV shaders SpirVTasks vulkan msbuild spirv glsl addons - $(ReleaseVersion)-beta + $(SpirVTasksPackageVersion) True False https://github.com/jpbruyere/vk.net/blob/master/SpirVTasks/README.md @@ -22,6 +22,8 @@ false true SpirVTasks_$(TargetFramework) + + true diff --git a/addons/Directory.Build.props b/addons/Directory.Build.props index 81a78f6..f1fba1a 100644 --- a/addons/Directory.Build.props +++ b/addons/Directory.Build.props @@ -1,4 +1,5 @@ + $(MSBuildThisFileDirectory)../ true @@ -16,7 +17,8 @@ 7.2 $(MSBuildThisFileDirectory)common\shaders - + + $(SolutionDir)build\$(Configuration)\ @@ -34,7 +36,7 @@ - + diff --git a/appveyor.yml b/appveyor.yml index 3f45e42..354ea62 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,19 +1,45 @@ -version: 1.0.{build} -image: Visual Studio 2019 +version: 0.1.{build} -environment: - VULKAN_SDK: C:/VulkanSDK/1.1.130.0 - APPVEYOR_SAVE_CACHE_ON_ERROR: true +image: + - Visual Studio 2019 + - Ubuntu -cache: - - VulkanSDK.exe - - c:\VulkanSDK\ - -install: - - if not exist VulkanSDK.exe curl -L --silent --show-error --output VulkanSDK.exe https://vulkan.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true && VulkanSDK.exe /S - -before_build: - - nuget restore build: verbosity: minimal + +for: + - + matrix: + only: + - image: Visual Studio 2019 + environment: + VULKAN_SDK: C:/VulkanSDK/1.1.130.0 + APPVEYOR_SAVE_CACHE_ON_ERROR: true + cache: + - VulkanSDK.exe + - c:\VulkanSDK\ + install: + - if not exist VulkanSDK.exe curl -L --silent --show-error --output VulkanSDK.exe https://vulkan.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true && VulkanSDK.exe /S + build_script: + - msbuild /p:Configuration=ReleaseSpirVTasks /t:restore + - msbuild /p:Configuration=ReleaseSpirVTasks + - msbuild /p:Configuration=Release /t:restore + - msbuild /p:Configuration=Release + + - + matrix: + only: + - image: Ubuntu + environment: + FrameworkPathOverride: /usr/lib/mono/4.5/ + install: + - wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - + - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-bionic.list https://packages.lunarg.com/vulkan/lunarg-vulkan-bionic.list + - sudo apt -qq update + - sudo apt -y install vulkan-sdk + - glslc --version + build_script: + - dotnet build /p:Configuration=ReleaseSpirVTasks + - dotnet build /p:Configuration=Release + diff --git a/netfx.props b/netfx.props deleted file mode 100644 index 25fdbe0..0000000 --- a/netfx.props +++ /dev/null @@ -1,27 +0,0 @@ - - - - - true - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - - - diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index 0f2b9a8..2600f8b 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -1,4 +1,5 @@ + $(MSBuildThisFileDirectory)../ true @@ -15,7 +16,8 @@ false $(MSBuildThisFileDirectory)common\shaders - + + $(SolutionDir)build\$(Configuration)\ @@ -33,7 +35,7 @@ - + diff --git a/samples/DistanceFieldFontTest/Program.cs b/samples/DistanceFieldFontTest/Program.cs index 7e0d330..b0df355 100644 --- a/samples/DistanceFieldFontTest/Program.cs +++ b/samples/DistanceFieldFontTest/Program.cs @@ -62,7 +62,9 @@ namespace DistanceFieldFontTest { Vector4 textColor = new Vector4 (1.0f, 1.0f, 0.0f, 1.0f);//alpha => 0:disabled 1:enabled Vector4 outlineColor = new Vector4 (1.0f, 0.0f, 0.0f, 0.6f);//alpha => 0:disabled 1:enabled - Program () : base () { + protected override void initVulkan () { + base.initVulkan (); + cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount); font = new BMFont (Utils.DataDirectory + "font.fnt"); diff --git a/samples/Model/main.cs b/samples/Model/main.cs index e93019d..21e0269 100644 --- a/samples/Model/main.cs +++ b/samples/Model/main.cs @@ -45,9 +45,10 @@ namespace ModelSample float rotX, rotY, rotZ = 0f, zoom = 2f; SimpleModel helmet; - vke.DebugUtils.Messenger dbgmsg; - Program () : base () { + protected override void initVulkan () { + base.initVulkan (); + cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount); descriptorPool = new DescriptorPool (dev, 2, @@ -222,7 +223,6 @@ namespace ModelSample frameBuffers?.Dispose(); descriptorPool.Dispose (); uboMats.Dispose (); - dbgmsg?.Dispose (); } } diff --git a/samples/Textured/main.cs b/samples/Textured/main.cs index b14dd45..fb671bb 100644 --- a/samples/Textured/main.cs +++ b/samples/Textured/main.cs @@ -6,16 +6,15 @@ using vke; using Vulkan; namespace Textured { + /// + /// Simple textured quad sample + /// class Program : VkWindow { static void Main (string[] args) { #if DEBUG Instance.VALIDATION = true; Instance.RENDER_DOC_CAPTURE = true; #endif - - foreach (string s in System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceNames ()) - Console.WriteLine (s); - using (Program vke = new Program ()) { vke.Run (); } @@ -67,7 +66,9 @@ namespace Textured { Utils.DataDirectory + "font.ktx", }; - Program () : base () { + protected override void initVulkan () { + base.initVulkan (); + cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount); loadTexture (imgPathes[currentImgIndex]); @@ -113,27 +114,30 @@ namespace Textured { dev.WaitIdle (); cmdPool.Reset(); for (int i = 0; i < swapChain.ImageCount; ++i) { - cmds[i].Start(); - recordDraw (cmds[i], frameBuffers[i]); - cmds[i].End (); - } - } - void recordDraw (CommandBuffer cmd, FrameBuffer fb) { - pipeline.RenderPass.Begin (cmd, fb); + CommandBuffer cmd = cmds[i]; + FrameBuffer fb = frameBuffers[i]; + + cmd.Start(); - cmd.SetViewport (fb.Width, fb.Height); - cmd.SetScissor (fb.Width, fb.Height); - cmd.BindDescriptorSet (pipeline.Layout, descriptorSet); + pipeline.RenderPass.Begin (cmd, fb); - pipeline.Bind (cmd); + cmd.SetViewport (fb.Width, fb.Height); + cmd.SetScissor (fb.Width, fb.Height); + cmd.BindDescriptorSet (pipeline.Layout, descriptorSet); - cmd.BindVertexBuffer (vbo, 0); - cmd.BindIndexBuffer (ibo, VkIndexType.Uint16); - cmd.DrawIndexed ((uint)indices.Length); + pipeline.Bind (cmd); - pipeline.RenderPass.End (cmd); + cmd.BindVertexBuffer (vbo, 0); + cmd.BindIndexBuffer (ibo, VkIndexType.Uint16); + cmd.DrawIndexed ((uint)indices.Length); + + pipeline.RenderPass.End (cmd); + + cmd.End (); + } } + VkMemoryPropertyFlags imgProp = VkMemoryPropertyFlags.DeviceLocal; bool genMipMaps = true; VkImageTiling tiling = VkImageTiling.Optimal; @@ -169,6 +173,7 @@ namespace Textured { texture = nextTexture; nextTexture = null; } + void updateMatrices () { matrices.projection = Matrix4x4.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (60f), (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f); matrices.view = Matrix4x4.CreateTranslation (0, 0, -2.5f * zoom); diff --git a/samples/TexturedCube/main.cs b/samples/TexturedCube/main.cs index d15a029..cfd19c2 100644 --- a/samples/TexturedCube/main.cs +++ b/samples/TexturedCube/main.cs @@ -10,6 +10,9 @@ using Vulkan; using Buffer = vke.Buffer; namespace TextureCube { + /// + /// Simple textured cube sampled. + /// class Program : VkWindow { static void Main (string[] args) { #if DEBUG @@ -109,8 +112,10 @@ namespace TextureCube { #endif - Program () : base () { - cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount); + protected override void initVulkan () { + base.initVulkan (); + + cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount); vbo = new GPUBuffer (presentQueue, cmdPool, VkBufferUsageFlags.VertexBuffer, g_vertex_buffer_data); @@ -147,7 +152,6 @@ namespace TextureCube { if (nextTexture != null) updateTextureSet (); - #if WITH_VKVG dsVkvg = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]); vkvgPipeline = new VkvgPipeline.VkvgPipeline (instance, dev, presentQueue, pipeline); diff --git a/samples/Triangle/main.cs b/samples/Triangle/main.cs index d498562..e9b1996 100644 --- a/samples/Triangle/main.cs +++ b/samples/Triangle/main.cs @@ -10,30 +10,24 @@ 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 - Instance.VALIDATION = true; - Instance.RENDER_DOC_CAPTURE = false; -#endif - using (Program vke = new Program ()) { vke.Run (); } } - float rotSpeed = 0.01f, zoomSpeed = 0.01f; + const float rotSpeed = 0.01f, zoomSpeed = 0.01f; float rotX, rotY, rotZ = 0f, zoom = 1f; + [StructLayout (LayoutKind.Sequential)] struct Matrices { public Matrix4x4 projection; public Matrix4x4 view; public Matrix4x4 model; } + + [StructLayout(LayoutKind.Sequential)] struct Vertex { Vector3 position; Vector3 color; @@ -50,6 +44,7 @@ namespace Triangle { HostBuffer vbo; HostBuffer uboMats; + DescriptorPool descriptorPool; DescriptorSet descriptorSet; FrameBuffers frameBuffers; @@ -62,33 +57,23 @@ namespace Triangle { }; ushort[] indices = new ushort[] { 0, 1, 2 }; + Program () : base () {} - - public Renderer r = new Renderer (); - - Program () : base () { - cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount); + protected override void initVulkan () { + base.initVulkan (); vbo = new HostBuffer (dev, VkBufferUsageFlags.VertexBuffer, vertices); ibo = new HostBuffer (dev, VkBufferUsageFlags.IndexBuffer, indices); uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices); - r.descriptorPool = new DescriptorPool (dev, 1, - new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer), - new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler)); + descriptorPool = new DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer)); - 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); - GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1,false); + cfg.Layout = new PipelineLayout (dev, + new DescriptorSetLayout (dev, + new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer))); - cfg.Layout = new PipelineLayout (dev, r.dsLayout); cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, cfg.Samples); cfg.AddVertexBinding (0); cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat); @@ -100,17 +85,19 @@ namespace Triangle { //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 = r.descriptorPool.Allocate (r.dsLayout); + descriptorSet = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]); - DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, r.dsLayout); + DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, pipeline.Layout.DescriptorSetLayouts[0]); uboUpdate.Write (dev, uboMats.Descriptor); uboMats.Map (); + + cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount); } 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, 256.0f); matrices.view = Matrix4x4.CreateFromAxisAngle (Vector3.UnitZ, rotZ) * Matrix4x4.CreateFromAxisAngle (Vector3.UnitY, rotY) * @@ -133,6 +120,7 @@ namespace Triangle { return; updateViewRequested = true; } + void buildCommandBuffers() { cmdPool.Reset (VkCommandPoolResetFlags.ReleaseResources); @@ -176,7 +164,7 @@ namespace Triangle { pipeline.Dispose (); frameBuffers?.Dispose(); - r.descriptorPool.Dispose (); + descriptorPool.Dispose (); vbo.Dispose (); ibo.Dispose (); uboMats.Dispose (); diff --git a/samples/compute/delaunay.cs b/samples/compute/delaunay.cs index 4a36790..7f707d3 100644 --- a/samples/compute/delaunay.cs +++ b/samples/compute/delaunay.cs @@ -30,8 +30,6 @@ namespace delaunay { ComputePipeline plCompute, plNormalize; - DebugReport dbgReport; - const uint imgDim = 256; uint zoom = 2; int invocationCount = 8; @@ -51,8 +49,9 @@ namespace delaunay { } + protected override void initVulkan () { + base.initVulkan (); - public Program () : base () { imgResult = new Image (dev, VkFormat.R32g32b32a32Sfloat, VkImageUsageFlags.TransferDst | VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal, imgDim, imgDim); imgResult.CreateView (); @@ -307,8 +306,6 @@ namespace delaunay { stagingDataBuff.Dispose (); imgResult.Dispose (); - - dbgReport?.Dispose (); } } diff --git a/samples/deferred/main-crow.cs b/samples/deferred/main-crow.cs index 20f6566..f90efcb 100644 --- a/samples/deferred/main-crow.cs +++ b/samples/deferred/main-crow.cs @@ -138,15 +138,17 @@ namespace deferred { DebugReport dbgRepport; - Program () : base() { + protected override void initVulkan () { + base.initVulkan (); - if (Instance.DEBUG_UTILS) - dbgRepport = new DebugReport (instance, +#if DEBUG + dbgRepport = new DebugReport (instance, VkDebugReportFlagsEXT.ErrorEXT | VkDebugReportFlagsEXT.DebugEXT | VkDebugReportFlagsEXT.WarningEXT | VkDebugReportFlagsEXT.PerformanceWarningEXT ); +#endif camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 16f); camera.SetPosition (0, 0, 2); diff --git a/samples/deferred/main.cs b/samples/deferred/main.cs index 85e81aa..1a6ea63 100644 --- a/samples/deferred/main.cs +++ b/samples/deferred/main.cs @@ -1,4 +1,8 @@ -using System; +// Copyright (c) 2020 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using System; using System.Numerics; using System.Runtime.InteropServices; using vke; @@ -7,17 +11,20 @@ using Glfw; using Vulkan; namespace deferred { + /// + /// Deferred PBR rendering. + /// class Deferred : VkWindow { static void Main (string[] args) { #if DEBUG Instance.VALIDATION = true; - Instance.RENDER_DOC_CAPTURE = true; + //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.R16g16b16a16Sfloat; + DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount8; + DeferredPbrRenderer.HDR_FORMAT = VkFormat.R32g32b32a32Sfloat; + DeferredPbrRenderer.MRT_FORMAT = VkFormat.R32g32b32a32Sfloat; PbrModelTexArray.TEXTURE_DIM = 1024; @@ -80,13 +87,16 @@ namespace deferred { vke.DebugUtils.Messenger dbgmsg; - Deferred () : base("deferred") { + protected override void initVulkan () { + base.initVulkan (); + +#if DEBUG dbgmsg = new vke.DebugUtils.Messenger (instance, VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT | VkDebugUtilsMessageTypeFlagsEXT.ValidationEXT | VkDebugUtilsMessageTypeFlagsEXT.GeneralEXT, VkDebugUtilsMessageSeverityFlagsEXT.InfoEXT | VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT | VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT | VkDebugUtilsMessageSeverityFlagsEXT.VerboseEXT); - +#endif camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 16f); camera.SetPosition (0, 0, -2); @@ -358,7 +368,7 @@ namespace deferred { renderer.Dispose (); plToneMap.Dispose (); descriptorPool.Dispose (); - dbgmsg.Dispose (); + dbgmsg?.Dispose (); } } base.Dispose (disposing); diff --git a/samples/pbr/main.cs b/samples/pbr/main.cs index 7bc30ea..4375fec 100644 --- a/samples/pbr/main.cs +++ b/samples/pbr/main.cs @@ -13,7 +13,7 @@ using Vulkan; using vke; namespace pbrSample { - class Program : VkWindow{ + class Program : VkWindow { static void Main (string[] args) { #if DEBUG @@ -34,7 +34,7 @@ namespace pbrSample { enabled_features.samplerAnisotropy = available_features.samplerAnisotropy; } - VkSampleCountFlags samples = VkSampleCountFlags.SampleCount4; + VkSampleCountFlags samples = VkSampleCountFlags.SampleCount8; FrameBuffers frameBuffers; PBRPipeline pbrPipeline; @@ -94,7 +94,7 @@ namespace pbrSample { VkvgPipeline.VkvgPipeline vkvgPipeline; void vkvgDraw () { - using (vkvg.Context ctx = vkvgPipeline.CreateContext ()) { + using (vkvg.Context ctx = vkvgPipeline.CreateContext ()) { ctx.Clear (); ctx.LineWidth = 1; @@ -124,7 +124,7 @@ namespace pbrSample { ctx.ShowText (string.Format ($"Gamma: {pbrPipeline.matrices.gamma,5} ")); y += dy; ctx.MoveTo (x, y); - ctx.ShowText (string.Format ($"Light pos: {lightPos.ToString()} ")); + ctx.ShowText (string.Format ($"Light pos: {lightPos.ToString ()} ")); #if PIPELINE_STATS if (results == null) @@ -167,13 +167,14 @@ namespace pbrSample { Vector4 lightPos = new Vector4 (1, 0, 0, 0); uint curModelIndex = 0; - Program () : base() { + protected override void initVulkan () { + base.initVulkan (); //UpdateFrequency = 20; camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 64f); camera.SetPosition (0, 0, -2); - pbrPipeline = new PBRPipeline(presentQueue, + pbrPipeline = new PBRPipeline (presentQueue, new RenderPass (dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat (), samples)); loadCurrentModel (); @@ -221,7 +222,7 @@ namespace pbrSample { #if WITH_VKVG vkvgPipeline.RecordDraw (cmd); -#endif +#endif pbrPipeline.RenderPass.End (cmd); } @@ -269,11 +270,11 @@ namespace pbrSample { vkvgDraw (); #endif } -#endregion + #endregion + - protected override void OnResize () { - base.OnResize(); + base.OnResize (); dev.WaitIdle (); #if WITH_VKVG @@ -283,8 +284,8 @@ namespace pbrSample { UpdateView (); - frameBuffers?.Dispose(); - frameBuffers = pbrPipeline.RenderPass.CreateFrameBuffers(swapChain); + frameBuffers?.Dispose (); + frameBuffers = pbrPipeline.RenderPass.CreateFrameBuffers (swapChain); buildCommandBuffers (); dev.WaitIdle (); @@ -308,7 +309,7 @@ namespace pbrSample { switch (key) { case Key.Space: if (modifiers.HasFlag (Modifier.Shift)) - curModelIndex = curModelIndex == 0 ? (uint)modelPathes.Length - 1 : curModelIndex-1; + curModelIndex = curModelIndex == 0 ? (uint)modelPathes.Length - 1 : curModelIndex - 1; else curModelIndex = curModelIndex < (uint)modelPathes.Length - 1 ? curModelIndex + 1 : 0; reloadModel = true; @@ -338,95 +339,95 @@ namespace pbrSample { } queryUpdatePrefilCube = updateViewRequested = true; break;*/ - case Key.P: - showDebugImg = !showDebugImg; - queryUpdatePrefilCube = updateViewRequested = true; - break; - case Key.Keypad0: - currentDebugView = DebugView.none; - break; - case Key.Keypad1: - currentDebugView = DebugView.color; - break; - case Key.Keypad2: - currentDebugView = DebugView.normal; - break; - case Key.Keypad3: - currentDebugView = DebugView.occlusion; - break; - case Key.Keypad4: - currentDebugView = DebugView.emissive; - break; - case Key.Keypad5: - currentDebugView = DebugView.metallic; - break; - case Key.Keypad6: - currentDebugView = DebugView.roughness; - break; - case Key.Up: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos -= Vector4.UnitZ; - else - camera.Move (0, 0, 1); - break; - case Key.Down: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos += Vector4.UnitZ; - else - camera.Move (0, 0, -1); - break; - case Key.Left: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos -= Vector4.UnitX; - else - camera.Move (1, 0, 0); - break; - case Key.Right: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos += Vector4.UnitX; - else - camera.Move (-1, 0, 0); - break; - case Key.PageUp: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos += Vector4.UnitY; - else - camera.Move (0, 1, 0); - break; - case Key.PageDown: - if (modifiers.HasFlag (Modifier.Shift)) - lightPos -= Vector4.UnitY; - else - camera.Move (0, -1, 0); - break; - case Key.S: - if (modifiers.HasFlag (Modifier.Shift)) - pbrPipeline.matrices.scaleIBLAmbient -= 0.1f; - else - pbrPipeline.matrices.scaleIBLAmbient += 0.1f; - break; - case Key.F2: - if (modifiers.HasFlag (Modifier.Shift)) - pbrPipeline.matrices.exposure -= 0.3f; - else - pbrPipeline.matrices.exposure += 0.3f; - break; + case Key.P: + showDebugImg = !showDebugImg; + queryUpdatePrefilCube = updateViewRequested = true; + break; + case Key.Keypad0: + currentDebugView = DebugView.none; + break; + case Key.Keypad1: + currentDebugView = DebugView.color; + break; + case Key.Keypad2: + currentDebugView = DebugView.normal; + break; + case Key.Keypad3: + currentDebugView = DebugView.occlusion; + break; + case Key.Keypad4: + currentDebugView = DebugView.emissive; + break; + case Key.Keypad5: + currentDebugView = DebugView.metallic; + break; + case Key.Keypad6: + currentDebugView = DebugView.roughness; + break; + case Key.Up: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos -= Vector4.UnitZ; + else + camera.Move (0, 0, 1); + break; + case Key.Down: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos += Vector4.UnitZ; + else + camera.Move (0, 0, -1); + break; + case Key.Left: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos -= Vector4.UnitX; + else + camera.Move (1, 0, 0); + break; + case Key.Right: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos += Vector4.UnitX; + else + camera.Move (-1, 0, 0); + break; + case Key.PageUp: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos += Vector4.UnitY; + else + camera.Move (0, 1, 0); + break; + case Key.PageDown: + if (modifiers.HasFlag (Modifier.Shift)) + lightPos -= Vector4.UnitY; + else + camera.Move (0, -1, 0); + break; + case Key.S: + if (modifiers.HasFlag (Modifier.Shift)) + pbrPipeline.matrices.scaleIBLAmbient -= 0.1f; + else + pbrPipeline.matrices.scaleIBLAmbient += 0.1f; + break; + case Key.F2: + if (modifiers.HasFlag (Modifier.Shift)) + pbrPipeline.matrices.exposure -= 0.3f; + else + pbrPipeline.matrices.exposure += 0.3f; + break; case Key.F3: - if (modifiers.HasFlag (Modifier.Shift)) - pbrPipeline.matrices.gamma -= 0.1f; - else - pbrPipeline.matrices.gamma += 0.1f; - break; - case Key.F4: - if (camera.Type == Camera.CamType.FirstPerson) - camera.Type = Camera.CamType.LookAt; - else - camera.Type = Camera.CamType.FirstPerson; - Console.WriteLine ($"camera type = {camera.Type}"); - break; - default: - base.onKeyDown (key, scanCode, modifiers); - return; + if (modifiers.HasFlag (Modifier.Shift)) + pbrPipeline.matrices.gamma -= 0.1f; + else + pbrPipeline.matrices.gamma += 0.1f; + break; + case Key.F4: + if (camera.Type == Camera.CamType.FirstPerson) + camera.Type = Camera.CamType.LookAt; + else + camera.Type = Camera.CamType.FirstPerson; + Console.WriteLine ($"camera type = {camera.Type}"); + break; + default: + base.onKeyDown (key, scanCode, modifiers); + return; } updateViewRequested = true; } @@ -436,7 +437,7 @@ namespace pbrSample { if (disposing) { if (!isDisposed) { dev.WaitIdle (); - frameBuffers?.Dispose(); + frameBuffers?.Dispose (); pbrPipeline.Dispose (); #if WITH_VKVG vkvgPipeline.Dispose (); diff --git a/samples/pbr/pbr.csproj b/samples/pbr/pbr.csproj index c0a4e2c..1648b09 100644 --- a/samples/pbr/pbr.csproj +++ b/samples/pbr/pbr.csproj @@ -2,7 +2,7 @@ - NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;WITH_VKVG;TRACE;DEBUG;NETFRAMEWORK;NET471 + _WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG diff --git a/samples/pbr/screenshot.png b/samples/pbr/screenshot.png new file mode 100644 index 0000000..fdecfa2 Binary files /dev/null and b/samples/pbr/screenshot.png differ diff --git a/vke.net.sln b/vke.net.sln index fd98d3c..3f41d4e 100644 --- a/vke.net.sln +++ b/vke.net.sln @@ -33,10 +33,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "deferred", "samples\deferre EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pbr", "samples\pbr\pbr.csproj", "{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vkeEditor", "samples\vkeEditor\vkeEditor.csproj", "{81619805-9E6F-404A-BC0D-A2C25DDA2EDC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "samples\tests\tests.csproj", "{F9117397-E105-44DD-A9BD-F6F8DC641095}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -115,12 +111,14 @@ Global {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 + {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU + {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.ReleaseSpirVTasks|Any CPU.Build.0 = Release|Any CPU + {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Release|Any CPU.Build.0 = Release|Any CPU {F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Debug|Any CPU.ActiveCfg = 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 @@ -150,26 +148,6 @@ Global {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 - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Release|Any CPU.Build.0 = Release|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.BuildPackages|Any CPU.Build.0 = Release|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.Release|Any CPU.Build.0 = Release|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU - {F9117397-E105-44DD-A9BD-F6F8DC641095}.BuildPackages|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658} @@ -184,8 +162,6 @@ Global {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} - {81619805-9E6F-404A-BC0D-A2C25DDA2EDC} = {16439374-B8DB-4643-8116-EB3358B49A12} - {F9117397-E105-44DD-A9BD-F6F8DC641095} = {16439374-B8DB-4643-8116-EB3358B49A12} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/vke/vke.csproj b/vke/vke.csproj index b11e087..6646adf 100644 --- a/vke/vke.csproj +++ b/vke/vke.csproj @@ -3,7 +3,7 @@ netstandard2.0 - 0.1.11 + 0.1.12 $(ReleaseVersion) C# vulkan library with IDispose model and references counting @@ -11,6 +11,7 @@ vulkan game engine compute glfw c# $(AssemblyVersion)-beta True + true False https://github.com/jpbruyere/vke.net/blob/master/README.md MIT @@ -29,6 +30,8 @@ 7.2 true $(NoWarn);1591 + + $(SolutionDir)build\$(Configuration)\ @@ -36,12 +39,12 @@ full false true - MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0;DEBUG;NETFRAMEWORK;NET471 + MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0;DEBUG true - MEMORY_POOLS + MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0 @@ -49,13 +52,11 @@ - - + + - - testRsID - +