From 7b5b54d1497216f4dc4a9c36f9d9592b40316642 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Fri, 21 Apr 2023 09:44:22 +0200 Subject: [PATCH] Add more debugging to desc layout --- vulkan-rs/src/descriptorsetlayout.rs | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/vulkan-rs/src/descriptorsetlayout.rs b/vulkan-rs/src/descriptorsetlayout.rs index 86f3a9c..e91e8f9 100644 --- a/vulkan-rs/src/descriptorsetlayout.rs +++ b/vulkan-rs/src/descriptorsetlayout.rs @@ -70,6 +70,12 @@ impl DescriptorSetLayoutBuilder { */ } + let bindings = self + .layout_bindings + .iter() + .map(|b| DescriptorLayoutBinding::from(b.clone())) + .collect(); + let descriptor_set_layout = device.create_descriptor_set_layout(&descriptor_set_ci)?; let pool_sizes = self @@ -85,6 +91,8 @@ impl DescriptorSetLayoutBuilder { device, descriptor_set_layout, pool_sizes, + + bindings, })) } } @@ -94,6 +102,8 @@ pub struct DescriptorSetLayout { device: Arc, descriptor_set_layout: VkDescriptorSetLayout, pool_sizes: Vec, + + bindings: Vec, } impl DescriptorSetLayout { @@ -108,6 +118,10 @@ impl DescriptorSetLayout { pub(crate) fn pool_sizes(&self) -> &[VkDescriptorPoolSize] { self.pool_sizes.as_slice() } + + pub fn bindings(&self) -> &[DescriptorLayoutBinding] { + &self.bindings + } } impl VulkanDevice for DescriptorSetLayout { @@ -128,3 +142,42 @@ impl Drop for DescriptorSetLayout { .destroy_descriptor_set_layout(self.descriptor_set_layout); } } + +#[derive(Debug)] +pub struct DescriptorLayoutBinding { + pub binding: u32, + pub desc_type: VkDescriptorType, + pub stage_flags: Vec, +} + +impl From for DescriptorLayoutBinding { + fn from(value: VkDescriptorSetLayoutBinding) -> Self { + let flag_enum_list = [ + VK_SHADER_STAGE_VERTEX_BIT, + VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, + VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, + VK_SHADER_STAGE_GEOMETRY_BIT, + VK_SHADER_STAGE_FRAGMENT_BIT, + VK_SHADER_STAGE_COMPUTE_BIT, + VK_SHADER_STAGE_ALL_GRAPHICS, + VK_SHADER_STAGE_ALL, + VK_SHADER_STAGE_RAYGEN_BIT_KHR, + VK_SHADER_STAGE_ANY_HIT_BIT_KHR, + VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, + VK_SHADER_STAGE_MISS_BIT_KHR, + VK_SHADER_STAGE_INTERSECTION_BIT_KHR, + VK_SHADER_STAGE_CALLABLE_BIT_KHR, + VK_SHADER_STAGE_TASK_BIT_NV, + VK_SHADER_STAGE_MESH_BIT_NV, + ]; + + Self { + binding: value.binding, + desc_type: value.descriptorType, + stage_flags: flag_enum_list + .into_iter() + .filter(|&flag| (flag & value.stageFlagBits) != 0) + .collect(), + } + } +}