diff --git a/imgui.ini b/imgui.ini index 5a1a38d..4e39eef 100644 --- a/imgui.ini +++ b/imgui.ini @@ -18,3 +18,8 @@ Pos=112,297 Size=300,425 Collapsed=0 +[Window][Cortex Engine Debug] +Pos=60,60 +Size=226,196 +Collapsed=0 + diff --git a/src/CortexEngine.App/Program.cs b/src/CortexEngine.App/Program.cs index b59cc2b..05e8e1c 100644 --- a/src/CortexEngine.App/Program.cs +++ b/src/CortexEngine.App/Program.cs @@ -14,6 +14,7 @@ using Engine.Graphics.Loaders; using Engine.Graphics.Vulkan; using Engine.Physics; using Flecs.NET.Core; +using ImGuiNET; namespace CortexEngine.App; @@ -46,6 +47,16 @@ class Program var input = window.Input; using var renderer = renderContext.CreateRenderer(); + VulkanImGui? imGuiLayer = null; + if (!cameraTour && renderer is VulkanRenderer vkRenderer) + { + ImGui.CreateContext(); + imGuiLayer = new VulkanImGui(vkRenderer._ctx, vkRenderer._swapchain); + vkRenderer.ImGuiLayer = imGuiLayer; + ImGui.GetIO().DisplaySize = new System.Numerics.Vector2(window.Width, window.Height); + Console.WriteLine("[App] ImGui initialized."); + } + var (modelPath, mcpPort) = ParseArgs(args); var mesh = LoadModel(modelPath); @@ -249,6 +260,35 @@ class Program demoScreenshotRequested = true; } + if (imGuiLayer != null) + { + ImGui.NewFrame(); + ImGui.Begin("Cortex Engine Debug"); + ImGui.Text($"FPS: {currentFps}"); + ImGui.Text($"Delta: {timing.DeltaTime * 1000.0:F2} ms"); + ImGui.Text($"Camera: {cameraController.Name}"); + ImGui.Separator(); + var cam = cameraEntity.Get(); + ImGui.Text($"Pos: ({cam.Position.X:F2}, {cam.Position.Y:F2}, {cam.Position.Z:F2})"); + ImGui.Text($"Target: ({cam.Target.X:F2}, {cam.Target.Y:F2}, {cam.Target.Z:F2})"); + ImGui.Separator(); + + var entityCount = 0; + world.Each((Entity e, ref Transform _) => entityCount++); + ImGui.Text($"Entities: {entityCount}"); + ImGui.Text($"Press F to toggle camera"); + + ImGui.Separator(); + ImGui.Text("Lights:"); + world.Each((Entity e, ref Light light) => + { + ImGui.Text($" {e.Name()}: {light.Type} I={light.Intensity:F1}"); + }); + + ImGui.End(); + ImGui.Render(); + } + renderer.RenderWorld(world); queue.CompletePendingScreenshots(); @@ -263,6 +303,7 @@ class Program } Console.WriteLine("Shutting down..."); + imGuiLayer?.Dispose(); #if !RELEASE_AOT if (mcpApp != null) await mcpApp.StopAsync(); diff --git a/src/Engine.Graphics.Vulkan/Engine.Graphics.Vulkan.csproj b/src/Engine.Graphics.Vulkan/Engine.Graphics.Vulkan.csproj index c1bb767..f63c967 100644 --- a/src/Engine.Graphics.Vulkan/Engine.Graphics.Vulkan.csproj +++ b/src/Engine.Graphics.Vulkan/Engine.Graphics.Vulkan.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Engine.Graphics.Vulkan/Shaders/imgui.frag b/src/Engine.Graphics.Vulkan/Shaders/imgui.frag new file mode 100644 index 0000000..ce8cf37 --- /dev/null +++ b/src/Engine.Graphics.Vulkan/Shaders/imgui.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(location = 0) in vec2 fragUV; +layout(location = 1) in vec4 fragColor; + +layout(set = 0, binding = 0) uniform sampler2D fontTexture; + +layout(location = 0) out vec4 outColor; + +void main() { + outColor = fragColor * texture(fontTexture, fragUV); +} diff --git a/src/Engine.Graphics.Vulkan/Shaders/imgui.frag.spv b/src/Engine.Graphics.Vulkan/Shaders/imgui.frag.spv new file mode 100644 index 0000000..f72ca97 Binary files /dev/null and b/src/Engine.Graphics.Vulkan/Shaders/imgui.frag.spv differ diff --git a/src/Engine.Graphics.Vulkan/Shaders/imgui.vert b/src/Engine.Graphics.Vulkan/Shaders/imgui.vert new file mode 100644 index 0000000..a883eb3 --- /dev/null +++ b/src/Engine.Graphics.Vulkan/Shaders/imgui.vert @@ -0,0 +1,19 @@ +#version 450 + +layout(location = 0) in vec2 inPos; +layout(location = 1) in vec2 inUV; +layout(location = 2) in vec4 inColor; + +layout(push_constant) uniform PushConstants { + vec2 scale; + vec2 translate; +} pc; + +layout(location = 0) out vec2 fragUV; +layout(location = 1) out vec4 fragColor; + +void main() { + fragUV = inUV; + fragColor = inColor; + gl_Position = vec4(inPos * pc.scale + pc.translate, 0.0, 1.0); +} diff --git a/src/Engine.Graphics.Vulkan/Shaders/imgui.vert.spv b/src/Engine.Graphics.Vulkan/Shaders/imgui.vert.spv new file mode 100644 index 0000000..a712fb2 Binary files /dev/null and b/src/Engine.Graphics.Vulkan/Shaders/imgui.vert.spv differ diff --git a/src/Engine.Graphics.Vulkan/Vk.cs b/src/Engine.Graphics.Vulkan/Vk.cs index ec12c27..f576ebd 100644 --- a/src/Engine.Graphics.Vulkan/Vk.cs +++ b/src/Engine.Graphics.Vulkan/Vk.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace Engine.Graphics.Vulkan; -internal static unsafe class Vk +public static unsafe class Vk { public static VkInstance Instance; public static VkDevice Device; @@ -242,168 +242,168 @@ internal static unsafe class Vk } [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateInstance(VkInstanceCreateInfo* pCreateInfo, void* pAllocator, VkInstance* pInstance); +unsafe public delegate VkResult PFN_vkCreateInstance(VkInstanceCreateInfo* pCreateInfo, void* pAllocator, VkInstance* pInstance); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyInstance(VkInstance instance, void* pAllocator); +unsafe public delegate void PFN_vkDestroyInstance(VkInstance instance, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkEnumeratePhysicalDevices(VkInstance instance, uint* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +unsafe public delegate VkResult PFN_vkEnumeratePhysicalDevices(VkInstance instance, uint* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); +unsafe public delegate void PFN_vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties); +unsafe public delegate void PFN_vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); +unsafe public delegate void PFN_vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, byte* pLayerName, uint* pPropertyCount, VkExtensionProperties* pProperties); +unsafe public delegate VkResult PFN_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, byte* pLayerName, uint* pPropertyCount, VkExtensionProperties* pProperties); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo, void* pAllocator, VkDevice* pDevice); +unsafe public delegate VkResult PFN_vkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo, void* pAllocator, VkDevice* pDevice); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyDevice(VkDevice device, void* pAllocator); +unsafe public delegate void PFN_vkDestroyDevice(VkDevice device, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetDeviceQueue(VkDevice device, uint queueFamilyIndex, uint queueIndex, VkQueue* pQueue); +unsafe public delegate void PFN_vkGetDeviceQueue(VkDevice device, uint queueFamilyIndex, uint queueIndex, VkQueue* pQueue); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateSwapchainKHR(VkDevice device, VkSwapchainCreateInfoKHR* pCreateInfo, void* pAllocator, VkSwapchainKHR* pSwapchain); +unsafe public delegate VkResult PFN_vkCreateSwapchainKHR(VkDevice device, VkSwapchainCreateInfoKHR* pCreateInfo, void* pAllocator, VkSwapchainKHR* pSwapchain); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, void* pAllocator); +unsafe public delegate void PFN_vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint* pSwapchainImageCount, VkImage* pSwapchainImages); +unsafe public delegate VkResult PFN_vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint* pSwapchainImageCount, VkImage* pSwapchainImages); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateImageView(VkDevice device, VkImageViewCreateInfo* pCreateInfo, void* pAllocator, VkImageView* pView); +unsafe public delegate VkResult PFN_vkCreateImageView(VkDevice device, VkImageViewCreateInfo* pCreateInfo, void* pAllocator, VkImageView* pView); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyImageView(VkDevice device, VkImageView imageView, void* pAllocator); +unsafe public delegate void PFN_vkDestroyImageView(VkDevice device, VkImageView imageView, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateImage(VkDevice device, VkImageCreateInfo* pCreateInfo, void* pAllocator, VkImage* pImage); +unsafe public delegate VkResult PFN_vkCreateImage(VkDevice device, VkImageCreateInfo* pCreateInfo, void* pAllocator, VkImage* pImage); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyImage(VkDevice device, VkImage image, void* pAllocator); +unsafe public delegate void PFN_vkDestroyImage(VkDevice device, VkImage image, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetImageMemoryRequirements(VkDevice device, VkImage image, void* pMemoryRequirements); +unsafe public delegate void PFN_vkGetImageMemoryRequirements(VkDevice device, VkImage image, void* pMemoryRequirements); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, ulong memoryOffset); +unsafe public delegate VkResult PFN_vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, ulong memoryOffset); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateRenderPass(VkDevice device, VkRenderPassCreateInfo* pCreateInfo, void* pAllocator, VkRenderPass* pRenderPass); +unsafe public delegate VkResult PFN_vkCreateRenderPass(VkDevice device, VkRenderPassCreateInfo* pCreateInfo, void* pAllocator, VkRenderPass* pRenderPass); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, void* pAllocator); +unsafe public delegate void PFN_vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateFramebuffer(VkDevice device, VkFramebufferCreateInfo* pCreateInfo, void* pAllocator, VkFramebuffer* pFramebuffer); +unsafe public delegate VkResult PFN_vkCreateFramebuffer(VkDevice device, VkFramebufferCreateInfo* pCreateInfo, void* pAllocator, VkFramebuffer* pFramebuffer); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, void* pAllocator); +unsafe public delegate void PFN_vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateShaderModule(VkDevice device, VkShaderModuleCreateInfo* pCreateInfo, void* pAllocator, VkShaderModule* pShaderModule); +unsafe public delegate VkResult PFN_vkCreateShaderModule(VkDevice device, VkShaderModuleCreateInfo* pCreateInfo, void* pAllocator, VkShaderModule* pShaderModule); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, void* pAllocator); +unsafe public delegate void PFN_vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateDescriptorSetLayout(VkDevice device, VkDescriptorSetLayoutCreateInfo* pCreateInfo, void* pAllocator, VkDescriptorSetLayout* pSetLayout); +unsafe public delegate VkResult PFN_vkCreateDescriptorSetLayout(VkDevice device, VkDescriptorSetLayoutCreateInfo* pCreateInfo, void* pAllocator, VkDescriptorSetLayout* pSetLayout); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, void* pAllocator); +unsafe public delegate void PFN_vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreatePipelineLayout(VkDevice device, VkPipelineLayoutCreateInfo* pCreateInfo, void* pAllocator, VkPipelineLayout* pPipelineLayout); +unsafe public delegate VkResult PFN_vkCreatePipelineLayout(VkDevice device, VkPipelineLayoutCreateInfo* pCreateInfo, void* pAllocator, VkPipelineLayout* pPipelineLayout); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, void* pAllocator); +unsafe public delegate void PFN_vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateGraphicsPipelines(VkDevice device, ulong pipelineCache, uint createInfoCount, VkGraphicsPipelineCreateInfo* pCreateInfos, void* pAllocator, VkPipeline* pPipelines); +unsafe public delegate VkResult PFN_vkCreateGraphicsPipelines(VkDevice device, ulong pipelineCache, uint createInfoCount, VkGraphicsPipelineCreateInfo* pCreateInfos, void* pAllocator, VkPipeline* pPipelines); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyPipeline(VkDevice device, VkPipeline pipeline, void* pAllocator); +unsafe public delegate void PFN_vkDestroyPipeline(VkDevice device, VkPipeline pipeline, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolCreateInfo* pCreateInfo, void* pAllocator, VkDescriptorPool* pDescriptorPool); +unsafe public delegate VkResult PFN_vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolCreateInfo* pCreateInfo, void* pAllocator, VkDescriptorPool* pDescriptorPool); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, void* pAllocator); +unsafe public delegate void PFN_vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkAllocateDescriptorSets(VkDevice device, VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); +unsafe public delegate VkResult PFN_vkAllocateDescriptorSets(VkDevice device, VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkUpdateDescriptorSets(VkDevice device, uint descriptorWriteCount, VkWriteDescriptorSet* pDescriptorWrites, uint descriptorCopyCount, void* pDescriptorCopies); +unsafe public delegate void PFN_vkUpdateDescriptorSets(VkDevice device, uint descriptorWriteCount, VkWriteDescriptorSet* pDescriptorWrites, uint descriptorCopyCount, void* pDescriptorCopies); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateBuffer(VkDevice device, VkBufferCreateInfo* pCreateInfo, void* pAllocator, VkBuffer* pBuffer); +unsafe public delegate VkResult PFN_vkCreateBuffer(VkDevice device, VkBufferCreateInfo* pCreateInfo, void* pAllocator, VkBuffer* pBuffer); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyBuffer(VkDevice device, VkBuffer buffer, void* pAllocator); +unsafe public delegate void PFN_vkDestroyBuffer(VkDevice device, VkBuffer buffer, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, void* pMemoryRequirements); +unsafe public delegate void PFN_vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, void* pMemoryRequirements); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, ulong memoryOffset); +unsafe public delegate VkResult PFN_vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, ulong memoryOffset); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkAllocateMemory(VkDevice device, VkMemoryAllocateInfo* pAllocateInfo, void* pAllocator, VkDeviceMemory* pMemory); +unsafe public delegate VkResult PFN_vkAllocateMemory(VkDevice device, VkMemoryAllocateInfo* pAllocateInfo, void* pAllocator, VkDeviceMemory* pMemory); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkFreeMemory(VkDevice device, VkDeviceMemory memory, void* pAllocator); +unsafe public delegate void PFN_vkFreeMemory(VkDevice device, VkDeviceMemory memory, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkMapMemory(VkDevice device, VkDeviceMemory memory, ulong offset, ulong size, uint flags, void** ppData); +unsafe public delegate VkResult PFN_vkMapMemory(VkDevice device, VkDeviceMemory memory, ulong offset, ulong size, uint flags, void** ppData); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkUnmapMemory(VkDevice device, VkDeviceMemory memory); +unsafe public delegate void PFN_vkUnmapMemory(VkDevice device, VkDeviceMemory memory); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateCommandPool(VkDevice device, VkCommandPoolCreateInfo* pCreateInfo, void* pAllocator, VkCommandPool* pCommandPool); +unsafe public delegate VkResult PFN_vkCreateCommandPool(VkDevice device, VkCommandPoolCreateInfo* pCreateInfo, void* pAllocator, VkCommandPool* pCommandPool); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, void* pAllocator); +unsafe public delegate void PFN_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkAllocateCommandBuffers(VkDevice device, VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); +unsafe public delegate VkResult PFN_vkAllocateCommandBuffers(VkDevice device, VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint commandBufferCount, VkCommandBuffer* pCommandBuffers); +unsafe public delegate void PFN_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint commandBufferCount, VkCommandBuffer* pCommandBuffers); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferBeginInfo* pBeginInfo); +unsafe public delegate VkResult PFN_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferBeginInfo* pBeginInfo); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkEndCommandBuffer(VkCommandBuffer commandBuffer); +unsafe public delegate VkResult PFN_vkEndCommandBuffer(VkCommandBuffer commandBuffer); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkResetCommandBuffer(VkCommandBuffer commandBuffer, uint flags); +unsafe public delegate VkResult PFN_vkResetCommandBuffer(VkCommandBuffer commandBuffer, uint flags); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkQueueSubmit(VkQueue queue, uint submitCount, VkSubmitInfo* pSubmits, VkFence fence); +unsafe public delegate VkResult PFN_vkQueueSubmit(VkQueue queue, uint submitCount, VkSubmitInfo* pSubmits, VkFence fence); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkQueueWaitIdle(VkQueue queue); +unsafe public delegate VkResult PFN_vkQueueWaitIdle(VkQueue queue); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkQueuePresentKHR(VkQueue queue, VkPresentInfoKHR* pPresentInfo); +unsafe public delegate VkResult PFN_vkQueuePresentKHR(VkQueue queue, VkPresentInfoKHR* pPresentInfo); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, ulong timeout, VkSemaphore semaphore, VkFence fence, uint* pImageIndex); +unsafe public delegate VkResult PFN_vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, ulong timeout, VkSemaphore semaphore, VkFence fence, uint* pImageIndex); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateSemaphore(VkDevice device, VkSemaphoreCreateInfo* pCreateInfo, void* pAllocator, VkSemaphore* pSemaphore); +unsafe public delegate VkResult PFN_vkCreateSemaphore(VkDevice device, VkSemaphoreCreateInfo* pCreateInfo, void* pAllocator, VkSemaphore* pSemaphore); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, void* pAllocator); +unsafe public delegate void PFN_vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateFence(VkDevice device, VkFenceCreateInfo* pCreateInfo, void* pAllocator, VkFence* pFence); +unsafe public delegate VkResult PFN_vkCreateFence(VkDevice device, VkFenceCreateInfo* pCreateInfo, void* pAllocator, VkFence* pFence); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroyFence(VkDevice device, VkFence fence, void* pAllocator); +unsafe public delegate void PFN_vkDestroyFence(VkDevice device, VkFence fence, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkWaitForFences(VkDevice device, uint fenceCount, VkFence* pFences, uint waitAll, ulong timeout); +unsafe public delegate VkResult PFN_vkWaitForFences(VkDevice device, uint fenceCount, VkFence* pFences, uint waitAll, ulong timeout); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkResetFences(VkDevice device, uint fenceCount, VkFence* pFences); +unsafe public delegate VkResult PFN_vkResetFences(VkDevice device, uint fenceCount, VkFence* pFences); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents); +unsafe public delegate void PFN_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdEndRenderPass(VkCommandBuffer commandBuffer); +unsafe public delegate void PFN_vkCmdEndRenderPass(VkCommandBuffer commandBuffer); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdBindPipeline(VkCommandBuffer commandBuffer, int pipelineBindPoint, VkPipeline pipeline); +unsafe public delegate void PFN_vkCmdBindPipeline(VkCommandBuffer commandBuffer, int pipelineBindPoint, VkPipeline pipeline); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, int pipelineBindPoint, VkPipelineLayout layout, uint firstSet, uint descriptorSetCount, VkDescriptorSet* pDescriptorSets, uint dynamicOffsetCount, uint* pDynamicOffsets); +unsafe public delegate void PFN_vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, int pipelineBindPoint, VkPipelineLayout layout, uint firstSet, uint descriptorSetCount, VkDescriptorSet* pDescriptorSets, uint dynamicOffsetCount, uint* pDynamicOffsets); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint firstBinding, uint bindingCount, VkBuffer* pBuffers, ulong* pOffsets); +unsafe public delegate void PFN_vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint firstBinding, uint bindingCount, VkBuffer* pBuffers, ulong* pOffsets); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, ulong offset, VkIndexType indexType); +unsafe public delegate void PFN_vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, ulong offset, VkIndexType indexType); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint indexCount, uint instanceCount, uint firstIndex, int vertexOffset, uint firstInstance); +unsafe public delegate void PFN_vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint indexCount, uint instanceCount, uint firstIndex, int vertexOffset, uint firstInstance); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdDraw(VkCommandBuffer commandBuffer, uint vertexCount, uint instanceCount, uint firstVertex, uint firstInstance); +unsafe public delegate void PFN_vkCmdDraw(VkCommandBuffer commandBuffer, uint vertexCount, uint instanceCount, uint firstVertex, uint firstInstance); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint firstViewport, uint viewportCount, VkViewport* pViewports); +unsafe public delegate void PFN_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint firstViewport, uint viewportCount, VkViewport* pViewports); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint firstScissor, uint scissorCount, VkRect2D* pScissors); +unsafe public delegate void PFN_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint firstScissor, uint scissorCount, VkRect2D* pScissors); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, int dependencyFlags, uint memoryBarrierCount, void* pMemoryBarriers, uint bufferMemoryBarrierCount, VkBufferMemoryBarrier* pBufferMemoryBarriers, uint imageMemoryBarrierCount, VkImageMemoryBarrier* pImageMemoryBarriers); +unsafe public delegate void PFN_vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, int dependencyFlags, uint memoryBarrierCount, void* pMemoryBarriers, uint bufferMemoryBarrierCount, VkBufferMemoryBarrier* pBufferMemoryBarriers, uint imageMemoryBarrierCount, VkImageMemoryBarrier* pImageMemoryBarriers); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint regionCount, VkBufferCopy* pRegions); +unsafe public delegate void PFN_vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint regionCount, VkBufferCopy* pRegions); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, int dstImageLayout, uint regionCount, VkBufferImageCopy* pRegions); +unsafe public delegate void PFN_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, int dstImageLayout, uint regionCount, VkBufferImageCopy* pRegions); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, int srcImageLayout, VkBuffer dstBuffer, uint regionCount, VkBufferImageCopy* pRegions); +unsafe public delegate void PFN_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, int srcImageLayout, VkBuffer dstBuffer, uint regionCount, VkBufferImageCopy* pRegions); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, int imageLayout, VkClearColorValue* pColor, uint rangeCount, VkImageSubresourceRange* pRanges); +unsafe public delegate void PFN_vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, int imageLayout, VkClearColorValue* pColor, uint rangeCount, VkImageSubresourceRange* pRanges); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, uint size, void* pValues); +unsafe public delegate void PFN_vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, uint size, void* pValues); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkCreateSampler(VkDevice device, VkSamplerCreateInfo* pCreateInfo, void* pAllocator, void* pSampler); +unsafe public delegate VkResult PFN_vkCreateSampler(VkDevice device, VkSamplerCreateInfo* pCreateInfo, void* pAllocator, void* pSampler); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroySampler(VkDevice device, void* sampler, void* pAllocator); +unsafe public delegate void PFN_vkDestroySampler(VkDevice device, void* sampler, void* pAllocator); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint queueFamilyIndex, VkSurfaceKHR surface, uint* pSupported); +unsafe public delegate VkResult PFN_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint queueFamilyIndex, VkSurfaceKHR surface, uint* pSupported); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); +unsafe public delegate VkResult PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); +unsafe public delegate VkResult PFN_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate VkResult PFN_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint* pPresentModeCount, VkPresentModeKHR* pPresentModes); +unsafe public delegate VkResult PFN_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint* pPresentModeCount, VkPresentModeKHR* pPresentModes); [UnmanagedFunctionPointer(CallingConvention.Winapi)] -unsafe internal delegate void PFN_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, void* pAllocator); +unsafe public delegate void PFN_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, void* pAllocator); diff --git a/src/Engine.Graphics.Vulkan/VulkanBuffer.cs b/src/Engine.Graphics.Vulkan/VulkanBuffer.cs index 1b604ed..716fc40 100644 --- a/src/Engine.Graphics.Vulkan/VulkanBuffer.cs +++ b/src/Engine.Graphics.Vulkan/VulkanBuffer.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace Engine.Graphics.Vulkan; -internal sealed unsafe class VulkanBuffer : IDisposable +public sealed unsafe class VulkanBuffer : IDisposable { public VkBuffer Buffer; public VkDeviceMemory Memory; diff --git a/src/Engine.Graphics.Vulkan/VulkanContext.cs b/src/Engine.Graphics.Vulkan/VulkanContext.cs index c6afd40..0d316d4 100644 --- a/src/Engine.Graphics.Vulkan/VulkanContext.cs +++ b/src/Engine.Graphics.Vulkan/VulkanContext.cs @@ -5,7 +5,7 @@ using SDL; namespace Engine.Graphics.Vulkan; -internal sealed unsafe class VulkanContext : IDisposable +public sealed unsafe class VulkanContext : IDisposable { public VkInstance Instance; public VkPhysicalDevice PhysicalDevice; diff --git a/src/Engine.Graphics.Vulkan/VulkanImGui.cs b/src/Engine.Graphics.Vulkan/VulkanImGui.cs new file mode 100644 index 0000000..373d6ab --- /dev/null +++ b/src/Engine.Graphics.Vulkan/VulkanImGui.cs @@ -0,0 +1,521 @@ +using System.Runtime.InteropServices; +using System.Numerics; +using ImGuiNET; + +namespace Engine.Graphics.Vulkan; + +public sealed unsafe class VulkanImGui : IDisposable +{ + private readonly VulkanContext _ctx; + private readonly VulkanSwapchain _swapchain; + private VkCommandPool _initCommandPool; + private VkPipeline _pipeline; + private VkPipelineLayout _pipelineLayout; + private VkDescriptorSetLayout _descriptorSetLayout; + private VkDescriptorPool _descriptorPool; + private VkDescriptorSet _descriptorSet; + private VkShaderModule _vertexShader; + private VkShaderModule _fragmentShader; + private VkImage _fontImage; + private VkDeviceMemory _fontImageMemory; + private VkImageView _fontImageView; + private VkSampler _fontSampler; + private VulkanBuffer? _vertexBuffer; + private VulkanBuffer? _indexBuffer; + + private static readonly byte[] VkDescriptorWriteDummy = new byte[1]; + + public VulkanImGui(VulkanContext ctx, VulkanSwapchain swapchain) + { + _ctx = ctx; + _swapchain = swapchain; + Initialize(); + } + + private unsafe void Initialize() + { + var io = ImGui.GetIO(); + io.Fonts.AddFontDefault(); + io.Fonts.Build(); + + VkCommandPoolCreateInfo poolInfo = default; + poolInfo.sType = VkStructureType.CommandPoolCreateInfo; + poolInfo.flags = 0x00000002; + poolInfo.queueFamilyIndex = _ctx.GraphicsFamily; + VkCommandPool pool; + Vk.CheckResult(Vk.vkCreateCommandPool(_ctx.Device, &poolInfo, null, &pool), "vkCreateCommandPool (ImGui init)"); + _initCommandPool = pool; + + CreateFontTexture(); + CreateShaders(); + CreateDescriptorSetLayout(); + CreatePipelineLayout(); + CreatePipeline(); + CreateDescriptorPoolAndSet(); + + Vk.vkDestroyCommandPool(_ctx.Device, _initCommandPool, null); + } + + private unsafe void CreateFontTexture() + { + var io = ImGui.GetIO(); + int width, height, bpp; + byte* pixels; + io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height, out bpp); + + VkImageCreateInfo imageInfo = default; + imageInfo.sType = VkStructureType.ImageCreateInfo; + imageInfo.imageType = VkImageType._2D; + imageInfo.format = VkFormat.R8G8B8A8Unorm; + imageInfo.extent = new VkExtent3D { width = width, height = height, depth = 1 }; + imageInfo.mipLevels = 1; + imageInfo.arrayLayers = 1; + imageInfo.samples = VkSampleCountFlags.One; + imageInfo.tiling = 0; + imageInfo.usage = VkImageUsageFlags.Sampled | VkImageUsageFlags.TransferDst; + imageInfo.sharingMode = VkSharingMode.Exclusive; + imageInfo.initialLayout = 0; + + VkImage fontImage; + Vk.CheckResult(Vk.vkCreateImage(_ctx.Device, &imageInfo, null, &fontImage), "vkCreateImage (font)"); + _fontImage = fontImage; + + VkMemoryRequirements2 memReq; + Vk.vkGetImageMemoryRequirements(_ctx.Device, _fontImage, &memReq); + + VkMemoryAllocateInfo allocInfo = default; + allocInfo.sType = VkStructureType.MemoryAllocateInfo; + allocInfo.allocationSize = memReq.size; + allocInfo.memoryTypeIndex = _ctx.FindMemoryType(memReq.memoryTypeBits, VkMemoryPropertyFlags.DeviceLocal); + + VkDeviceMemory fontMem; + Vk.CheckResult(Vk.vkAllocateMemory(_ctx.Device, &allocInfo, null, &fontMem), "vkAllocateMemory (font)"); + _fontImageMemory = fontMem; + Vk.CheckResult(Vk.vkBindImageMemory(_ctx.Device, _fontImage, _fontImageMemory, 0), "vkBindImageMemory (font)"); + + var imageSize = (ulong)(width * height * 4); + var staging = new VulkanBuffer(_ctx, imageSize, + VkBufferUsageFlags.TransferSrc, + VkMemoryPropertyFlags.HostVisible | VkMemoryPropertyFlags.HostCoherent); + + Buffer.MemoryCopy(pixels, staging.MappedData, imageSize, imageSize); + + var cmd = VulkanBuffer.BeginSingleTimeCommands(_ctx, _initCommandPool); + + var barrier = new VkImageMemoryBarrier + { + sType = VkStructureType.ImageMemoryBarrier, + srcAccessMask = 0, + dstAccessMask = VkAccessFlags.TransferWrite, + oldLayout = VkImageLayout.Undefined, + newLayout = VkImageLayout.TransferDstOptimal, + srcQueueFamilyIndex = ~0u, + dstQueueFamilyIndex = ~0u, + image = _fontImage, + subresourceRange = new VkImageSubresourceRange + { + aspectMask = VkImageAspectFlags.Color, + baseMipLevel = 0, levelCount = 1, baseArrayLayer = 0, layerCount = 1 + } + }; + + Vk.vkCmdPipelineBarrier(cmd, VkPipelineStageFlags.Host, VkPipelineStageFlags.Transfer, + 0, 0, null, 0, null, 1, &barrier); + + var region = new VkBufferImageCopy + { + bufferOffset = 0, + bufferRowLength = (uint)width, + bufferImageHeight = (uint)height, + imageSubresource = new VkImageSubresourceLayers + { + aspectMask = VkImageAspectFlags.Color, + mipLevel = 0, baseArrayLayer = 0, layerCount = 1 + }, + imageOffset = new VkOffset3D { x = 0, y = 0, z = 0 }, + imageExtent = new VkExtent3D { width = width, height = height, depth = 1 } + }; + + Vk.vkCmdCopyBufferToImage(cmd, staging.Buffer, _fontImage, + (int)VkImageLayout.TransferDstOptimal, 1, ®ion); + + var barrier2 = new VkImageMemoryBarrier + { + sType = VkStructureType.ImageMemoryBarrier, + srcAccessMask = VkAccessFlags.TransferWrite, + dstAccessMask = VkAccessFlags.ShaderRead, + oldLayout = VkImageLayout.TransferDstOptimal, + newLayout = VkImageLayout.ShaderReadOnlyOptimal, + srcQueueFamilyIndex = ~0u, + dstQueueFamilyIndex = ~0u, + image = _fontImage, + subresourceRange = new VkImageSubresourceRange + { + aspectMask = VkImageAspectFlags.Color, + baseMipLevel = 0, levelCount = 1, baseArrayLayer = 0, layerCount = 1 + } + }; + + Vk.vkCmdPipelineBarrier(cmd, VkPipelineStageFlags.Transfer, VkPipelineStageFlags.FragmentShader, + 0, 0, null, 0, null, 1, &barrier2); + + VulkanBuffer.EndSingleTimeCommands(_ctx, _initCommandPool, cmd); + staging.Dispose(); + + VkImageViewCreateInfo viewInfo = default; + viewInfo.sType = VkStructureType.ImageViewCreateInfo; + viewInfo.image = _fontImage; + viewInfo.viewType = VkImageViewType._2D; + viewInfo.format = VkFormat.R8G8B8A8Unorm; + viewInfo.subresourceRange = new VkImageSubresourceRange + { + aspectMask = VkImageAspectFlags.Color, + baseMipLevel = 0, levelCount = 1, baseArrayLayer = 0, layerCount = 1 + }; + + VkImageView fontView; + Vk.CheckResult(Vk.vkCreateImageView(_ctx.Device, &viewInfo, null, &fontView), "vkCreateImageView (font)"); + _fontImageView = fontView; + + VkSamplerCreateInfo samplerInfo = default; + samplerInfo.sType = VkStructureType.SamplerCreateInfo; + samplerInfo.magFilter = VkFilter.Linear; + samplerInfo.minFilter = VkFilter.Linear; + samplerInfo.mipmapMode = VkSamplerMipmapMode.Linear; + samplerInfo.addressModeU = VkSamplerAddressMode.Repeat; + samplerInfo.addressModeV = VkSamplerAddressMode.Repeat; + samplerInfo.addressModeW = VkSamplerAddressMode.Repeat; + samplerInfo.minLod = -1000; + samplerInfo.maxLod = 1000; + + VkSampler fontSampler; + Vk.CheckResult(Vk.vkCreateSampler(_ctx.Device, &samplerInfo, null, (void*)&fontSampler), "vkCreateSampler (font)"); + _fontSampler = fontSampler; + } + + private unsafe VkShaderModule LoadShader(string path) + { + var fullPath = Path.Combine(AppContext.BaseDirectory, path); + if (!File.Exists(fullPath)) + throw new FileNotFoundException($"ImGui SPIR-V shader not found: {fullPath}"); + + var code = File.ReadAllBytes(fullPath); + fixed (byte* pCode = code) + { + VkShaderModuleCreateInfo createInfo = default; + createInfo.sType = VkStructureType.ShaderModuleCreateInfo; + createInfo.codeSize = (ulong)code.Length; + createInfo.pCode = (uint*)pCode; + + VkShaderModule module; + Vk.CheckResult(Vk.vkCreateShaderModule(_ctx.Device, &createInfo, null, &module), $"vkCreateShaderModule ({path})"); + return module; + } + } + + private void CreateShaders() + { + _vertexShader = LoadShader("Shaders/imgui.vert.spv"); + _fragmentShader = LoadShader("Shaders/imgui.frag.spv"); + } + + private unsafe void CreateDescriptorSetLayout() + { + var binding = new VkDescriptorSetLayoutBinding + { + binding = 0, + descriptorType = VkDescriptorType.CombinedImageSampler, + descriptorCount = 1, + stageFlags = VkShaderStageFlags.Fragment, + pImmutableSamplers = null + }; + + VkDescriptorSetLayoutCreateInfo createInfo = default; + createInfo.sType = VkStructureType.DescriptorSetLayoutCreateInfo; + createInfo.bindingCount = 1; + createInfo.pBindings = &binding; + + VkDescriptorSetLayout dsLayout; + Vk.CheckResult(Vk.vkCreateDescriptorSetLayout(_ctx.Device, &createInfo, null, &dsLayout), "vkCreateDescriptorSetLayout (ImGui)"); + _descriptorSetLayout = dsLayout; + } + + private unsafe void CreatePipelineLayout() + { + var pushConstantRange = new VkPushConstantRange + { + stageFlags = VkShaderStageFlags.Vertex, + offset = 0, + size = 16 + }; + + var dsLayout = _descriptorSetLayout; + VkPipelineLayoutCreateInfo createInfo = default; + createInfo.sType = VkStructureType.PipelineLayoutCreateInfo; + createInfo.setLayoutCount = 1; + createInfo.pSetLayouts = &dsLayout; + createInfo.pushConstantRangeCount = 1; + createInfo.pPushConstantRanges = &pushConstantRange; + + VkPipelineLayout pipeLayout; + Vk.CheckResult(Vk.vkCreatePipelineLayout(_ctx.Device, &createInfo, null, &pipeLayout), "vkCreatePipelineLayout (ImGui)"); + _pipelineLayout = pipeLayout; + } + + private unsafe void CreatePipeline() + { + var mainName = Vk.AllocUtf8("main"); + + var stages = stackalloc VkPipelineShaderStageCreateInfo[2]; + stages[0] = new VkPipelineShaderStageCreateInfo + { + sType = VkStructureType.PipelineShaderStageCreateInfo, + stage = VkShaderStageFlags.Vertex, + module = _vertexShader, + pName = mainName + }; + stages[1] = new VkPipelineShaderStageCreateInfo + { + sType = VkStructureType.PipelineShaderStageCreateInfo, + stage = VkShaderStageFlags.Fragment, + module = _fragmentShader, + pName = mainName + }; + + var bindingDesc = new VkVertexInputBindingDescription + { + binding = 0, + stride = (uint)Marshal.SizeOf(), + inputRate = 0 + }; + + var attrDescs = stackalloc VkVertexInputAttributeDescription[3]; + attrDescs[0] = new VkVertexInputAttributeDescription { location = 0, binding = 0, format = VkFormat.R32G32Sfloat, offset = 0 }; + attrDescs[1] = new VkVertexInputAttributeDescription { location = 1, binding = 0, format = VkFormat.R32G32Sfloat, offset = 8 }; + attrDescs[2] = new VkVertexInputAttributeDescription { location = 2, binding = 0, format = VkFormat.R8G8B8A8Unorm, offset = 16 }; + + VkPipelineVertexInputStateCreateInfo vertexInputState = default; + vertexInputState.sType = VkStructureType.PipelineVertexInputStateCreateInfo; + vertexInputState.vertexBindingDescriptionCount = 1; + vertexInputState.pVertexBindingDescriptions = &bindingDesc; + vertexInputState.vertexAttributeDescriptionCount = 3; + vertexInputState.pVertexAttributeDescriptions = attrDescs; + + VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = default; + inputAssemblyState.sType = VkStructureType.PipelineInputAssemblyStateCreateInfo; + inputAssemblyState.topology = VkPrimitiveTopology.TriangleList; + + var viewport = new VkViewport(); + var scissor = new VkRect2D(); + + VkPipelineViewportStateCreateInfo viewportState = default; + viewportState.sType = VkStructureType.PipelineViewportStateCreateInfo; + viewportState.viewportCount = 1; + viewportState.pViewports = &viewport; + viewportState.scissorCount = 1; + viewportState.pScissors = &scissor; + + VkPipelineRasterizationStateCreateInfo rasterState = default; + rasterState.sType = VkStructureType.PipelineRasterizationStateCreateInfo; + rasterState.polygonMode = VkPolygonMode.Fill; + rasterState.cullMode = VkCullModeFlags.None; + rasterState.frontFace = VkFrontFace.Clockwise; + rasterState.lineWidth = 1.0f; + + VkPipelineMultisampleStateCreateInfo msState = default; + msState.sType = VkStructureType.PipelineMultisampleStateCreateInfo; + msState.rasterizationSamples = VkSampleCountFlags.One; + + VkPipelineColorBlendAttachmentState blendAttachment = default; + blendAttachment.blendEnable = 1; + blendAttachment.srcColorBlendFactor = VkBlendFactor.SrcAlpha; + blendAttachment.dstColorBlendFactor = VkBlendFactor.OneMinusSrcAlpha; + blendAttachment.colorBlendOp = VkBlendOp.Add; + blendAttachment.srcAlphaBlendFactor = VkBlendFactor.OneMinusSrcAlpha; + blendAttachment.dstAlphaBlendFactor = VkBlendFactor.Zero; + blendAttachment.alphaBlendOp = VkBlendOp.Add; + blendAttachment.colorWriteMask = VkColorComponentFlags.R | VkColorComponentFlags.G | VkColorComponentFlags.B | VkColorComponentFlags.A; + + VkPipelineColorBlendStateCreateInfo blendState = default; + blendState.sType = VkStructureType.PipelineColorBlendStateCreateInfo; + blendState.attachmentCount = 1; + blendState.pAttachments = &blendAttachment; + + VkGraphicsPipelineCreateInfo pipelineInfo = default; + pipelineInfo.sType = VkStructureType.GraphicsPipelineCreateInfo; + pipelineInfo.stageCount = 2; + pipelineInfo.pStages = stages; + pipelineInfo.pVertexInputState = &vertexInputState; + pipelineInfo.pInputAssemblyState = &inputAssemblyState; + pipelineInfo.pViewportState = &viewportState; + pipelineInfo.pRasterizationState = &rasterState; + pipelineInfo.pMultisampleState = &msState; + pipelineInfo.pColorBlendState = &blendState; + pipelineInfo.layout = _pipelineLayout; + pipelineInfo.renderPass = _swapchain.RenderPass; + pipelineInfo.subpass = 0; + + VkPipeline pipe; + Vk.CheckResult(Vk.vkCreateGraphicsPipelines(_ctx.Device, 0, 1, &pipelineInfo, null, &pipe), "vkCreateGraphicsPipelines (ImGui)"); + _pipeline = pipe; + + Vk.FreeUtf8(mainName); + Console.WriteLine("[Vulkan] ImGui pipeline created."); + } + + private unsafe void CreateDescriptorPoolAndSet() + { + var poolSize = new VkDescriptorPoolSize + { + type = VkDescriptorType.CombinedImageSampler, + descriptorCount = 1 + }; + + VkDescriptorPoolCreateInfo poolInfo = default; + poolInfo.sType = VkStructureType.DescriptorPoolCreateInfo; + poolInfo.flags = VkDescriptorPoolCreateFlags.FreeDescriptorSet; + poolInfo.maxSets = 1; + poolInfo.poolSizeCount = 1; + poolInfo.pPoolSizes = &poolSize; + + VkDescriptorPool descPool; + Vk.CheckResult(Vk.vkCreateDescriptorPool(_ctx.Device, &poolInfo, null, &descPool), "vkCreateDescriptorPool (ImGui)"); + _descriptorPool = descPool; + + VkDescriptorSetAllocateInfo allocInfo = default; + allocInfo.sType = VkStructureType.DescriptorSetAllocateInfo; + allocInfo.descriptorPool = _descriptorPool; + allocInfo.descriptorSetCount = 1; + var dsLayout = _descriptorSetLayout; + allocInfo.pSetLayouts = &dsLayout; + + VkDescriptorSet descSet; + Vk.CheckResult(Vk.vkAllocateDescriptorSets(_ctx.Device, &allocInfo, &descSet), "vkAllocateDescriptorSets (ImGui)"); + _descriptorSet = descSet; + + var imageInfo = new VkDescriptorImageInfo + { + sampler = _fontSampler, + imageView = _fontImageView, + imageLayout = VkImageLayout.ShaderReadOnlyOptimal + }; + + VkWriteDescriptorSet writeInfo = default; + writeInfo.sType = VkStructureType.WriteDescriptorSet; + writeInfo.dstSet = _descriptorSet; + writeInfo.dstBinding = 0; + writeInfo.descriptorCount = 1; + writeInfo.descriptorType = VkDescriptorType.CombinedImageSampler; + writeInfo.pImageInfo = &imageInfo; + + Vk.vkUpdateDescriptorSets(_ctx.Device, 1, &writeInfo, 0, null); + } + + public unsafe void Render(VkCommandBuffer cmd) + { + var drawData = ImGui.GetDrawData(); + if (drawData.CmdListsCount == 0) return; + + drawData.ScaleClipRects(ImGui.GetIO().DisplayFramebufferScale); + UpdateBuffers(drawData); + + Vk.vkCmdBindPipeline(cmd, 0, _pipeline); + + var set = _descriptorSet; + Vk.vkCmdBindDescriptorSets(cmd, 0, _pipelineLayout, 0, 1, &set, 0, null); + + var displaySize = ImGui.GetIO().DisplaySize; + var scale = new Vector2(2.0f / displaySize.X, 2.0f / displaySize.Y); + var pushData = stackalloc float[2]; + pushData[0] = scale.X; + pushData[1] = -scale.Y; + + Vk.vkCmdPushConstants(cmd, _pipelineLayout, VkShaderStageFlags.Vertex, 0, 8, pushData); + + var vb = _vertexBuffer!.Buffer; + var offset = 0ul; + Vk.vkCmdBindVertexBuffers(cmd, 0, 1, &vb, &offset); + Vk.vkCmdBindIndexBuffer(cmd, _indexBuffer!.Buffer, 0, VkIndexType.Uint16); + + var indexOffset = 0u; + var vtxOffset = 0u; + for (var n = 0; n < drawData.CmdListsCount; n++) + { + var cmdList = new ImDrawListPtr(((ImDrawList**)drawData.CmdLists.Data)[n]); + for (var i = 0; i < cmdList.CmdBuffer.Size; i++) + { + var imCmd = cmdList.CmdBuffer[i]; + Vk.vkCmdDrawIndexed(cmd, (uint)imCmd.ElemCount, 1, indexOffset, (int)vtxOffset, 0); + indexOffset += (uint)imCmd.ElemCount; + } + vtxOffset += (uint)cmdList.VtxBuffer.Size; + } + } + + private unsafe void UpdateBuffers(ImDrawDataPtr drawData) + { + var vertexSize = (ulong)(drawData.TotalVtxCount * Marshal.SizeOf()); + var indexSize = (ulong)(drawData.TotalIdxCount * sizeof(ushort)); + + if (vertexSize == 0 || indexSize == 0) return; + + if (_vertexBuffer == null || _vertexBuffer.Size < vertexSize) + { + _vertexBuffer?.Dispose(); + _vertexBuffer = new VulkanBuffer(_ctx, vertexSize, + VkBufferUsageFlags.VertexBuffer, + VkMemoryPropertyFlags.HostVisible | VkMemoryPropertyFlags.HostCoherent); + } + + if (_indexBuffer == null || _indexBuffer.Size < indexSize) + { + _indexBuffer?.Dispose(); + _indexBuffer = new VulkanBuffer(_ctx, indexSize, + VkBufferUsageFlags.IndexBuffer, + VkMemoryPropertyFlags.HostVisible | VkMemoryPropertyFlags.HostCoherent); + } + + var vtxDst = (byte*)_vertexBuffer.MappedData; + var idxDst = (ushort*)_indexBuffer.MappedData; + + for (var n = 0; n < drawData.CmdListsCount; n++) + { + var cmdList = new ImDrawListPtr(((ImDrawList**)drawData.CmdLists.Data)[n]); + var vtxSize = cmdList.VtxBuffer.Size * Marshal.SizeOf(); + var idxSize = cmdList.IdxBuffer.Size * sizeof(ushort); + + Buffer.MemoryCopy((void*)cmdList.VtxBuffer.Data, vtxDst, vtxSize, vtxSize); + Buffer.MemoryCopy((void*)cmdList.IdxBuffer.Data, idxDst, idxSize, idxSize); + + vtxDst += vtxSize; + idxDst += cmdList.IdxBuffer.Size; + } + } + + public void Dispose() + { + Vk.vkQueueWaitIdle(_ctx.GraphicsQueue); + + _vertexBuffer?.Dispose(); + _indexBuffer?.Dispose(); + + if (_fontSampler.Value != 0) Vk.vkDestroySampler(_ctx.Device, (void*)_fontSampler.Value, null); + if (_fontImageView.Value != 0) Vk.vkDestroyImageView(_ctx.Device, _fontImageView, null); + if (_fontImage.Value != 0) Vk.vkDestroyImage(_ctx.Device, _fontImage, null); + if (_fontImageMemory.Value != 0) Vk.vkFreeMemory(_ctx.Device, _fontImageMemory, null); + if (_descriptorPool.Value != 0) Vk.vkDestroyDescriptorPool(_ctx.Device, _descriptorPool, null); + if (_pipeline.Value != 0) Vk.vkDestroyPipeline(_ctx.Device, _pipeline, null); + if (_pipelineLayout.Value != 0) Vk.vkDestroyPipelineLayout(_ctx.Device, _pipelineLayout, null); + if (_descriptorSetLayout.Value != 0) Vk.vkDestroyDescriptorSetLayout(_ctx.Device, _descriptorSetLayout, null); + if (_vertexShader.Value != 0) Vk.vkDestroyShaderModule(_ctx.Device, _vertexShader, null); + if (_fragmentShader.Value != 0) Vk.vkDestroyShaderModule(_ctx.Device, _fragmentShader, null); + } +} + +[StructLayout(LayoutKind.Sequential)] +internal struct VkDescriptorImageInfo +{ + public VkSampler sampler; + public VkImageView imageView; + public VkImageLayout imageLayout; +} diff --git a/src/Engine.Graphics.Vulkan/VulkanNative.cs b/src/Engine.Graphics.Vulkan/VulkanNative.cs index f57d4be..3089a92 100644 --- a/src/Engine.Graphics.Vulkan/VulkanNative.cs +++ b/src/Engine.Graphics.Vulkan/VulkanNative.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace Engine.Graphics.Vulkan; -internal static unsafe partial class VulkanNative +public static unsafe partial class VulkanNative { private const string VulkanLib = "vulkan-1.dll"; private const string VulkanLibLinux = "libvulkan.so.1"; diff --git a/src/Engine.Graphics.Vulkan/VulkanPipeline.cs b/src/Engine.Graphics.Vulkan/VulkanPipeline.cs index b387b8f..b69bfaa 100644 --- a/src/Engine.Graphics.Vulkan/VulkanPipeline.cs +++ b/src/Engine.Graphics.Vulkan/VulkanPipeline.cs @@ -3,7 +3,7 @@ using System.Text; namespace Engine.Graphics.Vulkan; -internal sealed unsafe class VulkanPipeline : IDisposable +public sealed unsafe class VulkanPipeline : IDisposable { public VkPipelineLayout PipelineLayout; public VkPipeline Pipeline; diff --git a/src/Engine.Graphics.Vulkan/VulkanRenderer.cs b/src/Engine.Graphics.Vulkan/VulkanRenderer.cs index fab192b..556abf7 100644 --- a/src/Engine.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Engine.Graphics.Vulkan/VulkanRenderer.cs @@ -7,11 +7,12 @@ using Flecs.NET.Core; namespace Engine.Graphics.Vulkan; -internal sealed unsafe class VulkanRenderer : IRenderer, IScreenshotProvider +public sealed unsafe class VulkanRenderer : IRenderer, IScreenshotProvider { - private readonly VulkanContext _ctx; - private readonly VulkanSwapchain _swapchain; + public readonly VulkanContext _ctx; + public readonly VulkanSwapchain _swapchain; private readonly VulkanPipeline _pipeline; + public VulkanImGui? ImGuiLayer; private VkCommandPool _commandPool; private VkCommandBuffer[] _commandBuffers = Array.Empty(); @@ -536,6 +537,11 @@ internal sealed unsafe class VulkanRenderer : IRenderer, IScreenshotProvider } }); + if (ImGuiLayer != null) + { + ImGuiLayer.Render(cmd); + } + Vk.vkCmdEndRenderPass(cmd); if (_screenshotRequested) diff --git a/src/Engine.Graphics.Vulkan/VulkanSwapchain.cs b/src/Engine.Graphics.Vulkan/VulkanSwapchain.cs index d74e259..74357b0 100644 --- a/src/Engine.Graphics.Vulkan/VulkanSwapchain.cs +++ b/src/Engine.Graphics.Vulkan/VulkanSwapchain.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace Engine.Graphics.Vulkan; -internal sealed unsafe class VulkanSwapchain : IDisposable +public sealed unsafe class VulkanSwapchain : IDisposable { public VkSwapchainKHR Swapchain; public VkImage[] SwapchainImages = Array.Empty(); diff --git a/src/Engine.Graphics.Vulkan/VulkanTypes.cs b/src/Engine.Graphics.Vulkan/VulkanTypes.cs index c16801c..4bdb763 100644 --- a/src/Engine.Graphics.Vulkan/VulkanTypes.cs +++ b/src/Engine.Graphics.Vulkan/VulkanTypes.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace Engine.Graphics.Vulkan; -internal enum VkResult : int +public enum VkResult : int { Success = 0, NotReady = 1, @@ -28,7 +28,7 @@ internal enum VkResult : int ErrorValidationFailedEXT = -1000011001, } -internal enum VkStructureType : int +public enum VkStructureType : int { ApplicationInfo = 0, InstanceCreateInfo = 1, @@ -82,7 +82,7 @@ internal enum VkStructureType : int SurfaceFormatKHR = 1000000001, } -internal enum VkFormat : int +public enum VkFormat : int { Undefined = 0, R8G8B8A8Unorm = 37, @@ -99,7 +99,7 @@ internal enum VkFormat : int D16Unorm = 124, } -internal enum VkImageUsageFlags : uint +public enum VkImageUsageFlags : uint { TransferSrc = 0x00000001, TransferDst = 0x00000002, @@ -109,14 +109,14 @@ internal enum VkImageUsageFlags : uint DepthStencilAttachment = 0x00000020, } -internal enum VkImageAspectFlags : uint +public enum VkImageAspectFlags : uint { Color = 0x00000001, Depth = 0x00000002, Stencil = 0x00000004, } -internal enum VkImageLayout : int +public enum VkImageLayout : int { Undefined = 0, General = 1, @@ -130,7 +130,7 @@ internal enum VkImageLayout : int PresentSrcKHR = 1000001002, } -internal enum VkPipelineStageFlags : uint +public enum VkPipelineStageFlags : uint { TopOfPipe = 0x00000001, DrawIndirect = 0x00000002, @@ -147,7 +147,7 @@ internal enum VkPipelineStageFlags : uint AllCommands = 0x00010000, } -internal enum VkAccessFlags : uint +public enum VkAccessFlags : uint { IndirectCommandRead = 0x00000001, IndexRead = 0x00000002, @@ -168,26 +168,26 @@ internal enum VkAccessFlags : uint MemoryWrite = 0x00010000, } -internal enum VkCommandBufferLevel : int +public enum VkCommandBufferLevel : int { Primary = 0, Secondary = 1, } -internal enum VkCommandBufferUsageFlags : uint +public enum VkCommandBufferUsageFlags : uint { OneTimeSubmit = 0x00000001, RenderPassContinue = 0x00000002, SimultaneousUse = 0x00000004, } -internal enum VkIndexType : int +public enum VkIndexType : int { Uint16 = 0, Uint32 = 1, } -internal enum VkPrimitiveTopology : int +public enum VkPrimitiveTopology : int { PointList = 0, LineList = 1, @@ -197,14 +197,14 @@ internal enum VkPrimitiveTopology : int TriangleFan = 5, } -internal enum VkPolygonMode : int +public enum VkPolygonMode : int { Fill = 0, Line = 1, Point = 2, } -internal enum VkCullModeFlags : uint +public enum VkCullModeFlags : uint { None = 0, Front = 0x00000001, @@ -212,13 +212,13 @@ internal enum VkCullModeFlags : uint FrontAndBack = 0x00000003, } -internal enum VkFrontFace : int +public enum VkFrontFace : int { CounterClockwise = 0, Clockwise = 1, } -internal enum VkBlendFactor : int +public enum VkBlendFactor : int { Zero = 0, One = 1, @@ -232,14 +232,14 @@ internal enum VkBlendFactor : int OneMinusDstAlpha = 9, } -internal enum VkBlendOp : int +public enum VkBlendOp : int { Add = 0, Subtract = 1, ReverseSubtract = 2, } -internal enum VkColorComponentFlags : uint +public enum VkColorComponentFlags : uint { R = 0x00000010, G = 0x00000020, @@ -247,7 +247,7 @@ internal enum VkColorComponentFlags : uint A = 0x00000080, } -internal enum VkCompareOp : int +public enum VkCompareOp : int { Never = 0, Less = 1, @@ -259,7 +259,7 @@ internal enum VkCompareOp : int Always = 7, } -internal enum VkDescriptorType : int +public enum VkDescriptorType : int { Sampler = 0, CombinedImageSampler = 1, @@ -273,14 +273,14 @@ internal enum VkDescriptorType : int StorageBufferDynamic = 9, } -internal enum VkShaderStageFlags : uint +public enum VkShaderStageFlags : uint { Vertex = 0x00000001, Fragment = 0x00000010, AllGraphics = 0x0000001F, } -internal enum VkBufferUsageFlags : uint +public enum VkBufferUsageFlags : uint { TransferSrc = 0x00000001, TransferDst = 0x00000002, @@ -293,7 +293,7 @@ internal enum VkBufferUsageFlags : uint IndirectBuffer = 0x00000100, } -internal enum VkMemoryPropertyFlags : uint +public enum VkMemoryPropertyFlags : uint { DeviceLocal = 0x00000001, HostVisible = 0x00000002, @@ -302,7 +302,7 @@ internal enum VkMemoryPropertyFlags : uint LazilyAllocated = 0x00000010, } -internal enum VkQueueFlags : uint +public enum VkQueueFlags : uint { Graphics = 0x00000001, Compute = 0x00000002, @@ -310,7 +310,7 @@ internal enum VkQueueFlags : uint SparseBinding = 0x00000008, } -internal enum VkPhysicalDeviceType : int +public enum VkPhysicalDeviceType : int { Other = 0, IntegratedGpu = 1, @@ -319,7 +319,7 @@ internal enum VkPhysicalDeviceType : int Cpu = 4, } -internal enum VkPresentModeKHR : int +public enum VkPresentModeKHR : int { Immediate = 0, Fifo = 1, @@ -327,57 +327,57 @@ internal enum VkPresentModeKHR : int Mailbox = 3, } -internal enum VkColorSpaceKHR : int +public enum VkColorSpaceKHR : int { SrgbNonlinear = 0, } -internal enum VkSurfaceTransformFlagsKHR : uint +public enum VkSurfaceTransformFlagsKHR : uint { Identity = 0x00000001, } -internal enum VkAttachmentLoadOp : int +public enum VkAttachmentLoadOp : int { Load = 0, Clear = 1, DontCare = 2, } -internal enum VkAttachmentStoreOp : int +public enum VkAttachmentStoreOp : int { Store = 0, DontCare = 1, } -internal enum VkSampleCountFlags : uint +public enum VkSampleCountFlags : uint { One = 0x00000001, } -internal enum VkSharingMode : int +public enum VkSharingMode : int { Exclusive = 0, Concurrent = 1, } -internal enum VkFenceCreateFlags : uint +public enum VkFenceCreateFlags : uint { Signaled = 0x00000001, } -internal enum VkDescriptorPoolCreateFlags : uint +public enum VkDescriptorPoolCreateFlags : uint { FreeDescriptorSet = 0x00000001, } -internal enum VkSubpassContents : int +public enum VkSubpassContents : int { Inline = 0, SecondaryCommandBuffers = 1, } -internal enum VkImageViewType : int +public enum VkImageViewType : int { _1D = 0, _2D = 1, @@ -388,14 +388,14 @@ internal enum VkImageViewType : int CubeArray = 6, } -internal enum VkImageType : int +public enum VkImageType : int { _1D = 0, _2D = 1, _3D = 2, } -internal enum VkSamplerAddressMode : int +public enum VkSamplerAddressMode : int { Repeat = 0, MirroredRepeat = 1, @@ -403,94 +403,96 @@ internal enum VkSamplerAddressMode : int ClampToBorder = 3, } -internal enum VkFilter : int +public enum VkFilter : int { Nearest = 0, Linear = 1, } -internal enum VkSamplerMipmapMode : int +public enum VkSamplerMipmapMode : int { Nearest = 0, Linear = 1, } -internal enum VkBorderColor : int +public enum VkBorderColor : int { FloatTransparentBlack = 4, } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkHandle { public ulong Value; } +unsafe public struct VkHandle { public ulong Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkInstance { public ulong Value; public static implicit operator ulong(VkInstance h) => h.Value; } +unsafe public struct VkInstance { public ulong Value; public static implicit operator ulong(VkInstance h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPhysicalDevice { public ulong Value; public static implicit operator ulong(VkPhysicalDevice h) => h.Value; } +unsafe public struct VkPhysicalDevice { public ulong Value; public static implicit operator ulong(VkPhysicalDevice h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDevice { public ulong Value; public static implicit operator ulong(VkDevice h) => h.Value; } +unsafe public struct VkDevice { public ulong Value; public static implicit operator ulong(VkDevice h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkQueue { public ulong Value; public static implicit operator ulong(VkQueue h) => h.Value; } +unsafe public struct VkQueue { public ulong Value; public static implicit operator ulong(VkQueue h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkCommandBuffer { public ulong Value; public static implicit operator ulong(VkCommandBuffer h) => h.Value; } +unsafe public struct VkCommandBuffer { public ulong Value; public static implicit operator ulong(VkCommandBuffer h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkCommandPool { public ulong Value; public static implicit operator ulong(VkCommandPool h) => h.Value; } +unsafe public struct VkCommandPool { public ulong Value; public static implicit operator ulong(VkCommandPool h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkBuffer { public ulong Value; public static implicit operator ulong(VkBuffer h) => h.Value; } +unsafe public struct VkBuffer { public ulong Value; public static implicit operator ulong(VkBuffer h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDeviceMemory { public ulong Value; public static implicit operator ulong(VkDeviceMemory h) => h.Value; } +unsafe public struct VkDeviceMemory { public ulong Value; public static implicit operator ulong(VkDeviceMemory h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImage { public ulong Value; public static implicit operator ulong(VkImage h) => h.Value; } +unsafe public struct VkImage { public ulong Value; public static implicit operator ulong(VkImage h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageView { public ulong Value; public static implicit operator ulong(VkImageView h) => h.Value; } +unsafe public struct VkImageView { public ulong Value; public static implicit operator ulong(VkImageView h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkShaderModule { public ulong Value; public static implicit operator ulong(VkShaderModule h) => h.Value; } +unsafe public struct VkShaderModule { public ulong Value; public static implicit operator ulong(VkShaderModule h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineLayout { public ulong Value; public static implicit operator ulong(VkPipelineLayout h) => h.Value; } +unsafe public struct VkPipelineLayout { public ulong Value; public static implicit operator ulong(VkPipelineLayout h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipeline { public ulong Value; public static implicit operator ulong(VkPipeline h) => h.Value; } +unsafe public struct VkPipeline { public ulong Value; public static implicit operator ulong(VkPipeline h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkRenderPass { public ulong Value; public static implicit operator ulong(VkRenderPass h) => h.Value; } +unsafe public struct VkSampler { public ulong Value; public static implicit operator ulong(VkSampler h) => h.Value; } + +unsafe public struct VkRenderPass { public ulong Value; public static implicit operator ulong(VkRenderPass h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkFramebuffer { public ulong Value; public static implicit operator ulong(VkFramebuffer h) => h.Value; } +unsafe public struct VkFramebuffer { public ulong Value; public static implicit operator ulong(VkFramebuffer h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorSetLayout { public ulong Value; public static implicit operator ulong(VkDescriptorSetLayout h) => h.Value; } +unsafe public struct VkDescriptorSetLayout { public ulong Value; public static implicit operator ulong(VkDescriptorSetLayout h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorPool { public ulong Value; public static implicit operator ulong(VkDescriptorPool h) => h.Value; } +unsafe public struct VkDescriptorPool { public ulong Value; public static implicit operator ulong(VkDescriptorPool h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorSet { public ulong Value; public static implicit operator ulong(VkDescriptorSet h) => h.Value; } +unsafe public struct VkDescriptorSet { public ulong Value; public static implicit operator ulong(VkDescriptorSet h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSemaphore { public ulong Value; public static implicit operator ulong(VkSemaphore h) => h.Value; } +unsafe public struct VkSemaphore { public ulong Value; public static implicit operator ulong(VkSemaphore h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkFence { public ulong Value; public static implicit operator ulong(VkFence h) => h.Value; } +unsafe public struct VkFence { public ulong Value; public static implicit operator ulong(VkFence h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSwapchainKHR { public ulong Value; public static implicit operator ulong(VkSwapchainKHR h) => h.Value; } +unsafe public struct VkSwapchainKHR { public ulong Value; public static implicit operator ulong(VkSwapchainKHR h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSurfaceKHR { public ulong Value; public static implicit operator ulong(VkSurfaceKHR h) => h.Value; } +unsafe public struct VkSurfaceKHR { public ulong Value; public static implicit operator ulong(VkSurfaceKHR h) => h.Value; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkApplicationInfo +unsafe public struct VkApplicationInfo { public VkStructureType sType; public void* pNext; @@ -502,7 +504,7 @@ unsafe internal struct VkApplicationInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkInstanceCreateInfo +unsafe public struct VkInstanceCreateInfo { public VkStructureType sType; public void* pNext; @@ -515,7 +517,7 @@ unsafe internal struct VkInstanceCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDeviceQueueCreateInfo +unsafe public struct VkDeviceQueueCreateInfo { public VkStructureType sType; public void* pNext; @@ -526,7 +528,7 @@ unsafe internal struct VkDeviceQueueCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDeviceCreateInfo +unsafe public struct VkDeviceCreateInfo { public VkStructureType sType; public void* pNext; @@ -541,12 +543,12 @@ unsafe internal struct VkDeviceCreateInfo } [StructLayout(LayoutKind.Sequential, Size = 228)] -internal struct VkPhysicalDeviceFeatures +public struct VkPhysicalDeviceFeatures { } [StructLayout(LayoutKind.Sequential)] -internal unsafe struct VkPhysicalDeviceProperties +public unsafe struct VkPhysicalDeviceProperties { public uint apiVersion; public uint driverVersion; @@ -560,7 +562,7 @@ internal unsafe struct VkPhysicalDeviceProperties } [StructLayout(LayoutKind.Sequential)] -internal unsafe struct VkPhysicalDeviceLimits +public unsafe struct VkPhysicalDeviceLimits { public uint maxImageDimension1D; public uint maxImageDimension2D; @@ -671,7 +673,7 @@ internal unsafe struct VkPhysicalDeviceLimits } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPhysicalDeviceSparseProperties +unsafe public struct VkPhysicalDeviceSparseProperties { public uint residencyStandard2DBlockShape; public uint residencyStandard2DMultisampleBlockShape; @@ -681,7 +683,7 @@ unsafe internal struct VkPhysicalDeviceSparseProperties } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkQueueFamilyProperties +unsafe public struct VkQueueFamilyProperties { public VkQueueFlags queueFlags; public uint queueCount; @@ -690,7 +692,7 @@ unsafe internal struct VkQueueFamilyProperties } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkExtent3D +unsafe public struct VkExtent3D { public int width; public int height; @@ -698,14 +700,14 @@ unsafe internal struct VkExtent3D } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkExtent2D +unsafe public struct VkExtent2D { public int width; public int height; } [StructLayout(LayoutKind.Sequential)] -internal unsafe struct VkPhysicalDeviceMemoryProperties +public unsafe struct VkPhysicalDeviceMemoryProperties { public uint memoryTypeCount; public VkMemoryType memoryTypes0; @@ -731,14 +733,14 @@ internal unsafe struct VkPhysicalDeviceMemoryProperties } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkMemoryType +unsafe public struct VkMemoryType { public VkMemoryPropertyFlags propertyFlags; public uint heapIndex; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkMemoryHeap +unsafe public struct VkMemoryHeap { public ulong size; public uint flags; @@ -746,7 +748,7 @@ unsafe internal struct VkMemoryHeap } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSurfaceCapabilitiesKHR +unsafe public struct VkSurfaceCapabilitiesKHR { public uint minImageCount; public uint maxImageCount; @@ -761,14 +763,14 @@ unsafe internal struct VkSurfaceCapabilitiesKHR } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSurfaceFormatKHR +unsafe public struct VkSurfaceFormatKHR { public VkFormat format; public VkColorSpaceKHR colorSpace; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSwapchainCreateInfoKHR +unsafe public struct VkSwapchainCreateInfoKHR { public VkStructureType sType; public void* pNext; @@ -791,7 +793,7 @@ unsafe internal struct VkSwapchainCreateInfoKHR } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPresentInfoKHR +unsafe public struct VkPresentInfoKHR { public VkStructureType sType; public void* pNext; @@ -804,7 +806,7 @@ unsafe internal struct VkPresentInfoKHR } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSubmitInfo +unsafe public struct VkSubmitInfo { public VkStructureType sType; public void* pNext; @@ -818,7 +820,7 @@ unsafe internal struct VkSubmitInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageCreateInfo +unsafe public struct VkImageCreateInfo { public VkStructureType sType; public void* pNext; @@ -838,7 +840,7 @@ unsafe internal struct VkImageCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageViewCreateInfo +unsafe public struct VkImageViewCreateInfo { public VkStructureType sType; public void* pNext; @@ -851,7 +853,7 @@ unsafe internal struct VkImageViewCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkComponentMapping +unsafe public struct VkComponentMapping { public int r; public int g; @@ -860,7 +862,7 @@ unsafe internal struct VkComponentMapping } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageSubresourceRange +unsafe public struct VkImageSubresourceRange { public VkImageAspectFlags aspectMask; public uint baseMipLevel; @@ -870,7 +872,7 @@ unsafe internal struct VkImageSubresourceRange } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkMemoryAllocateInfo +unsafe public struct VkMemoryAllocateInfo { public VkStructureType sType; public void* pNext; @@ -879,7 +881,7 @@ unsafe internal struct VkMemoryAllocateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkBufferCreateInfo +unsafe public struct VkBufferCreateInfo { public VkStructureType sType; public void* pNext; @@ -892,7 +894,7 @@ unsafe internal struct VkBufferCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkShaderModuleCreateInfo +unsafe public struct VkShaderModuleCreateInfo { public VkStructureType sType; public void* pNext; @@ -902,7 +904,7 @@ unsafe internal struct VkShaderModuleCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineShaderStageCreateInfo +unsafe public struct VkPipelineShaderStageCreateInfo { public VkStructureType sType; public void* pNext; @@ -914,7 +916,7 @@ unsafe internal struct VkPipelineShaderStageCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineLayoutCreateInfo +unsafe public struct VkPipelineLayoutCreateInfo { public VkStructureType sType; public void* pNext; @@ -926,7 +928,7 @@ unsafe internal struct VkPipelineLayoutCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPushConstantRange +unsafe public struct VkPushConstantRange { public VkShaderStageFlags stageFlags; public uint offset; @@ -934,7 +936,7 @@ unsafe internal struct VkPushConstantRange } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorSetLayoutCreateInfo +unsafe public struct VkDescriptorSetLayoutCreateInfo { public VkStructureType sType; public void* pNext; @@ -944,7 +946,7 @@ unsafe internal struct VkDescriptorSetLayoutCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorSetLayoutBinding +unsafe public struct VkDescriptorSetLayoutBinding { public uint binding; public VkDescriptorType descriptorType; @@ -954,7 +956,7 @@ unsafe internal struct VkDescriptorSetLayoutBinding } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorPoolCreateInfo +unsafe public struct VkDescriptorPoolCreateInfo { public VkStructureType sType; public void* pNext; @@ -965,14 +967,14 @@ unsafe internal struct VkDescriptorPoolCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorPoolSize +unsafe public struct VkDescriptorPoolSize { public VkDescriptorType type; public uint descriptorCount; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorSetAllocateInfo +unsafe public struct VkDescriptorSetAllocateInfo { public VkStructureType sType; public void* pNext; @@ -982,7 +984,7 @@ unsafe internal struct VkDescriptorSetAllocateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkWriteDescriptorSet +unsafe public struct VkWriteDescriptorSet { public VkStructureType sType; public void* pNext; @@ -997,7 +999,7 @@ unsafe internal struct VkWriteDescriptorSet } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkDescriptorBufferInfo +unsafe public struct VkDescriptorBufferInfo { public VkBuffer buffer; public ulong offset; @@ -1005,7 +1007,7 @@ unsafe internal struct VkDescriptorBufferInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkVertexInputBindingDescription +unsafe public struct VkVertexInputBindingDescription { public uint binding; public uint stride; @@ -1013,7 +1015,7 @@ unsafe internal struct VkVertexInputBindingDescription } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkVertexInputAttributeDescription +unsafe public struct VkVertexInputAttributeDescription { public uint location; public uint binding; @@ -1022,7 +1024,7 @@ unsafe internal struct VkVertexInputAttributeDescription } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineVertexInputStateCreateInfo +unsafe public struct VkPipelineVertexInputStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1034,7 +1036,7 @@ unsafe internal struct VkPipelineVertexInputStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineInputAssemblyStateCreateInfo +unsafe public struct VkPipelineInputAssemblyStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1044,7 +1046,7 @@ unsafe internal struct VkPipelineInputAssemblyStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkViewport +unsafe public struct VkViewport { public float x; public float y; @@ -1055,21 +1057,21 @@ unsafe internal struct VkViewport } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkRect2D +unsafe public struct VkRect2D { public VkOffset2D offset; public VkExtent2D extent; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkOffset2D +unsafe public struct VkOffset2D { public int x; public int y; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineViewportStateCreateInfo +unsafe public struct VkPipelineViewportStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1081,7 +1083,7 @@ unsafe internal struct VkPipelineViewportStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineRasterizationStateCreateInfo +unsafe public struct VkPipelineRasterizationStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1099,7 +1101,7 @@ unsafe internal struct VkPipelineRasterizationStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineMultisampleStateCreateInfo +unsafe public struct VkPipelineMultisampleStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1113,7 +1115,7 @@ unsafe internal struct VkPipelineMultisampleStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineDepthStencilStateCreateInfo +unsafe public struct VkPipelineDepthStencilStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1130,7 +1132,7 @@ unsafe internal struct VkPipelineDepthStencilStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -internal struct VkStencilOpState +public struct VkStencilOpState { public int failOp; public int passOp; @@ -1142,7 +1144,7 @@ internal struct VkStencilOpState } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineColorBlendAttachmentState +unsafe public struct VkPipelineColorBlendAttachmentState { public uint blendEnable; public VkBlendFactor srcColorBlendFactor; @@ -1155,7 +1157,7 @@ unsafe internal struct VkPipelineColorBlendAttachmentState } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkPipelineColorBlendStateCreateInfo +unsafe public struct VkPipelineColorBlendStateCreateInfo { public VkStructureType sType; public void* pNext; @@ -1168,7 +1170,7 @@ unsafe internal struct VkPipelineColorBlendStateCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkGraphicsPipelineCreateInfo +unsafe public struct VkGraphicsPipelineCreateInfo { public VkStructureType sType; public void* pNext; @@ -1192,7 +1194,7 @@ unsafe internal struct VkGraphicsPipelineCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkRenderPassCreateInfo +unsafe public struct VkRenderPassCreateInfo { public VkStructureType sType; public void* pNext; @@ -1206,7 +1208,7 @@ unsafe internal struct VkRenderPassCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkAttachmentDescription +unsafe public struct VkAttachmentDescription { public uint flags; public VkFormat format; @@ -1220,14 +1222,14 @@ unsafe internal struct VkAttachmentDescription } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkAttachmentReference +unsafe public struct VkAttachmentReference { public uint attachment; public VkImageLayout layout; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSubpassDescription +unsafe public struct VkSubpassDescription { public uint flags; public int pipelineBindPoint; @@ -1242,7 +1244,7 @@ unsafe internal struct VkSubpassDescription } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSubpassDependency +unsafe public struct VkSubpassDependency { public uint srcSubpass; public uint dstSubpass; @@ -1255,7 +1257,7 @@ unsafe internal struct VkSubpassDependency } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkFramebufferCreateInfo +unsafe public struct VkFramebufferCreateInfo { public VkStructureType sType; public void* pNext; @@ -1269,7 +1271,7 @@ unsafe internal struct VkFramebufferCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkCommandPoolCreateInfo +unsafe public struct VkCommandPoolCreateInfo { public VkStructureType sType; public void* pNext; @@ -1278,7 +1280,7 @@ unsafe internal struct VkCommandPoolCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkCommandBufferAllocateInfo +unsafe public struct VkCommandBufferAllocateInfo { public VkStructureType sType; public void* pNext; @@ -1288,7 +1290,7 @@ unsafe internal struct VkCommandBufferAllocateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkCommandBufferBeginInfo +unsafe public struct VkCommandBufferBeginInfo { public VkStructureType sType; public void* pNext; @@ -1297,7 +1299,7 @@ unsafe internal struct VkCommandBufferBeginInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkRenderPassBeginInfo +unsafe public struct VkRenderPassBeginInfo { public VkStructureType sType; public void* pNext; @@ -1309,27 +1311,27 @@ unsafe internal struct VkRenderPassBeginInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkClearValue +unsafe public struct VkClearValue { public VkClearColorValue color; public VkClearDepthStencilValue depthStencil; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkClearColorValue +unsafe public struct VkClearColorValue { public float r, g, b, a; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkClearDepthStencilValue +unsafe public struct VkClearDepthStencilValue { public float depth; public uint stencil; } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkBufferCopy +unsafe public struct VkBufferCopy { public ulong srcOffset; public ulong dstOffset; @@ -1337,7 +1339,7 @@ unsafe internal struct VkBufferCopy } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkBufferImageCopy +unsafe public struct VkBufferImageCopy { public ulong bufferOffset; public uint bufferRowLength; @@ -1348,7 +1350,7 @@ unsafe internal struct VkBufferImageCopy } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageSubresourceLayers +unsafe public struct VkImageSubresourceLayers { public VkImageAspectFlags aspectMask; public uint mipLevel; @@ -1357,7 +1359,7 @@ unsafe internal struct VkImageSubresourceLayers } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkOffset3D +unsafe public struct VkOffset3D { public int x; public int y; @@ -1365,7 +1367,7 @@ unsafe internal struct VkOffset3D } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkImageMemoryBarrier +unsafe public struct VkImageMemoryBarrier { public VkStructureType sType; public void* pNext; @@ -1380,7 +1382,7 @@ unsafe internal struct VkImageMemoryBarrier } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkBufferMemoryBarrier +unsafe public struct VkBufferMemoryBarrier { public VkStructureType sType; public void* pNext; @@ -1394,7 +1396,7 @@ unsafe internal struct VkBufferMemoryBarrier } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSemaphoreCreateInfo +unsafe public struct VkSemaphoreCreateInfo { public VkStructureType sType; public void* pNext; @@ -1402,7 +1404,7 @@ unsafe internal struct VkSemaphoreCreateInfo } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkFenceCreateInfo +unsafe public struct VkFenceCreateInfo { public VkStructureType sType; public void* pNext; @@ -1410,14 +1412,14 @@ unsafe internal struct VkFenceCreateInfo } [StructLayout(LayoutKind.Sequential, Size = 260)] -internal unsafe struct VkExtensionProperties +public unsafe struct VkExtensionProperties { public fixed byte extensionName[256]; public uint specVersion; } [StructLayout(LayoutKind.Sequential, Size = 264)] -internal unsafe struct VkLayerProperties +public unsafe struct VkLayerProperties { public fixed byte layerName[256]; public uint specVersion; @@ -1426,7 +1428,7 @@ internal unsafe struct VkLayerProperties } [StructLayout(LayoutKind.Sequential)] -unsafe internal struct VkSamplerCreateInfo +unsafe public struct VkSamplerCreateInfo { public VkStructureType sType; public void* pNext;