From: Jean-Philippe Bruyère Date: Tue, 1 Dec 2020 10:59:01 +0000 (+0100) Subject: wip X-Git-Tag: v0.2.0-beta~4 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=139c4613237ff4c087903463a8a8cd9f14cd66eb;p=jp%2Fvke.net.git wip --- diff --git a/.travis.yml b/.travis.yml index 4956f1c..9f6e04b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp -dist: xenial +dist: bionic dotnet: 3.1 @@ -10,7 +10,7 @@ env: 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-xenial.list https://packages.lunarg.com/vulkan/lunarg-vulkan-xenial.list + - 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 install vulkan-sdk diff --git a/README.md b/README.md index 15f1b23..0a41155 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ vke is in early development stage. ### Requirements - [GLFW](https://www.glfw.org/) if you use the `VkWindow` class. -- If you want to use `jpg`, `jpeg`, `png` image [libstb](https://github.com/nothings/stb) (on debian install **libstb-dev**). Note that `ktx` image loading has no dependencies. - [Vulkan Sdk](https://www.lunarg.com/vulkan-sdk/), **glslc** has to be in the path. - optionaly for ui, you will need [vkvg](https://github.com/jpbruyere/vkvg). diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index 75dd174..03a8c6b 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -19,14 +19,7 @@ $(SolutionDir)build\$(Configuration)\ - - - TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;_WITH_VKVG - - - NETSTANDARD;NETSTANDARD2_0;WITH_SHADOWS;_WITH_VKVG - - + diff --git a/samples/TexturedCube/main.cs b/samples/TexturedCube/main.cs index c91c22a..7be99ee 100644 --- a/samples/TexturedCube/main.cs +++ b/samples/TexturedCube/main.cs @@ -105,19 +105,6 @@ namespace TextureCube { VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1; -#if WITH_VKVG - VkvgPipeline.VkvgPipeline vkvgPipeline; - - void vkvgDraw () { - using (vkvg.Context ctx = vkvgPipeline.CreateContext()) { - ctx.Clear (); - vkvgPipeline.DrawResources (ctx, (int)swapChain.Width, (int)swapChain.Height); - } - } - - -#endif - protected override void initVulkan () { base.initVulkan (); @@ -159,15 +146,6 @@ namespace TextureCube { loadTexture (imgPathes[currentImgIndex]); if (nextTexture != null) updateTextureSet (); - -#if WITH_VKVG - dsVkvg = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]); - vkvgPipeline = new VkvgPipeline.VkvgPipeline (instance, dev, presentQueue, pipeline); - } - - public override void Update () { - vkvgDraw (); -#endif } void buildCommandBuffers () { @@ -179,11 +157,6 @@ namespace TextureCube { } } void recordDraw (PrimaryCommandBuffer cmd, FrameBuffer fb) { -#if WITH_VKVG - vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color, - VkImageLayout.ColorAttachmentOptimal, VkImageLayout.ShaderReadOnlyOptimal, - VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.FragmentShader); -#endif pipeline.RenderPass.Begin (cmd, fb); cmd.SetViewport (fb.Width, fb.Height); @@ -195,16 +168,7 @@ namespace TextureCube { cmd.BindVertexBuffer (vbo, 0); cmd.Draw (36); -#if WITH_VKVG - cmd.BindDescriptorSet (pipeline.Layout, dsVkvg); - vkvgPipeline.RecordDraw (cmd); - pipeline.RenderPass.End (cmd); - vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color, - VkImageLayout.ShaderReadOnlyOptimal, VkImageLayout.ColorAttachmentOptimal, - VkPipelineStageFlags.FragmentShader, VkPipelineStageFlags.ColorAttachmentOutput); -#else pipeline.RenderPass.End (cmd); -#endif } //in the thread of the keyboard @@ -293,17 +257,6 @@ namespace TextureCube { base.OnResize (); dev.WaitIdle(); - -#if WITH_VKVG - vkvgPipeline.Resize ((int)Width, (int)Height, new DescriptorSetWrites (dsVkvg, dsLayout.Bindings[1])); - PrimaryCommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit); - vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color, - VkImageLayout.Undefined, VkImageLayout.ColorAttachmentOptimal, - VkPipelineStageFlags.AllCommands, VkPipelineStageFlags.ColorAttachmentOutput); - presentQueue.EndSubmitAndWait (cmd, true); - -#endif - updateMatrices (); frameBuffers?.Dispose(); @@ -322,10 +275,6 @@ namespace TextureCube { texture.Dispose (); uboMats.Dispose (); vbo.Dispose (); - -#if WITH_VKVG - vkvgPipeline.Dispose (); -#endif } } diff --git a/samples/compute/compute.csproj b/samples/compute/compute.csproj index 02579c9..30c6b43 100644 --- a/samples/compute/compute.csproj +++ b/samples/compute/compute.csproj @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/compute/main.cs b/samples/compute/main.cs index 02f7069..a281384 100644 --- a/samples/compute/main.cs +++ b/samples/compute/main.cs @@ -1,13 +1,19 @@ -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.Runtime.InteropServices; -using CVKL; -using VK; using System.Linq; +using Vulkan; +using vke; +//very simple compute example that just do an addition on every items of a random list of numbers. namespace SimpleCompute { - class Program : IDisposable { - VkPhysicalDeviceFeatures enabledFeatures = default (VkPhysicalDeviceFeatures); - string[] enabledExtensions = { Ext.D.VK_KHR_swapchain }; + class Program : IDisposable { + static void Main (string[] args) { + using (Program vke = new Program ()) + vke.Run (); + } Instance instance; PhysicalDevice phy; @@ -21,34 +27,27 @@ namespace SimpleCompute { ComputePipeline plCompute; - DebugReport dbgReport; - const uint data_size = 256; + //random datas generation + const uint data_size = 16; int[] datas; + void createRandomDatas () { + datas = new int[data_size]; + Random rnd = new Random (); + for (uint i = 0; i < data_size; i++) + datas[i] = rnd.Next (); + } + public Program () { instance = new Instance (); - -#if DEBUG - dbgReport = new DebugReport (instance, - VkDebugReportFlagsEXT.ErrorEXT - | VkDebugReportFlagsEXT.DebugEXT - | VkDebugReportFlagsEXT.WarningEXT - | VkDebugReportFlagsEXT.PerformanceWarningEXT - - ); -#endif - phy = instance.GetAvailablePhysicalDevice ().FirstOrDefault (); dev = new Device (phy); computeQ = new Queue (dev, VkQueueFlags.Compute); - dev.Activate (enabledFeatures, enabledExtensions); - datas = new int[data_size]; - Random rnd = new Random (); - for (uint i = 0; i < data_size; i++) { - datas[i] = rnd.Next (); - } + dev.Activate (default (VkPhysicalDeviceFeatures)); + + createRandomDatas (); inBuff = new HostBuffer (dev, VkBufferUsageFlags.StorageBuffer, datas); outBuff = new HostBuffer (dev, VkBufferUsageFlags.StorageBuffer, data_size); @@ -59,25 +58,19 @@ namespace SimpleCompute { new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Compute, VkDescriptorType.StorageBuffer) ); - plCompute = new ComputePipeline (new PipelineLayout (dev, dsLayout), "shaders/compute.comp.spv" ); + plCompute = new ComputePipeline (new PipelineLayout (dev, dsLayout), "#shaders.compute.comp.spv" ); dset = dsPool.Allocate (dsLayout); DescriptorSetWrites dsUpdate = new DescriptorSetWrites (dset, dsLayout); dsUpdate.Write (dev, inBuff.Descriptor, outBuff.Descriptor); } - - public void Run () { using (CommandPool cmdPool = new CommandPool (dev, computeQ.qFamIndex)) { - - CommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit); - + PrimaryCommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit); plCompute.Bind (cmd); plCompute.BindDescriptorSet (cmd, dset); - cmd.Dispatch (data_size * sizeof (int)); - cmd.End (); computeQ.Submit (cmd); @@ -93,16 +86,16 @@ namespace SimpleCompute { outBuff.Map (); Marshal.Copy (outBuff.MappedData, results, 0, results.Length); - Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Write ("IN :"); - for (int i = 0; i < data_size; i++) { - Console.Write ($" {datas[i]} "); - } - Console.WriteLine (); + for (int i = 0; i < data_size; i++) + Console.Write ($"{datas[i]} "); + + Console.WriteLine ();Console.WriteLine (); + Console.Write ("OUT:"); - for (int i = 0; i < data_size; i++) { - Console.Write ($" {results[i]} "); - } + for (int i = 0; i < data_size; i++) + Console.Write ($"{results[i]} "); + Console.WriteLine (); outBuff.Unmap (); } @@ -118,16 +111,7 @@ namespace SimpleCompute { outBuff.Dispose (); dev.Dispose (); - -#if DEBUG - dbgReport.Dispose (); -#endif instance.Dispose (); } - - static void Main (string[] args) { - using (Program vke = new Program ()) - vke.Run (); - } } } diff --git a/samples/pbr/main.cs b/samples/pbr/main.cs index 3fe3246..6b979ca 100644 --- a/samples/pbr/main.cs +++ b/samples/pbr/main.cs @@ -47,22 +47,6 @@ namespace pbrSample { 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; diff --git a/samples/pbr/pbr.csproj b/samples/pbr/pbr.csproj index cb7b729..b4f61c1 100644 --- a/samples/pbr/pbr.csproj +++ b/samples/pbr/pbr.csproj @@ -1,18 +1,16 @@ - + + + + vke.simpletexture.frag.spv + + + + $(DefineConstants);WITH_SHADOWS + - - - _WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG - - - - vke.simpletexture.frag.spv - - - - - - - + + + +