language: csharp
-dist: xenial
+dist: bionic
dotnet: 3.1
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-xenial.list https://packages.lunarg.com/vulkan/lunarg-vulkan-xenial.list
+ - 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 install vulkan-sdk
### Requirements
- [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).
<RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
</PropertyGroup>
-
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DefineConstants>TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0;_WITH_SHADOWS;_WITH_VKVG</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DefineConstants>NETSTANDARD;NETSTANDARD2_0;WITH_SHADOWS;_WITH_VKVG</DefineConstants>
- </PropertyGroup>
-
+
<ItemGroup Condition=" '$(Configuration)|$(Platform)' != 'BuildPackages|AnyCPU' ">
<ProjectReference Include="..\..\vke\vke.csproj" />
</ItemGroup>
VkSampleCountFlags samples = VkSampleCountFlags.SampleCount1;
-#if WITH_VKVG
- VkvgPipeline.VkvgPipeline vkvgPipeline;
-
- void vkvgDraw () {
- using (vkvg.Context ctx = vkvgPipeline.CreateContext()) {
- ctx.Clear ();
- vkvgPipeline.DrawResources (ctx, (int)swapChain.Width, (int)swapChain.Height);
- }
- }
-
-
-#endif
-
protected override void initVulkan () {
base.initVulkan ();
loadTexture (imgPathes[currentImgIndex]);
if (nextTexture != null)
updateTextureSet ();
-
-#if WITH_VKVG
- dsVkvg = descriptorPool.Allocate (pipeline.Layout.DescriptorSetLayouts[0]);
- vkvgPipeline = new VkvgPipeline.VkvgPipeline (instance, dev, presentQueue, pipeline);
- }
-
- public override void Update () {
- vkvgDraw ();
-#endif
}
void buildCommandBuffers () {
}
}
void recordDraw (PrimaryCommandBuffer cmd, FrameBuffer fb) {
-#if WITH_VKVG
- vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color,
- VkImageLayout.ColorAttachmentOptimal, VkImageLayout.ShaderReadOnlyOptimal,
- VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.FragmentShader);
-#endif
pipeline.RenderPass.Begin (cmd, fb);
cmd.SetViewport (fb.Width, fb.Height);
cmd.BindVertexBuffer (vbo, 0);
cmd.Draw (36);
-#if WITH_VKVG
- cmd.BindDescriptorSet (pipeline.Layout, dsVkvg);
- vkvgPipeline.RecordDraw (cmd);
- pipeline.RenderPass.End (cmd);
- vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color,
- VkImageLayout.ShaderReadOnlyOptimal, VkImageLayout.ColorAttachmentOptimal,
- VkPipelineStageFlags.FragmentShader, VkPipelineStageFlags.ColorAttachmentOutput);
-#else
pipeline.RenderPass.End (cmd);
-#endif
}
//in the thread of the keyboard
base.OnResize ();
dev.WaitIdle();
-
-#if WITH_VKVG
- vkvgPipeline.Resize ((int)Width, (int)Height, new DescriptorSetWrites (dsVkvg, dsLayout.Bindings[1]));
- PrimaryCommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit);
- vkvgPipeline.Texture.SetLayout (cmd, VkImageAspectFlags.Color,
- VkImageLayout.Undefined, VkImageLayout.ColorAttachmentOptimal,
- VkPipelineStageFlags.AllCommands, VkPipelineStageFlags.ColorAttachmentOutput);
- presentQueue.EndSubmitAndWait (cmd, true);
-
-#endif
-
updateMatrices ();
frameBuffers?.Dispose();
texture.Dispose ();
uboMats.Dispose ();
vbo.Dispose ();
-
-#if WITH_VKVG
- vkvgPipeline.Dispose ();
-#endif
}
}
</PropertyGroup>
<ItemGroup>
- <Compile Include="delaunay.cs" />
+ <Compile Include="main.cs" />
</ItemGroup>
</Project>
\ No newline at end of file
-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.Runtime.InteropServices;
-using CVKL;
-using VK;
using System.Linq;
+using Vulkan;
+using vke;
+//very simple compute example that just do an addition on every items of a random list of numbers.
namespace SimpleCompute {
- class Program : IDisposable {
- VkPhysicalDeviceFeatures enabledFeatures = default (VkPhysicalDeviceFeatures);
- string[] enabledExtensions = { Ext.D.VK_KHR_swapchain };
+ class Program : IDisposable {
+ static void Main (string[] args) {
+ using (Program vke = new Program ())
+ vke.Run ();
+ }
Instance instance;
PhysicalDevice phy;
ComputePipeline plCompute;
- DebugReport dbgReport;
- const uint data_size = 256;
+ //random datas generation
+ const uint data_size = 16;
int[] datas;
+ void createRandomDatas () {
+ datas = new int[data_size];
+ Random rnd = new Random ();
+ for (uint i = 0; i < data_size; i++)
+ datas[i] = rnd.Next ();
+ }
+
public Program () {
instance = new Instance ();
-
-#if DEBUG
- dbgReport = new DebugReport (instance,
- VkDebugReportFlagsEXT.ErrorEXT
- | VkDebugReportFlagsEXT.DebugEXT
- | VkDebugReportFlagsEXT.WarningEXT
- | VkDebugReportFlagsEXT.PerformanceWarningEXT
-
- );
-#endif
-
phy = instance.GetAvailablePhysicalDevice ().FirstOrDefault ();
dev = new Device (phy);
computeQ = new Queue (dev, VkQueueFlags.Compute);
- dev.Activate (enabledFeatures, enabledExtensions);
- datas = new int[data_size];
- Random rnd = new Random ();
- for (uint i = 0; i < data_size; i++) {
- datas[i] = rnd.Next ();
- }
+ dev.Activate (default (VkPhysicalDeviceFeatures));
+
+ createRandomDatas ();
inBuff = new HostBuffer<int> (dev, VkBufferUsageFlags.StorageBuffer, datas);
outBuff = new HostBuffer<int> (dev, VkBufferUsageFlags.StorageBuffer, data_size);
new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Compute, VkDescriptorType.StorageBuffer)
);
- plCompute = new ComputePipeline (new PipelineLayout (dev, dsLayout), "shaders/compute.comp.spv" );
+ plCompute = new ComputePipeline (new PipelineLayout (dev, dsLayout), "#shaders.compute.comp.spv" );
dset = dsPool.Allocate (dsLayout);
DescriptorSetWrites dsUpdate = new DescriptorSetWrites (dset, dsLayout);
dsUpdate.Write (dev, inBuff.Descriptor, outBuff.Descriptor);
}
-
-
public void Run () {
using (CommandPool cmdPool = new CommandPool (dev, computeQ.qFamIndex)) {
-
- CommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit);
-
+ PrimaryCommandBuffer cmd = cmdPool.AllocateAndStart (VkCommandBufferUsageFlags.OneTimeSubmit);
plCompute.Bind (cmd);
plCompute.BindDescriptorSet (cmd, dset);
-
cmd.Dispatch (data_size * sizeof (int));
-
cmd.End ();
computeQ.Submit (cmd);
outBuff.Map ();
Marshal.Copy (outBuff.MappedData, results, 0, results.Length);
- Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write ("IN :");
- for (int i = 0; i < data_size; i++) {
- Console.Write ($" {datas[i]} ");
- }
- Console.WriteLine ();
+ for (int i = 0; i < data_size; i++)
+ Console.Write ($"{datas[i]} ");
+
+ Console.WriteLine ();Console.WriteLine ();
+
Console.Write ("OUT:");
- for (int i = 0; i < data_size; i++) {
- Console.Write ($" {results[i]} ");
- }
+ for (int i = 0; i < data_size; i++)
+ Console.Write ($"{results[i]} ");
+
Console.WriteLine ();
outBuff.Unmap ();
}
outBuff.Dispose ();
dev.Dispose ();
-
-#if DEBUG
- dbgReport.Dispose ();
-#endif
instance.Dispose ();
}
-
- static void Main (string[] args) {
- using (Program vke = new Program ())
- vke.Run ();
- }
}
}
Utils.DataDirectory + "models/ISS_stationary.glb",
Utils.DataDirectory + "models/MER_static.glb",
Utils.DataDirectory + "models/Box.gltf",
-
- /*"/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Avocado/glTF/Avocado.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BarramundiFish/glTF/BarramundiFish.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/BoomBoxWithAxes/glTF/BoomBoxWithAxes.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Box/glTF/Box.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/EnvironmentTest/glTF/EnvironmentTest.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/MetalRoughSpheres/glTF/MetalRoughSpheres.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/OrientationTest/glTF/OrientationTest.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Buggy/glTF/Buggy.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/2CylinderEngine/glTF-Embedded/2CylinderEngine.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/FlightHelmet/glTF/FlightHelmet.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/GearboxAssy/glTF/GearboxAssy.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Lantern/glTF/Lantern.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf",
- "/mnt/devel/vulkan/glTF-Sample-Models-master/2.0/Sponza/glTF/Sponza.gltf",
- "/mnt/devel/vkChess/data/chess.gltf"*/
};
DebugView currentDebugView = DebugView.none;
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
+ <ItemGroup>
+ <GLSLShader Update="shaders/simpletexture.frag">
+ <LogicalName>vke.simpletexture.frag.spv</LogicalName>
+ </GLSLShader>
+ </ItemGroup>
+ <PropertyGroup>
+ <DefineConstants>$(DefineConstants);WITH_SHADOWS</DefineConstants>
+ </PropertyGroup>
-
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DefineConstants>_WITH_SHADOWS;_WITH_VKVG;TRACE;DEBUG</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <GLSLShader Update="shaders/simpletexture.frag">
- <LogicalName>vke.simpletexture.frag.spv</LogicalName>
- </GLSLShader>
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
- <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
- </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\addons\gltfLoader\gltfLoader.csproj" />
+ <ProjectReference Include="..\..\addons\EnvironmentPipeline\EnvironmentPipeline.csproj" />
+ </ItemGroup>
</Project>