From b10c8dc1a14c443647350c96c97c5cd2968f392c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 26 Feb 2023 20:54:11 +0900 Subject: [PATCH] [vulkan] Parse in descriptor set layouts For now, just their create info is parsed, but they will be created on demand. Most importantly, they are named for ease of use in pipeline layouts. --- include/QF/Vulkan/render.h | 10 + libs/video/renderer/vulkan/rp_main_def.plist | 184 +++++++++++++++++++ libs/video/renderer/vulkan/vkparse.plist | 19 +- 3 files changed, 209 insertions(+), 4 deletions(-) diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index 86a33fa8a..6b057d210 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -24,6 +24,14 @@ typedef struct qfv_reference_s { int line; } qfv_reference_t; +typedef struct qfv_descriptorsetinfo_s { + const char *name; + VkDescriptorSetLayoutCreateFlags flags; + uint32_t num_bindings; + VkDescriptorSetLayoutBinding *bindings; + VkDescriptorSetLayout setLayout; +} qfv_descriptorsetinfo_t; + typedef struct qfv_imageinfo_s { const char *name; VkImageCreateFlags flags; @@ -157,6 +165,8 @@ typedef struct qfv_renderinfo_s { uint32_t num_renderpasses; qfv_renderpassinfo_t *renderpasses; qfv_output_t output; + uint32_t num_descriptorsets; + qfv_descriptorsetinfo_t *descriptorsets; } qfv_renderinfo_t; typedef struct qfv_label_s { diff --git a/libs/video/renderer/vulkan/rp_main_def.plist b/libs/video/renderer/vulkan/rp_main_def.plist index 125bc031a..4205b7c8a 100644 --- a/libs/video/renderer/vulkan/rp_main_def.plist +++ b/libs/video/renderer/vulkan/rp_main_def.plist @@ -495,6 +495,190 @@ properties = { }; } }; +descriptorSetLayouts = { + matrix_set = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = vertex|geometry; + }, + ); + }; + quad_data_set = { + bindings = ( + { + // glyph texture data + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment; + }, + { + // glyph geometry data (offset and uv) + binding = 1; + descriptorType = uniform_texel_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + texture_set = { + bindings = ( + { + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment|vertex; + }, + ); + }; + oit_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 1; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 2; + descriptorType = storage_image; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + entity_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + bone_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + sprite_set = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + { + binding = 1; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + lighting_attach = { + bindings = ( + { + binding = 0; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 1; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 2; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 3; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 4; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + lighting_lights = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + lighting_shadow = { + bindings = ( + { + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 32; + stageFlags = fragment; + }, + ); + }; + compose_attach = { + bindings = ( + { + binding = 0; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + particle_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 1; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 2; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + ); + }; +}; images = { depth = { @inherit = $image_base; diff --git a/libs/video/renderer/vulkan/vkparse.plist b/libs/video/renderer/vulkan/vkparse.plist index 48122bccd..73f9db74c 100644 --- a/libs/video/renderer/vulkan/vkparse.plist +++ b/libs/video/renderer/vulkan/vkparse.plist @@ -34,6 +34,7 @@ qfv_subpass_t, qfv_output_t, + qfv_descriptorsetinfo_t, qfv_imageinfo_t, qfv_imageviewinfo_t, qfv_dependencyinfo_t, @@ -587,10 +588,6 @@ }; qfv_renderpassinfo_s = { .name = qfv_renderpassinfo_t; - name = { - type = string; - string = name; - }; color = auto; attachments = { type = (labeledarray, qfv_attachmentinfo_t, name); @@ -604,6 +601,15 @@ values = subpasses; }; }; + qfv_descriptorsetinfo_s = { + .name = qfv_descriptorsetinfo_t; + flags = auto; + bindings = { + type = (array, VkDescriptorSetLayoutBinding); + size = num_bindings; + values = bindings; + }; + }; qfv_renderinfo_s = { .name = qfv_renderinfo_t; properties = ignore; @@ -623,6 +629,11 @@ size = num_renderpasses; values = renderpasses; }; + descriptorSetLayouts = { + type = (labeledarray, qfv_descriptorsetinfo_t, name); + size = num_descriptorsets; + values = descriptorsets; + }; }; }; }