]> O.S.I.I.S - jp/vke.net.git/commitdiff
debug
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 12 Sep 2019 03:08:12 +0000 (05:08 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 12 Sep 2019 03:08:12 +0000 (05:08 +0200)
96 files changed:
Directory.Build.props [deleted file]
README.md
SpirVTasks/README.md
SpirVTasks/SpirVTasks.targets
addons/Directory.Build.props
addons/DistanceFieldFont/BMChar.cs
addons/DistanceFieldFont/BMFont.cs
addons/VkvgPipeline/VkvgPipeline.cs
addons/gltfLoader/PbrModel.cs
addons/gltfLoader/PbrModelSeparateTextures.cs
addons/gltfLoader/PbrModelTexArray.cs
addons/gltfLoader/glTFLoader.cs
datas/font.fnt [new file with mode: 0644]
datas/models/Box.gltf [new file with mode: 0644]
datas/models/DamagedHelmet/glTF-Embedded/DamagedHelmet.gltf [new file with mode: 0644]
datas/models/DamagedHelmet/glTF/DamagedHelmet.bin [new file with mode: 0644]
datas/models/DamagedHelmet/glTF/DamagedHelmet.gltf [new file with mode: 0644]
datas/models/Sponza/README.md [new file with mode: 0644]
datas/models/Sponza/glTF/Sponza.bin [new file with mode: 0644]
datas/models/Sponza/glTF/Sponza.gltf [new file with mode: 0644]
datas/models/chess.gltf [new file with mode: 0644]
datas/models/cube.gltf [new file with mode: 0644]
datas/models/icosphere.gltf [new file with mode: 0644]
datas/models/shadow.bin [new file with mode: 0644]
datas/models/shadow.gltf [new file with mode: 0644]
datas/models/shadow2.gltf [new file with mode: 0644]
datas/models/untitled.bin [new file with mode: 0644]
datas/models/untitled.gltf [new file with mode: 0644]
datas/textures/tex.astc [new file with mode: 0644]
samples/Directory.Build.props
samples/DistanceFieldFontTest/Program.cs
samples/Model/data/DamagedHelmet.bin [deleted file]
samples/Model/data/DamagedHelmet.gltf [deleted file]
samples/Model/main.cs
samples/Textured/main.cs
samples/TexturedCube/main.cs
samples/Triangle/Triangle.csproj
samples/Triangle/main.cs
samples/common/CrowWin.cs
samples/compute/delaunay.cs
samples/deferred/DeferredPbrRenderer.cs
samples/deferred/EnvironmentPipeline.cs
samples/deferred/main-crow.cs
samples/deferred/main.cs
samples/deferred/shadowMapRenderer.cs
samples/pbr/EnvironmentPipeline.cs
samples/pbr/PbrModel.cs
samples/pbr/PbrPipeline.cs
samples/pbr/main.cs
samples/pbr/pbr.csproj
vke.net.sln
vke/src/Camera.cs
vke/src/ExtensionMethods.cs
vke/src/FrameBuffers.cs [new file with mode: 0644]
vke/src/MarshaledObject.cs
vke/src/MemoryPool.cs
vke/src/ResourceManager.cs
vke/src/ShaderInfo.cs
vke/src/SpecializationConstant.cs
vke/src/StbImage.cs
vke/src/Utils.cs
vke/src/VkWindow.cs
vke/src/base/Activable.cs
vke/src/base/Buffer.cs
vke/src/base/CommandBuffer.cs
vke/src/base/CommandPool.cs
vke/src/base/ComputePipeline.cs
vke/src/base/DebuDrawPipeline.cs
vke/src/base/DebugReport.cs
vke/src/base/DebugUtilsMessenger.cs
vke/src/base/DescriptorPool.cs
vke/src/base/DescriptorSet.cs
vke/src/base/DescriptorSetLayout.cs
vke/src/base/DescriptorSetWrites.cs
vke/src/base/Device.cs
vke/src/base/FrameBuffer.cs
vke/src/base/GPUBuffer.cs
vke/src/base/GraphicPipeline.cs
vke/src/base/GraphicPipelineConfig.cs
vke/src/base/HostBuffer.cs
vke/src/base/Image.cs
vke/src/base/Instance.cs
vke/src/base/PhysicalDevice.cs
vke/src/base/Pipeline.cs
vke/src/base/PipelineCache.cs
vke/src/base/PipelineLayout.cs
vke/src/base/QueryPool.cs
vke/src/base/Queue.cs
vke/src/base/RenderPass.cs
vke/src/base/Resource.cs
vke/src/base/SubPass.cs
vke/src/base/SwapChain.cs
vke/src/ktx.cs
vke/src/model/BoundingBox.cs
vke/src/model/Model.cs
vke/vke.csproj

diff --git a/Directory.Build.props b/Directory.Build.props
deleted file mode 100644 (file)
index 449260d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<Project>
-    <PropertyGroup>
-        <RootDirectory>$(MSBuildThisFileDirectory)</RootDirectory>
-        <Deterministic>true</Deterministic>
-        
-        <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
-        
-               <RepositoryUrl>https://github.com/jpbruyere/vke.net</RepositoryUrl>
-               <License>MIT</License>
-           <Authors>Jean-Philippe Bruyère</Authors>
-           
-           <LangVersion>7.2</LangVersion>
-    </PropertyGroup>
-</Project>
index 26256a78aee8b05934be3e75e18707a6b32d2503..3f59e442dd32b206f2c12b748c7b098a1b952f2f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,6 +3,12 @@ vke.net
   <br>  
 <p align="center">
   <a href="https://www.nuget.org/packages/vke"><img src="https://buildstats.info/nuget/vke"></a>
+  <a href="https://travis-ci.org/jpbruyere/vke.net">
+      <img src="https://travis-ci.org/jpbruyere/vke.net.svg?branch=master">
+  </a>
+  <a href="https://ci.appveyor.com/project/jpbruyere/vke-net">
+    <img src="https://ci.appveyor.com/api/projects/status/j387lo59vnov8jbc?svg=true">
+  </a>
   <a href="https://www.paypal.me/GrandTetraSoftware">
     <img src="https://img.shields.io/badge/Donate-PayPal-green.svg">
   </a>
@@ -19,8 +25,8 @@ vke.net
 **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.
 
 ### Requirements
-- [GLFW](https://www.glfw.org/)
-- [libstb](https://github.com/nothings/stb), on debian install **libstb-dev**.
+- [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 226e438c59d4e9966710c32692f5d32ee3d70358..e3659cdcf583e65eb2ac6d636847762ae79ad91b 100644 (file)
@@ -11,8 +11,8 @@
 </p>
 </h1>
 
-**SpirVTasks** package add **SpirV** compilation support to msbuild project. Error and warning
-are routed to the **IDE**.
+`SpirVTasks` package add `SpirV` compilation support to msbuild project. Error and warning
+are routed to the `IDE`.
 
 
 #### Usage
@@ -21,7 +21,7 @@ are routed to the **IDE**.
   <GLSLShader Include="shaders\*.frag;shaders\*.vert;shaders\*.comp;shaders\*.geom" />
 </ItemGroup> 
 ```
-Resulting `.spv` files are embedded with resource ID = **ProjectName.file.ext.spv**. You can override the default resource id by adding a custom LogicalName.
+Resulting `.spv` files are embedded with resource ID = `ProjectName.file.ext.spv`. You can override the default resource id by adding a custom LogicalName.
 ```xml
 <ItemGroup>    
   <GLSLShader Include="shaders\skybox.vert">
@@ -29,14 +29,13 @@ Resulting `.spv` files are embedded with resource ID = **ProjectName.file.ext.sp
   </GLSLShader>
 </ItemGroup> 
 ```
-**VULKAN_SDK**/bin then **PATH** are searched for the **glslc** executable. You can also use **`SpirVglslcPath`** property.
+`VULKAN_SDK`/bin then `PATH` are searched for the `glslc` executable. You can also use the `SpirVglslcPath` property.
 ```xml
 <PropertyGroup>
   <SpirVglslcPath>bin\glslc.exe</SpirVglslcPath>
 </PropertyGroup>
 ```
 
-
 #### Include in glsl
 ```glsl
 #include <preamble.inc>
@@ -49,9 +48,7 @@ void main()
     outFragColor = vec4(inColor, 1.0);
 }
 ```
-
-Included files are searched from the location of the current parsed file, then in the **`<SpirVAdditionalIncludeDirectories>`** directories if present.
-
+Included files are searched from the location of the current parsed file, then in the `SpirVAdditionalIncludeDirectories`directories if present.
 ```xml
 <PropertyGroup>
   <SpirVAdditionalIncludeDirectories>$(MSBuildThisFileDirectory)common;testdir;../anotherdir</SpirVAdditionalIncludeDirectories>
@@ -59,4 +56,5 @@ Included files are searched from the location of the current parsed file, then i
 ```
 
 #### todo
+
 - Error source file and line with included files.
index 6825c47f4218e860b30a454a1dfd859567a0f0eb..690712f548685771c212b4550e24a1a8815b72f7 100644 (file)
                                         DestinationFile="$(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension).spv" />                
     <CreateItem  Condition=" '%(GLSLShader.LogicalName)'!='' "
         Include="$(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension).spv"                   
-               AdditionalMetadata="LogicalName=%(GLSLShader.LogicalName)">
+                               AdditionalMetadata="LogicalName=%(GLSLShader.LogicalName)">
                <Output                         
-                       TaskParameter="Include"                 
-                       ItemName="EmbeddedResource"/>       
+                                       TaskParameter="Include"                 
+                                       ItemName="EmbeddedResource"/>       
     </CreateItem>
     <CreateItem Condition=" '%(GLSLShader.LogicalName)'=='' "
         Include="$(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension).spv"                   
-               AdditionalMetadata="LogicalName=$(AssemblyName).%(GLSLShader.Filename)%(Extension).spv">
+                               AdditionalMetadata="LogicalName=$(AssemblyName).%(GLSLShader.Filename)%(Extension).spv">
                <Output                         
-                       TaskParameter="Include"                 
-                       ItemName="EmbeddedResource"/>       
+                                       TaskParameter="Include"                 
+                                       ItemName="EmbeddedResource"/>       
     </CreateItem>              
        <Message Importance="High" Text="%(GLSLShader.Identity) -> $(AssemblyName).%(Filename)%(Extension).spv (Embedded Resource)" />
   </Target>
index bce5b09d20aecb6d84c8bef86686cfee8ed2c0ef..224a27ac805e8ad6d7a2cf4881a8ffa5a6b294c1 100644 (file)
@@ -27,7 +27,8 @@
        </PropertyGroup>        
        
        <ItemGroup>
-               <PackageReference Include="vke" Version="0.1.7-beta" />
+                               <!--<PackageReference Include="vke" Version="0.1.7" />-->
+    <ProjectReference Include="..\..\vke\vke.csproj" />
                <PackageReference Include="SpirVTasks" Version="0.1.9-beta" />        
                <PackageReference Include="Vulkan" Version="0.1.4" />
        </ItemGroup>    
index 0667fc3df6012d97bd3ffe7806c725d23893b5c1..4b9576e8b7820b90bd0106e0e2676218028b40e7 100644 (file)
@@ -2,7 +2,7 @@
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
-namespace CVKL.DistanceFieldFont {
+namespace vke.DistanceFieldFont {
        public struct BMChar {
                public enum Channel {
                        Blue = 0x01,
index e277517b4d5f0e6b31cb79b405b9fb31c446f7cc..824d2657286f1b5c4c5ace99ff6e6342637c668e 100644 (file)
@@ -7,7 +7,7 @@ using System.IO;
 using System.Reflection;
 using VK;
 
-namespace CVKL.DistanceFieldFont {
+namespace vke.DistanceFieldFont {
        /// <summary>
        /// BMF font. (http://www.angelcode.com/products/bmfont/doc/file_format.html)
        /// </summary>
index 1d4ce024fc1c162689672323b9d9f32bfe9e0569..62e852be28c58bc8add89cd18d57590dbc65d8b2 100644 (file)
@@ -3,7 +3,7 @@
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
 using System.Numerics;
-using CVKL;
+using vke;
 using VK;
 
 namespace VkvgPipeline {
@@ -104,7 +104,7 @@ namespace VkvgPipeline {
                                                if (img.CreateInfo.usage.HasFlag (VkImageUsageFlags.Sampled))
                                                        c.X += 0.3f;
                                        } else {
-                                               CVKL.Buffer buff = r as CVKL.Buffer;
+                                               vke.Buffer buff = r as vke.Buffer;
                                                c.X = 1f;
                                                if (buff.Infos.usage.HasFlag (VkBufferUsageFlags.IndexBuffer))
                                                        c.Y += 0.2f;
index 396c42ff229b08418652f2d5b830236106675c3f..11f28b520e4af1bdf147980ac05f12f9fdd743ca 100644 (file)
@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
 using VK;
 using System.Collections.Generic;
 
-namespace CVKL.glTF {
+namespace vke.glTF {
        //TODO:stride in buffer views?
        public abstract class PbrModel : Model {        
                //public new struct Vertex {
index c1a6ee9e03ec37e444d737dd7a9fc77198ecd837..de2f67af3d9f7a86e97c059b0073c6b070185908 100644 (file)
@@ -7,7 +7,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL.glTF {
+namespace vke.glTF {
        /// <summary>
        /// Indexed pbr model whith one descriptorSet per material with separate textures attachments
        /// </summary>
index 5943774f492b21409cc8e82163e2063498bfe8ab..7c07de0d9cf9b3a7b37c26f59d8fa186f5116cad 100644 (file)
@@ -6,7 +6,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL.glTF {
+namespace vke.glTF {
        /// <summary>
        /// Indexed pbr model whith one descriptorSet per material with separate textures attachments
        /// </summary>
index 06e8ad6e41e6eb9f97783a45697cdebec1b5a14b..936db08ddca79aa95cca2dcb5bcfb604e6c1721a 100644 (file)
@@ -14,9 +14,9 @@ using System.IO;
 
 
 
-namespace CVKL.glTF {
+namespace vke.glTF {
        using static VK.Utils;
-       using static CVKL.Model;
+       using static vke.Model;
 
        /// <summary>
        /// Loading context with I as the vertex index type (uint16,uint32)
diff --git a/datas/font.fnt b/datas/font.fnt
new file mode 100644 (file)
index 0000000..81cb615
--- /dev/null
@@ -0,0 +1,343 @@
+info face="Arial Black Standard" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=4,4,4,4 spacing=-8,-8
+common lineHeight=46 base=36 scaleW=512 scaleH=512 pages=1 packed=0
+page id=0 file="font.ktx"
+chars count=97
+char id=0     x=237  y=102  width=25   height=29   xoffset=-4   yoffset=11   xadvance=24   page=0    chnl=0 
+char id=10    x=0    y=0    width=0    height=0    xoffset=-4   yoffset=0    xadvance=0    page=0    chnl=0 
+char id=32    x=0    y=0    width=0    height=0    xoffset=-4   yoffset=0    xadvance=11   page=0    chnl=0 
+char id=33    x=27   y=102  width=15   height=32   xoffset=-4   yoffset=8    xadvance=11   page=0    chnl=0 
+char id=34    x=298  y=134  width=24   height=17   xoffset=-4   yoffset=8    xadvance=16   page=0    chnl=0 
+char id=35    x=154  y=102  width=28   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=36    x=150  y=0    width=28   height=37   xoffset=-4   yoffset=6    xadvance=21   page=0    chnl=0 
+char id=37    x=117  y=102  width=37   height=32   xoffset=-4   yoffset=8    xadvance=32   page=0    chnl=0 
+char id=38    x=182  y=102  width=34   height=32   xoffset=-4   yoffset=8    xadvance=28   page=0    chnl=0 
+char id=39    x=322  y=134  width=15   height=17   xoffset=-4   yoffset=8    xadvance=9    page=0    chnl=0 
+char id=40    x=20   y=0    width=18   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=41    x=38   y=0    width=19   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=42    x=279  y=134  width=19   height=21   xoffset=-4   yoffset=8    xadvance=18   page=0    chnl=0 
+char id=43    x=186  y=134  width=26   height=26   xoffset=-4   yoffset=11   xadvance=21   page=0    chnl=0 
+char id=44    x=264  y=134  width=15   height=21   xoffset=-4   yoffset=25   xadvance=11   page=0    chnl=0 
+char id=45    x=394  y=134  width=18   height=14   xoffset=-4   yoffset=20   xadvance=11   page=0    chnl=0 
+char id=46    x=363  y=134  width=15   height=15   xoffset=-4   yoffset=25   xadvance=11   page=0    chnl=0 
+char id=47    x=83   y=102  width=17   height=32   xoffset=-4   yoffset=8    xadvance=9    page=0    chnl=0 
+char id=48    x=0    y=102  width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=49    x=261  y=70   width=22   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=50    x=283  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=51    x=310  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=52    x=337  y=70   width=29   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=53    x=366  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=54    x=393  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=55    x=420  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=56    x=447  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=57    x=474  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=58    x=171  y=134  width=15   height=26   xoffset=-4   yoffset=14   xadvance=11   page=0    chnl=0 
+char id=59    x=68   y=102  width=15   height=32   xoffset=-4   yoffset=14   xadvance=11   page=0    chnl=0 
+char id=60    x=262  y=102  width=26   height=27   xoffset=-4   yoffset=11   xadvance=21   page=0    chnl=0 
+char id=61    x=238  y=134  width=26   height=22   xoffset=-4   yoffset=13   xadvance=21   page=0    chnl=0 
+char id=62    x=288  y=102  width=26   height=27   xoffset=-4   yoffset=11   xadvance=21   page=0    chnl=0 
+char id=63    x=42   y=102  width=26   height=32   xoffset=-4   yoffset=8    xadvance=20   page=0    chnl=0 
+char id=64    x=178  y=0    width=33   height=35   xoffset=-4   yoffset=8    xadvance=24   page=0    chnl=0 
+char id=65    x=244  y=0    width=33   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=66    x=277  y=0    width=30   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=67    x=307  y=0    width=30   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=68    x=337  y=0    width=30   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=69    x=367  y=0    width=28   height=32   xoffset=-4   yoffset=8    xadvance=23   page=0    chnl=0 
+char id=70    x=395  y=0    width=26   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=71    x=421  y=0    width=33   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=72    x=454  y=0    width=31   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=73    x=485  y=0    width=16   height=32   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=74    x=0    y=38   width=26   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=75    x=26   y=38   width=33   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=76    x=59   y=38   width=26   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=77    x=85   y=38   width=34   height=32   xoffset=-4   yoffset=8    xadvance=30   page=0    chnl=0 
+char id=78    x=119  y=38   width=31   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=79    x=150  y=38   width=33   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=80    x=183  y=38   width=27   height=32   xoffset=-4   yoffset=8    xadvance=23   page=0    chnl=0 
+char id=81    x=211  y=0    width=33   height=34   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=82    x=210  y=38   width=31   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=83    x=241  y=38   width=30   height=32   xoffset=-4   yoffset=8    xadvance=23   page=0    chnl=0 
+char id=84    x=271  y=38   width=30   height=32   xoffset=-4   yoffset=8    xadvance=23   page=0    chnl=0 
+char id=85    x=301  y=38   width=31   height=32   xoffset=-4   yoffset=8    xadvance=27   page=0    chnl=0 
+char id=86    x=332  y=38   width=33   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=87    x=365  y=38   width=41   height=32   xoffset=-4   yoffset=8    xadvance=32   page=0    chnl=0 
+char id=88    x=406  y=38   width=33   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=89    x=439  y=38   width=33   height=32   xoffset=-4   yoffset=8    xadvance=25   page=0    chnl=0 
+char id=90    x=472  y=38   width=29   height=32   xoffset=-4   yoffset=8    xadvance=23   page=0    chnl=0 
+char id=91    x=57   y=0    width=19   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=92    x=100  y=102  width=17   height=32   xoffset=-4   yoffset=8    xadvance=9    page=0    chnl=0 
+char id=93    x=76   y=0    width=19   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=94    x=212  y=134  width=26   height=22   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=95    x=412  y=134  width=25   height=11   xoffset=-4   yoffset=33   xadvance=16   page=0    chnl=0 
+char id=96    x=378  y=134  width=16   height=14   xoffset=-4   yoffset=8    xadvance=11   page=0    chnl=0 
+char id=97    x=314  y=102  width=26   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=98    x=0    y=70   width=26   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=99    x=340  y=102  width=26   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=100   x=26   y=70   width=26   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=101   x=366  y=102  width=27   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=102   x=52   y=70   width=21   height=32   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=103   x=73   y=70   width=26   height=32   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=104   x=99   y=70   width=25   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=105   x=124  y=70   width=15   height=32   xoffset=-4   yoffset=8    xadvance=11   page=0    chnl=0 
+char id=106   x=0    y=0    width=20   height=38   xoffset=-4   yoffset=8    xadvance=11   page=0    chnl=0 
+char id=107   x=139  y=70   width=27   height=32   xoffset=-4   yoffset=8    xadvance=21   page=0    chnl=0 
+char id=108   x=166  y=70   width=15   height=32   xoffset=-4   yoffset=8    xadvance=11   page=0    chnl=0 
+char id=109   x=393  y=102  width=37   height=26   xoffset=-4   yoffset=14   xadvance=32   page=0    chnl=0 
+char id=110   x=430  y=102  width=25   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=111   x=455  y=102  width=27   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=112   x=181  y=70   width=26   height=32   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=113   x=207  y=70   width=26   height=32   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=114   x=482  y=102  width=22   height=26   xoffset=-4   yoffset=14   xadvance=14   page=0    chnl=0 
+char id=115   x=0    y=134  width=27   height=26   xoffset=-4   yoffset=14   xadvance=20   page=0    chnl=0 
+char id=116   x=216  y=102  width=21   height=31   xoffset=-4   yoffset=9    xadvance=14   page=0    chnl=0 
+char id=117   x=27   y=134  width=25   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=118   x=52   y=134  width=27   height=26   xoffset=-4   yoffset=14   xadvance=20   page=0    chnl=0 
+char id=119   x=79   y=134  width=39   height=26   xoffset=-4   yoffset=14   xadvance=30   page=0    chnl=0 
+char id=120   x=118  y=134  width=29   height=26   xoffset=-4   yoffset=14   xadvance=21   page=0    chnl=0 
+char id=121   x=233  y=70   width=28   height=32   xoffset=-4   yoffset=14   xadvance=20   page=0    chnl=0 
+char id=122   x=147  y=134  width=24   height=26   xoffset=-4   yoffset=14   xadvance=18   page=0    chnl=0 
+char id=123   x=95   y=0    width=21   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=124   x=137  y=0    width=13   height=38   xoffset=-4   yoffset=8    xadvance=9    page=0    chnl=0 
+char id=125   x=116  y=0    width=21   height=38   xoffset=-4   yoffset=8    xadvance=12   page=0    chnl=0 
+char id=126   x=337  y=134  width=26   height=17   xoffset=-4   yoffset=15   xadvance=21   page=0    chnl=0 
+kernings count=241
+kerning first=102 second=101 amount=-1
+kerning first=76 second=89 amount=-2
+kerning first=76 second=79 amount=-1
+kerning first=80 second=65 amount=-3
+kerning first=102 second=111 amount=-1
+kerning first=86 second=97 amount=-1
+kerning first=84 second=114 amount=-1
+kerning first=119 second=44 amount=-2
+kerning first=65 second=79 amount=-1
+kerning first=86 second=67 amount=-1
+kerning first=66 second=44 amount=1
+kerning first=84 second=45 amount=-2
+kerning first=80 second=46 amount=-6
+kerning first=65 second=89 amount=-3
+kerning first=67 second=46 amount=1
+kerning first=112 second=119 amount=-1
+kerning first=84 second=67 amount=-1
+kerning first=84 second=58 amount=-1
+kerning first=84 second=59 amount=-1
+kerning first=114 second=113 amount=1
+kerning first=102 second=63 amount=3
+kerning first=80 second=111 amount=-1
+kerning first=86 second=114 amount=-1
+kerning first=89 second=67 amount=-2
+kerning first=114 second=111 amount=1
+kerning first=88 second=71 amount=-1
+kerning first=80 second=101 amount=-1
+kerning first=87 second=46 amount=-2
+kerning first=75 second=117 amount=-1
+kerning first=114 second=100 amount=1
+kerning first=86 second=117 amount=-1
+kerning first=87 second=79 amount=-1
+kerning first=86 second=79 amount=-1
+kerning first=81 second=86 amount=-1
+kerning first=82 second=81 amount=-1
+kerning first=115 second=119 amount=-1
+kerning first=65 second=85 amount=-1
+kerning first=68 second=87 amount=1
+kerning first=112 second=46 amount=-1
+kerning first=81 second=89 amount=-2
+kerning first=114 second=97 amount=1
+kerning first=84 second=97 amount=-2
+kerning first=65 second=86 amount=-2
+kerning first=84 second=99 amount=-2
+kerning first=89 second=100 amount=-3
+kerning first=102 second=102 amount=1
+kerning first=114 second=103 amount=1
+kerning first=87 second=104 amount=1
+kerning first=86 second=105 amount=1
+kerning first=114 second=106 amount=1
+kerning first=74 second=111 amount=-1
+kerning first=99 second=108 amount=-1
+kerning first=84 second=109 amount=-1
+kerning first=114 second=110 amount=2
+kerning first=118 second=111 amount=-1
+kerning first=89 second=112 amount=-2
+kerning first=70 second=114 amount=-1
+kerning first=97 second=116 amount=-1
+kerning first=89 second=117 amount=-2
+kerning first=76 second=119 amount=-1
+kerning first=101 second=120 amount=-1
+kerning first=99 second=121 amount=-1
+kerning first=82 second=119 amount=1
+kerning first=66 second=65 amount=-1
+kerning first=81 second=84 amount=-1
+kerning first=80 second=44 amount=-6
+kerning first=97 second=103 amount=1
+kerning first=111 second=120 amount=-1
+kerning first=65 second=112 amount=1
+kerning first=84 second=46 amount=-5
+kerning first=86 second=101 amount=-2
+kerning first=119 second=104 amount=1
+kerning first=114 second=117 amount=1
+kerning first=121 second=44 amount=-3
+kerning first=121 second=46 amount=-3
+kerning first=89 second=97 amount=-3
+kerning first=75 second=101 amount=-1
+kerning first=65 second=118 amount=-1
+kerning first=70 second=97 amount=-1
+kerning first=119 second=113 amount=-1
+kerning first=75 second=111 amount=-1
+kerning first=75 second=71 amount=-1
+kerning first=87 second=97 amount=-1
+kerning first=101 second=103 amount=1
+kerning first=87 second=105 amount=1
+kerning first=81 second=46 amount=1
+kerning first=86 second=71 amount=-1
+kerning first=67 second=44 amount=1
+kerning first=114 second=99 amount=1
+kerning first=70 second=44 amount=-5
+kerning first=66 second=85 amount=-1
+kerning first=76 second=86 amount=-2
+kerning first=89 second=59 amount=-2
+kerning first=84 second=44 amount=-5
+kerning first=120 second=101 amount=-1
+kerning first=108 second=121 amount=1
+kerning first=89 second=101 amount=-3
+kerning first=114 second=46 amount=-2
+kerning first=121 second=99 amount=-1
+kerning first=114 second=101 amount=1
+kerning first=101 second=118 amount=-1
+kerning first=81 second=44 amount=1
+kerning first=74 second=121 amount=-1
+kerning first=82 second=79 amount=-1
+kerning first=89 second=113 amount=-3
+kerning first=119 second=46 amount=-3
+kerning first=68 second=89 amount=-1
+kerning first=119 second=111 amount=-1
+kerning first=102 second=46 amount=-2
+kerning first=86 second=44 amount=-4
+kerning first=114 second=109 amount=2
+kerning first=79 second=89 amount=-2
+kerning first=86 second=65 amount=-2
+kerning first=103 second=114 amount=1
+kerning first=102 second=33 amount=3
+kerning first=84 second=122 amount=-1
+kerning first=86 second=46 amount=-4
+kerning first=70 second=101 amount=-1
+kerning first=99 second=104 amount=-1
+kerning first=89 second=44 amount=-5
+kerning first=68 second=86 amount=-1
+kerning first=88 second=79 amount=-1
+kerning first=82 second=89 amount=-1
+kerning first=75 second=67 amount=-1
+kerning first=98 second=118 amount=-1
+kerning first=89 second=65 amount=-3
+kerning first=114 second=107 amount=1
+kerning first=84 second=101 amount=-2
+kerning first=89 second=79 amount=-2
+kerning first=114 second=118 amount=2
+kerning first=84 second=111 amount=-2
+kerning first=120 second=111 amount=-1
+kerning first=82 second=111 amount=-1
+kerning first=79 second=87 amount=-1
+kerning first=84 second=71 amount=-1
+kerning first=118 second=100 amount=-1
+kerning first=74 second=97 amount=-1
+kerning first=89 second=45 amount=-3
+kerning first=84 second=81 amount=-1
+kerning first=114 second=115 amount=1
+kerning first=68 second=46 amount=-1
+kerning first=79 second=44 amount=-1
+kerning first=121 second=100 amount=-1
+kerning first=114 second=112 amount=1
+kerning first=87 second=71 amount=-1
+kerning first=89 second=83 amount=-1
+kerning first=86 second=111 amount=-2
+kerning first=87 second=111 amount=-1
+kerning first=70 second=46 amount=-5
+kerning first=81 second=65 amount=1
+kerning first=114 second=58 amount=1
+kerning first=84 second=104 amount=1
+kerning first=114 second=116 amount=2
+kerning first=87 second=101 amount=-1
+kerning first=65 second=67 amount=-1
+kerning first=70 second=65 amount=-3
+kerning first=65 second=81 amount=-1
+kerning first=118 second=46 amount=-3
+kerning first=103 second=121 amount=1
+kerning first=87 second=67 amount=-1
+kerning first=74 second=46 amount=-1
+kerning first=76 second=67 amount=-1
+kerning first=75 second=79 amount=-1
+kerning first=87 second=44 amount=-1
+kerning first=89 second=58 amount=-2
+kerning first=86 second=59 amount=-1
+kerning first=114 second=121 amount=2
+kerning first=121 second=97 amount=-1
+kerning first=76 second=87 amount=-1
+kerning first=118 second=44 amount=-3
+kerning first=79 second=84 amount=-1
+kerning first=111 second=119 amount=-1
+kerning first=111 second=118 amount=-1
+kerning first=84 second=108 amount=1
+kerning first=82 second=117 amount=-1
+kerning first=89 second=46 amount=-5
+kerning first=111 second=122 amount=1
+kerning first=84 second=65 amount=-2
+kerning first=74 second=117 amount=-1
+kerning first=107 second=111 amount=-1
+kerning first=85 second=65 amount=-1
+kerning first=111 second=121 amount=-1
+kerning first=114 second=59 amount=1
+kerning first=65 second=84 amount=-2
+kerning first=89 second=118 amount=-1
+kerning first=86 second=58 amount=-1
+kerning first=87 second=100 amount=-1
+kerning first=76 second=84 amount=-2
+kerning first=102 second=32 amount=2
+kerning first=111 second=46 amount=-1
+kerning first=114 second=114 amount=1
+kerning first=82 second=86 amount=-1
+kerning first=74 second=44 amount=-1
+kerning first=118 second=99 amount=-1
+kerning first=86 second=81 amount=-1
+kerning first=79 second=88 amount=-2
+kerning first=85 second=44 amount=-1
+kerning first=118 second=101 amount=-1
+kerning first=88 second=67 amount=-1
+kerning first=79 second=86 amount=-1
+kerning first=75 second=118 amount=-1
+kerning first=76 second=85 amount=-1
+kerning first=107 second=101 amount=-1
+kerning first=84 second=117 amount=-1
+kerning first=120 second=99 amount=-1
+kerning first=75 second=121 amount=-1
+kerning first=84 second=115 amount=-2
+kerning first=114 second=44 amount=-2
+kerning first=82 second=71 amount=-1
+kerning first=85 second=46 amount=-1
+kerning first=70 second=111 amount=-1
+kerning first=97 second=118 amount=-1
+kerning first=121 second=111 amount=-1
+kerning first=79 second=65 amount=-1
+kerning first=82 second=101 amount=-1
+kerning first=65 second=71 amount=-1
+kerning first=102 second=44 amount=-2
+kerning first=112 second=121 amount=-1
+kerning first=74 second=101 amount=-1
+kerning first=86 second=45 amount=-1
+kerning first=121 second=101 amount=-1
+kerning first=84 second=79 amount=-1
+kerning first=89 second=111 amount=-3
+kerning first=118 second=113 amount=-1
+kerning first=74 second=65 amount=-1
+kerning first=76 second=71 amount=-1
+kerning first=79 second=46 amount=-1
+kerning first=68 second=65 amount=-1
+kerning first=114 second=108 amount=1
+kerning first=71 second=44 amount=1
+kerning first=110 second=118 amount=-1
+kerning first=82 second=85 amount=-1
+kerning first=87 second=117 amount=-1
+kerning first=120 second=100 amount=-1
+kerning first=80 second=97 amount=-1
+kerning first=99 second=107 amount=-1
+kerning first=66 second=46 amount=1
+kerning first=89 second=71 amount=-2
+kerning first=107 second=121 amount=1
+kerning first=82 second=67 amount=-1
+kerning first=84 second=121 amount=-1
diff --git a/datas/models/Box.gltf b/datas/models/Box.gltf
new file mode 100644 (file)
index 0000000..8f9e0d3
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f98a369e29ffc754cc897f78d695754ac6812ba7ddcd23705dd8d4e258f5f13b
+size 3791
diff --git a/datas/models/DamagedHelmet/glTF-Embedded/DamagedHelmet.gltf b/datas/models/DamagedHelmet/glTF-Embedded/DamagedHelmet.gltf
new file mode 100644 (file)
index 0000000..0f51039
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c0fa7be52a4c63e96af2be05735caba968b04a633a9c5eaf1b4c95fb25588003
+size 5033556
diff --git a/datas/models/DamagedHelmet/glTF/DamagedHelmet.bin b/datas/models/DamagedHelmet/glTF/DamagedHelmet.bin
new file mode 100644 (file)
index 0000000..662eacc
Binary files /dev/null and b/datas/models/DamagedHelmet/glTF/DamagedHelmet.bin differ
diff --git a/datas/models/DamagedHelmet/glTF/DamagedHelmet.gltf b/datas/models/DamagedHelmet/glTF/DamagedHelmet.gltf
new file mode 100644 (file)
index 0000000..d685d77
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:efe99dfac198094a30c71dc02a4d3421f0eef6bf335aeb695daa4d62134cd93f
+size 4537
diff --git a/datas/models/Sponza/README.md b/datas/models/Sponza/README.md
new file mode 100644 (file)
index 0000000..89e3787
--- /dev/null
@@ -0,0 +1,68 @@
+# Sponza
+
+## Screenshot
+
+Lights are shown here, they are not part of the model.
+
+![screenshot](screenshot/large.jpg)
+
+## Model notes
+
+Tangents have been computed using MikkTSpace, as the original OBJ model did not have them.
+I have manually inspected the normals, and it looks correct to me.
+Be aware that W is -1.0 for most of the tangent signs, you will need to handle tangent W for correct results.
+
+
+## Sources
+
+### http://www.crytek.com/cryengine/cryengine3/downloads
+- http://www.crytek.com/download/sponza\_obj.rar
+- http://www.crytek.com/download/sponza\_textures.rar
+
+### http://www.alexandre-pestana.com/pbr-textures-sponza/
+- http://www.alexandre-pestana.com/downloads/SponzaPBR\_Textures.rar
+
+I needed to resize some of the alpha mask textures to the 1024x1024 resolution used by the new texture pack,
+and merge in diffuse with alpha.
+I also repacked the separate metallic/roughness textures into the glTF layout (G - roughness, B - metallic).
+The images are also re-encoded as PNG instead of TGA.
+All the materials also had a constant diffuse factor of about 0.58. I assume it was supposed to be there, so I kept it.
+I also ran the vertices and indices through a mesh optimizer.
+
+## Licensing notes
+
+Taken from copyright.txt in SponzaPBR\_Textures.rar
+
+```
+PBR textures for the Sponza model.
+For more informations: www.alexandre-pestana.com
+
+
+Original copyright:
+
+July 14, 2011 Morgan McGuire modified the model from Crytek's OBJ
+export to correct some small errors.  He computed bump maps from the
+normal maps using <a
+href="http://cs.williams.edu/~morgan/code/">normal2bump.cpp</a> (since
+MTL files expect height bumps, not normals), put the "mask" textures
+into the alpha channel of the associated diffuse texture, cleaned up
+noise in the masks, created the missing gi_flag.tga texture, and
+removed the long untextured banner floating in the middle of the
+atrium that appears in the file but in none of the published images of
+the model.  The banner is in banner.obj.
+
+
+
+http://www.crytek.com/cryengine/cryengine3/downloads
+
+
+Sponza Model
+August 19, 2010
+The Atrium Sponza Palace, Dubrovnik, is an elegant and improved model created by Frank Meinl. The original Sponza model was created by Marko Dabrovic in early 2002. Over the years, the Sponza Atrium scene has become one of the most popular 3D scenes for testing global illumination and radiosity due to it's specific architectural structure which is particularly complex for global illumination light.
+
+However, nowadays it is considered as a simple model, thus it was decided to crate a new model with highly improved appearance and scene complexity. It is donated to the public for  radiosity and is represented in several different formats (3ds, Obj) for use with various commercial 3D applications and renderers.
+
+
+Screenshot from the I3D paper
+http://crytek.com/sites/default/files/20100301_lpv.pdf
+```
diff --git a/datas/models/Sponza/glTF/Sponza.bin b/datas/models/Sponza/glTF/Sponza.bin
new file mode 100644 (file)
index 0000000..971accb
Binary files /dev/null and b/datas/models/Sponza/glTF/Sponza.bin differ
diff --git a/datas/models/Sponza/glTF/Sponza.gltf b/datas/models/Sponza/glTF/Sponza.gltf
new file mode 100644 (file)
index 0000000..3168453
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e17c14edbc06b757dafcfed99f8815af9c5f5d9f9de3f0bc7740c37e68e0d829
+size 212504
diff --git a/datas/models/chess.gltf b/datas/models/chess.gltf
new file mode 100644 (file)
index 0000000..4f42cd5
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a021b7609d4fbc590c4ffe495e3496cd2204f2c226f7f4d5c9421d4a3f8d2eb5
+size 3407650
diff --git a/datas/models/cube.gltf b/datas/models/cube.gltf
new file mode 100644 (file)
index 0000000..7d72524
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:87aed37664ba8a792a79e0245c07ce34babcaa40abf94e469234e44cb8ecc9df
+size 3663
diff --git a/datas/models/icosphere.gltf b/datas/models/icosphere.gltf
new file mode 100644 (file)
index 0000000..ef72668
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3720ae8e6ce9ceb1669396453ea1107575146494588b2e52463020e7ca9cf4d4
+size 34170
diff --git a/datas/models/shadow.bin b/datas/models/shadow.bin
new file mode 100644 (file)
index 0000000..b332f19
Binary files /dev/null and b/datas/models/shadow.bin differ
diff --git a/datas/models/shadow.gltf b/datas/models/shadow.gltf
new file mode 100644 (file)
index 0000000..62b6133
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a516145efb32792dbf6422ef2f6e5cd0907765584ee083a1f47cf6a94c503fb6
+size 13832
diff --git a/datas/models/shadow2.gltf b/datas/models/shadow2.gltf
new file mode 100644 (file)
index 0000000..82bf335
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4e2e77f34b0c623f58d2e07eed7a03100f9d09034cc6bfa4ec907105137ee714
+size 11207
diff --git a/datas/models/untitled.bin b/datas/models/untitled.bin
new file mode 100644 (file)
index 0000000..621d5e6
Binary files /dev/null and b/datas/models/untitled.bin differ
diff --git a/datas/models/untitled.gltf b/datas/models/untitled.gltf
new file mode 100644 (file)
index 0000000..31670a5
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac5f07807d147c9adee8898cac57b977c5130df73847b0fc0adafbb8d495e505
+size 9717
diff --git a/datas/textures/tex.astc b/datas/textures/tex.astc
new file mode 100644 (file)
index 0000000..6756ffb
Binary files /dev/null and b/datas/textures/tex.astc differ
index b61e7bda40a2c6aa3b094499a4454d839bf30ab9..8c1d092d33b827575b6b5dffd70c1dc23a8786f0 100644 (file)
@@ -26,7 +26,8 @@
        </PropertyGroup>
                
        <ItemGroup>
-               <PackageReference Include="vke" Version="0.1.7-beta" />
+               <!--<PackageReference Include="vke" Version="0.1.7" />-->
+    <ProjectReference Include="..\..\vke\vke.csproj" />
                <PackageReference Include="SpirVTasks" Version="0.1.9-beta" />     
                <PackageReference Include="Vulkan" Version="0.1.4" />        
        </ItemGroup>    
index 5820a0231ad94f5c89e516ad77ac6948f540c0c0..6ba6039bf812852e50f0c13b2f8aa45d1f5bb410 100644 (file)
@@ -4,8 +4,8 @@ using System.Runtime.InteropServices;
 using Glfw;
 
 using VK;
-using CVKL;
-using CVKL.DistanceFieldFont;
+using vke;
+using vke.DistanceFieldFont;
 
 namespace DistanceFieldFontTest {
 
@@ -46,7 +46,7 @@ namespace DistanceFieldFontTest {
                DescriptorSet descriptorSet;
 
                GraphicPipeline pipeline;
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
 
                Image fontTexture;
 
@@ -64,11 +64,12 @@ namespace DistanceFieldFontTest {
                Vector4 outlineColor = new Vector4 (1.0f, 0.0f, 0.0f, 0.6f);//alpha => 0:disabled 1:enabled
 
                Program () : base () {
+                       cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
 
-                       font = new BMFont ("../data/font.fnt");
+                       font = new BMFont (Utils.DataDirectory + "font.fnt");
 
-                       vbo = new GPUBuffer<float> (dev, VkBufferUsageFlags.VertexBuffer, 1024);
-                       ibo = new GPUBuffer<ushort> (dev, VkBufferUsageFlags.IndexBuffer, 2048);
+                       vbo = new GPUBuffer<float> (dev, VkBufferUsageFlags.VertexBuffer | VkBufferUsageFlags.TransferDst, 1024);
+                       ibo = new GPUBuffer<ushort> (dev, VkBufferUsageFlags.IndexBuffer | VkBufferUsageFlags.TransferDst, 2048);
 
                        descriptorPool = new DescriptorPool (dev, 1,
                                new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer),
@@ -132,6 +133,8 @@ namespace DistanceFieldFontTest {
                        List<ushort> indices = new List<ushort> ();
                        ushort indexOffset = 0;
 
+                       float charSize = 1.0f;
+                       
                        float w = fontTexture.Width;
 
                        float posx = 0.0f;
@@ -145,10 +148,10 @@ namespace DistanceFieldFontTest {
                                        charInfo.width = 36;
 
                                float charw = ((float)(charInfo.width) / 36.0f);
-                               float dimx = 1.0f * charw;
+                               float dimx = charSize * charw;
                                float charh = ((float)(charInfo.height) / 36.0f);
-                               float dimy = 1.0f * charh;
-                               posy = 1.0f - charh;
+                               float dimy = charSize * charh;
+                               posy = 1.0f - charh * charSize;
 
                                float us = charInfo.x / w;
                                float ue = (charInfo.x + charInfo.width) / w;
@@ -166,7 +169,7 @@ namespace DistanceFieldFontTest {
                                indices.AddRange (new ushort[] { indexOffset, (ushort)(indexOffset + 1), (ushort)(indexOffset + 2), (ushort)(indexOffset + 2), (ushort)(indexOffset + 3), indexOffset });
                                indexOffset += 4;
 
-                               float advance = charInfo.xadvance / 36.0f;
+                               float advance = charSize * charInfo.xadvance / 36.0f;
                                posx += advance;
                        }
 
@@ -197,9 +200,11 @@ namespace DistanceFieldFontTest {
                }
 
                void buildCommandBuffers () {
+
+                       cmdPool.Reset();
+
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               cmds[i]?.Free ();
-                               cmds[i] = cmdPool.AllocateAndStart ();
+                               cmds[i].Start();
 
                                recordDraw (cmds[i], frameBuffers[i]);
 
@@ -207,7 +212,7 @@ namespace DistanceFieldFontTest {
                        }
                }
 
-               void recordDraw (CommandBuffer cmd, Framebuffer fb) {
+               void recordDraw (CommandBuffer cmd, FrameBuffer fb) {
                        pipeline.RenderPass.Begin (cmd, fb);
 
                        cmd.SetViewport (fb.Width, fb.Height);
@@ -274,21 +279,8 @@ namespace DistanceFieldFontTest {
 
                        updateViewRequested = true;
 
-                       if (frameBuffers != null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                       } : new Image[] {
-                                               null,
-                                               swapChain.images[i]
-                                       });
-                       }
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
 
                        buildCommandBuffers ();
                }
@@ -299,8 +291,7 @@ namespace DistanceFieldFontTest {
                                        dev.WaitIdle ();
                                        pipeline.Dispose ();
                                        dsLayout.Dispose ();
-                                       for (int i = 0; i < swapChain.ImageCount; i++)
-                                               frameBuffers[i].Dispose ();
+                                       frameBuffers?.Dispose();
                                        descriptorPool.Dispose ();
                                        fontTexture?.Dispose ();
                                        vbo.Dispose ();
diff --git a/samples/Model/data/DamagedHelmet.bin b/samples/Model/data/DamagedHelmet.bin
deleted file mode 100644 (file)
index 662eacc..0000000
Binary files a/samples/Model/data/DamagedHelmet.bin and /dev/null differ
diff --git a/samples/Model/data/DamagedHelmet.gltf b/samples/Model/data/DamagedHelmet.gltf
deleted file mode 100644 (file)
index d685d77..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:efe99dfac198094a30c71dc02a4d3421f0eef6bf335aeb695daa4d62134cd93f
-size 4537
index e60810e589ab4d575097b92a5f295f7cc615aaa4..dbea068db9c5f2cc958b9407778f5bfade0b12b8 100644 (file)
@@ -1,11 +1,14 @@
-using System.Collections.Generic;
+// 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.Numerics;
 using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
 using VK;
 
-namespace ModelSample {
+namespace ModelSample
+{
        class Program : VkWindow {
                static void Main (string[] args) {
 #if DEBUG
@@ -38,7 +41,7 @@ namespace ModelSample {
                DescriptorSetLayout descLayoutMatrix;
                DescriptorSetLayout descLayoutTextures;
 
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
 
                GraphicPipeline pipeline;
 
@@ -48,10 +51,10 @@ namespace ModelSample {
                float rotX, rotY, rotZ = 0f, zoom = 2f;
 
                SimpleModel helmet;
-               CVKL.DebugUtils.Messenger dbgmsg;
+               vke.DebugUtils.Messenger dbgmsg;
 
                Program () : base () {
-
+                       cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
 
                        descriptorPool = new DescriptorPool (dev, 2,
                                new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer),
@@ -90,15 +93,11 @@ namespace ModelSample {
                        pipeline = new GraphicPipeline (cfg);
 
                        helmet = new SimpleModel (presentQueue, Utils.DataDirectory + "models/DamagedHelmet/glTF/DamagedHelmet.gltf");
-                       //helmet = new SimpleModel (presentQueue, Utils.DataDirectory + "models/Hubble.glb");
-
-                       //helmet = new SimpleModel (presentQueue, "/mnt/devel/vulkan/Lugdunum/resources/models/Box.gltf");
 
                        dsMatrices = descriptorPool.Allocate (descLayoutMatrix);
                        dsTextures = descriptorPool.Allocate (descLayoutTextures);
 
                        uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices);
-                       //matrices.lightPos = new Vector4 (0.0f, 0.0f, -2.0f, 1.0f);
 
                        DescriptorSetWrites uboUpdate = new DescriptorSetWrites (dsMatrices, descLayoutMatrix);
                        uboUpdate.Write (dev, uboMats.Descriptor);
@@ -138,10 +137,9 @@ namespace ModelSample {
                }
                void buildCommandBuffers () {
                        cmdPool.Reset (VkCommandPoolResetFlags.ReleaseResources);
-                       cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount);
 
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               Framebuffer fb = frameBuffers[i];
+                               FrameBuffer fb = frameBuffers[i];
                                cmds[i].Start ();
 
                                pipeline.RenderPass.Begin (cmds[i], fb);
@@ -168,21 +166,8 @@ namespace ModelSample {
                protected override void OnResize () {
                        base.OnResize();
 
-                       if (frameBuffers != null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i)
-                               frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                               null
-                                       } : new Image[] {
-                                               null,
-                                               null,
-                                               swapChain.images[i]
-                                       });
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
 
                        buildCommandBuffers ();
                }
@@ -205,7 +190,7 @@ namespace ModelSample {
                                dev = transferQ.Dev;
 
                                using (CommandPool cmdPool = new CommandPool (dev, transferQ.index)) {
-                                       using (CVKL.glTF.glTFLoader ctx = new CVKL.glTF.glTFLoader(path, transferQ, cmdPool)) {
+                                       using (vke.glTF.glTFLoader ctx = new vke.glTF.glTFLoader(path, transferQ, cmdPool)) {
                                                loadSolids<Vertex> (ctx);
                                                textures = ctx.LoadImages ();
                                        }
@@ -244,8 +229,7 @@ namespace ModelSample {
                                        pipeline.Dispose ();
                                        descLayoutMatrix.Dispose ();
                                        descLayoutTextures.Dispose ();
-                                       for (int i = 0; i < swapChain.ImageCount; i++)
-                                               frameBuffers[i]?.Dispose ();
+                                       frameBuffers?.Dispose();
                                        descriptorPool.Dispose ();
                                        uboMats.Dispose ();
                                        dbgmsg?.Dispose ();
index 390e217f6589c4e63de7f3615691ef585348f992..41c3454e888db01ca61c3e8a62c700001435b6c2 100644 (file)
@@ -2,7 +2,7 @@
 using System.Numerics;
 using System.Runtime.InteropServices;
 using Glfw;
-using CVKL;
+using vke;
 using VK;
 
 namespace Textured {
@@ -47,7 +47,7 @@ namespace Textured {
                DescriptorSet descriptorSet;
 
                GraphicPipeline pipeline;
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
 
                Image texture;
                Image nextTexture;
@@ -70,7 +70,8 @@ namespace Textured {
                        Utils.DataDirectory + "textures/tex256.jpg",
                };
 
-               Program () : base () {          
+               Program () : base () {
+                       cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
                                
                        loadTexture (imgPathes[currentImgIndex]);
 
@@ -112,16 +113,14 @@ namespace Textured {
                }
 
                void buildCommandBuffers () {
+                       cmdPool.Reset();
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               cmds[i]?.Free ();
-                               cmds[i] = cmdPool.AllocateAndStart ();
-
+                               cmds[i].Start();
                                recordDraw (cmds[i], frameBuffers[i]);
-
                                cmds[i].End ();                          
                        }
                }
-               void recordDraw (CommandBuffer cmd, Framebuffer fb) {
+               void recordDraw (CommandBuffer cmd, FrameBuffer fb) {
                        pipeline.RenderPass.Begin (cmd, fb);
 
                        cmd.SetViewport (fb.Width, fb.Height);
@@ -149,7 +148,7 @@ namespace Textured {
                                        nextTexture = KTX.KTX.Load (presentQueue, cmdPool, path,
                                                VkImageUsageFlags.Sampled, imgProp, genMipMaps, tiling);
                                else
-                                       nextTexture = Image.Load (dev, presentQueue, cmdPool, path, VkFormat.R8g8b8a8Unorm, imgProp, tiling, genMipMaps);
+                                       nextTexture = Image.Load (dev, presentQueue, cmdPool, path, VkFormat.R8g8b8a8Unorm, imgProp, tiling, genMipMaps);
                                updateViewRequested = true;
                        } catch (Exception ex) {
                                Console.WriteLine (ex);
@@ -223,23 +222,8 @@ namespace Textured {
 
                        updateMatrices ();
 
-                       if (frameBuffers!=null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                               null
-                                       } : new Image[] {
-                                               null,
-                                               null,
-                                               swapChain.images[i]
-                                       });     
-                       }
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
 
                        buildCommandBuffers ();
                }       
@@ -250,8 +234,7 @@ namespace Textured {
                                        dev.WaitIdle ();
                                        pipeline.Dispose ();
                                        dsLayout.Dispose ();
-                                       for (int i = 0; i < swapChain.ImageCount; i++)
-                                               frameBuffers[i].Dispose ();
+                                       frameBuffers.Dispose();
                                        descriptorPool.Dispose ();
                                        texture?.Dispose ();
                                        nextTexture?.Dispose ();
index 98fd5c38bf1d754260f90587b2143210199a133e..88d409e90485991eb3f61cda50746c865150df9d 100644 (file)
@@ -5,9 +5,9 @@ using System;
 using System.Numerics;
 using System.Runtime.InteropServices;
 using Glfw;
-using CVKL;
+using vke;
 using VK;
-using Buffer = CVKL.Buffer;
+using Buffer = vke.Buffer;
 
 namespace TextureCube {
        class Program : VkWindow {
@@ -38,7 +38,7 @@ namespace TextureCube {
                DescriptorSetLayout dsLayout;
                DescriptorSet           descriptorSet, dsVkvg;
                GraphicPipeline         pipeline;
-               Framebuffer[]           frameBuffers;
+               FrameBuffers            frameBuffers;
 
                Image texture;
                Image nextTexture;
@@ -112,9 +112,9 @@ namespace TextureCube {
 
 #endif
 
-
-
                Program () : base () {
+                       cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
+
                        vbo = new GPUBuffer<float> (presentQueue, cmdPool, VkBufferUsageFlags.VertexBuffer, g_vertex_buffer_data);
 
                        descriptorPool = new DescriptorPool (dev, 2,
@@ -162,17 +162,14 @@ namespace TextureCube {
                }
 
                void buildCommandBuffers () {
+                       cmdPool.Reset();
                        for (int i = 0; i < swapChain.ImageCount; ++i) {                                                                
-                       cmds[i]?.Free ();
-                               cmds[i] = cmdPool.AllocateCommandBuffer ();
                                cmds[i].Start ();
-
                                recordDraw (cmds[i], frameBuffers[i]);
-
                                cmds[i].End ();                          
                        }
                } 
-               void recordDraw (CommandBuffer cmd, Framebuffer fb) { 
+               void recordDraw (CommandBuffer cmd, FrameBuffer fb) { 
                        pipeline.RenderPass.Begin (cmd, fb);
 
                        cmd.SetViewport (fb.Width, fb.Height);
@@ -277,33 +274,18 @@ namespace TextureCube {
                protected override void OnResize () {
                        base.OnResize ();
 
+                       dev.WaitIdle();
+
 #if WITH_VKVG
                        vkvgPipeline.Resize ((int)Width, (int)Height, new DescriptorSetWrites (dsVkvg, dsLayout.Bindings[1]));
 #endif
 
                        updateMatrices ();
 
-                       if (frameBuffers!=null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                               null
-                                       } : new Image[] {
-                                               null,
-                                               null,
-                                               swapChain.images[i]
-                                       });     
-                       }
-
-                       buildCommandBuffers ();
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
 
-                       dev.WaitIdle ();
+                       buildCommandBuffers();
                }
                        
                protected override void Dispose (bool disposing) {
@@ -311,8 +293,7 @@ namespace TextureCube {
                                if (!isDisposed) {
                                        dev.WaitIdle ();
                                        pipeline.Dispose ();
-                                       for (int i = 0; i < swapChain.ImageCount; i++)
-                                               frameBuffers[i].Dispose ();
+                                       frameBuffers?.Dispose();
                                        descriptorPool.Dispose ();
                                        texture.Dispose ();
                                        uboMats.Dispose ();
index dbb4bc8191991d7be93b1fb07ad0161fc7e93486..25c90c06aa95a501751636524bbaee24e0bb6095 100644 (file)
@@ -2,5 +2,5 @@
   <Import Project="$(RootDirectory)netfx.props" />
   <PropertyGroup>
     <IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>
-  </PropertyGroup>    
+  </PropertyGroup>  
 </Project>
index 2dcb68ff7f550233ba55e32ca72d754ac8f1edca..cb9918e260b68a5f6e4de1b976c2bb9dbdf9404e 100644 (file)
@@ -3,7 +3,7 @@
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System.Numerics;
 using System.Runtime.InteropServices;
-using CVKL;
+using vke;
 using VK;
 
 namespace Triangle {
@@ -48,7 +48,7 @@ namespace Triangle {
                DescriptorSetLayout dsLayout;
                DescriptorSet descriptorSet;
 
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
                GraphicPipeline pipeline;
 
                Vertex[] vertices = {
@@ -59,6 +59,9 @@ namespace Triangle {
                ushort[] indices = new ushort[] { 0, 1, 2 };
 
                Program () : base () {
+
+                       cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
+
                        vbo = new HostBuffer<Vertex> (dev, VkBufferUsageFlags.VertexBuffer, vertices);
                        ibo = new HostBuffer<ushort> (dev, VkBufferUsageFlags.IndexBuffer, indices);
                        uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices);
@@ -115,10 +118,9 @@ namespace Triangle {
                }
                void buildCommandBuffers() {
                        cmdPool.Reset (VkCommandPoolResetFlags.ReleaseResources);
-                       cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount);
 
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               Framebuffer fb = frameBuffers[i];
+                               FrameBuffer fb = frameBuffers[i];
                                cmds[i].Start ();
 
                                pipeline.RenderPass.Begin (cmds[i], fb);
@@ -143,19 +145,8 @@ namespace Triangle {
                protected override void OnResize () {
                        base.OnResize ();
 
-                       if (frameBuffers != null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) 
-                               frameBuffers[i] = new Framebuffer (pipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                       } : new Image[] {
-                                               null,
-                                               swapChain.images[i]
-                                       });
+                       frameBuffers?.Dispose();
+                       frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);
 
                        buildCommandBuffers ();
                }
@@ -165,8 +156,8 @@ namespace Triangle {
                        if (disposing) {
                                if (!isDisposed) {
                                        pipeline.Dispose ();
-                                       for (int i = 0; i < swapChain.ImageCount; i++)
-                                               frameBuffers[i].Dispose ();
+
+                                       frameBuffers?.Dispose();
                                        descriptorPool.Dispose ();
                                        vbo.Dispose ();
                                        ibo.Dispose ();
index 0a9809e0fdbbaa1638182abaf8fb9e81ef2b0ba3..d7d9f8a75b0e86831e8d611b8845dfb6d0ea8356 100644 (file)
@@ -4,7 +4,7 @@ using VK;
 using System.Threading;
 
 namespace Crow {
-       public class CrowWin : CVKL.VkWindow, IValueChange {
+       public class CrowWin : vke.VkWindow, IValueChange {
                #region IValueChange implementation
                public event EventHandler<ValueChangeEventArgs> ValueChanged;
                public virtual void NotifyValueChanged (string MemberName, object _value) {
@@ -13,16 +13,16 @@ namespace Crow {
                }
                #endregion
 
-               CVKL.DescriptorPool descriptorPool;
-               CVKL.DescriptorSetLayout descLayout;
-               CVKL.DescriptorSet dsCrow;
+               vke.DescriptorPool descriptorPool;
+               vke.DescriptorSetLayout descLayout;
+               vke.DescriptorSet dsCrow;
 
-               CVKL.GraphicPipeline uiPipeline;
-               CVKL.Framebuffer[] uiFrameBuffers;
+               vke.GraphicPipeline uiPipeline;
+               vke.FrameBuffer[] uiFrameBuffers;
 
                protected Interface crow;
                protected vkvg.Device vkvgDev;
-               protected CVKL.Image uiImage;
+               protected vke.Image uiImage;
                protected bool isRunning, rebuildBuffers;
 
                protected CrowWin (string name = "CrowWin", uint _width = 1024, uint _height = 768, bool vSync = false) :
@@ -57,27 +57,27 @@ namespace Crow {
                }
 
                void initUIPipeline (VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1) {
-                       descriptorPool = new CVKL.DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler));
-                       descLayout = new CVKL.DescriptorSetLayout (dev,
+                       descriptorPool = new vke.DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler));
+                       descLayout = new vke.DescriptorSetLayout (dev,
                                new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                        );
 
-                       CVKL.GraphicPipelineConfig cfg = CVKL.GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, samples, false);
-                       cfg.Layout = new CVKL.PipelineLayout (dev, descLayout);
-                       cfg.RenderPass = new CVKL.RenderPass (dev, swapChain.ColorFormat, samples);
+                       vke.GraphicPipelineConfig cfg = vke.GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, samples, false);
+                       cfg.Layout = new vke.PipelineLayout (dev, descLayout);
+                       cfg.RenderPass = new vke.RenderPass (dev, swapChain.ColorFormat, samples);
                        cfg.AddShader (VkShaderStageFlags.Vertex, "#deferred.FullScreenQuad.vert.spv");
                        cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.simpletexture.frag.spv");
 
                        cfg.blendAttachments[0] = new VkPipelineColorBlendAttachmentState (true);
 
-                       uiPipeline = new CVKL.GraphicPipeline (cfg);
+                       uiPipeline = new vke.GraphicPipeline (cfg);
 
                        dsCrow = descriptorPool.Allocate (descLayout);
                }
                void initUISurface () {
                        lock (crow.UpdateMutex) {
                                uiImage?.Dispose ();
-                               uiImage = new CVKL.Image (dev, new VkImage ((ulong)crow.surf.VkImage.ToInt64 ()), VkFormat.B8g8r8a8Unorm,
+                               uiImage = new vke.Image (dev, new VkImage ((ulong)crow.surf.VkImage.ToInt64 ()), VkFormat.B8g8r8a8Unorm,
                                        VkImageUsageFlags.Sampled, swapChain.Width, swapChain.Height);
                                uiImage.SetName ("uiImage");
                                uiImage.CreateView (VkImageViewType.ImageView2D, VkImageAspectFlags.Color);
@@ -119,14 +119,14 @@ namespace Crow {
                                System.Diagnostics.Debug.WriteLine (ex.ToString ());
                        }
                }
-               protected virtual void recordDraw (CVKL.CommandBuffer cmd, int imageIndex) { }
+               protected virtual void recordDraw (vke.CommandBuffer cmd, int imageIndex) { }
 
                void buildCommandBuffers () {
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
                                cmds[i]?.Free ();
                                cmds[i] = cmdPool.AllocateAndStart ();
 
-                               CVKL.CommandBuffer cmd = cmds[i];
+                               vke.CommandBuffer cmd = cmds[i];
 
                                recordDraw (cmd, i);
 
@@ -166,20 +166,20 @@ namespace Crow {
 
                        initUISurface ();
 
-                       CVKL.DescriptorSetWrites uboUpdate = new CVKL.DescriptorSetWrites (dsCrow, descLayout);
+                       vke.DescriptorSetWrites uboUpdate = new vke.DescriptorSetWrites (dsCrow, descLayout);
                        uboUpdate.Write (dev, uiImage.Descriptor);
 
                        if (uiFrameBuffers != null)
                                for (int i = 0; i < swapChain.ImageCount; ++i)
                                        uiFrameBuffers[i]?.Dispose ();
 
-                       uiFrameBuffers = new CVKL.Framebuffer[swapChain.ImageCount];
+                       uiFrameBuffers = new vke.FrameBuffer[swapChain.ImageCount];
 
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               uiFrameBuffers[i] = new CVKL.Framebuffer (uiPipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (uiPipeline.Samples == VkSampleCountFlags.SampleCount1) ? new CVKL.Image[] {
+                               uiFrameBuffers[i] = new vke.FrameBuffer (uiPipeline.RenderPass, swapChain.Width, swapChain.Height,
+                                       (uiPipeline.Samples == VkSampleCountFlags.SampleCount1) ? new vke.Image[] {
                                                swapChain.images[i],
-                                       } : new CVKL.Image[] {
+                                       } : new vke.Image[] {
                                                null,
                                                swapChain.images[i]
                                        });
index a01cd856730be69d14b99d6c22c3a702c62bfe9b..aba1418761525ca7a5c8032e748ee41043698508 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 using Glfw;
 using VK;
-using CVKL;
+using vke;
 
 namespace delaunay {
        class Program : VkWindow {
@@ -16,7 +16,7 @@ namespace delaunay {
                        }
                }
 
-               Framebuffer[] frameBuffers;
+               FrameBuffer[] frameBuffers;
                GraphicPipeline grPipeline;
 
                Image imgResult;
@@ -136,10 +136,10 @@ namespace delaunay {
                        if (frameBuffers != null)
                                for (int i = 0; i < swapChain.ImageCount; ++i)
                                        frameBuffers[i]?.Dispose ();
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
+                       frameBuffers = new FrameBuffer[swapChain.ImageCount];
 
                        for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (grPipeline.RenderPass, swapChain.Width, swapChain.Height,
+                               frameBuffers[i] = new FrameBuffer (grPipeline.RenderPass, swapChain.Width, swapChain.Height,
                                        (grPipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
                                                swapChain.images[i],
                                                null
index 3dc8520082e3be6ff40684812a3cc37413baa2fc..540de6a9cd4131f4a83206d86b1b81f3447519a3 100644 (file)
@@ -1,8 +1,8 @@
 using System;
 using System.Numerics;
 using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
 using VK;
 
 namespace deferred {
@@ -66,7 +66,7 @@ namespace deferred {
                        }*/
                };
 
-               Framebuffer frameBuffer;
+               FrameBuffer frameBuffer;
                public Image gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgResolved, hdrImgMS;
 
                DescriptorPool descriptorPool;
@@ -484,9 +484,9 @@ namespace deferred {
                        createGBuff ();
 
                        frameBuffer = (NUM_SAMPLES == VkSampleCountFlags.SampleCount1) ?
-                               new Framebuffer (renderPass, width, height, new Image[] {
+                               new FrameBuffer (renderPass, width, height, new Image[] {
                                        hdrImgResolved, null, gbColorRough, gbEmitMetal, gbN_AO, gbPos}) :
-                               new Framebuffer (renderPass, width, height, new Image[] {
+                               new FrameBuffer (renderPass, width, height, new Image[] {
                                        hdrImgResolved, null, gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgMS});
                }
 
index 4e97a1c812a7a83f10b4ab6d6a462bddb4b20e75..0716c01d643f00bf4cc6c5a88cb16ad000d75cbf 100644 (file)
@@ -4,7 +4,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
        public class EnvironmentCube : GraphicPipeline {
 
                GPUBuffer vboSkybox;
@@ -123,7 +123,7 @@ namespace CVKL {
                        cfg.AddShader (VkShaderStageFlags.Fragment, "#deferred.genbrdflut.frag.spv");
 
                        using (GraphicPipeline pl = new GraphicPipeline (cfg)) {
-                               using (Framebuffer fb = new Framebuffer (cfg.RenderPass, dim, dim, lutBrdf)) {
+                               using (FrameBuffer fb = new FrameBuffer (cfg.RenderPass, dim, dim, lutBrdf)) {
                                        CommandBuffer cmd = cmdPool.AllocateCommandBuffer ();
                                        cmd.Start (VkCommandBufferUsageFlags.OneTimeSubmit);
                                        pl.RenderPass.Begin (cmd, fb);
@@ -223,7 +223,7 @@ namespace CVKL {
                                dsUpdate.Write (Dev, dset, cubemap.Descriptor);
                                Dev.WaitIdle ();
 
-                               using (Framebuffer fb = new Framebuffer (pl.RenderPass, dim, dim, imgFbOffscreen)) {
+                               using (FrameBuffer fb = new FrameBuffer (pl.RenderPass, dim, dim, imgFbOffscreen)) {
                                        CommandBuffer cmd = cmdPool.AllocateCommandBuffer ();
                                        cmd.Start (VkCommandBufferUsageFlags.OneTimeSubmit);
 
index e5c5598e9bc6f89a3b402d58a6f1fa47a4c10760..2a2301bcd0b800cfeb37ed278c544ee4fcde4956 100644 (file)
@@ -2,7 +2,7 @@
 using System.Numerics;
 using Glfw;
 using VK;
-using CVKL;
+using vke;
 using System.Collections.Generic;
 using System.Linq;
 
index 8ad5dbe02df140319cfeb7fb2f1e19e8a60a30fe..46386618bf25b1d45f2fbb11bb3d0d16d96bbda7 100644 (file)
@@ -1,8 +1,8 @@
 using System;
 using System.Numerics;
 using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
 using Glfw;
 using VK;
 
@@ -71,7 +71,7 @@ namespace deferred {
 
 
                GraphicPipeline plToneMap;
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
                DescriptorPool descriptorPool;
                DescriptorSet descriptorSet;
 
@@ -203,8 +203,8 @@ namespace deferred {
                }
 
 
-               CommandBuffer cmdPbr;
-               CommandBuffer cmdBlur;
+               //CommandBuffer cmdPbr;
+               //CommandBuffer cmdBlur;
                VkSemaphore blurComplete;
                const uint downSizing = 1;
                float finalDebug = -1.0f;
@@ -322,21 +322,8 @@ namespace deferred {
                        pcBloom.texSize.X = downSamp.Width;
                        pcBloom.texSize.Y = downSamp.Height;
 
-                       if (frameBuffers != null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (plToneMap.RenderPass, swapChain.Width, swapChain.Height,
-                                       (plToneMap.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                       } : new Image[] {
-                                               null,
-                                               swapChain.images[i]
-                                       });
-                       }
+                       frameBuffers?.Dispose();
+                       frameBuffers = plToneMap.RenderPass.CreateFrameBuffers(swapChain);
 
                        DescriptorSetWrites dsUpdate = new DescriptorSetWrites (plToneMap.Layout.DescriptorSetLayouts[0]);
                        dsUpdate.Write (dev, descriptorSet, renderer.hdrImgResolved.Descriptor, downSamp.Descriptor);
@@ -530,9 +517,7 @@ namespace deferred {
                                        computeCmdPool.Dispose ();
                                        downSamp?.Dispose ();
                                        downSamp2?.Dispose ();
-                                       if (frameBuffers != null)
-                                               foreach (Framebuffer fb in frameBuffers)
-                                                       fb.Dispose ();
+                                       frameBuffers?.Dispose();
                                        renderer.Dispose ();
                                        plBlur.Dispose ();
                                        plToneMap.Dispose ();
index a4684ecc751d4862555f27acea254e9495f7d3af..60da3782c8ff34783986636c4752a866cebcdfbb 100644 (file)
@@ -6,8 +6,8 @@
 using System;
 using System.Numerics;
 using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
 using VK;
 using static deferred.DeferredPbrRenderer;
 
@@ -29,7 +29,7 @@ namespace deferred {
 
 
                RenderPass shadowPass;
-               Framebuffer fbShadowMap;
+               FrameBuffer fbShadowMap;
                public Image shadowMap { get; private set; }
                Pipeline shadowPipeline;
                DescriptorPool descriptorPool;
@@ -99,7 +99,7 @@ namespace deferred {
                        shadowMap.CreateSampler (VkSamplerAddressMode.ClampToBorder);
                        shadowMap.Descriptor.imageLayout = VkImageLayout.DepthStencilReadOnlyOptimal;
 
-                       fbShadowMap = new Framebuffer (shadowPass, SHADOWMAP_SIZE, SHADOWMAP_SIZE, (uint)renderer.lights.Length);
+                       fbShadowMap = new FrameBuffer (shadowPass, SHADOWMAP_SIZE, SHADOWMAP_SIZE, (uint)renderer.lights.Length);
                        fbShadowMap.attachments.Add (shadowMap);
                        fbShadowMap.Activate ();
 
index 7b5428ec9c187640f50485d100e7f2b3f51a4191..06636f77f56d973b3e9e5b8c4a75278a3c27788d 100644 (file)
@@ -4,7 +4,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
        class EnvironmentCube : GraphicPipeline {
 
                GPUBuffer vboSkybox;
@@ -138,7 +138,7 @@ namespace CVKL {
                        cfg.AddShader (VkShaderStageFlags.Fragment, "#pbr.genbrdflut.frag.spv");
 
                        using (GraphicPipeline pl = new GraphicPipeline (cfg)) {
-                               using (Framebuffer fb = new Framebuffer (cfg.RenderPass, dim, dim, lutBrdf)) {
+                               using (FrameBuffer fb = new FrameBuffer (cfg.RenderPass, dim, dim, lutBrdf)) {
                                        CommandBuffer cmd = cmdPool.AllocateCommandBuffer ();
                                        cmd.Start (VkCommandBufferUsageFlags.OneTimeSubmit);
                                        pl.RenderPass.Begin (cmd, fb);
@@ -237,7 +237,7 @@ namespace CVKL {
                                DescriptorSetWrites dsUpdate = new DescriptorSetWrites (dsLayout);
                                dsUpdate.Write (Dev, dset, cubemap.Descriptor);
 
-                               using (Framebuffer fb = new Framebuffer (pl.RenderPass, dim, dim, imgFbOffscreen)) {
+                               using (FrameBuffer fb = new FrameBuffer (pl.RenderPass, dim, dim, imgFbOffscreen)) {
                                        CommandBuffer cmd = cmdPool.AllocateCommandBuffer ();
                                        cmd.Start (VkCommandBufferUsageFlags.OneTimeSubmit);
 
index a48fe11a2a1b99543bab026bc45713ccf5f2221b..e4a516d3de9e700407c87775a10da6a9938a3c2a 100644 (file)
@@ -6,8 +6,8 @@ using System.Runtime.InteropServices;
 
 using VK;
 
-namespace CVKL {
-       using CVKL.glTF;
+namespace vke {
+       using vke.glTF;
 
 
        //TODO:stride in buffer views?
index a8d3fae1f06f0bb7d8b58860b6e3b397263b2d42..94abe0904e1289146c11b103b6409a908df64798 100644 (file)
@@ -7,7 +7,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
        class PBRPipeline : GraphicPipeline {
 
                public struct Matrices {
index 0a0cd3516543b190a6e3fe66814c5195724761d7..35d9db7f9bdb2bee804a1759a2b9177290369139 100644 (file)
@@ -10,7 +10,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using Glfw;
 using VK;
-using CVKL;
+using vke;
 
 namespace pbrSample {
        class Program : VkWindow{
@@ -35,7 +35,7 @@ namespace pbrSample {
 
                VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1;
 
-               Framebuffer[] frameBuffers;
+               FrameBuffers frameBuffers;
                PBRPipeline pbrPipeline;
 
                enum DebugView {
@@ -193,7 +193,7 @@ namespace pbrSample {
                                cmds[i].End ();
                        }
                }
-               void recordDraw (CommandBuffer cmd, Framebuffer fb) {
+               void recordDraw (CommandBuffer cmd, FrameBuffer fb) {
                        pbrPipeline.RenderPass.Begin (cmd, fb);
 
                        cmd.SetViewport (fb.Width, fb.Height);
@@ -257,23 +257,8 @@ namespace pbrSample {
 
                        UpdateView ();
 
-                       if (frameBuffers != null)
-                               for (int i = 0; i < swapChain.ImageCount; ++i)
-                                       frameBuffers[i]?.Dispose ();
-
-                       frameBuffers = new Framebuffer[swapChain.ImageCount];
-
-                       for (int i = 0; i < swapChain.ImageCount; ++i) {
-                               frameBuffers[i] = new Framebuffer (pbrPipeline.RenderPass, swapChain.Width, swapChain.Height,
-                                       (pbrPipeline.RenderPass.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
-                                               swapChain.images[i],
-                                               null
-                                       } : new Image[] {
-                                               null,
-                                               null,
-                                               swapChain.images[i]
-                                       });
-                       }
+                       frameBuffers?.Dispose();
+                       frameBuffers = pbrPipeline.RenderPass.CreateFrameBuffers(swapChain);
 
                        buildCommandBuffers ();
                        dev.WaitIdle ();
@@ -411,9 +396,7 @@ namespace pbrSample {
                        if (disposing) {
                                if (!isDisposed) {
                                        dev.WaitIdle ();
-                                       for (int i = 0; i < swapChain.ImageCount; ++i)
-                                               frameBuffers[i]?.Dispose ();
-
+                                       frameBuffers?.Dispose();
                                        pbrPipeline.Dispose ();
 #if WITH_VKVG
                                        vkvgPipeline.Dispose ();
index acc948d734ed5c7daeaa48f7378064440cab92c5..c3fa145776f51d6d5ae900e06916a6cafcfa4852 100644 (file)
@@ -6,8 +6,8 @@
                 
   <ItemGroup>
     <GLSLShader Update="shaders/simpletexture.frag">
-               <LogicalName>vke.simpletexture.frag.spv</LogicalName>           
-       </GLSLShader>
+                  <LogicalName>vke.simpletexture.frag.spv</LogicalName>                
+          </GLSLShader>
   </ItemGroup>    
        
   <ItemGroup>
index 815782bc4dd8359b9aabc8a7a408f39646f5f265..21934665de5fa9540cd66a7059ecd84d5c8ecb48 100644 (file)
@@ -29,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TexturedCube", "samples\Tex
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Triangle", "samples\Triangle\Triangle.csproj", "{A30AEC45-54A3-4120-B341-B3299CC1B00E}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpirVTasks", "SpirVTasks\SpirVTasks.csproj", "{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -108,6 +110,12 @@ Global
                {A30AEC45-54A3-4120-B341-B3299CC1B00E}.Release|Any CPU.Build.0 = Release|Any CPU
                {A30AEC45-54A3-4120-B341-B3299CC1B00E}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
                {A30AEC45-54A3-4120-B341-B3299CC1B00E}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
+               {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.Build.0 = 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
        EndGlobalSection
        GlobalSection(NestedProjects) = preSolution
                {FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
@@ -122,4 +130,10 @@ Global
                {8185163E-A67C-4C0E-8548-67E2A9F16309} = {16439374-B8DB-4643-8116-EB3358B49A12}
                {A30AEC45-54A3-4120-B341-B3299CC1B00E} = {16439374-B8DB-4643-8116-EB3358B49A12}
        EndGlobalSection
+       GlobalSection(MonoDevelopProperties) = preSolution
+               Policies = $0
+               $0.TextStylePolicy = $1
+               $1.FileWidth = 80
+               $1.scope = text/x-cgsrc
+       EndGlobalSection
 EndGlobal
index 0410e0edd1948747b5ebfc506f402e644a200b72..ac6aa2917b5839695eadd2e1bc58ea2417928dea 100644 (file)
@@ -3,7 +3,7 @@
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System.Numerics;
 
-namespace CVKL {
+namespace vke {
        public class Camera {
                /// <summary>Corection matrix for vulkan projection</summary>
                public static readonly Matrix4x4 VKProjectionCorrection =
index 287e88763b798aaa255f98aae316a4b4396c1fab..34c1740ca9e739e11ec7d037886dcdf82471431f 100644 (file)
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        public static class ExtensionMethods {
                /// <summary>
                /// Extensions method to check byte array equality.
diff --git a/vke/src/FrameBuffers.cs b/vke/src/FrameBuffers.cs
new file mode 100644 (file)
index 0000000..7b5a567
--- /dev/null
@@ -0,0 +1,20 @@
+// 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.Collections.ObjectModel;
+
+namespace vke
+{
+       public class FrameBuffers : Collection<FrameBuffer>, IDisposable
+       {
+               //public Framebuffer this[int index] => Items[index];
+
+               public void Dispose()
+               {
+                       foreach (FrameBuffer fb in Items)
+                               fb.Dispose();
+                       ClearItems();
+               }
+       }
+}
index 231e69aa908d34988276f5ef1aed8156d06c74c1..f6dd178e76ca6d4346ff941c7a0c9c33f45565e5 100644 (file)
@@ -4,7 +4,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace CVKL {
+namespace vke {
        public class MarshaledObject<T> : IDisposable where T : struct {
 
         GCHandle handle;
index 2fbc8d8b97e6c3b6cf9bc74c470faa7c4a17c55e..6706c49c676262d29b67de7d56c5abf48e5873e4 100644 (file)
@@ -6,7 +6,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
 #if MEMORY_POOLS
        public enum MemoryPoolType {
                Random,
@@ -57,7 +57,11 @@ namespace CVKL {
                        if (previous != null) {
                                do {
                                        offset = previous.poolOffset + previous.AllocatedDeviceMemorySize;
-                                       offset += resource.MemoryAlignment - (offset % resource.MemoryAlignment);
+
+                                       if (previous.IsLinar != resource.IsLinar && offset % dev.BufferImageGranularity > 0)
+                                               offset += dev.BufferImageGranularity - (offset % dev.BufferImageGranularity);
+                                       if (offset % resource.MemoryAlignment > 0)
+                                               offset += resource.MemoryAlignment - (offset % resource.MemoryAlignment);
 
                                        if (previous.next == null) {
                                                if (offset + resource.AllocatedDeviceMemorySize >= limit) {
index c6bbd2252486b6a87db4722681da69d6b03c9c5d..c01afda8545727d746515f16b87f902e45aceab4 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 using VK;
 
-namespace CVKL {
+namespace vke {
 #if MEMORY_POOLS
        /// <summary>
        /// Resource manager is responsible for the memory allocations. It holds one pool for each memory type
index 105883085ca4ddd16e77fe7abe01504f9f67493a..0762801eaab951acfb8a7679e9671f099b13457b 100644 (file)
@@ -4,7 +4,7 @@
 using System;
 using VK;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// This class is a helper class for VkPipelineShaderStageCreateInfo creation.
        /// </summary>
index b455cca3e05f09f9cd57057a0e4bce942a7ccb42..91d43565b43739086f14d847394002f8dd470213 100644 (file)
@@ -28,7 +28,7 @@ using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Hold shader specialization constant value and type
        /// </summary>
index 3ea1d7fae4fd6805f24f8ece75daecf9a6d1d7ae..208b4a5994acf27e14d2c103100def9c666200a4 100644 (file)
@@ -5,7 +5,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace CVKL {
+namespace vke {
     public class StbImage : IDisposable {
         const string stblib = "stb";
 
index 9205b976c100446f6871d163fc2b75dfb8e62c63..3ac89286b5171363712f2729f00261375b161b8d 100644 (file)
@@ -285,5 +285,58 @@ namespace VK {
                                        break;
                        }
                }
-    }
+               public static bool TryGetCompressedFormatBlockSize (this VkFormat format, out uint width, out uint height)
+               {
+                       width = height = 1;
+                       if (format < VkFormat.Bc1RgbUnormBlock || format > (VkFormat)1000066013) //VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT)
+                               return false;
+                       if (format < VkFormat.Astc5x4UnormBlock)
+                               width = height = 4;
+                       else {
+                               string str = format.ToString ();
+                               if (str.StartsWith ("Astc", StringComparison.OrdinalIgnoreCase)) {
+                                       width = uint.Parse (str.Substring (4, 1));
+                                       height = uint.Parse (str.Substring (6, 1));
+                               }
+                       }
+
+                       return true;
+               }
+               //TODO:quick done list, refine needed
+               public static VkPipelineStageFlags GetDefaultStage (this VkImageLayout layout) {
+                       switch (layout) {
+                       case VkImageLayout.Preinitialized:
+                       case VkImageLayout.Undefined:
+                               return VkPipelineStageFlags.AllCommands;
+
+                       case VkImageLayout.General:
+                               return VkPipelineStageFlags.ComputeShader;
+
+                       case VkImageLayout.ColorAttachmentOptimal:
+                       case VkImageLayout.DepthStencilAttachmentOptimal:
+                               return VkPipelineStageFlags.ColorAttachmentOutput;
+
+                       case VkImageLayout.DepthStencilReadOnlyOptimal:
+                       case VkImageLayout.DepthReadOnlyStencilAttachmentOptimalKHR:
+                       case VkImageLayout.DepthAttachmentStencilReadOnlyOptimalKHR:
+                               return VkPipelineStageFlags.EarlyFragmentTests;
+
+                       case VkImageLayout.ShaderReadOnlyOptimal:
+                               return VkPipelineStageFlags.FragmentShader;
+
+                       case VkImageLayout.TransferSrcOptimal:
+                       case VkImageLayout.TransferDstOptimal:
+                               return VkPipelineStageFlags.Transfer;
+
+                       case VkImageLayout.PresentSrcKHR:
+                       case VkImageLayout.SharedPresentKHR:
+                               return VkPipelineStageFlags.ColorAttachmentOutput;
+
+                       //case VkImageLayout.ShadingRateOptimalNV:
+                       //case VkImageLayout.FragmentDensityMapOptimalEXT:
+                       default:
+                               return VkPipelineStageFlags.AllCommands;
+                       }
+               }
+       }
 }
index 320757415266a5d78462b0215ff116dc3d604115..125820808d0be28f196b6c596a258be3a76cceae 100644 (file)
@@ -9,7 +9,7 @@ using Glfw;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Base class to build vulkan application.
        /// Provide default swapchain with its command pool and buffers per image and the main present queue
index b77443c32692dcd7520a0f012acbef6d8d515080..28a82ee1d5d500c4822d247f5488055b18c1b65e 100644 (file)
@@ -1,33 +1,11 @@
-//
-// Activable.cs
+// Copyright (c) 2019  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// Copyright (c) 2019 jp
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Tristate status of activables, reflecting vulkan openrations
        /// </summary>
index 254d547e87475c5d906a75a5b1a5377bc5a8b1fd..8af3517c40b8707bf8b22b54e3a8a6c79dbe0754 100644 (file)
@@ -5,7 +5,7 @@ using System;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
 
     /// <summary>
     /// Base class for HostBuffer and GPUBuffer
@@ -17,7 +17,8 @@ namespace CVKL {
                public VkDescriptorBufferInfo Descriptor;
                public VkBuffer Handle => handle;
                public VkBufferCreateInfo Infos => createInfo;
-        
+               public override bool IsLinar => true;
+
                protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
                        => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.BufferEXT, handle.Handle);
 
@@ -67,9 +68,7 @@ namespace CVKL {
         }
 
         public void CopyTo (CommandBuffer cmd, Image img, VkImageLayout finalLayout = VkImageLayout.ShaderReadOnlyOptimal) {
-            img.SetLayout (cmd, VkImageAspectFlags.Color,
-                VkImageLayout.Undefined, VkImageLayout.TransferDstOptimal,
-                VkPipelineStageFlags.AllCommands, VkPipelineStageFlags.Transfer);
+            img.SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.TransferDstOptimal);
 
             VkBufferImageCopy bufferCopyRegion = new VkBufferImageCopy {
                 imageExtent = img.CreateInfo.extent,
@@ -78,10 +77,8 @@ namespace CVKL {
 
             vkCmdCopyBufferToImage (cmd.Handle, handle, img.handle, VkImageLayout.TransferDstOptimal, 1, ref bufferCopyRegion);
 
-            img.SetLayout (cmd, VkImageAspectFlags.Color,
-                VkImageLayout.TransferDstOptimal, finalLayout,
-                VkPipelineStageFlags.Transfer, VkPipelineStageFlags.Transfer);
-        }
+                       img.SetLayout (cmd, VkImageAspectFlags.Color, finalLayout);
+               }
         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,
index 0c381a7b58de21dc6a9534438380d38163cfe678..9a2215803889f0825ac0ff032f25c65f7e200054 100644 (file)
@@ -8,7 +8,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Command buffers are objects used to record commands which can be subsequently submitted to a device queue for execution.
        /// There are two levels of command buffers 
@@ -92,7 +92,13 @@ namespace CVKL {
             VkRect2D scissor = new VkRect2D (offsetX, offsetY, width, height);
             vkCmdSetScissor (handle, 0, 1, ref scissor);
         }
-        public void BindPipeline (Pipeline pipeline, VkPipelineBindPoint bindPoint) {
+               //TODO:update generator to handle float array in this command
+               public void SetBlendConstants (float r, float g, float b, float a)
+               {
+                       throw new NotImplementedException();
+                       //vkCmdSetBlendConstants(handle, );
+               }
+               public void BindPipeline (Pipeline pipeline, VkPipelineBindPoint bindPoint) {
             vkCmdBindPipeline (handle, bindPoint, pipeline.Handle);
         }
                public void Dispatch (uint groupCountX, uint groupCountY = 1, uint groupCountZ = 1) {
index 33177331ba29fe8f43268940dac1e522a981e799..6be3e0af150d2846319946daeb359183537c742f 100644 (file)
@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Command pools are opaque objects that command buffer memory is allocated from, and which allow the implementation
        /// to amortize the cost of resource creation across multiple command buffers.
index e57a7d0a5618535ed88f3faa431daf3fa7fcbe3c..c8d9f13b91db566ef1b8d06ae7b6efae8f92b56e 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public sealed class ComputePipeline : Pipeline {
 
                public string SpirVPath;
index c974416afc58003c034f8cf856d34aa959881c78..43aae957cdc06dd46d7cdd15ecc668a60d07f777 100644 (file)
@@ -3,7 +3,7 @@ using System.Numerics;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
        public class DebugDrawPipeline : GraphicPipeline {
                public HostBuffer Vertices;
                uint vertexCount;
@@ -54,7 +54,7 @@ namespace CVKL {
                        Vertices.Update (data, 12 * sizeof (float), (lineNum-1) * 2 * 6 * sizeof (float));
                }
 
-               public void RecordDraw (CommandBuffer cmd, Framebuffer fb, Matrix4x4 projection, Matrix4x4 view) {
+               public void RecordDraw (CommandBuffer cmd, FrameBuffer fb, Matrix4x4 projection, Matrix4x4 view) {
 
             //cmd.SetViewport (fb.Width/ratio, fb.Height/ratio, (ratio-1) * (int)fb.Width / ratio, (ratio-1) * (int)fb.Height / ratio);
             //cmd.SetViewport (200, 200,100,100,-10,10);//, 4 * (int)fb.Width / 5, 4 * (int)fb.Height / 5);
index 3bda80b8552221c6b52a18bef67a1c599cb3801b..d1ce888a5473adeb153208091f76c6978fd98d8f 100644 (file)
@@ -28,7 +28,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
 
     public class DebugReport : IDisposable {        
         VkDebugReportCallbackEXT handle;
index b048c3614ef9abeb6abd3f5d7a1151dfe856a6ad..58c818777e928d9ea68705a47d9744b5d604f2e1 100644 (file)
@@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL.DebugUtils {
+namespace vke.DebugUtils {
 
     public class Messenger : IDisposable {
                Instance inst;
index 6c9f9c4fdf65c0afc3f3314e4077c34c008394cf..7f0cde2385b4e3145065957ad9ca60137f98e491 100644 (file)
@@ -7,7 +7,7 @@ using System.Collections.Generic;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public sealed class DescriptorPool : Activable {
         internal VkDescriptorPool handle;        
         public readonly uint MaxSets;
index 19b231c7b5aefe73af5ffcbc3b1bd423fbdea2fa..30482283b2ae025b8530631c9b42113df703b7e8 100644 (file)
@@ -4,7 +4,7 @@
 using System.Collections.Generic;
 using VK;
 
-namespace CVKL {
+namespace vke {
        public class DescriptorSet {
         internal VkDescriptorSet handle;
                public VkDescriptorSet Handle => handle;
index f63e5e2b208c64c2f62d3d5122d967c8ef8b6138..1113adc00448d6eb146f6bd140373ebc4e00f0bc 100644 (file)
@@ -6,7 +6,7 @@ using System.Collections.Generic;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Descriptor set layout, automatically activated when used in pipeline creation, so don't allocate descriptor sets using
        /// this layout unless it has been activated.
index b47d7d066e17368c64096c393709104654b56d76..cbacae6069d2d678f0d4af50dff27fc9918624c1 100644 (file)
@@ -29,7 +29,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Descriptor set writes is defined once, then update affect descriptors to write array
        /// </summary>
index 299b2886d274520e491b83115ff9daf914c94bc5..fcb8734c5f79547d39c42f2d55da2baeb272c470 100644 (file)
@@ -33,7 +33,7 @@ using VK;
 using static VK.Vk;
 
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Logical device encapsulating vulkan logical device handle. Implements only IDisposable an do not derive from
        /// Activable, so it may be activated only once and no reference counting on it is handled, and no reactivation is posible
@@ -45,6 +45,7 @@ namespace CVKL {
                VkDevice dev;
                public VkDevice VkDev => dev;
                public IntPtr Handle => dev.Handle;
+               public readonly ulong BufferImageGranularity;
 
                internal List<Queue> queues = new List<Queue> ();
                internal bool debugMarkersEnabled;
@@ -55,6 +56,7 @@ namespace CVKL {
 
                public Device (PhysicalDevice _phy) {
                        phy = _phy;
+                       BufferImageGranularity = phy.Limits.bufferImageGranularity;
                }
 
                public void Activate (VkPhysicalDeviceFeatures enabledFeatures, params string[] extensions) {
index 2f668e0e2ea7a57660d07dcabf6c6c1abdbe35be..2b73e7fb511db81982bbb2b83e941f47914d6dea 100644 (file)
@@ -30,9 +30,9 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
 
-    public class Framebuffer : Activable {
+    public class FrameBuffer : Activable {
         internal VkFramebuffer handle;
         RenderPass renderPass;
         
@@ -47,15 +47,21 @@ namespace CVKL {
                        => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.FramebufferEXT, handle.Handle);
 
                #region CTORS
-               public Framebuffer (RenderPass _renderPass, uint _width, uint _height, uint _layers = 1) : base(_renderPass.Dev) {
+               public FrameBuffer (RenderPass _renderPass, uint _width, uint _height, uint _layers = 1) : base(_renderPass.Dev) {
             renderPass = _renderPass;
             createInfo.width = _width;
             createInfo.height = _height;
             createInfo.layers = _layers;
             createInfo.renderPass = renderPass.handle;
         }
-
-               public Framebuffer (RenderPass _renderPass, uint _width, uint _height, params Image[] views)
+               /// <summary>
+               /// Create and Activate a new frabuffer for the supplied RenderPass.
+               /// </summary>
+               /// <param name="_renderPass">Render pass.</param>
+               /// <param name="_width">Width.</param>
+               /// <param name="_height">Height.</param>
+               /// <param name="views">Views.</param>
+               public FrameBuffer (RenderPass _renderPass, uint _width, uint _height, params Image[] views)
         : this (_renderPass, _width, _height) {
                        for (int i = 0; i < views.Length; i++) {
                                Image v = views[i];
index 61504fd762ec53958ae6a0649223eceb15bbc3ff..b670812e057286161621c8ac4338ab9f434f8aba 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Runtime.InteropServices;
 using VK;
 
-namespace CVKL {
+namespace vke {
 
     /// <summary>
     /// Device local Buffer
index 562e4fa2b1c32cfa444ad89b904bdb8a046349c4..5d16b2c7447fbad3c9d0c24d672576fc95845967 100644 (file)
@@ -28,7 +28,7 @@ using System.Collections.Generic;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public class GraphicPipeline : Pipeline {
 
                public readonly RenderPass RenderPass;
@@ -64,6 +64,15 @@ namespace CVKL {
                                        shaderStages.Add (shader.GetStageCreateInfo (Dev));
 
                                VkPipelineColorBlendStateCreateInfo colorBlendInfo = VkPipelineColorBlendStateCreateInfo.New ();
+                               colorBlendInfo.logicOpEnable = cfg.ColorBlendLogicOpEnable;
+                               colorBlendInfo.logicOp = cfg.ColorBlendLogicOp;
+                               unsafe
+                               {
+                                       colorBlendInfo.blendConstants[0] = cfg.ColorBlendConstants.X;
+                                       colorBlendInfo.blendConstants[1] = cfg.ColorBlendConstants.Y;
+                                       colorBlendInfo.blendConstants[2] = cfg.ColorBlendConstants.Z;
+                                       colorBlendInfo.blendConstants[3] = cfg.ColorBlendConstants.W;
+                               }
                                colorBlendInfo.attachmentCount = (uint)cfg.blendAttachments.Count;
                                colorBlendInfo.pAttachments = cfg.blendAttachments.Pin ();
 
index 56b74ca6e62ecfcf74cd3d3b9e2f61c8a79c2c8f..697e62392bb105ab83f1903784b6da4578bef695 100644 (file)
 // THE SOFTWARE.
 using System;
 using System.Collections.Generic;
+using System.Numerics;
 using System.Reflection;
 using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public class GraphicPipelineConfig {
                public uint SubpassIndex;
         public PipelineLayout Layout;
@@ -47,7 +48,10 @@ namespace CVKL {
         public List<VkVertexInputBindingDescription> vertexBindings = new List<VkVertexInputBindingDescription> ();
         public List<VkVertexInputAttributeDescription> vertexAttributes = new List<VkVertexInputAttributeDescription> ();
         public readonly List<ShaderInfo> shaders = new List<ShaderInfo>();
-        
+               public VkBool32 ColorBlendLogicOpEnable = false;
+               public VkLogicOp ColorBlendLogicOp;
+               public Vector4 ColorBlendConstants;
+
                public VkSampleCountFlags Samples {
                        get { return multisampleState.rasterizationSamples; }
                }
index 20734c890b58ab60513c3940fee0bbe4790e927d..94656145ea20d065d4ae72385015a8d78cb5fe67 100644 (file)
@@ -29,7 +29,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        
        public class HostBuffer<T> : HostBuffer {
         int TSize;
index 3787e3cb0a99c89e6d4ae9a02f07aca937adac22..96ab24ab820f000005c0039f805429480f767cc8 100644 (file)
@@ -29,7 +29,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Combined Image/Descriptor class. Optional Sampler and View are disposed with the vkImage. If multiple view/sampler have to be
        /// created for the same vkImage, you may call the constructor accepting a vkImage as parameter to import an existing one. vkImage handle of
@@ -53,6 +53,9 @@ namespace CVKL {
                public VkImage Handle => handle;
                public uint Width => CreateInfo.extent.width;
                public uint Height => CreateInfo.extent.height;
+               public override bool IsLinar => CreateInfo.tiling == VkImageTiling.Linear;
+
+               VkImageLayout lastKnownLayout;
 
                protected override VkDebugMarkerObjectNameInfoEXT DebugMarkerInfo
                        => new VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT.ImageEXT, handle.Handle);
@@ -79,6 +82,8 @@ namespace CVKL {
             info.sharingMode = VkSharingMode.Exclusive;
                        info.flags = createFlags;
 
+                       lastKnownLayout = info.initialLayout;
+
             Activate ();//DONT OVERRIDE Activate in derived classes!!!!
         }
 
@@ -397,13 +402,24 @@ namespace CVKL {
             Descriptor.sampler = sampler;
         }
 
-        public void SetLayout (
+               public void SetLayout (CommandBuffer cmdbuffer,
+                       VkImageAspectFlags aspectMask,
+                       VkImageLayout newImageLayout) {
+                       SetLayout (cmdbuffer, aspectMask, lastKnownLayout, newImageLayout, lastKnownLayout.GetDefaultStage (), newImageLayout.GetDefaultStage ());
+               }
+               public void SetLayout (CommandBuffer cmdbuffer,
+                       VkImageAspectFlags aspectMask,
+            VkImageLayout oldImageLayout,
+                       VkImageLayout newImageLayout) {
+                       SetLayout (cmdbuffer, aspectMask, oldImageLayout, newImageLayout, oldImageLayout.GetDefaultStage (), newImageLayout.GetDefaultStage ());
+               }
+               public void SetLayout (
             CommandBuffer cmdbuffer,
             VkImageAspectFlags aspectMask,
             VkImageLayout oldImageLayout,
             VkImageLayout newImageLayout,
-            VkPipelineStageFlags srcStageMask = VkPipelineStageFlags.AllCommands,
-            VkPipelineStageFlags dstStageMask = VkPipelineStageFlags.AllCommands) {
+            VkPipelineStageFlags srcStageMask,
+            VkPipelineStageFlags dstStageMask) {
             VkImageSubresourceRange subresourceRange = new VkImageSubresourceRange {
                 aspectMask = aspectMask,
                 baseMipLevel = 0,
@@ -539,7 +555,7 @@ namespace CVKL {
                 case VkImageLayout.TransferSrcOptimal:
                     // Image will be used as a transfer source
                     // Make sure any reads from and writes to the image have been finished
-                    imageMemoryBarrier.srcAccessMask = imageMemoryBarrier.srcAccessMask | VkAccessFlags.TransferRead;
+                    imageMemoryBarrier.srcAccessMask |= VkAccessFlags.TransferRead;
                     imageMemoryBarrier.dstAccessMask = VkAccessFlags.TransferRead;
                     break;
 
@@ -575,6 +591,8 @@ namespace CVKL {
                 0,IntPtr.Zero,
                 0, IntPtr.Zero,
                 1, ref imageMemoryBarrier);
+
+                       lastKnownLayout = newImageLayout;
         }
 
                public void BuildMipmaps (Queue copyQ, CommandPool copyCmdPool) {
@@ -594,7 +612,9 @@ namespace CVKL {
                        cmd.Free ();
                }
                public void BuildMipmaps (CommandBuffer cmd) {
+
                        VkImageSubresourceRange mipSubRange = new VkImageSubresourceRange (VkImageAspectFlags.Color, 0, 1, 0, info.arrayLayers);
+                       SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.TransferDstOptimal);
 
                        for (int i = 1; i < info.mipLevels; i++) {
                                VkImageBlit imageBlit = new VkImageBlit {
@@ -609,6 +629,8 @@ namespace CVKL {
                                vkCmdBlitImage (cmd.Handle, handle, VkImageLayout.TransferSrcOptimal, handle, VkImageLayout.TransferDstOptimal, 1, ref imageBlit, VkFilter.Linear);
                                mipSubRange.baseMipLevel = (uint)i;
                        }
+                       SetLayout (cmd, VkImageLayout.TransferDstOptimal, VkImageLayout.TransferSrcOptimal, mipSubRange,
+                                       VkPipelineStageFlags.Transfer, VkPipelineStageFlags.Transfer);
                        SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.TransferSrcOptimal, VkImageLayout.ShaderReadOnlyOptimal,
                                        VkPipelineStageFlags.Transfer, VkPipelineStageFlags.FragmentShader);
                }
index d8a06d3b0dbb915532ffd6a39b801b2fd165a5e2..2807ed2ed647e9b182d14c8d84e3b3c3e0953cdd 100644 (file)
@@ -29,7 +29,7 @@ using System.Runtime.InteropServices;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Vulkan Instance disposable class
        /// </summary>
index 265c6fa899900510b01115353dac56fff90cc500..289a6292d09eb4328bd7ecdbe300a7bd5c4746f3 100644 (file)
@@ -31,7 +31,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
 
-namespace CVKL {
+namespace vke {
     public class PhysicalDeviceCollection : IEnumerable<PhysicalDevice> {
         VkInstance inst;
         PhysicalDevice[] phys;
index 3e6eac3dfa8f2ef8ea055ef024cce8b1c79426d0..bb67cbc856c9c653abe1b012a8e6671fbe6c536d 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        public abstract class Pipeline : Activable {
         protected VkPipeline handle;
                protected PipelineLayout layout;
index c1396961aed07b2a222f97aa0e3205f1318b845c..40fae4ee58597a59878cda8aa0e3f2c9215fed2f 100644 (file)
@@ -32,7 +32,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        /// <summary>
        /// Activable holding the pipeline cache handle. Activation is triggered by usage, so disposing pipelines that use this
        /// cache is enough to have the cache disposed correctly. 
index 1c59f9077a1a1537dda1276e2af50ffd89271df7..f864a1bdd4de57cde56ba6f74241f4640c095fa8 100644 (file)
@@ -29,7 +29,7 @@ using System.Linq;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        public sealed class PipelineLayout : Activable {
         internal VkPipelineLayout handle;
                public VkPipelineLayout Handle => handle;
index 1d951741cbdb9242064fc3dcaeafd070070d1b9f..256e780c1c32627b09eee1d455cb3bce4ffadf1e 100644 (file)
@@ -28,7 +28,7 @@ using System.Collections.Generic;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        public class TimestampQueryPool : QueryPool {
                public readonly float Period;
 
index 93444aeb75d105e8b9e220faebbdbcae609270c8..a3a3fd276a740f513aff0421f04325fba4f860fa 100644 (file)
@@ -29,7 +29,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
 
     public class PresentQueue : Queue {
         public readonly VkSurfaceKHR Surface;
index c5662f96d8cb68e096c018308ea133a5d2cbeae2..48c3278611876e4de5f4316b2d21d7ccb36a41f9 100644 (file)
 // THE SOFTWARE.
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public class RenderPass : Activable {
         internal VkRenderPass handle;        
 
@@ -208,13 +209,13 @@ namespace CVKL {
         /// <summary>
         /// Begin Render pass with framebuffer extent dimensions
         /// </summary>
-        public void Begin (CommandBuffer cmd, Framebuffer frameBuffer) {
+        public void Begin (CommandBuffer cmd, FrameBuffer frameBuffer) {
             Begin (cmd, frameBuffer, frameBuffer.Width, frameBuffer.Height);
         }
         /// <summary>
         /// Begin Render pass with custom render area
         /// </summary>
-        public void Begin (CommandBuffer cmd, Framebuffer frameBuffer, uint width, uint height) {
+        public void Begin (CommandBuffer cmd, FrameBuffer frameBuffer, uint width, uint height) {
 
             VkRenderPassBeginInfo info = VkRenderPassBeginInfo.New();
             info.renderPass = handle;
@@ -238,6 +239,24 @@ namespace CVKL {
             vkCmdEndRenderPass (cmd.Handle);
         }
 
+               public FrameBuffers CreateFrameBuffers (SwapChain swapChain) {
+                       FrameBuffers fbs = new FrameBuffers();
+                       Image[] images = new Image[attachments.Count];
+
+                       int presentableImgIdx = attachments.IndexOf(attachments.FirstOrDefault(a => a.finalLayout == VkImageLayout.PresentSrcKHR || a.finalLayout == VkImageLayout.SharedPresentKHR));
+
+                       if (presentableImgIdx<0)
+                               throw new Exception("RenderPass used in Pipeline has no presentable attachment");
+
+                       for (int i = 0; i < swapChain.ImageCount; ++i)
+                       {
+                               images[presentableImgIdx] = swapChain.images[i];
+                               fbs.Add(new FrameBuffer(this, swapChain.Width, swapChain.Height, images));
+                       }
+                       return fbs;
+               }
+       
+
                public override string ToString () {
                        return string.Format ($"{base.ToString ()}[0x{handle.Handle.ToString("x")}]");
                }
index f5b4c8778c4154fbcda72332977490f9d04ed6dd..89552eeb4b572cfa6fd6cdafa53fa21d61b052f5 100644 (file)
@@ -6,7 +6,7 @@ using VK;
 
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
        [DebuggerDisplay ("{previous.name} <- {name} -> {next.name}")]
        public abstract class Resource : Activable {
                protected VkMemoryRequirements memReqs;
@@ -24,6 +24,7 @@ namespace CVKL {
                public ulong AllocatedDeviceMemorySize => memReqs.size;
                public uint TypeBits => memReqs.memoryTypeBits;
                public ulong MemoryAlignment => memReqs.alignment;
+               public abstract bool IsLinar { get; }
 
                protected IntPtr mappedData;
                public IntPtr MappedData => mappedData;
index 2396cdb94097bed436a8d592c0edded634f3a098..4a490e004d7b8046ace503657b3ed12db0832166 100644 (file)
@@ -26,7 +26,7 @@
 using System.Collections.Generic;
 using VK;
 
-namespace CVKL {
+namespace vke {
        public class SubPass {
                public uint Index { get; internal set; }
                List<VkAttachmentReference> colorRefs = new List<VkAttachmentReference>();
index f5190551937bb7ea0c55bc7f6dca00dbb65a7df3..9c2bea71237c527ac0108f0eb395eea1e77592f4 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using VK;
 using static VK.Vk;
 
-namespace CVKL {
+namespace vke {
     public class SwapChain : Activable {
                /// <summary>
                /// Set the default swapchain image format.
@@ -158,7 +158,7 @@ namespace CVKL {
             return (int)currentImageIndex;
         }
 
-        void _destroy () {
+               void _destroy () {
             for (int i = 0; i < ImageCount; i++) 
                 images[i].Dispose ();
 
index 4ea7c41a2eb2fdc06693833e62ea58f154375d26..2d6271c1766d93c3c2e561a4a23c810f63737ece 100644 (file)
@@ -5,7 +5,7 @@ using System;
 using System.IO;
 
 using VK;
-using CVKL;
+using vke;
 using System.Runtime.InteropServices;
 using System.Collections.Generic;
 
@@ -93,9 +93,13 @@ namespace KTX {
                                                
                                        byte[] keyValueDatas = br.ReadBytes ((int)bytesOfKeyValueData);
 
+                                       uint blockW, blockH;
+                                       bool isCompressed = vkFormat.TryGetCompressedFormatBlockSize (out blockW, out blockH);
+                                       uint blockSize = blockW * blockH;
 
                                        if (memoryProperty.HasFlag (VkMemoryPropertyFlags.DeviceLocal)) {
-                                               ulong staggingSize = (ulong)ktxStream.Length;//img.AllocatedDeviceMemorySize;
+                                               ulong staggingSize = (ulong)ktxStream.Length + 256;//img.AllocatedDeviceMemorySize;
+                                               Console.WriteLine ($"KtxStream size = {ktxStream.Length}, img Allocation = {img.AllocatedDeviceMemorySize}");
 
                                                using (HostBuffer stagging = new HostBuffer (staggingQ.Dev, VkBufferUsageFlags.TransferSrc, staggingSize)) {
                                                        stagging.Map ();
@@ -119,14 +123,20 @@ namespace KTX {
                                                        for (int mips = 0; mips < numberOfMipmapLevels; mips++) {
                                                                UInt32 imgSize = br.ReadUInt32 ();
 
-                                                               bufferCopyRegion.bufferImageHeight = imgHeight;
                                                                bufferCopyRegion.bufferRowLength = imgWidth;
+                                                               bufferCopyRegion.bufferImageHeight = imgHeight;
+
+                                                               if (isCompressed && (imgWidth % blockW > 0 || imgHeight % blockH > 0)) {
+                                                                       bufferCopyRegion.bufferRowLength += blockW -  imgWidth % blockW;
+                                                                       bufferCopyRegion.bufferImageHeight += blockH - imgHeight % blockH;
+                                                               }
                                                                bufferCopyRegion.bufferOffset = bufferOffset;
                                                                bufferCopyRegion.imageSubresource.mipLevel = (uint)mips;
                                                                bufferCopyRegion.imageExtent.width = imgWidth;
                                                                bufferCopyRegion.imageExtent.height = imgHeight;
 
                                                                if (createFlags.HasFlag (VkImageCreateFlags.CubeCompatible)) {
+                                                                       //TODO:handle compressed formats
                                                                        for (uint face = 0; face < numberOfFaces; face++) {
                                                                                Marshal.Copy (br.ReadBytes ((int)imgSize), 0, stagging.MappedData + (int)bufferOffset, (int)imgSize);
                                                                                uint faceOffset = imgSize + (imgSize % 4);//cube padding                                                                                                                                                                  
@@ -134,12 +144,22 @@ namespace KTX {
                                                                        }
                                                                        buffCopies.Add (bufferCopyRegion);
                                                                        bufferCopyRegion.bufferOffset = bufferOffset;
+                                                               } else if (isCompressed && (imgWidth % blockW > 0 || imgHeight % blockH > 0)) {
+                                                                       for (int line = 0; line < imgHeight; line++) {
+                                                                               Marshal.Copy (br.ReadBytes ((int)imgWidth), 0, stagging.MappedData + (int)bufferOffset, (int)imgWidth);
+                                                                               bufferOffset += bufferCopyRegion.bufferRowLength;
+                                                                       }
+                                                                       buffCopies.Add (bufferCopyRegion);
                                                                } else {
+
                                                                        Marshal.Copy (br.ReadBytes ((int)imgSize), 0, stagging.MappedData + (int)bufferOffset, (int)imgSize);
                                                                        buffCopies.Add (bufferCopyRegion);
                                                                        bufferOffset += imgSize;
                                                                }
 
+                                                               if (isCompressed && bufferOffset % blockSize > 0) 
+                                                                       bufferOffset += blockSize - bufferOffset % blockSize;
+
                                                                imgWidth /= 2;
                                                                imgHeight /= 2;
                                                        }
index 07747c8ba53690cd277769db542bdb0aa65d54b3..a03eb4d574b5caadce5c651337375d1a08a67568 100644 (file)
@@ -26,7 +26,7 @@
 // THE SOFTWARE.
 using System.Numerics;
 /* code derived from https://github.com/mellinoe*/
-namespace CVKL {
+namespace vke {
        public struct BoundingBox {
                public Vector3 min;
                public Vector3 max;
index 0bc56e894fb1d399451106cb57943da1d93d5b7d..6b7d0f1b5bbfa4f8bd202549dc2510318b7a22fb 100644 (file)
@@ -28,7 +28,7 @@ using System.Collections.Generic;
 using System.Numerics;
 using VK;
 
-namespace CVKL {
+namespace vke {
 
        public enum AlphaMode : UInt32 {
                Opaque,
index 8c4ca40c4ec841909f67b03bd800ab631a851ffb..d4b65630470975d686b33ddfa093b4effd0090c6 100644 (file)
@@ -1,17 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
+    <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
+               
                <ReleaseVersion>0.1.7</ReleaseVersion>          
                <AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
                <Description>C# vulkan library with IDispose model and references counting</Description>                
+               <RepositoryUrl>https://github.com/jpbruyere/vke.net</RepositoryUrl>
                <PackageTags>vulkan game engine compute glfw c#</PackageTags>
-               <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
+               <PackageVersion>$(AssemblyVersion)</PackageVersion>
                <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
                <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
                <PackageProjectUrl>https://github.com/jpbruyere/vke.net/blob/master/README.md</PackageProjectUrl>
                <License>MIT</License>
-               <PackageReleaseNotes>
-                       
+               <Authors>Jean-Philippe Bruyère</Authors>
+               <PackageReleaseNotes>                   
                </PackageReleaseNotes>
                <!--<PackageIconUrl>https://github.com/KhronosGroup/glTF/blob/master/specification/figures/gltf.png</PackageIconUrl>-->
                <SynchReleaseVersion>false</SynchReleaseVersion>
@@ -22,6 +25,7 @@
                <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
                
                <EnableDefaultNoneItems>false</EnableDefaultNoneItems>          
+    <LangVersion>7.2</LangVersion>
        </PropertyGroup>
        
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -49,6 +53,6 @@
                <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">
                        <ResourceId>testRsID</ResourceId>
                </GLSLShader>
-               <Compile Remove="Properties\AssemblyInfo.cs;src\Renderer.cs;src\QueueFamily.cs" />
+               <Compile Remove="build\**\*.cs;Properties\AssemblyInfo.cs;src\Renderer.cs;src\QueueFamily.cs" />
        </ItemGroup>
 </Project>