+
language: csharp
-dist: bionic
-
-dotnet: 2.2.401-1
-mono: latest
+
+dist: xenial
+
+dotnet: 3.1
+
+env:
+ - FrameworkPathOverride=/usr/lib/mono/4.5/
before_install:
- wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
- - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.1.121-bionic.list http://packages.lunarg.com/vulkan/1.1.121/lunarg-vulkan-1.1.121-bionic.list
- - sudo apt update
+ - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-xenial.list https://packages.lunarg.com/vulkan/lunarg-vulkan-xenial.list
+ - sudo apt -qq update
- sudo apt install vulkan-sdk
script:
- - msbuild /t:restore
- - msbuild
+ - dotnet build /p:Configuration=ReleaseSpirVTasks
+ - dotnet build /p:Configuration=Release
--- /dev/null
+<Project>
+ <PropertyGroup>
+ <RootDirectory>$(MSBuildThisFileDirectory)</RootDirectory>
+ <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
+ <SpirVTasksReleaseVersion>0.1.41</SpirVTasksReleaseVersion>
+ <SpirVTasksPackageVersion>$(SpirVTasksReleaseVersion)-beta</SpirVTasksPackageVersion>
+ </PropertyGroup>
+</Project>
<h1 align="center">
-vke.net
- <br>
+ vke.net
+ <br>
+ Vulkan Engine for .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">
+ <img src="https://img.shields.io/appveyor/ci/jpbruyere/vke-net?label=Windows&logo=appveyor&logoColor=lightgrey">
</a>
<a href="https://www.paypal.me/GrandTetraSoftware">
<img src="https://img.shields.io/badge/Donate-PayPal-green.svg">
<br>adaptation of the gltf PBR sample from Sacha Willems</br>
</p>
-**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.
+**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.
+
+
Use the 'download_datas.sh' script for downloading sample's datas.
/// Use the SpirVCompilerPath element if present. if not search 'VULKAN_SDK' environment, then PATH env variable.
/// </summary>
bool tryFindGlslcExecutable (out string glslcPath) {
+ glslcPath = "";
if (!string.IsNullOrEmpty (SpirVCompilerPath?.ItemSpec)) {
glslcPath = SpirVCompilerPath.ItemSpec;
if (!File.Exists (glslcPath))
if (Environment.OSVersion.Platform.ToString ().StartsWith ("Win", StringComparison.Ordinal))
glslcExec = glslcExec + ".exe";
- glslcPath = Path.Combine (Environment.GetEnvironmentVariable ("VULKAN_SDK"), "bin");
- glslcPath = Path.Combine (glslcPath, glslcExec);
- if (File.Exists (glslcPath))
- return true;
+ string vkSdk = Environment.GetEnvironmentVariable ("VULKAN_SDK");
+ if (!string.IsNullOrEmpty (vkSdk)) {
+ glslcPath = Path.Combine (vkSdk, "bin");
+ glslcPath = Path.Combine (glslcPath, glslcExec);
+ if (File.Exists (glslcPath))
+ return true;
+ }
string envStrPathes = Environment.GetEnvironmentVariable ("PATH");
if (!string.IsNullOrEmpty (envStrPathes)) {
- foreach (string path in envStrPathes.Split (';')) {
+ foreach (string path in envStrPathes.Split (':')) {
glslcPath = Path.Combine (path, glslcExec);
if (File.Exists (glslcPath))
return true;
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
+ <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
- <ReleaseVersion>0.1.38</ReleaseVersion>
+ <ReleaseVersion>$(SpirVTasksReleaseVersion)</ReleaseVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
<Description>MSBuild addon to compile and embed spirV shaders</Description>
<PackageId>SpirVTasks</PackageId>
<PackageTags>vulkan msbuild spirv glsl addons</PackageTags>
- <PackageVersion>$(ReleaseVersion)-beta</PackageVersion>
+ <PackageVersion>$(SpirVTasksPackageVersion)</PackageVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/jpbruyere/vk.net/blob/master/SpirVTasks/README.md</PackageProjectUrl>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
<AssemblyName>SpirVTasks_$(TargetFramework)</AssemblyName>
+
+ <RestoreIgnoreFailedSource>true</RestoreIgnoreFailedSource>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
<Project>
+ <Import Project="../Directory.Build.props" />
<PropertyGroup>
<RootDirectory>$(MSBuildThisFileDirectory)../</RootDirectory>
<Deterministic>true</Deterministic>
<LangVersion>7.2</LangVersion>
<SpirVAdditionalIncludeDirectories>$(MSBuildThisFileDirectory)common\shaders</SpirVAdditionalIncludeDirectories>
-
+
+ <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</ItemGroup>
<ItemGroup>
- <PackageReference Include="SpirVTasks" Version="0.1.38-beta" />
+ <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>
-version: 1.0.{build}
-image: Visual Studio 2019
+version: 0.1.{build}
-environment:
- VULKAN_SDK: C:/VulkanSDK/1.1.130.0
- APPVEYOR_SAVE_CACHE_ON_ERROR: true
+image:
+ - Visual Studio 2019
+ - Ubuntu
-cache:
- - VulkanSDK.exe
- - c:\VulkanSDK\
-
-install:
- - if not exist VulkanSDK.exe curl -L --silent --show-error --output VulkanSDK.exe https://vulkan.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true && VulkanSDK.exe /S
-
-before_build:
- - nuget restore
build:
verbosity: minimal
+
+for:
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2019
+ environment:
+ VULKAN_SDK: C:/VulkanSDK/1.1.130.0
+ APPVEYOR_SAVE_CACHE_ON_ERROR: true
+ cache:
+ - VulkanSDK.exe
+ - c:\VulkanSDK\
+ install:
+ - if not exist VulkanSDK.exe curl -L --silent --show-error --output VulkanSDK.exe https://vulkan.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true && VulkanSDK.exe /S
+ build_script:
+ - msbuild /p:Configuration=ReleaseSpirVTasks /t:restore
+ - msbuild /p:Configuration=ReleaseSpirVTasks
+ - msbuild /p:Configuration=Release /t:restore
+ - msbuild /p:Configuration=Release
+
+ -
+ matrix:
+ only:
+ - image: Ubuntu
+ environment:
+ FrameworkPathOverride: /usr/lib/mono/4.5/
+ install:
+ - wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
+ - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-bionic.list https://packages.lunarg.com/vulkan/lunarg-vulkan-bionic.list
+ - sudo apt -qq update
+ - sudo apt -y install vulkan-sdk
+ - glslc --version
+ build_script:
+ - dotnet build /p:Configuration=ReleaseSpirVTasks
+ - dotnet build /p:Configuration=Release
+
+++ /dev/null
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
- <!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
- <TargetIsMono Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">true</TargetIsMono>
-
- <!-- Look in the standard install locations -->
- <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
- <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
- <BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
-
- <!-- If we found Mono reference assemblies, then use them -->
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
- <FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
- <EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
-
- <!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
- <AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
- </PropertyGroup>
-</Project>
-
<Project>
+ <Import Project="../Directory.Build.props" />
<PropertyGroup>
<RootDirectory>$(MSBuildThisFileDirectory)../</RootDirectory>
<Deterministic>true</Deterministic>
<IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>
<SpirVAdditionalIncludeDirectories>$(MSBuildThisFileDirectory)common\shaders</SpirVAdditionalIncludeDirectories>
-
+
+ <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</ItemGroup>
<ItemGroup>
- <PackageReference Include="SpirVTasks" Version="0.1.38-beta" />
+ <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
</ItemGroup>
<ItemGroup>
Vector4 textColor = new Vector4 (1.0f, 1.0f, 0.0f, 1.0f);//alpha => 0:disabled 1:enabled
Vector4 outlineColor = new Vector4 (1.0f, 0.0f, 0.0f, 0.6f);//alpha => 0:disabled 1:enabled
- Program () : base () {
+ protected override void initVulkan () {
+ base.initVulkan ();
+
cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
font = new BMFont (Utils.DataDirectory + "font.fnt");
float rotX, rotY, rotZ = 0f, zoom = 2f;
SimpleModel helmet;
- vke.DebugUtils.Messenger dbgmsg;
- Program () : base () {
+ protected override void initVulkan () {
+ base.initVulkan ();
+
cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
descriptorPool = new DescriptorPool (dev, 2,
frameBuffers?.Dispose();
descriptorPool.Dispose ();
uboMats.Dispose ();
- dbgmsg?.Dispose ();
}
}
using Vulkan;
namespace Textured {
+ /// <summary>
+ /// Simple textured quad sample
+ /// </summary>
class Program : VkWindow {
static void Main (string[] args) {
#if DEBUG
Instance.VALIDATION = true;
Instance.RENDER_DOC_CAPTURE = true;
#endif
-
- foreach (string s in System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceNames ())
- Console.WriteLine (s);
-
using (Program vke = new Program ()) {
vke.Run ();
}
Utils.DataDirectory + "font.ktx",
};
- Program () : base () {
+ protected override void initVulkan () {
+ base.initVulkan ();
+
cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
loadTexture (imgPathes[currentImgIndex]);
dev.WaitIdle ();
cmdPool.Reset();
for (int i = 0; i < swapChain.ImageCount; ++i) {
- cmds[i].Start();
- recordDraw (cmds[i], frameBuffers[i]);
- cmds[i].End ();
- }
- }
- void recordDraw (CommandBuffer cmd, FrameBuffer fb) {
- pipeline.RenderPass.Begin (cmd, fb);
+ CommandBuffer cmd = cmds[i];
+ FrameBuffer fb = frameBuffers[i];
+
+ cmd.Start();
- cmd.SetViewport (fb.Width, fb.Height);
- cmd.SetScissor (fb.Width, fb.Height);
- cmd.BindDescriptorSet (pipeline.Layout, descriptorSet);
+ pipeline.RenderPass.Begin (cmd, fb);
- pipeline.Bind (cmd);
+ cmd.SetViewport (fb.Width, fb.Height);
+ cmd.SetScissor (fb.Width, fb.Height);
+ cmd.BindDescriptorSet (pipeline.Layout, descriptorSet);
- cmd.BindVertexBuffer (vbo, 0);
- cmd.BindIndexBuffer (ibo, VkIndexType.Uint16);
- cmd.DrawIndexed ((uint)indices.Length);
+ pipeline.Bind (cmd);
- pipeline.RenderPass.End (cmd);
+ cmd.BindVertexBuffer (vbo, 0);
+ cmd.BindIndexBuffer (ibo, VkIndexType.Uint16);
+ cmd.DrawIndexed ((uint)indices.Length);
+
+ pipeline.RenderPass.End (cmd);
+
+ cmd.End ();
+ }
}
+
VkMemoryPropertyFlags imgProp = VkMemoryPropertyFlags.DeviceLocal;
bool genMipMaps = true;
VkImageTiling tiling = VkImageTiling.Optimal;
texture = nextTexture;
nextTexture = null;
}
+
void updateMatrices () {
matrices.projection = Matrix4x4.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (60f), (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f);
matrices.view = Matrix4x4.CreateTranslation (0, 0, -2.5f * zoom);
using Buffer = vke.Buffer;
namespace TextureCube {
+ /// <summary>
+ /// Simple textured cube sampled.
+ /// </summary>
class Program : VkWindow {
static void Main (string[] args) {
#if DEBUG
#endif
- Program () : base () {
- cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
+ protected override void initVulkan () {
+ base.initVulkan ();
+
+ cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount);
vbo = new GPUBuffer<float> (presentQueue, cmdPool, VkBufferUsageFlags.VertexBuffer, g_vertex_buffer_data);
if (nextTexture != null)
updateTextureSet ();
-
#if WITH_VKVG
dsVkvg = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]);
vkvgPipeline = new VkvgPipeline.VkvgPipeline (instance, dev, presentQueue, pipeline);
using Vulkan;
namespace Triangle {
- public class Renderer {
- public DescriptorPool descriptorPool;
- [XmlIgnore] public DescriptorSetLayout dsLayout;
- }
class Program : VkWindow {
static void Main (string[] args) {
-#if DEBUG
- Instance.VALIDATION = true;
- Instance.RENDER_DOC_CAPTURE = false;
-#endif
-
using (Program vke = new Program ()) {
vke.Run ();
}
}
- float rotSpeed = 0.01f, zoomSpeed = 0.01f;
+ const float rotSpeed = 0.01f, zoomSpeed = 0.01f;
float rotX, rotY, rotZ = 0f, zoom = 1f;
+ [StructLayout (LayoutKind.Sequential)]
struct Matrices {
public Matrix4x4 projection;
public Matrix4x4 view;
public Matrix4x4 model;
}
+
+ [StructLayout(LayoutKind.Sequential)]
struct Vertex {
Vector3 position;
Vector3 color;
HostBuffer vbo;
HostBuffer uboMats;
+ DescriptorPool descriptorPool;
DescriptorSet descriptorSet;
FrameBuffers frameBuffers;
};
ushort[] indices = new ushort[] { 0, 1, 2 };
+ Program () : base () {}
-
- public Renderer r = new Renderer ();
-
- Program () : base () {
- cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
+ protected override void initVulkan () {
+ base.initVulkan ();
vbo = new HostBuffer<Vertex> (dev, VkBufferUsageFlags.VertexBuffer, vertices);
ibo = new HostBuffer<ushort> (dev, VkBufferUsageFlags.IndexBuffer, indices);
uboMats = new HostBuffer (dev, VkBufferUsageFlags.UniformBuffer, matrices);
- r.descriptorPool = new DescriptorPool (dev, 1,
- new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer),
- new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler));
+ descriptorPool = new DescriptorPool (dev, 1, new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer));
- XmlSerializer serializer = new XmlSerializer (typeof(Renderer), Utils.GetXmlOverrides());
- using (Stream s = new FileStream ("/home/jp/test.xml", FileMode.Create)) {
- serializer.Serialize (s, r);
- }
-
-
- r.dsLayout = new DescriptorSetLayout (dev,
- new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer));
+ GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1, false);
- GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, VkSampleCountFlags.SampleCount1,false);
+ cfg.Layout = new PipelineLayout (dev,
+ new DescriptorSetLayout (dev,
+ new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer)));
- cfg.Layout = new PipelineLayout (dev, r.dsLayout);
cfg.RenderPass = new RenderPass (dev, swapChain.ColorFormat, cfg.Samples);
cfg.AddVertexBinding<Vertex> (0);
cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat);
//note that descriptor set is allocated after the pipeline creation that use this layout, layout is activated
//automaticaly on pipeline creation, and will be disposed automatically when no longuer in use.
- descriptorSet = r.descriptorPool.Allocate (r.dsLayout);
+ descriptorSet = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]);
- DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, r.dsLayout);
+ DescriptorSetWrites uboUpdate = new DescriptorSetWrites (descriptorSet, pipeline.Layout.DescriptorSetLayouts[0]);
uboUpdate.Write (dev, uboMats.Descriptor);
uboMats.Map ();
+
+ cmds = cmdPool.AllocateCommandBuffer (swapChain.ImageCount);
}
public override void UpdateView () {
- matrices.projection = Matrix4x4.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (45f),
- (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f) * Camera.VKProjectionCorrection;
+ matrices.projection = Utils.CreatePerspectiveFieldOfView (Utils.DegreesToRadians (45f),
+ (float)swapChain.Width / (float)swapChain.Height, 0.1f, 256.0f);
matrices.view =
Matrix4x4.CreateFromAxisAngle (Vector3.UnitZ, rotZ) *
Matrix4x4.CreateFromAxisAngle (Vector3.UnitY, rotY) *
return;
updateViewRequested = true;
}
+
void buildCommandBuffers() {
cmdPool.Reset (VkCommandPoolResetFlags.ReleaseResources);
pipeline.Dispose ();
frameBuffers?.Dispose();
- r.descriptorPool.Dispose ();
+ descriptorPool.Dispose ();
vbo.Dispose ();
ibo.Dispose ();
uboMats.Dispose ();
ComputePipeline plCompute, plNormalize;
- DebugReport dbgReport;
-
const uint imgDim = 256;
uint zoom = 2;
int invocationCount = 8;
}
+ protected override void initVulkan () {
+ base.initVulkan ();
- public Program () : base () {
imgResult = new Image (dev, VkFormat.R32g32b32a32Sfloat, VkImageUsageFlags.TransferDst | VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal,
imgDim, imgDim);
imgResult.CreateView ();
stagingDataBuff.Dispose ();
imgResult.Dispose ();
-
- dbgReport?.Dispose ();
}
}
DebugReport dbgRepport;
- Program () : base() {
+ protected override void initVulkan () {
+ base.initVulkan ();
- if (Instance.DEBUG_UTILS)
- dbgRepport = new DebugReport (instance,
+#if DEBUG
+ dbgRepport = new DebugReport (instance,
VkDebugReportFlagsEXT.ErrorEXT
| VkDebugReportFlagsEXT.DebugEXT
| VkDebugReportFlagsEXT.WarningEXT
| VkDebugReportFlagsEXT.PerformanceWarningEXT
);
+#endif
camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 16f);
camera.SetPosition (0, 0, 2);
-using System;
+// Copyright (c) 2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
using System.Numerics;
using System.Runtime.InteropServices;
using vke;
using Vulkan;
namespace deferred {
+ /// <summary>
+ /// Deferred PBR rendering.
+ /// </summary>
class Deferred : VkWindow {
static void Main (string[] args) {
#if DEBUG
Instance.VALIDATION = true;
- Instance.RENDER_DOC_CAPTURE = true;
+ //Instance.RENDER_DOC_CAPTURE = true;
#endif
SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Srgb;
DeferredPbrRenderer.TEXTURE_ARRAY = true;
- DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount1;
- DeferredPbrRenderer.HDR_FORMAT = VkFormat.R16g16b16a16Sfloat;
- DeferredPbrRenderer.MRT_FORMAT = VkFormat.R16g16b16a16Sfloat;
+ DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount8;
+ DeferredPbrRenderer.HDR_FORMAT = VkFormat.R32g32b32a32Sfloat;
+ DeferredPbrRenderer.MRT_FORMAT = VkFormat.R32g32b32a32Sfloat;
PbrModelTexArray.TEXTURE_DIM = 1024;
vke.DebugUtils.Messenger dbgmsg;
- Deferred () : base("deferred") {
+ protected override void initVulkan () {
+ base.initVulkan ();
+
+#if DEBUG
dbgmsg = new vke.DebugUtils.Messenger (instance, VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT | VkDebugUtilsMessageTypeFlagsEXT.ValidationEXT | VkDebugUtilsMessageTypeFlagsEXT.GeneralEXT,
VkDebugUtilsMessageSeverityFlagsEXT.InfoEXT |
VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT |
VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT |
VkDebugUtilsMessageSeverityFlagsEXT.VerboseEXT);
-
+#endif
camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 16f);
camera.SetPosition (0, 0, -2);
renderer.Dispose ();
plToneMap.Dispose ();
descriptorPool.Dispose ();
- dbgmsg.Dispose ();
+ dbgmsg?.Dispose ();
}
}
base.Dispose (disposing);
using vke;
namespace pbrSample {
- class Program : VkWindow{
+ class Program : VkWindow {
static void Main (string[] args) {
#if DEBUG
enabled_features.samplerAnisotropy = available_features.samplerAnisotropy;
}
- VkSampleCountFlags samples = VkSampleCountFlags.SampleCount4;
+ VkSampleCountFlags samples = VkSampleCountFlags.SampleCount8;
FrameBuffers frameBuffers;
PBRPipeline pbrPipeline;
VkvgPipeline.VkvgPipeline vkvgPipeline;
void vkvgDraw () {
- using (vkvg.Context ctx = vkvgPipeline.CreateContext ()) {
+ using (vkvg.Context ctx = vkvgPipeline.CreateContext ()) {
ctx.Clear ();
ctx.LineWidth = 1;
ctx.ShowText (string.Format ($"Gamma: {pbrPipeline.matrices.gamma,5} "));
y += dy;
ctx.MoveTo (x, y);
- ctx.ShowText (string.Format ($"Light pos: {lightPos.ToString()} "));
+ ctx.ShowText (string.Format ($"Light pos: {lightPos.ToString ()} "));
#if PIPELINE_STATS
if (results == null)
Vector4 lightPos = new Vector4 (1, 0, 0, 0);
uint curModelIndex = 0;
- Program () : base() {
+ protected override void initVulkan () {
+ base.initVulkan ();
//UpdateFrequency = 20;
camera = new Camera (Utils.DegreesToRadians (45f), 1f, 0.1f, 64f);
camera.SetPosition (0, 0, -2);
- pbrPipeline = new PBRPipeline(presentQueue,
+ pbrPipeline = new PBRPipeline (presentQueue,
new RenderPass (dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat (), samples));
loadCurrentModel ();
#if WITH_VKVG
vkvgPipeline.RecordDraw (cmd);
-#endif
+#endif
pbrPipeline.RenderPass.End (cmd);
}
vkvgDraw ();
#endif
}
-#endregion
+ #endregion
+
-
protected override void OnResize () {
- base.OnResize();
+ base.OnResize ();
dev.WaitIdle ();
#if WITH_VKVG
UpdateView ();
- frameBuffers?.Dispose();
- frameBuffers = pbrPipeline.RenderPass.CreateFrameBuffers(swapChain);
+ frameBuffers?.Dispose ();
+ frameBuffers = pbrPipeline.RenderPass.CreateFrameBuffers (swapChain);
buildCommandBuffers ();
dev.WaitIdle ();
switch (key) {
case Key.Space:
if (modifiers.HasFlag (Modifier.Shift))
- curModelIndex = curModelIndex == 0 ? (uint)modelPathes.Length - 1 : curModelIndex-1;
+ curModelIndex = curModelIndex == 0 ? (uint)modelPathes.Length - 1 : curModelIndex - 1;
else
curModelIndex = curModelIndex < (uint)modelPathes.Length - 1 ? curModelIndex + 1 : 0;
reloadModel = true;
}
queryUpdatePrefilCube = updateViewRequested = true;
break;*/
- case Key.P:
- showDebugImg = !showDebugImg;
- queryUpdatePrefilCube = updateViewRequested = true;
- break;
- case Key.Keypad0:
- currentDebugView = DebugView.none;
- break;
- case Key.Keypad1:
- currentDebugView = DebugView.color;
- break;
- case Key.Keypad2:
- currentDebugView = DebugView.normal;
- break;
- case Key.Keypad3:
- currentDebugView = DebugView.occlusion;
- break;
- case Key.Keypad4:
- currentDebugView = DebugView.emissive;
- break;
- case Key.Keypad5:
- currentDebugView = DebugView.metallic;
- break;
- case Key.Keypad6:
- currentDebugView = DebugView.roughness;
- break;
- case Key.Up:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos -= Vector4.UnitZ;
- else
- camera.Move (0, 0, 1);
- break;
- case Key.Down:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos += Vector4.UnitZ;
- else
- camera.Move (0, 0, -1);
- break;
- case Key.Left:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos -= Vector4.UnitX;
- else
- camera.Move (1, 0, 0);
- break;
- case Key.Right:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos += Vector4.UnitX;
- else
- camera.Move (-1, 0, 0);
- break;
- case Key.PageUp:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos += Vector4.UnitY;
- else
- camera.Move (0, 1, 0);
- break;
- case Key.PageDown:
- if (modifiers.HasFlag (Modifier.Shift))
- lightPos -= Vector4.UnitY;
- else
- camera.Move (0, -1, 0);
- break;
- case Key.S:
- if (modifiers.HasFlag (Modifier.Shift))
- pbrPipeline.matrices.scaleIBLAmbient -= 0.1f;
- else
- pbrPipeline.matrices.scaleIBLAmbient += 0.1f;
- break;
- case Key.F2:
- if (modifiers.HasFlag (Modifier.Shift))
- pbrPipeline.matrices.exposure -= 0.3f;
- else
- pbrPipeline.matrices.exposure += 0.3f;
- break;
+ case Key.P:
+ showDebugImg = !showDebugImg;
+ queryUpdatePrefilCube = updateViewRequested = true;
+ break;
+ case Key.Keypad0:
+ currentDebugView = DebugView.none;
+ break;
+ case Key.Keypad1:
+ currentDebugView = DebugView.color;
+ break;
+ case Key.Keypad2:
+ currentDebugView = DebugView.normal;
+ break;
+ case Key.Keypad3:
+ currentDebugView = DebugView.occlusion;
+ break;
+ case Key.Keypad4:
+ currentDebugView = DebugView.emissive;
+ break;
+ case Key.Keypad5:
+ currentDebugView = DebugView.metallic;
+ break;
+ case Key.Keypad6:
+ currentDebugView = DebugView.roughness;
+ break;
+ case Key.Up:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos -= Vector4.UnitZ;
+ else
+ camera.Move (0, 0, 1);
+ break;
+ case Key.Down:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos += Vector4.UnitZ;
+ else
+ camera.Move (0, 0, -1);
+ break;
+ case Key.Left:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos -= Vector4.UnitX;
+ else
+ camera.Move (1, 0, 0);
+ break;
+ case Key.Right:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos += Vector4.UnitX;
+ else
+ camera.Move (-1, 0, 0);
+ break;
+ case Key.PageUp:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos += Vector4.UnitY;
+ else
+ camera.Move (0, 1, 0);
+ break;
+ case Key.PageDown:
+ if (modifiers.HasFlag (Modifier.Shift))
+ lightPos -= Vector4.UnitY;
+ else
+ camera.Move (0, -1, 0);
+ break;
+ case Key.S:
+ if (modifiers.HasFlag (Modifier.Shift))
+ pbrPipeline.matrices.scaleIBLAmbient -= 0.1f;
+ else
+ pbrPipeline.matrices.scaleIBLAmbient += 0.1f;
+ break;
+ case Key.F2:
+ if (modifiers.HasFlag (Modifier.Shift))
+ pbrPipeline.matrices.exposure -= 0.3f;
+ else
+ pbrPipeline.matrices.exposure += 0.3f;
+ break;
case Key.F3:
- if (modifiers.HasFlag (Modifier.Shift))
- pbrPipeline.matrices.gamma -= 0.1f;
- else
- pbrPipeline.matrices.gamma += 0.1f;
- break;
- case Key.F4:
- if (camera.Type == Camera.CamType.FirstPerson)
- camera.Type = Camera.CamType.LookAt;
- else
- camera.Type = Camera.CamType.FirstPerson;
- Console.WriteLine ($"camera type = {camera.Type}");
- break;
- default:
- base.onKeyDown (key, scanCode, modifiers);
- return;
+ if (modifiers.HasFlag (Modifier.Shift))
+ pbrPipeline.matrices.gamma -= 0.1f;
+ else
+ pbrPipeline.matrices.gamma += 0.1f;
+ break;
+ case Key.F4:
+ if (camera.Type == Camera.CamType.FirstPerson)
+ camera.Type = Camera.CamType.LookAt;
+ else
+ camera.Type = Camera.CamType.FirstPerson;
+ Console.WriteLine ($"camera type = {camera.Type}");
+ break;
+ default:
+ base.onKeyDown (key, scanCode, modifiers);
+ return;
}
updateViewRequested = true;
}
if (disposing) {
if (!isDisposed) {
dev.WaitIdle ();
- frameBuffers?.Dispose();
+ frameBuffers?.Dispose ();
pbrPipeline.Dispose ();
#if WITH_VKVG
vkvgPipeline.Dispose ();
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DefineConstants>NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;WITH_VKVG;TRACE;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
+ <DefineConstants>_WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<GLSLShader Update="shaders/simpletexture.frag">
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pbr", "samples\pbr\pbr.csproj", "{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vkeEditor", "samples\vkeEditor\vkeEditor.csproj", "{81619805-9E6F-404A-BC0D-A2C25DDA2EDC}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "samples\tests\tests.csproj", "{F9117397-E105-44DD-A9BD-F6F8DC641095}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
{8185163E-A67C-4C0E-8548-67E2A9F16309}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.ActiveCfg = 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
{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
{7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
+ {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Release|Any CPU
+ {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.ReleaseSpirVTasks|Any CPU.Build.0 = Release|Any CPU
+ {7B05B5A7-49E2-4D05-BEF8-734F70CDBF17}.Release|Any CPU.Build.0 = Release|Any CPU
{F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F04C3F79-2E08-4D35-A804-43039DCB7F5E}.Release|Any CPU.Build.0 = Release|Any CPU
{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.Release|Any CPU.Build.0 = Release|Any CPU
{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.Release|Any CPU.Build.0 = Release|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.Release|Any CPU.Build.0 = Release|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.DebugCrow|Any CPU.ActiveCfg = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.DebugCrow|Any CPU.Build.0 = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.ReleaseSpirVTasks|Any CPU.ActiveCfg = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.ReleaseSpirVTasks|Any CPU.Build.0 = Debug|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.BuildPackages|Any CPU.ActiveCfg = Release|Any CPU
- {F9117397-E105-44DD-A9BD-F6F8DC641095}.BuildPackages|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FEF3AF30-5B88-4D3C-8BD7-8734200E0D1E} = {4AA67AB0-C331-4CB2-9C00-B74F5DE31658}
{D9A41382-444E-44ED-B638-3D8F06F2FBC2} = {16439374-B8DB-4643-8116-EB3358B49A12}
{124152F8-FAE6-4D4B-87B9-6074DD365E9B} = {16439374-B8DB-4643-8116-EB3358B49A12}
{7EB2430B-6BC0-4AE9-B1FA-57C3DB2AE1C5} = {16439374-B8DB-4643-8116-EB3358B49A12}
- {81619805-9E6F-404A-BC0D-A2C25DDA2EDC} = {16439374-B8DB-4643-8116-EB3358B49A12}
- {F9117397-E105-44DD-A9BD-F6F8DC641095} = {16439374-B8DB-4643-8116-EB3358B49A12}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
- <ReleaseVersion>0.1.11</ReleaseVersion>
+ <ReleaseVersion>0.1.12</ReleaseVersion>
<AssemblyVersion>$(ReleaseVersion)</AssemblyVersion>
<Description>C# vulkan library with IDispose model and references counting</Description>
<PackageTags>vulkan game engine compute glfw c#</PackageTags>
<PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/jpbruyere/vke.net/blob/master/README.md</PackageProjectUrl>
<License>MIT</License>
<LangVersion>7.2</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
+
+ <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
- <DefineConstants>MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
+ <DefineConstants>MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
- <DefineConstants>MEMORY_POOLS</DefineConstants>
+ <DefineConstants>MEMORY_POOLS;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
</ItemGroup>
<ItemGroup>
- <PackageReference Include="SpirVTasks" Version="0.1.37-beta" />
- <PackageReference Include="Vulkan" Version="0.1.9-beta" />
+ <PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
+ <PackageReference Include="Vulkan" Version="0.2.0-beta" />
</ItemGroup>
<ItemGroup>
- <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">
- <ResourceId>testRsID</ResourceId>
- </GLSLShader>
+ <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom" />
<Compile Remove="build\**\*.cs;Properties\AssemblyInfo.cs;src\Renderer.cs;src\QueueFamily.cs" />
</ItemGroup>
</Project>