]> O.S.I.I.S - jp/vke.net.git/commitdiff
netcoreapp3.0 support, update docs v0.2.2-beta
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 4 Nov 2021 08:52:14 +0000 (09:52 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 4 Nov 2021 08:52:14 +0000 (09:52 +0100)
.vscode/launch.json
.vscode/tasks.json
README.md
addons/Directory.Build.props
samples/ClearScreen/README.md
samples/Triangle/README.md
samples/Triangle/shaders/main.frag
samples/Triangle/shaders/main.vert
samples/common/SampleBase.cs
vke/src/VkWindow.cs
vke/vke.csproj

index a933a8992f37f392098a511c6f2f0ed291ad5400..ec51fd35e2ee536755d15e98d3a9273f15f10815 100644 (file)
                        "stopAtEntry": false,
                        "console": "internalConsole"
                },
+               {
+                       "name": ".NET Core Launch (DistanceFieldFontTest)",
+                       "type": "coreclr",
+                       "request": "launch",
+                       "preLaunchTask": "build DistanceFieldFontTest",
+                       "program": "${workspaceFolder}/build/Debug/netcoreapp3.1/DistanceFieldFontTest",
+                       "args": [],
+                       "cwd": "${workspaceFolder}/build/Debug/netcoreapp3.1/",
+                       "console": "internalConsole",
+                       "stopAtEntry": false
+               },
                {
                        "name": ".NET Core Launch (ImmutableSampler)",
                        "type": "coreclr",
index 8aa8d5a247cd789b0fb3b7194bc81ad3f00123b6..95eda6a00efa1f9527829cf8bb610f8c7697b39d 100644 (file)
                        ],
                        "problemMatcher": "$msCompile"
                },
