]> O.S.I.I.S - jp/vke.net.git/commitdiff
wip 7/head
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 1 Dec 2020 10:59:01 +0000 (11:59 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 1 Dec 2020 10:59:01 +0000 (11:59 +0100)
.travis.yml
README.md
samples/Directory.Build.props
samples/TexturedCube/main.cs
samples/compute/compute.csproj
samples/compute/main.cs
samples/pbr/main.cs
samples/pbr/pbr.csproj

index 4956f1c0c0fc97b2cb3a2f4fd828564a79d371bb..9f6e04b5cd6e4f3d9d836afca91ca15e4e1d0d19 100644 (file)
@@ -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
 
index 15f1b23bbb19a42438569521d79381165d95d955..0a411552d10980a9e9c5ee7e0dfac14a871778ac 100644 (file)
--- 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).
 
index 75dd174477a1a977870de6953250ce485d2e1417..03a8c6b49e0442ddb1b0496f3ed85f72b8b31e79 100644 (file)
                
                <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
        </PropertyGroup>
-    
-       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">    
-               <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)' != 'BuildPackages|AnyCPU' ">
                <ProjectReference Include="..\..\vke\vke.csproj" />
        </ItemGroup>
index c91c22ae3ef2c42d22427ceb13df019b7c57d536..7be99eec726f8beeba1edea907d02d561d767cf3 100644 (file)
@@ -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
                                }
                        }
 
index 02579c9c732d7f0ce73a77bee9597ad6db9bb482..30c6b43802093ed306910073c97e70639f416e09 100644 (file)
@@ -4,6 +4,6 @@
   </PropertyGroup>
               
   <ItemGroup>    
-    <Compile Include="delaunay.cs" /> 
+    <Compile Include="main.cs" /> 
   </ItemGroup>     
 </Project>
\ No newline at end of file
index 02f7069af001557d2e1916db358d0cf9b587d699..a2813844611c493987b3bcbc880ccfbebc72097b 100644 (file)
@@ -1,13 +1,19 @@
-using System;
+// Copyright (c) 2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
 using System.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<int> (dev, VkBufferUsageFlags.StorageBuffer, datas);
                        outBuff = new HostBuffer<int> (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 ();
-               }
        }
 }
index 3fe3246aa980c35eb2b521858eb9966ec3e5b633..6b979ca778b323c10a4737945b14bd32b6594f01 100644 (file)
@@ -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;
index cb7b729748b9e752a2e94fd2b1d0663df4c35bdd..b4f61c18aa14964c24ebb78033a58a33e0979679 100644 (file)
@@ -1,18 +1,16 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">                
+       <ItemGroup>
+               <GLSLShader Update="shaders/simpletexture.frag">
+                       <LogicalName>vke.simpletexture.frag.spv</LogicalName>           
+               </GLSLShader>
+       </ItemGroup>
+       <PropertyGroup>
+               <DefineConstants>$(DefineConstants);WITH_SHADOWS</DefineConstants>
+       </PropertyGroup>
 
-                
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DefineConstants>_WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG</DefineConstants>
-  </PropertyGroup>
-  <ItemGroup>
-    <GLSLShader Update="shaders/simpletexture.frag">
-                  <LogicalName>vke.simpletexture.frag.spv</LogicalName>                
-          </GLSLShader>
-  </ItemGroup>    
-       
-  <ItemGroup>
-    <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
-       <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
-  </ItemGroup>    
+       <ItemGroup>
+               <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
+               <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
+       </ItemGroup>    
   
 </Project>