diff --git a/Src/Samples/Samples/ComputeTexture/ComputeTexture.cs b/Src/Samples/Samples/ComputeTexture/ComputeTexture.cs index 25dde3b..4c48a9f 100644 --- a/Src/Samples/Samples/ComputeTexture/ComputeTexture.cs +++ b/Src/Samples/Samples/ComputeTexture/ComputeTexture.cs @@ -41,7 +41,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = true + Debug = true }; diff --git a/Src/Samples/Samples/DiffuseLighting/DiffuseLighting.cs b/Src/Samples/Samples/DiffuseLighting/DiffuseLighting.cs index 12d9fb6..537351d 100644 --- a/Src/Samples/Samples/DiffuseLighting/DiffuseLighting.cs +++ b/Src/Samples/Samples/DiffuseLighting/DiffuseLighting.cs @@ -52,7 +52,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = false, + Debug = false, Fullscreen = false, }; diff --git a/Src/Samples/Samples/LoadGLTF/LoadGLTFExample.cs b/Src/Samples/Samples/LoadGLTF/LoadGLTFExample.cs index ffa8e68..2526dff 100644 --- a/Src/Samples/Samples/LoadGLTF/LoadGLTFExample.cs +++ b/Src/Samples/Samples/LoadGLTF/LoadGLTFExample.cs @@ -54,7 +54,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = false, + Debug = false, Fullscreen = false, }; diff --git a/Src/Samples/Samples/LoadTexture/LoadTextureExample.cs b/Src/Samples/Samples/LoadTexture/LoadTextureExample.cs index 2d22f9e..5ace699 100644 --- a/Src/Samples/Samples/LoadTexture/LoadTextureExample.cs +++ b/Src/Samples/Samples/LoadTexture/LoadTextureExample.cs @@ -47,7 +47,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = false, + Debug = false, Fullscreen = false, }; diff --git a/Src/Samples/Samples/PushConstant/PushConstantExample.cs b/Src/Samples/Samples/PushConstant/PushConstantExample.cs index 53f12ae..6aa09b7 100644 --- a/Src/Samples/Samples/PushConstant/PushConstantExample.cs +++ b/Src/Samples/Samples/PushConstant/PushConstantExample.cs @@ -121,7 +121,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = false, + Debug = false, Fullscreen = false, //ForceExclusiveTransferQueue = true }; diff --git a/Src/Samples/Samples/Transformations/TransformationsExample.cs b/Src/Samples/Samples/Transformations/TransformationsExample.cs index 2e84284..7f32be0 100644 --- a/Src/Samples/Samples/Transformations/TransformationsExample.cs +++ b/Src/Samples/Samples/Transformations/TransformationsExample.cs @@ -123,7 +123,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = false, + Debug = false, Fullscreen = false, }; diff --git a/Src/Samples/Samples/Triangle/TriangleExample.cs b/Src/Samples/Samples/Triangle/TriangleExample.cs index a5ebae5..5220a14 100644 --- a/Src/Samples/Samples/Triangle/TriangleExample.cs +++ b/Src/Samples/Samples/Triangle/TriangleExample.cs @@ -41,7 +41,7 @@ public override void Initialize() AdapterConfig = new() { SwapChain = true, - VulkanDebug = true, + Debug = true, }; diff --git a/Src/Vultaik/Buffer.cs b/Src/Vultaik/Buffer.cs index 46d2861..6bebbfd 100644 --- a/Src/Vultaik/Buffer.cs +++ b/Src/Vultaik/Buffer.cs @@ -125,7 +125,7 @@ internal void Recreate() sType = VkStructureType.MemoryAllocateInfo, pNext = null, allocationSize = memReqs.size, - memoryTypeIndex = NativeDevice.GetMemoryTypeIndex(memReqs.memoryTypeBits, memoryProperties), + memoryTypeIndex = NativeDevice.get_memory_type(memReqs.memoryTypeBits, memoryProperties), }; diff --git a/Src/Vultaik/CommandBuffer.cs b/Src/Vultaik/CommandBuffer.cs index 14c57b5..3cda1db 100644 --- a/Src/Vultaik/CommandBuffer.cs +++ b/Src/Vultaik/CommandBuffer.cs @@ -26,11 +26,11 @@ public CommandBuffer(Device graphicsDevice, CommandBufferType type) : base(graph Recreate(); - //WaitFence = new(NativeDevice, true); + WaitFence = new(NativeDevice, true); } public CommandBufferType Type { get; set; } - //public Fence WaitFence { get; set; } + public Fence WaitFence { get; set; } public void Recreate() { @@ -70,8 +70,8 @@ public void Begin() { BeginRenderPassContinue(); - //WaitFence.Wait(); - //WaitFence.Reset(); + WaitFence.Wait(); + WaitFence.Reset(); } @@ -585,7 +585,7 @@ public void Free() public void Dispose() { - //WaitFence.Dispose(); + WaitFence.Dispose(); vkDestroyCommandPool(NativeDevice.handle, cmd_command_pool, null); } diff --git a/Src/Vultaik/Compute/ComputePipeline.cs b/Src/Vultaik/Compute/ComputePipeline.cs index da10683..fc9aab8 100644 --- a/Src/Vultaik/Compute/ComputePipeline.cs +++ b/Src/Vultaik/Compute/ComputePipeline.cs @@ -140,7 +140,7 @@ public void CreatePipeline() sType = VkStructureType.PipelineShaderStageCreateInfo, pNext = null, stage = VkShaderStageFlags.Compute, - module = NativeDevice.LoadSpir_V_Shader(shader.Data), + module = NativeDevice.load_spirv_shader(shader.Data), pName = Interop.String.ToPointer(shader.EntryPoint), }; diff --git a/Src/Vultaik/Device.cs b/Src/Vultaik/Device.cs index f68b970..7d76153 100644 --- a/Src/Vultaik/Device.cs +++ b/Src/Vultaik/Device.cs @@ -525,7 +525,7 @@ internal void CreateCommandQueues() - internal VkShaderModule LoadSpir_V_Shader(Span bytes) + internal VkShaderModule load_spirv_shader(Span bytes) { fixed (byte* ptr = bytes) @@ -546,7 +546,7 @@ internal VkShaderModule LoadSpir_V_Shader(Span bytes) } - internal uint GetMemoryTypeIndex(uint typeBits, VkMemoryPropertyFlags properties) + internal uint get_memory_type(uint typeBits, VkMemoryPropertyFlags properties) { // Iterate over all memory types available for the Device used in this example for (uint i = 0; i < _memoryProperties.memoryTypeCount; i++) @@ -753,127 +753,127 @@ public VkQueue get_queue_type_cmd(CommandBuffer cmd) return VkQueue.Null; } - public void SubmitTransfer(CommandBuffer commandBuffer, Fence? fence = null) - { - VkQueue queue = get_queue_type_cmd(commandBuffer); - VkCommandBuffer cmd = commandBuffer.handle; + //public void SubmitTransfer(CommandBuffer commandBuffer, Fence? fence = null) + //{ + // VkQueue queue = get_queue_type_cmd(commandBuffer); + // VkCommandBuffer cmd = commandBuffer.handle; - VkSubmitInfo submit_info = new() - { - sType = VkStructureType.SubmitInfo, - commandBufferCount = 1, - pCommandBuffers = &cmd, - }; + // VkSubmitInfo submit_info = new() + // { + // sType = VkStructureType.SubmitInfo, + // commandBufferCount = 1, + // pCommandBuffers = &cmd, + // }; - vkQueueSubmit(queue, 1, &submit_info, VkFence.Null); - } + // vkQueueSubmit(queue, 1, &submit_info, VkFence.Null); + //} - public void Submit(CommandBuffer commandBuffer, Fence? fence = null) - { - VkQueue queue = get_queue_type_cmd(commandBuffer); - VkCommandBuffer cmd = commandBuffer.handle; - VkSemaphore signal_semaphore = render_finished_semaphore; - VkSemaphore wait_semaphore = image_available_semaphore; + //public void Submit(CommandBuffer commandBuffer, Fence? fence = null) + //{ + // VkQueue queue = get_queue_type_cmd(commandBuffer); + // VkCommandBuffer cmd = commandBuffer.handle; + // VkSemaphore signal_semaphore = render_finished_semaphore; + // VkSemaphore wait_semaphore = image_available_semaphore; - VkSubmitInfo submit_info = new() - { - sType = VkStructureType.SubmitInfo, - commandBufferCount = 1, - pCommandBuffers = &cmd, - }; + // VkSubmitInfo submit_info = new() + // { + // sType = VkStructureType.SubmitInfo, + // commandBufferCount = 1, + // pCommandBuffers = &cmd, + // }; - submit_info.waitSemaphoreCount = 1; - submit_info.pWaitSemaphores = &wait_semaphore; + // submit_info.waitSemaphoreCount = 1; + // submit_info.pWaitSemaphores = &wait_semaphore; - submit_info.signalSemaphoreCount = 1; - submit_info.pSignalSemaphores = &signal_semaphore; + // submit_info.signalSemaphoreCount = 1; + // submit_info.pSignalSemaphores = &signal_semaphore; - vkQueueSubmit(queue, 1, &submit_info, VkFence.Null); - } + // vkQueueSubmit(queue, 1, &submit_info, VkFence.Null); + //} - //public void Submit(CommandBuffer commandBuffer, Fence? fence = null) - //{ - // VkPipelineStageFlags wait_stages = VkPipelineStageFlags.ColorAttachmentOutput; - // VkSemaphore signal_semaphore = render_finished_semaphore; - // VkSemaphore wait_semaphore = image_available_semaphore; - // VkQueue queue = get_queue_type_cmd(commandBuffer); - // CommandBufferType cmd_type = commandBuffer.Type; - // VkCommandBuffer cmd = commandBuffer.handle; - // var force_exclusive_transfer_queue = false; - // VkFence sync_fence = VkFence.Null; - // bool use_semaphore = true; + public void Submit(CommandBuffer commandBuffer, Fence? fence = null) + { + VkPipelineStageFlags wait_stages = VkPipelineStageFlags.ColorAttachmentOutput; + VkSemaphore signal_semaphore = render_finished_semaphore; + VkSemaphore wait_semaphore = image_available_semaphore; + VkQueue queue = get_queue_type_cmd(commandBuffer); + CommandBufferType cmd_type = commandBuffer.Type; + VkCommandBuffer cmd = commandBuffer.handle; + var force_exclusive_transfer_queue = false; + VkFence sync_fence = VkFence.Null; + bool use_semaphore = true; - // if (queue == transfer_queue && cmd_type == CommandBufferType.AsyncTransfer) - // { - // wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; + if (queue == transfer_queue && cmd_type == CommandBufferType.AsyncTransfer) + { + wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; - // if (force_exclusive_transfer_queue) - // wait_stages |= VkPipelineStageFlags.Transfer; + if (force_exclusive_transfer_queue) + wait_stages |= VkPipelineStageFlags.Transfer; - // use_semaphore = false; - // } + use_semaphore = false; + } - // if (queue == graphics_queue && cmd_type == CommandBufferType.AsyncTransfer) - // { - // wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; + if (queue == graphics_queue && cmd_type == CommandBufferType.AsyncTransfer) + { + wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; - // if(force_exclusive_transfer_queue) - // wait_stages |= VkPipelineStageFlags.Transfer; + if (force_exclusive_transfer_queue) + wait_stages |= VkPipelineStageFlags.Transfer; - // use_semaphore = false; - // } + use_semaphore = false; + } - // if (queue == graphics_queue && cmd_type == CommandBufferType.AsyncCompute) - // { - // wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; - // wait_stages |= VkPipelineStageFlags.ComputeShader; + if (queue == graphics_queue && cmd_type == CommandBufferType.AsyncCompute) + { + wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; + wait_stages |= VkPipelineStageFlags.ComputeShader; - // use_semaphore = false; - // } + use_semaphore = false; + } - // if (queue == compute_queue && cmd_type == CommandBufferType.AsyncCompute) - // { - // wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; - // wait_stages |= VkPipelineStageFlags.ComputeShader; + if (queue == compute_queue && cmd_type == CommandBufferType.AsyncCompute) + { + wait_stages &= ~VkPipelineStageFlags.ColorAttachmentOutput; + wait_stages |= VkPipelineStageFlags.ComputeShader; - // use_semaphore = false; - // } + use_semaphore = false; + } - // VkSubmitInfo submit_info = new() - // { - // sType = VkStructureType.SubmitInfo, - // pWaitDstStageMask = &wait_stages, - // pNext = null, - // commandBufferCount = 1, - // pCommandBuffers = &cmd, - // }; + VkSubmitInfo submit_info = new() + { + sType = VkStructureType.SubmitInfo, + pWaitDstStageMask = &wait_stages, + pNext = null, + commandBufferCount = 1, + pCommandBuffers = &cmd, + }; - // if (use_semaphore) - // { - // submit_info.waitSemaphoreCount = 1; - // submit_info.pWaitSemaphores = &wait_semaphore; + if (use_semaphore) + { + submit_info.waitSemaphoreCount = 1; + submit_info.pWaitSemaphores = &wait_semaphore; - // submit_info.signalSemaphoreCount = 1; - // submit_info.pSignalSemaphores = &signal_semaphore; - // } + submit_info.signalSemaphoreCount = 1; + submit_info.pSignalSemaphores = &signal_semaphore; + } - // //if (fence is not null) - // // sync_fence = fence.handle; - // //else - // // sync_fence = commandBuffer.WaitFence.handle; + if (fence is not null) + sync_fence = fence.handle; + else + sync_fence = commandBuffer.WaitFence.handle; - // //if (sync_fence != VkFence.Null && queue != VkQueue.Null) - // vkQueueSubmit(queue, 1, &submit_info, sync_fence); - //} + if (sync_fence != VkFence.Null && queue != VkQueue.Null) + vkQueueSubmit(queue, 1, &submit_info, sync_fence); + } internal VkMemoryType memory_prop_ext(VkPhysicalDeviceMemoryProperties memory, uint index) { diff --git a/Src/Vultaik/Graphics/GraphicsPipeline.cs b/Src/Vultaik/Graphics/GraphicsPipeline.cs index 873ad49..cfef8d4 100644 --- a/Src/Vultaik/Graphics/GraphicsPipeline.cs +++ b/Src/Vultaik/Graphics/GraphicsPipeline.cs @@ -199,7 +199,7 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description) sType = VkStructureType.PipelineShaderStageCreateInfo, pNext = null, stage = (VkShaderStageFlags)shaders[i].Stage, - module = NativeDevice.LoadSpir_V_Shader(shaders[i].Data), + module = NativeDevice.load_spirv_shader(shaders[i].Data), pName = Interop.String.ToPointer(shaders[i].EntryPoint), }; } diff --git a/Src/Vultaik/Image.cs b/Src/Vultaik/Image.cs index 9e92863..50217c0 100644 --- a/Src/Vultaik/Image.cs +++ b/Src/Vultaik/Image.cs @@ -253,7 +253,7 @@ internal void create_image(int w, int h) VkMemoryPropertyFlags memoryProperties = VkMemoryPropertyFlags.DeviceLocal; - uint imageHeapIndex = NativeDevice.GetMemoryTypeIndex(imageMemReq.memoryTypeBits, memoryProperties); + uint imageHeapIndex = NativeDevice.get_memory_type(imageMemReq.memoryTypeBits, memoryProperties); Console.WriteLine(imageMemReq.size); VkMemoryAllocateInfo allocInfo = new VkMemoryAllocateInfo { @@ -328,7 +328,7 @@ internal void create_image() VkMemoryPropertyFlags memoryProperties = VkMemoryPropertyFlags.DeviceLocal; - uint imageHeapIndex = NativeDevice.GetMemoryTypeIndex(imageMemReq.memoryTypeBits, memoryProperties); + uint imageHeapIndex = NativeDevice.get_memory_type(imageMemReq.memoryTypeBits, memoryProperties); VkMemoryAllocateInfo allocInfo = new VkMemoryAllocateInfo { @@ -432,17 +432,17 @@ public void SetData(byte[] data) cmd.End(); - //Fence fence = new Fence(NativeDevice); + Fence fence = new Fence(NativeDevice); - NativeDevice.SubmitTransfer(cmd, null); + NativeDevice.Submit(cmd, fence); - //fence.Wait(); + fence.Wait(); //if (fence.IsSignaled) // Cleanup staging resources. - //fence.Dispose(); + fence.Dispose(); vkFreeMemory(NativeDevice.handle, buffer_memory, null); vkDestroyBuffer(NativeDevice.handle, buffer.handle, null);