summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2018-06-29 20:03:49 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-07-03 10:25:21 -0700
commitfed76b3269d1c6539eaf659983c44f691fb45d00 (patch)
tree086dafb8977e34a8735b270a2bb9dd356b44150f
parentfde83d5f2bcc0408b5f4bbc60ba779f49f975c8c (diff)
anv: Be more careful about hashing pipeline layouts
Previously, we just hashed the entire descriptor set layout verbatim. This meant that a bunch of extra stuff such as pointers and reference counts made its way into the cache. It also meant that we weren't properly hashing in the Y'CbCr conversion information information from bound immutable samplers. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (cherry picked from commit d1c778b362d3ccf203f33095bee2af45dc8cde9a)
-rw-r--r--src/intel/vulkan/anv_descriptor_set.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 67511e4b28..8b200f81df 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -257,13 +257,48 @@ void anv_DestroyDescriptorSetLayout(
anv_descriptor_set_layout_unref(device, set_layout);
}
+#define SHA1_UPDATE_VALUE(ctx, x) _mesa_sha1_update(ctx, &(x), sizeof(x));
+
+static void
+sha1_update_immutable_sampler(struct mesa_sha1 *ctx,
+ const struct anv_sampler *sampler)
+{
+ if (!sampler->conversion)
+ return;
+
+ /* The only thing that affects the shader is ycbcr conversion */
+ _mesa_sha1_update(ctx, sampler->conversion,
+ sizeof(*sampler->conversion));
+}
+
+static void
+sha1_update_descriptor_set_binding_layout(struct mesa_sha1 *ctx,
+ const struct anv_descriptor_set_binding_layout *layout)
+{
+ SHA1_UPDATE_VALUE(ctx, layout->array_size);
+ SHA1_UPDATE_VALUE(ctx, layout->descriptor_index);
+ SHA1_UPDATE_VALUE(ctx, layout->dynamic_offset_index);
+ SHA1_UPDATE_VALUE(ctx, layout->buffer_index);
+ _mesa_sha1_update(ctx, layout->stage, sizeof(layout->stage));
+
+ if (layout->immutable_samplers) {
+ for (uint16_t i = 0; i < layout->array_size; i++)
+ sha1_update_immutable_sampler(ctx, layout->immutable_samplers[i]);
+ }
+}
+
static void
sha1_update_descriptor_set_layout(struct mesa_sha1 *ctx,
const struct anv_descriptor_set_layout *layout)
{
- size_t size = sizeof(*layout) +
- sizeof(layout->binding[0]) * layout->binding_count;
- _mesa_sha1_update(ctx, layout, size);
+ SHA1_UPDATE_VALUE(ctx, layout->binding_count);
+ SHA1_UPDATE_VALUE(ctx, layout->size);
+ SHA1_UPDATE_VALUE(ctx, layout->shader_stages);
+ SHA1_UPDATE_VALUE(ctx, layout->buffer_count);
+ SHA1_UPDATE_VALUE(ctx, layout->dynamic_offset_count);
+
+ for (uint16_t i = 0; i < layout->binding_count; i++)
+ sha1_update_descriptor_set_binding_layout(ctx, &layout->binding[i]);
}
/*