[Mesa-dev] [PATCH 3/7] anv: descriptorSetLayout: allocate additional space for a hidden ubo
Lionel Landwerlin
llandwerlin at gmail.com
Mon Nov 21 17:47:36 UTC 2016
This additional buffer will store workaround border colors for integer
formats on Gen7.5.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/anv_descriptor_set.c | 42 +++++++++++++++++++++++++++++++++++
src/intel/vulkan/anv_private.h | 9 ++++++++
2 files changed, 51 insertions(+)
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 578bf7b..82f2d1e 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -48,12 +48,33 @@ VkResult anv_CreateDescriptorSetLayout(
uint32_t max_binding = 0;
uint32_t immutable_sampler_count = 0;
+ uint32_t border_colors_wa = 0;
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
max_binding = MAX2(max_binding, pCreateInfo->pBindings[j].binding);
if (pCreateInfo->pBindings[j].pImmutableSamplers)
immutable_sampler_count += pCreateInfo->pBindings[j].descriptorCount;
+
+
+ /* We need an additional buffer slot on Ivybridge/Haswell to store
+ * integer border color values. Count how many entries we need in that
+ * buffer. */
+ const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[j];
+ switch (binding->descriptorType) {
+ case VK_DESCRIPTOR_TYPE_SAMPLER:
+ case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+ border_colors_wa += binding->descriptorCount;
+ break;
+
+ default:
+ continue;
+ }
}
+ if (device->info.is_haswell && border_colors_wa > 0)
+ max_binding++;
+ else
+ border_colors_wa = 0;
+
size_t size = sizeof(struct anv_descriptor_set_layout) +
(max_binding + 1) * sizeof(set_layout->binding[0]) +
immutable_sampler_count * sizeof(struct anv_sampler *);
@@ -69,6 +90,7 @@ VkResult anv_CreateDescriptorSetLayout(
memset(set_layout, 0, sizeof(*set_layout));
set_layout->binding_count = max_binding + 1;
+ set_layout->border_color_index = -1;
for (uint32_t b = 0; b <= max_binding; b++) {
/* Initialize all binding_layout entries to -1 */
@@ -119,6 +141,9 @@ VkResult anv_CreateDescriptorSetLayout(
set_layout->binding[b].stage[s].sampler_index = sampler_count[s];
sampler_count[s] += binding->descriptorCount;
}
+ set_layout->binding[b].border_color_array_index =
+ set_layout->border_color_count;
+ set_layout->border_color_count += binding->descriptorCount;
break;
default:
break;
@@ -184,6 +209,23 @@ VkResult anv_CreateDescriptorSetLayout(
set_layout->shader_stages |= binding->stageFlags;
}
+ if (border_colors_wa > 0) {
+ uint32_t index = max_binding;
+ set_layout->border_color_index = index;
+ set_layout->binding[index].buffer_index = buffer_count;
+#ifndef NDEBUG
+ set_layout->binding[index].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+#endif
+ set_layout->binding[index].array_size = 1;
+ set_layout->binding[index].descriptor_index = set_layout->size;
+ for (int s = 0; s < ARRAY_SIZE(set_layout->binding[index].stage); s++) {
+ set_layout->binding[index].stage[s].surface_index = surface_count[s];
+ surface_count[s]++;
+ }
+ set_layout->size++;
+ buffer_count++;
+ }
+
set_layout->buffer_count = buffer_count;
set_layout->dynamic_offset_count = dynamic_offset_count;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 8231f6b..19b08b3 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -821,6 +821,9 @@ struct anv_descriptor_set_binding_layout {
/* Index into the descriptor set buffer views */
int16_t buffer_index;
+ /* Index into the border color array */
+ int16_t border_color_array_index;
+
struct {
/* Index into the binding table for the associated surface */
int16_t surface_index;
@@ -852,6 +855,12 @@ struct anv_descriptor_set_layout {
/* Number of dynamic offsets used by this descriptor set */
uint16_t dynamic_offset_count;
+ /* Number of samplers used by this descriptor set */
+ uint16_t border_color_count;
+
+ /* Index of the border color buffer into the descriptor set buffer views */
+ int16_t border_color_index;
+
/* Bindings in this descriptor set */
struct anv_descriptor_set_binding_layout binding[0];
};
--
2.10.2
More information about the mesa-dev
mailing list