From 1eb731d9fe41bdf5813a8e3646a7df36121b244c Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 16 Nov 2015 22:26:03 -0800 Subject: [PATCH] anv/descriptor_set: Add support for storage images in layouts --- src/vulkan/anv_descriptor_set.c | 20 ++++++++++++++++++-- src/vulkan/anv_private.h | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/vulkan/anv_descriptor_set.c b/src/vulkan/anv_descriptor_set.c index e1cfd788b73..9c4210025e3 100644 --- a/src/vulkan/anv_descriptor_set.c +++ b/src/vulkan/anv_descriptor_set.c @@ -79,6 +79,7 @@ VkResult anv_CreateDescriptorSetLayout( uint32_t sampler_count[MESA_SHADER_STAGES] = { 0, }; uint32_t surface_count[MESA_SHADER_STAGES] = { 0, }; + uint32_t image_count[MESA_SHADER_STAGES] = { 0, }; uint32_t dynamic_offset_count = 0; for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) { @@ -132,6 +133,13 @@ VkResult anv_CreateDescriptorSetLayout( break; } + if (binding->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) { + for_each_bit(s, binding->stageFlags) { + set_layout->binding[b].stage[s].image_index = image_count[s]; + image_count[s] += binding->descriptorCount; + } + } + if (binding->pImmutableSamplers) { set_layout->binding[b].immutable_samplers = samplers; samplers += binding->descriptorCount; @@ -199,6 +207,7 @@ VkResult anv_CreatePipelineLayout( for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) { l.set[set].stage[s].surface_start = l.stage[s].surface_count; l.set[set].stage[s].sampler_start = l.stage[s].sampler_count; + l.set[set].stage[s].image_start = l.stage[s].image_count; for (uint32_t b = 0; b < set_layout->binding_count; b++) { unsigned array_size = set_layout->binding[b].array_size; @@ -212,13 +221,19 @@ VkResult anv_CreatePipelineLayout( if (set_layout->binding[b].stage[s].sampler_index >= 0) l.stage[s].sampler_count += array_size; + + if (set_layout->binding[b].stage[s].image_index >= 0) + l.stage[s].image_count += array_size; } } } unsigned num_bindings = 0; - for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) - num_bindings += l.stage[s].surface_count + l.stage[s].sampler_count; + for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) { + num_bindings += l.stage[s].surface_count + + l.stage[s].sampler_count + + l.stage[s].image_count; + } size_t size = sizeof(*layout) + num_bindings * sizeof(layout->entries[0]); @@ -234,6 +249,7 @@ VkResult anv_CreatePipelineLayout( entry += l.stage[s].surface_count; l.stage[s].sampler_to_descriptor = entry; entry += l.stage[s].sampler_count; + entry += l.stage[s].image_count; int surface = 0; int sampler = 0; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index a6db547e5e3..b3829216dd4 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -814,6 +814,9 @@ struct anv_descriptor_set_binding_layout { /* Index into the sampler table for the associated sampler */ int16_t sampler_index; + + /* Index into the image table for the associated image */ + int16_t image_index; } stage[MESA_SHADER_STAGES]; /* Immutable samplers (or NULL if no immutable samplers) */ @@ -894,6 +897,7 @@ struct anv_pipeline_layout { struct { uint32_t surface_start; uint32_t sampler_start; + uint32_t image_start; } stage[MESA_SHADER_STAGES]; } set[MAX_SETS]; @@ -905,6 +909,7 @@ struct anv_pipeline_layout { struct anv_pipeline_binding *surface_to_descriptor; uint32_t sampler_count; struct anv_pipeline_binding *sampler_to_descriptor; + uint32_t image_count; } stage[MESA_SHADER_STAGES]; struct anv_pipeline_binding entries[0]; -- 2.30.2