"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",
],
"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",
<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 |
| :------------------------------------------: | :------------------------------------------------: |
| [Textured](samples/Textured/README.md) |  |
-### Features
+# Features
- physicaly based rendering, direct and deferred
- glTF 2.0
<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>
-### 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 ();
}
+ }
}
```
-### 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.
```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
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.
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.
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
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);
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){}
}
/// 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>();
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
<ReleaseVersion>$(VkeReleaseVersion)</ReleaseVersion>
<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>