diff options
author | Jason Ekstrand <[email protected]> | 2015-10-14 15:18:49 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-10-14 18:38:33 -0700 |
commit | b37c38c1cada402a258079c6b4e70d5783fb96c5 (patch) | |
tree | 855578c4b7405b6b2ec220bbd2c2ff0a7c460c51 /src/vulkan/anv_private.h | |
parent | 7965fe7da6b72ad4ba259a9d68bd362c2c1dd5db (diff) |
anv: Completely rework descriptor set layouts
This patch reworks a bunch of stuff in the way we do descriptor set
layouts. Our previous approach had a couple of problems. First, it was
based on a misunderstanding of arrays in descriptor sets. Second, it
didn't properly handle descriptor sets where some bindings were missing
stages. The new apporach should be correct and also makes some operations,
particularly those on the hot-path, a bit easier.
We use the descriptor set layout for four things:
1) To determine the map from bindings to the actual flattened descriptor
set in vkUpdateDescriptorSets().
2) To determine the descriptor <-> binding table entry mapping to use in
anv_cmd_buffer_flush_descriptor_sets().
3) To determine the mappings of dynamic indices.
4) To determine the (set, binding, array index) -> binding table entry
mapping inside of shaders.
The new approach is directly taylored towards these operations.
Diffstat (limited to 'src/vulkan/anv_private.h')
-rw-r--r-- | src/vulkan/anv_private.h | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 6bc781fa072..523e6dfa747 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -660,23 +660,37 @@ struct anv_device_memory { void * map; }; -struct anv_descriptor_slot { - int8_t dynamic_slot; - uint8_t index; -}; +struct anv_descriptor_set_binding_layout { + /* Number of array elements in this binding */ + uint16_t array_size; + + /* Index into the dynamic state array for a dynamic buffer */ + int16_t dynamic_offset_index; -struct anv_descriptor_set_layout { struct { - uint32_t surface_count; - struct anv_descriptor_slot *surface_start; - uint32_t sampler_count; - struct anv_descriptor_slot *sampler_start; + /* Index into the binding table for the associated surface */ + int16_t surface_index; + + /* Index into the sampler table for the associated sampler */ + int16_t sampler_index; } stage[VK_SHADER_STAGE_NUM]; +}; + +struct anv_descriptor_set_layout { + /* Number of bindings in this descriptor set */ + uint16_t binding_count; + + /* Total size of the descriptor set with room for all array entries */ + uint16_t size; + + /* Shader stages affected by this descriptor set */ + uint16_t shader_stages; + + /* Number of dynamic offsets used by this descriptor set */ + uint16_t dynamic_offset_count; - uint32_t count; - uint32_t num_dynamic_buffers; - VkShaderStageFlags shader_stages; - struct anv_descriptor_slot entries[0]; + /* Don't use this directly */ + struct anv_descriptor_set_binding_layout binding[0]; }; enum anv_descriptor_type { @@ -718,6 +732,14 @@ anv_descriptor_set_destroy(struct anv_device *device, #define MAX_DYNAMIC_BUFFERS 16 #define MAX_IMAGES 8 +struct anv_pipeline_binding { + /* The descriptor set this surface corresponds to */ + uint16_t set; + + /* Offset into the descriptor set */ + uint16_t offset; +}; + struct anv_pipeline_layout { struct { struct anv_descriptor_set_layout *layout; @@ -733,8 +755,12 @@ struct anv_pipeline_layout { struct { bool has_dynamic_offsets; uint32_t surface_count; + struct anv_pipeline_binding *surface_to_descriptor; uint32_t sampler_count; + struct anv_pipeline_binding *sampler_to_descriptor; } stage[VK_SHADER_STAGE_NUM]; + + struct anv_pipeline_binding entries[0]; }; struct anv_buffer { |