+++ /dev/null
-<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>
<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>
**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).
</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
<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">
</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>
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>
```
#### todo
+
- Error source file and line with included files.
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>
</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>
//
// 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,
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>
// 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 {
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;
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 {
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>
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>
-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)
--- /dev/null
+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
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:f98a369e29ffc754cc897f78d695754ac6812ba7ddcd23705dd8d4e258f5f13b
+size 3791
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:c0fa7be52a4c63e96af2be05735caba968b04a633a9c5eaf1b4c95fb25588003
+size 5033556
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:efe99dfac198094a30c71dc02a4d3421f0eef6bf335aeb695daa4d62134cd93f
+size 4537
--- /dev/null
+# Sponza
+
+## Screenshot
+
+Lights are shown here, they are not part of the model.
+
+
+
+## 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
+```
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:e17c14edbc06b757dafcfed99f8815af9c5f5d9f9de3f0bc7740c37e68e0d829
+size 212504
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a021b7609d4fbc590c4ffe495e3496cd2204f2c226f7f4d5c9421d4a3f8d2eb5
+size 3407650
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:87aed37664ba8a792a79e0245c07ce34babcaa40abf94e469234e44cb8ecc9df
+size 3663
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:3720ae8e6ce9ceb1669396453ea1107575146494588b2e52463020e7ca9cf4d4
+size 34170
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a516145efb32792dbf6422ef2f6e5cd0907765584ee083a1f47cf6a94c503fb6
+size 13832
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:4e2e77f34b0c623f58d2e07eed7a03100f9d09034cc6bfa4ec907105137ee714
+size 11207
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac5f07807d147c9adee8898cac57b977c5130df73847b0fc0adafbb8d495e505
+size 9717
</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>
using Glfw;
using VK;
-using CVKL;
-using CVKL.DistanceFieldFont;
+using vke;
+using vke.DistanceFieldFont;
namespace DistanceFieldFontTest {
DescriptorSet descriptorSet;
GraphicPipeline pipeline;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
Image fontTexture;
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),
List<ushort> indices = new List<ushort> ();
ushort indexOffset = 0;
+ float charSize = 1.0f;
+
float w = fontTexture.Width;
float posx = 0.0f;
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;
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;
}
}
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]);
}
}
- void recordDraw (CommandBuffer cmd, Framebuffer fb) {
+ void recordDraw (CommandBuffer cmd, FrameBuffer fb) {
pipeline.RenderPass.Begin (cmd, fb);
cmd.SetViewport (fb.Width, fb.Height);
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 ();
}
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 ();
+++ /dev/null
-version https://git-lfs.github.com/spec/v1
-oid sha256:efe99dfac198094a30c71dc02a4d3421f0eef6bf335aeb695daa4d62134cd93f
-size 4537
-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
DescriptorSetLayout descLayoutMatrix;
DescriptorSetLayout descLayoutTextures;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
GraphicPipeline pipeline;
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),
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);
}
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);
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 ();
}
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 ();
}
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 ();
using System.Numerics;
using System.Runtime.InteropServices;
using Glfw;
-using CVKL;
+using vke;
using VK;
namespace Textured {
DescriptorSet descriptorSet;
GraphicPipeline pipeline;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
Image texture;
Image nextTexture;
Utils.DataDirectory + "textures/tex256.jpg",
};
- Program () : base () {
+ Program () : base () {
+ cmds = cmdPool.AllocateCommandBuffer(swapChain.ImageCount);
loadTexture (imgPathes[currentImgIndex]);
}
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);
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);
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 ();
}
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 ();
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 {
DescriptorSetLayout dsLayout;
DescriptorSet descriptorSet, dsVkvg;
GraphicPipeline pipeline;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
Image texture;
Image nextTexture;
#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,
}
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);
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) {
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 ();
<Import Project="$(RootDirectory)netfx.props" />
<PropertyGroup>
<IncludeDefaultNoneItems>false</IncludeDefaultNoneItems>
- </PropertyGroup>
+ </PropertyGroup>
</Project>
// 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 {
DescriptorSetLayout dsLayout;
DescriptorSet descriptorSet;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
GraphicPipeline pipeline;
Vertex[] vertices = {
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);
}
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);
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 ();
}
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 ();
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) {
}
#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) :
}
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);
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);
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]
});
using System;
using Glfw;
using VK;
-using CVKL;
+using vke;
namespace delaunay {
class Program : VkWindow {
}
}
- Framebuffer[] frameBuffers;
+ FrameBuffer[] frameBuffers;
GraphicPipeline grPipeline;
Image imgResult;
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
using System;
using System.Numerics;
using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
using VK;
namespace deferred {
}*/
};
- Framebuffer frameBuffer;
+ FrameBuffer frameBuffer;
public Image gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImgResolved, hdrImgMS;
DescriptorPool descriptorPool;
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});
}
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
public class EnvironmentCube : GraphicPipeline {
GPUBuffer vboSkybox;
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);
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);
using System.Numerics;
using Glfw;
using VK;
-using CVKL;
+using vke;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
using System.Runtime.InteropServices;
-using CVKL;
-using CVKL.glTF;
+using vke;
+using vke.glTF;
using Glfw;
using VK;
GraphicPipeline plToneMap;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
DescriptorPool descriptorPool;
DescriptorSet descriptorSet;
}
- CommandBuffer cmdPbr;
- CommandBuffer cmdBlur;
+ //CommandBuffer cmdPbr;
+ //CommandBuffer cmdBlur;
VkSemaphore blurComplete;
const uint downSizing = 1;
float finalDebug = -1.0f;
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);
computeCmdPool.Dispose ();
downSamp?.Dispose ();
downSamp2?.Dispose ();
- if (frameBuffers != null)
- foreach (Framebuffer fb in frameBuffers)
- fb.Dispose ();
+ frameBuffers?.Dispose();
renderer.Dispose ();
plBlur.Dispose ();
plToneMap.Dispose ();
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;
RenderPass shadowPass;
- Framebuffer fbShadowMap;
+ FrameBuffer fbShadowMap;
public Image shadowMap { get; private set; }
Pipeline shadowPipeline;
DescriptorPool descriptorPool;
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 ();
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
class EnvironmentCube : GraphicPipeline {
GPUBuffer vboSkybox;
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);
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);
using VK;
-namespace CVKL {
- using CVKL.glTF;
+namespace vke {
+ using vke.glTF;
//TODO:stride in buffer views?
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
class PBRPipeline : GraphicPipeline {
public struct Matrices {
using System.Runtime.InteropServices;
using Glfw;
using VK;
-using CVKL;
+using vke;
namespace pbrSample {
class Program : VkWindow{
VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1;
- Framebuffer[] frameBuffers;
+ FrameBuffers frameBuffers;
PBRPipeline pbrPipeline;
enum DebugView {
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);
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 ();
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 ();
<ItemGroup>
<GLSLShader Update="shaders/simpletexture.frag">
- <LogicalName>vke.simpletexture.frag.spv</LogicalName>
- </GLSLShader>
+ <LogicalName>vke.simpletexture.frag.spv</LogicalName>
+ </GLSLShader>
</ItemGroup>
<ItemGroup>
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
{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}
{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
// 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 =
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public static class ExtensionMethods {
/// <summary>
/// Extensions method to check byte array equality.
--- /dev/null
+// 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();
+ }
+ }
+}
using System;
using System.Runtime.InteropServices;
-namespace CVKL {
+namespace vke {
public class MarshaledObject<T> : IDisposable where T : struct {
GCHandle handle;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
#if MEMORY_POOLS
public enum MemoryPoolType {
Random,
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) {
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
using System;
using VK;
-namespace CVKL {
+namespace vke {
/// <summary>
/// This class is a helper class for VkPipelineShaderStageCreateInfo creation.
/// </summary>
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
/// <summary>
/// Hold shader specialization constant value and type
/// </summary>
using System;
using System.Runtime.InteropServices;
-namespace CVKL {
+namespace vke {
public class StbImage : IDisposable {
const string stblib = "stb";
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;
+ }
+ }
+ }
}
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
-//
-// 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>
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
/// <summary>
/// Base class for HostBuffer and GPUBuffer
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);
}
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,
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,
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
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) {
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.
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public sealed class ComputePipeline : Pipeline {
public string SpirVPath;
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
public class DebugDrawPipeline : GraphicPipeline {
public HostBuffer Vertices;
uint vertexCount;
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);
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class DebugReport : IDisposable {
VkDebugReportCallbackEXT handle;
using VK;
using static VK.Vk;
-namespace CVKL.DebugUtils {
+namespace vke.DebugUtils {
public class Messenger : IDisposable {
Instance inst;
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public sealed class DescriptorPool : Activable {
internal VkDescriptorPool handle;
public readonly uint MaxSets;
using System.Collections.Generic;
using VK;
-namespace CVKL {
+namespace vke {
public class DescriptorSet {
internal VkDescriptorSet handle;
public VkDescriptorSet Handle => handle;
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.
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>
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
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;
public Device (PhysicalDevice _phy) {
phy = _phy;
+ BufferImageGranularity = phy.Limits.bufferImageGranularity;
}
public void Activate (VkPhysicalDeviceFeatures enabledFeatures, params string[] extensions) {
using static VK.Vk;
-namespace CVKL {
+namespace vke {
- public class Framebuffer : Activable {
+ public class FrameBuffer : Activable {
internal VkFramebuffer handle;
RenderPass renderPass;
=> 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];
using System.Runtime.InteropServices;
using VK;
-namespace CVKL {
+namespace vke {
/// <summary>
/// Device local Buffer
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class GraphicPipeline : Pipeline {
public readonly RenderPass RenderPass;
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 ();
// 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;
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; }
}
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class HostBuffer<T> : HostBuffer {
int TSize;
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
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);
info.sharingMode = VkSharingMode.Exclusive;
info.flags = createFlags;
+ lastKnownLayout = info.initialLayout;
+
Activate ();//DONT OVERRIDE Activate in derived classes!!!!
}
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,
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;
0,IntPtr.Zero,
0, IntPtr.Zero,
1, ref imageMemoryBarrier);
+
+ lastKnownLayout = newImageLayout;
}
public void BuildMipmaps (Queue copyQ, CommandPool copyCmdPool) {
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 {
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);
}
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
/// <summary>
/// Vulkan Instance disposable class
/// </summary>
using System.Collections.Generic;
using System.Runtime.InteropServices;
-namespace CVKL {
+namespace vke {
public class PhysicalDeviceCollection : IEnumerable<PhysicalDevice> {
VkInstance inst;
PhysicalDevice[] phys;
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public abstract class Pipeline : Activable {
protected VkPipeline handle;
protected PipelineLayout layout;
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.
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public sealed class PipelineLayout : Activable {
internal VkPipelineLayout handle;
public VkPipelineLayout Handle => handle;
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class TimestampQueryPool : QueryPool {
public readonly float Period;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class PresentQueue : Queue {
public readonly VkSurfaceKHR Surface;
// 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;
/// <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;
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")}]");
}
using static VK.Vk;
-namespace CVKL {
+namespace vke {
[DebuggerDisplay ("{previous.name} <- {name} -> {next.name}")]
public abstract class Resource : Activable {
protected VkMemoryRequirements memReqs;
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;
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>();
using VK;
using static VK.Vk;
-namespace CVKL {
+namespace vke {
public class SwapChain : Activable {
/// <summary>
/// Set the default swapchain image format.
return (int)currentImageIndex;
}
- void _destroy () {
+ void _destroy () {
for (int i = 0; i < ImageCount; i++)
images[i].Dispose ();
using System.IO;
using VK;
-using CVKL;
+using vke;
using System.Runtime.InteropServices;
using System.Collections.Generic;
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 ();
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
}
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;
}
// 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;
using System.Numerics;
using VK;
-namespace CVKL {
+namespace vke {
public enum AlphaMode : UInt32 {
Opaque,
<?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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
+ <LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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>