]> O.S.I.I.S - jp/vke.net.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 30 Aug 2020 11:52:38 +0000 (13:52 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 30 Aug 2020 11:52:38 +0000 (13:52 +0200)
24 files changed:
addons/Directory.Build.props
addons/VkvgPipeline/VkvgPipeline.cs
samples/ClearScreen/README.md
samples/ClearScreen/main.cs
samples/DistanceFieldFontTest/Program.cs
samples/Textured/README.md
samples/Textured/main.cs
samples/Textured/shaders/main.vert
samples/TexturedCube/main.cs
samples/Triangle/README.md
samples/Triangle/main.cs
samples/crowWin/Program.cs
samples/deferred/DeferredPbrRenderer.cs
samples/deferred/main.cs
samples/deferred/shaders/tone_mapping.frag
samples/pbr/PbrPipeline.cs
samples/pbr/main.cs
samples/pbr/pbr.csproj
samples/vkeEditor/Program.cs
vke/src/VkWindow.cs
vke/src/base/Buffer.cs
vke/src/base/ComputePipeline.cs
vke/src/ktx.cs
vke/vke.csproj

index c9d2565a39909777b49b5e88a505f78b231d5b12..709ac075eb98db8822060c889904de233f2e26dd 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 a2df026f5e308bec3f6bc1f6c7890ff98aad41ee..6aa5ca345b15a8f43cde18341f4bd125253719c7 100644 (file)
@@ -1,8 +1,6 @@
 // Copyright (c) 2019  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-using System;
-using System.Numerics;
 using vke;
 using Vulkan;
 
@@ -60,6 +58,7 @@ namespace VkvgPipeline {
                        cmd.Draw (3, 1, 0, 0);
 
                }
+#if MEMORY_POOLs
                public void DrawResources (vkvg.Context ctx, int width, int height) {
                        ResourceManager rm = Dev.resourceManager;
 
@@ -121,6 +120,7 @@ namespace VkvgPipeline {
                                y += memPoolHeight;
                        }
                }
+#endif
                protected override void Dispose (bool disposing) {
                        Texture?.Dispose ();
                        vkvgSurf?.Dispose ();
index 8a342fd1fa8e50b5a67d0ebceba1621faace2111..2e4cd6837a979dad0358d3078ea72d926c1241ba 100644 (file)
@@ -4,8 +4,10 @@ To build a minimal vulkan application, add the [vke](https://www.nuget.org/packa
 
 ```xml
 <Project Sdk="Microsoft.NET.Sdk">
-    <TargetFrameworks>net472</TargetFrameworks>
-    <OutputType>Exe</OutputType>
+    <PropertyGroup>
+        <TargetFrameworks>net472</TargetFrameworks>
+        <OutputType>Exe</OutputType>
+    </PropertyGroup>
     <ItemGroup>    
         <GLSLShader Include="shaders\*.*" />           
     </ItemGroup>
@@ -24,6 +26,7 @@ To build a minimal vulkan application, add the [vke](https://www.nuget.org/packa
 ```csharp
 class Program : VkWindow {
     static void Main (string[] args) {
+        Instance.VALIDATION = true;
        using (Program vke = new Program ()) {
                vke.Run ();
        }
@@ -33,7 +36,7 @@ class Program : VkWindow {
 
 ### Vulkan Initialization
 
-`initVulkan` is the first method called by the 'Run' method. Default initialization will provide a vulkan window, a default swap chain bound to it, and a draw and present semaphore to sync the rendering.
+**`initVulkan`** is the first method called by the **`Run`** method. Default initialization will provide a vulkan window, a default swap chain bound to it, and a draw and present semaphore to sync the rendering.
 ```csharp
 protected override void initVulkan () {
     base.initVulkan ();
@@ -52,7 +55,7 @@ Note that because we only reset the command buffers when rebuilding these, we ne
 
 ### Frame buffer creation
 
-The resize method is called at least once before any rendering, so it's a safe place to initialize output size related vulkan objects like the frame buffers. vke provide a FrameBuffer collection object to ease handling of multiple related buffers like those used for a swap chain for example..
+The **`OnResize`** method is called at least once before any rendering, so it's a safe place to initialize output size related vulkan objects like the frame buffers. vke provide a FrameBuffer collection object to ease handling of multiple related buffers like those used for a swap chain for example..
 ```csharp
 FrameBuffers frameBuffers;
 
@@ -67,8 +70,6 @@ protected override void OnResize () {
 ```
 It's common to rebuild the command buffers targeting the swap chain images after a resize so that the drawing is scaled. So it's a good idea to build/rebuild your commands here.
 
-
-
 ### The command buffers
 
 The `VkWindow` class has a default array of command buffers, one for each swap chain image. But it's up to you to allocate and populate them. 
index 3e11384431d2732ab852a139e09b9a47ecf3efb9..c343e993d943491fec92872222acd3fa1350a645 100644 (file)
@@ -15,7 +15,7 @@ namespace ClearScreen {
                        }
                }
 
-               //frame buffer collection to handle on fb per swapchain image.
+               //frame buffer collection to handle one frame buffer per swapchain image.
                FrameBuffers frameBuffers;
                RenderPass renderPass;
 
index d59227cbfb2e28cdc661431e9f94b1f6d5c6e1a8..de274e5261476d39ae6fb7faab6faa3ba0d8e130 100644 (file)
@@ -249,10 +249,10 @@ namespace DistanceFieldFontTest {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton[1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        }
 
index 331e752e2f23e2a29144e99be273c215a036f7a6..143de578ea718dd7130ee3925928d27fa5a4f9ed 100644 (file)
@@ -1,21 +1,30 @@
 ### Enabling extensions
 
-The `VkWindow` class provides two properties that you may override to enable additional extensions.
+The **`VkWindow`** class provides two properties that you may override to enable additional extensions.
 
+```csharp
+public override string[] EnabledInstanceExtensions => new string[] {
+    Ext.I.VK_EXT_debug_utils
+};
+public override string[] EnabledDeviceExtensions => new string[] {
+    Ext.D.VK_KHR_swapchain,
+};
+```
+Extension's names are organized in two subclasses of the `Ext` static class, one for the instance extensions (**`Ext.I`**) and one for the device ones (**`Ext.D`**).
 ### Enabling features
 
-Override the `configureEnabledFeatures` method of `VkWindow` to enable features.
+Override the **`configureEnabledFeatures`** method of **`VkWindow`** to enable features.
 ```csharp
 protected override void configureEnabledFeatures (
-             VkPhysicalDeviceFeatures available_features,
-             ref VkPhysicalDeviceFeatures enabled_features) 
-{    
-       enabled_features.samplerAnisotropy = available_features.samplerAnisotropy;
+    VkPhysicalDeviceFeatures available_features,
+    ref VkPhysicalDeviceFeatures enabled_features) {    
+    
+    enabled_features.samplerAnisotropy = available_features.samplerAnisotropy;
 }
 ```
 ### Creating queues
 
-To create queues, override the `createQueues` method of `VkWindow`. This function is called before the logical device creation and will take care of physically available queues, creating duplicates if count exceed availability. The `base` method will create a default presentable queue.
+To create queues, override the **`createQueues`** method of **`VkWindow`**. This function is called before the logical device creation and will take care of physically available queues, creating duplicates if count exceed availability. The `base` method will create a default presentable queue.
 
 ```csharp
 protected override void createQueues () {
index bf903f1d53138db982be223c4b7cfc5a3ffad43c..e23d443ad1d22eeedbffa98b6ff3d4582af50434 100644 (file)
@@ -19,10 +19,10 @@ namespace Textured {
                                vke.Run ();
                        }
                }
-               protected override void configureEnabledFeatures (VkPhysicalDeviceFeatures available_features, ref VkPhysicalDeviceFeatures features) {
-                       base.configureEnabledFeatures (available_features, ref features);
-                       features.textureCompressionBC = available_features.textureCompressionBC;
-                       features.textureCompressionASTC_LDR = available_features.textureCompressionASTC_LDR;
+               protected override void configureEnabledFeatures (VkPhysicalDeviceFeatures available_features, ref VkPhysicalDeviceFeatures enabled_features) {
+                       base.configureEnabledFeatures (available_features, ref enabled_features);
+                       enabled_features.textureCompressionBC = available_features.textureCompressionBC;
+                       enabled_features.textureCompressionASTC_LDR = available_features.textureCompressionASTC_LDR;
                }
 
                float rotSpeed = 0.01f, zoomSpeed = 0.01f;
@@ -59,7 +59,6 @@ namespace Textured {
                ushort[] indices = { 0, 1, 2, 2, 0, 3 };
                int currentImgIndex = 0;
                string[] imgPathes = {
-                       vke.samples.Utils.DataDirectory + "models/Bricks16_col.jpg",
                        vke.samples.Utils.DataDirectory + "textures/texturearray_rocks_bc3_unorm.ktx",
                        vke.samples.Utils.DataDirectory + "textures/texture.jpg",
                        vke.samples.Utils.DataDirectory + "textures/tex256.jpg",
@@ -98,9 +97,7 @@ namespace Textured {
 
                        pipeline = new GraphicPipeline (cfg);
 
-
-                       uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices);
-                       uboMats.Map ();//permanent map
+                       uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices, true);
 
                        descriptorSet = descriptorPool.Allocate (dsLayout);
 
@@ -198,10 +195,10 @@ namespace Textured {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton[1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        }
 
index 3b395bf2c3017ba70f04786fb2f99f07a0b39eaa..9efd0338f6708efe7dee247398cad4320ac91426 100644 (file)
@@ -4,7 +4,7 @@
 #extension GL_ARB_shading_language_420pack : enable
 
 layout (location = 0) in vec3 inPos;
-layout (location = 1) in vec3 inColor;
+layout (location = 1) in vec2 inTex;
 
 layout (binding = 0) uniform UBO 
 {
@@ -13,7 +13,7 @@ layout (binding = 0) uniform UBO
        mat4 modelMatrix;
 } ubo;
 
-layout (location = 0) out vec3 outColor;
+layout (location = 0) out vec2 outTex;
 
 out gl_PerVertex 
 {
@@ -23,6 +23,6 @@ out gl_PerVertex
 
 void main() 
 {
-       outColor = inColor;
+       outTex = inTex;
        gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0);
 }
index b42ec9d69f821f3ce75c224466b22b061e07abbc..ab32327971da1b9e2083babd5e4c50f9b1f5fe18 100644 (file)
@@ -265,10 +265,10 @@ namespace TextureCube {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton[1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        }
 
index fc767145b62c04ccf1980cf970d91af6bd6b9ba1..3f7f02dac9fa41382576b25aee15a287bdd677a2 100644 (file)
@@ -36,7 +36,7 @@ cfg.AddVertexBinding<Vertex> (0);
 cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat,  //position
                             VkFormat.R32g32b32Sfloat);//color
 ```
-shader are automatically compiled by [`SpirVTacks`](../../SpirVTasks/README.md) if added to the project. The resulting shaders are automatically embedded in the assembly. To specifiy that the shader path is a resource name, put the **'#'** prefix. Else the path will be search on disk.
+shader are automatically compiled by [`SpirVTasks`](../../SpirVTasks/README.md) if added to the project. The resulting shaders are automatically embedded in the assembly. To specifiy that the shader path is a resource name, put the **'#'** prefix. Else the path will be search on disk.
 ```csharp
 cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.main.vert.spv");
 cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.main.frag.spv");
index 12007df7707bc2ea214826c4fbf9519529d057b7..6914623031f970b08fb30e010e6406b1daf6256a 100644 (file)
@@ -16,6 +16,7 @@ namespace Triangle {
                                vke.Run ();
                        }
                }
+               Program () : base ("triangle", 800, 600, false) { }
 
                const float rotSpeed = 0.01f, zoomSpeed = 0.01f;
                float rotX, rotY, zoom = 1f;
@@ -119,10 +120,10 @@ namespace Triangle {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton [0]) {
+                       if (GetButton(Glfw.MouseButton.Left) == Glfw.InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton [1]) {
+                       } else if (GetButton (Glfw.MouseButton.Right) == Glfw.InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        } else
                                return;
index 096f5cefb183add0e73cdb7c6763cd5fbb8410fd..d5adf88f1710fb28cd0229e056d7520e76dcf98c 100644 (file)
@@ -79,7 +79,7 @@ namespace vkeEditor {
 
                GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1, true);
 
-               Program () : base () {}
+               Program () : base ("crow", 800,600, false) {}
 
                protected override void initVulkan () {
                        base.initVulkan ();
@@ -182,10 +182,10 @@ namespace vkeEditor {
 
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton [0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton [1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        } else
                                return;
index 0c9d079cc61134a58a592b6f6f76d0832be4b45e..6c59d8213687429ee6ccfb85c5ebd893a1d18341 100644 (file)
@@ -58,13 +58,13 @@ namespace deferred {
                };
                public Light[] lights = {
                        new Light {
-                               position = new Vector4(1.5f,2.5f,1.5f,0f),
+                               position = new Vector4(1.5f,0.5f,0.5f,0f),
                                color = new Vector4(1,1.0f,1.0f,1)
-                       },
+                       }/*,
                        new Light {
                                position = new Vector4(-1.5f,2.5f,1.5f,0f),
                                color = new Vector4(0.8f,0.8f,1,1)
-                       }
+                       }*/
                };
 
                FrameBuffer frameBuffer;
index a735ee9a6f8a22a1942cdacfda780afdccb57b0e..7ae0dc34189eb3fa965800517613dc9c166b69a3 100644 (file)
@@ -18,7 +18,7 @@ namespace deferred {
                static void Main (string[] args) {
 #if DEBUG
                        Instance.VALIDATION = true;
-                       Instance.RENDER_DOC_CAPTURE = true;
+                       Instance.RENDER_DOC_CAPTURE = false;
 #endif
                        SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Srgb;
                        DeferredPbrRenderer.TEXTURE_ARRAY = true;
@@ -221,9 +221,9 @@ namespace deferred {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                camera.Rotate ((float)-diffY, (float)-diffX, 0);
-                       } else if (MouseButton[1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                camera.SetZoom ((float)diffY);
                        } else
                                return;
index 98f4a692a5a02815a5c5a73be05c244f6df978e3..a2e354ccf5d4e6a62f5a6a223809d8937ae29464 100644 (file)
@@ -14,21 +14,7 @@ layout (location = 0) out vec4 outColor;
                                                                                                          
 void main() 
 {
-               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);              
-    
-    
-    /*
-    outColor = vec4(SRGBtoLINEAR(tonemap(hdrColor.rgb)), hdrColor.a);;*/
-    
-/*  vec3 mapped = vec3(1.0) - exp(-hdrColor.rgb * pc.exposure);        
-    mapped = pow(mapped, vec3(1.0 / pc.gamma));
-    outColor = vec4(mapped, hdrColor.a);*/
+       ivec2 ts = textureSize(samplerHDR);
+       vec4 hdrColor = texelFetch (samplerHDR, ivec2(gl_FragCoord.xy), gl_SampleID);
+       outColor = tonemap(hdrColor, exposure, gamma);
 }
\ No newline at end of file
index 28e3760aa86caf94a268a62068d582e99ecab656..c4ee1059ed8d81314da43180a7b04f0942eb1653 100644 (file)
@@ -43,13 +43,7 @@ namespace vke {
 
                public PbrModel2 model;
                public vke.Environment.EnvironmentCube envCube;
-               string[] cubemapPathes = {
-                       Utils.DataDirectory + "textures/papermill.ktx",
-                       Utils.DataDirectory + "textures/cubemap_yokohama_bc3_unorm.ktx",
-                       Utils.DataDirectory + "textures/gcanyon_cube.ktx",
-                       Utils.DataDirectory + "textures/pisa_cube.ktx",
-                       Utils.DataDirectory + "textures/uffizi_cube.ktx",
-               };
+               string[] cubemapPathes = samples.Utils.CubeMaps;
                public PBRPipeline (Queue staggingQ, RenderPass renderPass, PipelineCache pipelineCache = null) :
                        base (renderPass, pipelineCache, "pbr pipeline") {
 
index 9ce48ebd37472edef50fa77f08a23bfed299be64..453fc0a118e68b2ed81888310944f93c7cdf0486 100644 (file)
@@ -49,29 +49,7 @@ 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"*/
-               };
+               string[] modelPathes = vke.samples.Utils.GltfFiles;
 
                DebugView currentDebugView = DebugView.none;
 
@@ -198,6 +176,7 @@ namespace pbrSample {
                bool rebuildBuffers, reloadModel;
 
                void buildCommandBuffers () {
+                       dev.WaitIdle ();
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
                                cmds[i]?.Free ();
                                cmds[i] = cmdPool.AllocateAndStart ();
@@ -248,6 +227,8 @@ namespace pbrSample {
                        pbrPipeline.matrices.camPos = new Vector4 (inv.M41, inv.M42, inv.M43, 0);
                        pbrPipeline.matrices.debugViewInputs = (float)currentDebugView;
 
+                       dev.WaitIdle ();
+
                        pbrPipeline.uboMats.Update (pbrPipeline.matrices, (uint)Marshal.SizeOf<PBRPipeline.Matrices> ());
 
                        updateViewRequested = false;
@@ -295,9 +276,9 @@ namespace pbrSample {
                protected override void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[0]) {
-                               camera.Rotate ((float)-diffY, (float)-diffX,0);
-                       } else if (MouseButton[1]) {
+                       if (GetButton(MouseButton.Left)== InputAction.Press) {
+                               camera.Rotate ((float)-diffY, (float)-diffX, 0);
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                camera.SetZoom ((float)diffY);
                        } else
                                return;
index 1648b091c22e7142da9fe962601611a12b7658a9..1d92e8e6f1af830cf57458334f66a8a42dae9c1c 100644 (file)
@@ -1,9 +1,9 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
                 
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  <!--<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DefineConstants>_WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG</DefineConstants>
-  </PropertyGroup>
+  </PropertyGroup>-->
   <ItemGroup>
     <GLSLShader Update="shaders/simpletexture.frag">
                   <LogicalName>vke.simpletexture.frag.spv</LogicalName>                
index 9eeec6983b3855aeed735a3006b1fdc485bd78a9..0e94860c7d7f0384aaa5b91733d23603840487b4 100644 (file)
@@ -223,10 +223,10 @@ namespace vkeEditor {
 
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton [0]) {
+                       if (GetButton (MouseButton.Left) == InputAction.Press) {
                                rotY -= rotSpeed * (float)diffX;
                                rotX += rotSpeed * (float)diffY;
-                       } else if (MouseButton [1]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                zoom += zoomSpeed * (float)diffY;
                        } else
                                return;
index 54424d8944e3a16fb74ead48759f4184db6d6643..e30d359a7c835d6a398151d8ef7272af5d7091e8 100644 (file)
@@ -41,7 +41,6 @@ namespace vke {
                protected bool updateViewRequested = true;
                protected double lastMouseX { get; private set; }
                protected double lastMouseY { get; private set; }
-               protected bool[] MouseButton => buttons;
 
                /// <summary>readonly GLFW window handle</summary>
                public IntPtr WindowHandle => hWin;
@@ -49,7 +48,6 @@ namespace vke {
                /**Default camera initialized with a Field of view of 40° and and aspect ratio of 1. */
                protected Camera camera = new Camera (Utils.DegreesToRadians (45f), 1f);
 
-               bool[] buttons = new bool[10];
                public Modifier KeyModifiers = 0;
                IntPtr currentCursor;
                uint frameCount;
@@ -155,8 +153,9 @@ namespace vke {
                        configureEnabledFeatures (phy.Features, ref enabledFeatures);
 
                        //First create the c# device class
-                       dev = new Device (phy);
-                       dev.debugUtilsEnabled = instance.debugUtilsEnabled;//store a boolean to prevent testing against the extension string presence.
+                       dev = new Device (phy) {
+                               debugUtilsEnabled = instance.debugUtilsEnabled//store a boolean to prevent testing against the extension string presence.
+                       };
 
                        //create queue class
                        createQueues ();
@@ -207,8 +206,8 @@ namespace vke {
                }
 
                /// <summary>
-               /// Main render method called each frame. get next swapchain image, process resize if needed, submit and present to the presentQueue.
-               /// Wait QueueIdle after presenting.
+               /// Main render method called each frame.
+               /// First get next swapchain image, process resize if needed, submit and present to the presentQueue.
                /// </summary>
                protected virtual void render () {
                        int idx = swapChain.GetNextImage ();
@@ -225,18 +224,16 @@ namespace vke {
 
                        presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx], drawFence);
                        presentQueue.Present (swapChain, drawComplete[idx]);
-
-                       //presentQueue.WaitIdle ();
                }
 
                protected virtual void onScroll (double xOffset, double yOffset) { }
                protected virtual void onMouseMove (double xPos, double yPos) {
                        double diffX = lastMouseX - xPos;
                        double diffY = lastMouseY - yPos;
-                       if (MouseButton[(int)Glfw.MouseButton.Left]) {
+                       if (GetButton(MouseButton.Left) == InputAction.Press) {
                                camera.Rotate ((float)-diffX, (float)-diffY);
                                updateViewRequested = true;
-                       } else if (MouseButton[(int)Glfw.MouseButton.Right]) {
+                       } else if (GetButton (MouseButton.Right) == InputAction.Press) {
                                camera.Move ((float)diffX,0,0);
                                camera.Move (0, 0, (float)-diffY);
                                updateViewRequested = true;
@@ -283,32 +280,30 @@ namespace vke {
                protected virtual void onKeyUp (Key key, int scanCode, Modifier modifiers) { }
                protected virtual void onChar (CodePoint cp) { }
 
-               #region events delegates
+               protected InputAction GetButton (MouseButton button) =>
+                       Glfw3.GetMouseButton (hWin, button);
 
+               #region events delegates
                static CursorPosDelegate HandleCursorPosDelegate = (window, xPosition, yPosition) => {
                        windows[window].onMouseMove (xPosition, yPosition);
                        windows[window].lastMouseX = xPosition;
                        windows[window].lastMouseY = yPosition;
                };
                static MouseButtonDelegate HandleMouseButtonDelegate = (IntPtr window, Glfw.MouseButton button, InputAction action, Modifier mods) => {
-                       if (action == InputAction.Press) {
-                               windows[window].buttons[(int)button] = true;
+                       if (action == InputAction.Press) 
                                windows[window].onMouseButtonDown (button);
-                       } else {
-                               windows[window].buttons[(int)button] = false;
+                        else
                                windows[window].onMouseButtonUp (button);
-                       }
                };
                static ScrollDelegate HandleScrollDelegate = (IntPtr window, double xOffset, double yOffset) => {
                        windows[window].onScroll (xOffset, yOffset);
                };
                static KeyDelegate HandleKeyDelegate = (IntPtr window, Key key, int scanCode, InputAction action, Modifier modifiers) => {
                        windows[window].KeyModifiers = modifiers;
-                       if (action == InputAction.Press || action == InputAction.Repeat) {
+                       if (action == InputAction.Press || action == InputAction.Repeat) 
                                windows[window].onKeyDown (key, scanCode, modifiers);
-                       } else {
+                       else
                                windows[window].onKeyUp (key, scanCode, modifiers);
-                       }
                };
                static CharDelegate HandleCharDelegate = (IntPtr window, CodePoint codepoint) => {
                        windows[window].onChar (codepoint);
index aa250041a7b71b01d58ce08b3776fd38390e1071..2139b700f25508c27c8f2374f517a9c287733e02 100644 (file)
@@ -115,7 +115,7 @@ namespace vke {
                /// <param name="dstOffset">an offset in the destination buffer for the copy operation.</param>
                public void CopyTo (CommandBuffer cmd, Buffer buff, ulong size = 0, ulong srcOffset = 0, ulong dstOffset = 0) {
                        VkBufferCopy bufferCopy = new VkBufferCopy {
-                               size = (size == 0) ? AllocatedDeviceMemorySize : size,
+                               size = (size == 0) ? createInfo.size: size,
                                srcOffset = srcOffset,
                                dstOffset = dstOffset
                        };
index 1d61ad8710a4f0643995891a0babdaf54bcfe365..b3c6ec5bc6b27c25336436a9c8c7037b3f5e6457 100644 (file)
@@ -39,8 +39,6 @@ namespace vke {
                                        info.basePipelineIndex = 0;
 
                                        Utils.CheckResult (Vk.vkCreateComputePipelines (Dev.VkDev, Cache == null ? VkPipelineCache.Null : Cache.handle, 1, ref info, IntPtr.Zero, out handle));
-
-                                       Dev.DestroyShaderModule (info.stage.module);
                                }
                        }
                        base.Activate ();
index c9a8ccf7c30734b87f78856b6bedc69aa4de2b5f..2c38068c42dbe62f010aecc5e93bf238c811232a 100644 (file)
@@ -97,7 +97,7 @@ namespace KTX {
                                        uint blockSize = blockW * blockH;
 
                                        if (memoryProperty.HasFlag (VkMemoryPropertyFlags.DeviceLocal)) {
-                                               ulong staggingSize = (ulong)ktxStream.Length + 256;//img.AllocatedDeviceMemorySize;
+                                               ulong staggingSize = img.AllocatedDeviceMemorySize;
                                                Console.WriteLine ($"KtxStream size = {ktxStream.Length}, img Allocation = {img.AllocatedDeviceMemorySize}");
 
                                                using (HostBuffer stagging = new HostBuffer (staggingQ.Dev, VkBufferUsageFlags.TransferSrc, staggingSize)) {
index 8def075071bf569c0ee40ccd2338746e85fc3451..454411129b1414839e0e5952d15d090d25b3a285 100644 (file)
@@ -49,7 +49,7 @@
                <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
                <PackageReference Include="Vulkan" Version="0.2.3-beta" />
                <PackageReference Include="shaderc.net" Version="0.1.0" />
-               <PackageReference Include="glfw-sharp" Version="0.2.6-beta" />
+               <PackageReference Include="glfw-sharp" Version="0.2.8-beta" />
        </ItemGroup>
        
        <ItemGroup>