+               {
+                       "label": "build DistanceFieldFontTest",
+                       "command": "dotnet",
+                       "type": "process",
+                       "args": [
+                               "build",
+                               "${workspaceFolder}/samples/DistanceFieldFontTest/DistanceFieldFontTest.csproj",
+                               "/property:GenerateFullPaths=true",
+                               "/property:SolutionDir=${workspaceFolder}/",
+                               "/property:Configuration=Debug",
+                               "/consoleloggerparameters:NoSummary"
+                       ],
+                       "problemMatcher": "$msCompile"
+               },
                {
                        "label": "build immutableSampler",
                        "command": "dotnet",
index 986c08192de7b9c6ff8df4543ee0d949d0836e17..8808a458730208b771826b98fc87559015cf3e6a 100644 (file)
--- a/README.md
+++ b/README.md
    <br>adaptation of the gltf PBR sample from Sacha Willems</br>
 </p>
 
-### Presentation
-**vke.net** (_vulkan engine for .net_) is a vulkan abstraction layer writen in **c#** composed of high level classes encapsulating [vulkan](https://www.khronos.org/vulkan/) objects and commands with `IDispose` model and **reference counting**. [GLFW](https://www.glfw.org/)  handles the default windowing system.
+# Presentation
+`vke.net` (_vulkan engine for .net_) is a vulkan abstraction layer writen in **c#** composed of high level classes encapsulating [vulkan](https://www.khronos.org/vulkan/) objects and commands with `IDispose` model and **reference counting**.
 
-vke aims to provide a simple api for all common vulkan tasks, ideal to quickly prototype vulkan applications, but fits also the needs to build complete application or game.
+`vke.net` use autogenerated [vk.net](https://github.com/jpbruyere/vk.net) library for low level binding to vulkan and [GLFW](https://www.glfw.org/) handles the default windowing system.
 
-To see **vke.net** in action check [vkChess.net](https://github.com/jpbruyere/vkChess.net).
+`vke.net` aims to provide a simple api for all common vulkan tasks, ideal to quickly prototype vulkan applications, but fits also the needs to build complete application or game.
 
-Vke use autogenerated [vk.net](https://github.com/jpbruyere/vk.net) library for low level binding to vulkan.
+To see `vke.net` in action check [vkChess.net](https://github.com/jpbruyere/vkChess.net), and to start a vulkan application with an integrated [GUI](https://github.com/jpbruyere/Crow), start with [VkCrowWindow](https://github.com/jpbruyere/VkCrowWindow).
 
 Use the `download_datas.sh` script for downloading sample's datas.
 
-vke is in early development stage.
+vke is in beta development stage.
 
-### Requirements
+# Requirements
 - [GLFW](https://www.glfw.org/) if you use the `VkWindow` class.
 - [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).
 
-### Quick Start
+`vke.net` supports `netcoreapp3.0`.
 
-Create a new dotnet console project, and add the [vke nuget package](https://www.nuget.org/packages/vke) to it.
 
-```xml
-<Project Sdk="Microsoft.NET.Sdk">
-  <TargetFrameworks>net472</TargetFrameworks>
-  <OutputType>Exe</OutputType>
-
-  <ItemGroup>
-    <PackageReference Include="vke" />
-  </ItemGroup>
-</Project>
-```
-For automatic shader compilation to SpirV, add also the [SpirVTasks](SpirVTasks/README.md) nuget package.
-
-```xml
-<ItemGroup>
-  <PackageReference Include="SpirVTasks" />
-    <GLSLShader Include="shaders\*.*" />
-</ItemGroup>
-```
-### Samples
+# Tutorials
 
 |                    Title                     |                    Screen shots                    |
 | :------------------------------------------: | :------------------------------------------------: |
@@ -73,7 +53,7 @@ For automatic shader compilation to SpirV, add also the [SpirVTasks](SpirVTasks/
 |    [Textured](samples/Textured/README.md)    |  ![screenshot](samples/screenShots/Textured.png)   |
 
 
-### Features
+# Features
 
 - physicaly based rendering, direct and deferred
 - glTF 2.0
index b0ee5f7afe39f01c41e61e73558334a329c93f4d..db6cad18a6ebc8539bcecf2099c6845c96f6ee33 100644 (file)
@@ -4,7 +4,7 @@
                <RootDirectory>$(MSBuildThisFileDirectory)../</RootDirectory>
                <Deterministic>true</Deterministic>
 
-               <TargetFrameworks>netstandard2.0</TargetFrameworks>
+               <TargetFrameworks>netcoreapp3.0</TargetFrameworks>
 
                <RepositoryUrl>https://github.com/jpbruyere/vke.net</RepositoryUrl>
                <PackageLicenseExpression>MIT</PackageLicenseExpression>
index b9f623fc8adfad47d8a65e618d351e3d46702f47..3eeab4d804a50ef7703980910d95ae197747eeb1 100644 (file)
@@ -1,34 +1,30 @@
-### The Project File.
-
-To build a minimal vulkan application, add the [vke](https://www.nuget.org/packages/vke/) nuget package, and to enable automatic shader compilation, add the [SpirVTasks](https://www.nuget.org/packages/SpirVTasks/) package and a generic **GLSLShader** item globing a full directory.
+# The Project File.
+Create a new dotnet console project, and add the [vke nuget package](https://www.nuget.org/packages/vke) to it.
 
 ```xml
 <Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <TargetFrameworks>net472</TargetFrameworks>
-    <OutputType>Exe</OutputType>
-  </PropertyGroup>
-  <ItemGroup>
-    <GLSLShader Include="shaders\*.*" />
-  </ItemGroup>
+  <TargetFrameworks>netcoreapp3.1</TargetFrameworks>
+  <OutputType>Exe</OutputType>
+
   <ItemGroup>
-    <PackageReference Include="SpirVTasks" />
     <PackageReference Include="vke" />
   </ItemGroup>
 </Project>
 ```
-
-### VkWindow class
+# VkWindow class
 
 **vke** use [GLFW](https://www.glfw.org/) to interface with the windowing system of the OS. Derive your application from the `VkWindow` base class to start with a vulkan enabled window. **Validation** and **RenderDoc** layers loading may be control at startup with public static boolean properties from the `Instance`class.
 
 ```csharp
 class Program : VkWindow {
-    static void Main (string[] args) {
-       using (Program vke = new Program ()) {
-               vke.Run ();
-       }
+  static void Main (string[] args) {
+
+    Instance.Validation = true;
+
+    using (Program vke = new Program ()) {
+      vke.Run ();
     }
+  }
 }
 ```
 
index d9343df0410cb18bcfe9f30a4438e72df483455a..d2bc07c5ff9fcc9f62d256c656a9e412adff3d3b 100644 (file)
@@ -1,4 +1,20 @@
-### Creating buffers
+# shaders
+For this tutorials we'll need a `vertex` and a `fragment` shaders. Vulkan need them to be compiled into [SPIR-V](https://www.khronos.org/spir/). Install the [Vulkan Sdk](https://www.lunarg.com/vulkan-sdk/) and after building it, ensure the `VULKAN_SDK` environment variable points to its binary subdir.
+```bash
+export VULKAN_SDK=/VulkanSDK/1.2.176.1/x86_64
+```
+To enable automatic shader compilation during build, add the [SpirVTasks package](https://www.nuget.org/packages/SpirVTasks/) and a generic **GLSLShader** item globing a full directory.
+```xml
+<ItemGroup>
+  <PackageReference Include="SpirVTasks" />
+</ItemGroup>
+<ItemGroup>
+  <GLSLShader Include="shaders\*.*" />
+</ItemGroup>
+```
+See [SpirVTasks documentation](https://github.com/jpbruyere/vke.net/tree/master/SpirVTasks) for more informations.
+
+# Creating buffers
 
 Vke has two classes to handle buffers. Mappable [`HostBuffer`](../../../../wiki/vke.HostBuffer) and device only [`GPUBuffer`](../../../../wiki/vke.GPUBuffer).
 For this first simple example, we will only use host mappable buffers. Those classes can handle a Generic argument of a blittable type to handle arrays. Resources like buffers or images are activated in constructor, and they need to be explicitly disposed on cleanup. Create them in the `initVulkan` override.
@@ -16,7 +32,7 @@ To be able to access the mvp matrix in a shader, we need a descriptor. This impl
 ```csharp
 descriptorPool = new DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer));
 ```
-### Creating pipelines
+# Configuring pipelines
 
 Graphic pipeline configuration are predefined by the [`GraphicPipelineConfig`](../../../../wiki/vke.GraphicPipelineConfig) class, which ease sharing configs for several pipelines having lots in common. The pipeline layout will be automatically activated on pipeline creation, so that sharing layout among different pipelines will benefit from the reference counting to automatically dispose unused layout on pipeline clean up. It's the same for [`DescriptorSetLayout`](../../wiki/api/DescriptorSetLayout).
 ```csharp
@@ -38,24 +54,72 @@ cfg.AddVertexBinding<Vertex> (0);
 cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat,  //position
                             VkFormat.R32g32b32Sfloat);//color
 ```
-shader are automatically compiled by [`SpirVTasks`](../../SpirVTasks/README.md) if added to the project. The resulting shaders are automatically embedded in the assembly. To specifiy that the shader path is a resource name, put the **'#'** prefix. Else the path will be search on disk.
+# Adding the shaders
+Add both vertex and fragment shaders to the globbed directory of your `.csproj`
+
+##### triangle.vert
+```glsl
+#version 450
+
+#extension GL_ARB_separate_shader_objects : enable
+#extension GL_ARB_shading_language_420pack : enable
+
+layout (location = 0) in vec3 inPos;
+layout (location = 1) in vec3 inColor;
+
+layout (binding = 0) uniform UBO
+{
+       mat4 mvp;
+};
+
+layout (location = 0) out vec3 outColor;
+
+out gl_PerVertex
+{
+  vec4 gl_Position;
+};
+
+void main()
+{
+       outColor = inColor;
+       gl_Position = mvp * vec4(inPos.xyz, 1.0);
+}
+```
+##### triangle.frag
+```glsl
+#version 450
+
+#extension GL_ARB_separate_shader_objects : enable
+#extension GL_ARB_shading_language_420pack : enable
+
+layout (location = 0) in vec3 inColor;
+layout (location = 0) out vec4 outFragColor;
+
+void main()
+{
+  outFragColor = vec4(inColor, 1.0);
+}
+```
+
+Shaders will be compiled into spir-v automatically during build by the `SpirVTasks`. The resulting shaders will be embedded in the assembly. To specifiy that the shader path is a resource name, put the '**`#`**' prefix. Else the path will be search on disk.
 ```csharp
-cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#shaders.main.vert.spv");
-cfg.AddShader (dev, VkShaderStageFlags.Fragment, "#shaders.main.frag.spv");
+cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#shaders.triangle.vert.spv");
+cfg.AddShader (dev, VkShaderStageFlags.Fragment, "#shaders.triangle.frag.spv");
 ```
-Because native ShaderModule used during pipeline creation may be disposed once the pipeline is created, The PipelineConfig class implement the
+Because native ShaderModule used during pipeline creation may be distroyed once the pipeline is created, The PipelineConfig class implement the
 'IDisposable' interface to release those pointers automaticaly.
 
-Once the pipeline configuration is complete, we use it to effectively create and activate a graphic pipeline. Activables used by the pipeline (like the RenderPass, or the PipelineLayout) are referenced in the newly created managed pipeline. So the Configuration object doesn't need cleanup.
+# Creating the pipeline
+Once the pipeline configuration is complete, we use it to effectively create and activate a new graphic pipeline. Activables used by the pipeline (like the RenderPass, or the PipelineLayout) are referenced in the newly created managed pipeline. So the Configuration object doesn't need cleanup.
 ```csharp
        pipeline = new GraphicPipeline (cfg);
 ```
+# Descriptor allocation
 Because descriptor layouts used for a pipeline are only activated on pipeline activation, descriptor sets must not be allocated before, except if the layout has been manually activated, but in this case, layouts will also need to be explicitly disposed.
 ```csharp
        descriptorSet = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]);
 ```
-
-### Descriptor update
+# Descriptor update
 
 The descriptor update is a two step operation. First we create a [`DescriptorSetWrites`](../../../../wiki/vke.DescriptorSetWrites) object defining the layout(s), than we write the descriptor(s).
 The `Descriptor` property of the mvp HostBuffer will return a default descriptor with no offset of the full size of the buffer.
@@ -67,7 +131,7 @@ DescriptorSetWrites uboUpdate =
 uboUpdate.Write (dev, uboMats.Descriptor);
 ```
 
-### Updating the view
+# Updating the view
 
 Override the `UpdateView` method of the `VkWindow` class to update view related stuff like matrices.
 
index a3cafac5cda8e14103a15bc8225161d875a773f7..85aeb08e00446b2cb0ab6c574c51e0c1084b363b 100644 (file)
@@ -6,7 +6,7 @@
 layout (location = 0) in vec3 inColor;
 layout (location = 0) out vec4 outFragColor;
 
-void main() 
+void main()
 {
-    outFragColor = vec4(inColor, 1.0);
+  outFragColor = vec4(inColor, 1.0);
 }
\ No newline at end of file
index 0997ca9a68fbde500ac5d2f5c953260f0ea44876..40a3796d9565412a37e3a72a584f2c27006913c0 100644 (file)
@@ -6,20 +6,20 @@
 layout (location = 0) in vec3 inPos;
 layout (location = 1) in vec3 inColor;
 
-layout (binding = 0) uniform UBO 
+layout (binding = 0) uniform UBO
 {
        mat4 mvp;
 };
 
 layout (location = 0) out vec3 outColor;
 
-out gl_PerVertex 
+out gl_PerVertex
 {
-    vec4 gl_Position;   
+    vec4 gl_Position;
 };
 
 
-void main() 
+void main()
 {
        outColor = inColor;
        gl_Position = mvp * vec4(inPos.xyz, 1.0);
index 32120d94d5677a4a1bffdbeff01646e04d129301..76a85f3fc4b1c5e6ee58b29b7838c6fb61aed785 100644 (file)
@@ -7,24 +7,6 @@ using System.Runtime.InteropServices;
 
 namespace vke {
        public abstract class SampleBase : VkWindow {
-#if NETCOREAPP         
-               static IntPtr resolveUnmanaged (Assembly assembly, String libraryName) {
-                       
-                       switch (libraryName)
-                       {
-                               case "glfw3":
-                                       return  NativeLibrary.Load("glfw", assembly, null);
-                               case "rsvg-2.40":
-                                       return  NativeLibrary.Load("rsvg-2", assembly, null);
-                       }
-                       Console.WriteLine ($"[UNRESOLVE] {assembly} {libraryName}");                    
-                       return IntPtr.Zero;
-               }
-
-               static SampleBase () {
-                       System.Runtime.Loader.AssemblyLoadContext.Default.ResolvingUnmanagedDll+=resolveUnmanaged;
-               }
-#endif
                public SampleBase (string name = "VkWindow", uint _width = 800, uint _height = 600, bool vSync = true) :
                        base (name, _width, _height, vSync){}
        }
index bd92295c0876044c852e1f06c091908abafd2fa5..6071969b4267e212935a46e04e793d427dde7d44 100644 (file)
@@ -16,7 +16,6 @@ namespace vke {
        /// Provide default swapchain with its command pool and buffers per image and the main present queue
        /// </summary>
        public abstract class VkWindow : IDisposable {
-
                /** GLFW callback may return a custom pointer, this list makes the link between the GLFW window pointer and the
                        manage VkWindow instance. */
                static Dictionary<IntPtr,VkWindow> windows = new Dictionary<IntPtr, VkWindow>();
index 19434e5900dc0af666e675d3066dfb480b64fef9..4b624b8e631b07624e809b2ab49bee8752fc3061 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
 
                <ReleaseVersion>$(VkeReleaseVersion)</ReleaseVersion>
 
@@ -50,7 +50,7 @@
                <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
                <PackageReference Include="Vulkan" Version="0.2.4" />
                <PackageReference Include="shaderc.net" Version="0.1.0" />
-               <PackageReference Include="glfw-sharp" Version="0.2.12-beta" />
+               <PackageReference Include="glfw-sharp" Version="0.2.14" />
        </ItemGroup>
 
        <ItemGroup>