mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
anv: add embedded sampler parameters in descriptor set layout hash
The way we implement embedded samplers will be to have the sampler handle as a relocated constant in the shader. This implies that 2 identical shaders with different embedded sampler parameters must have different hash as we cannot reuse the final shader binary. So add the sampler hash to the descriptor set layout hash when the set has embedded samplers. This has the effect of creating multiple shader entries in the cache unfortunately. An improvement over this would be to have a anv_device map of (embedded samplers hash + shader hash) to shader in instruction heap, so that pipeline caches only have a single entry regardless of embedded sampler parameters. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Ivan Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22151>
This commit is contained in:
parent
6d59168dc9
commit
3f25b2826f
1 changed files with 25 additions and 6 deletions
|
|
@ -930,18 +930,30 @@ anv_descriptor_set_layout_print(const struct anv_descriptor_set_layout *layout)
|
|||
|
||||
static void
|
||||
sha1_update_immutable_sampler(struct mesa_sha1 *ctx,
|
||||
bool embedded_sampler,
|
||||
const struct anv_sampler *sampler)
|
||||
{
|
||||
if (!sampler->vk.ycbcr_conversion)
|
||||
return;
|
||||
|
||||
/* The only thing that affects the shader is ycbcr conversion */
|
||||
/* Hash the conversion if any as this affect placement of descriptors in
|
||||
* the set due to the number of planes.
|
||||
*/
|
||||
SHA1_UPDATE_VALUE(ctx, sampler->vk.ycbcr_conversion->state);
|
||||
|
||||
/* For embedded samplers, we need to hash the sampler parameters as the
|
||||
* sampler handle is baked into the shader and this ultimately is part of
|
||||
* the shader hash key. We can only consider 2 shaders identical if all
|
||||
* their embedded samplers parameters are identical.
|
||||
*/
|
||||
if (embedded_sampler)
|
||||
SHA1_UPDATE_VALUE(ctx, sampler->sha1);
|
||||
}
|
||||
|
||||
static void
|
||||
sha1_update_descriptor_set_binding_layout(struct mesa_sha1 *ctx,
|
||||
const struct anv_descriptor_set_binding_layout *layout)
|
||||
bool embedded_samplers,
|
||||
const struct anv_descriptor_set_binding_layout *layout)
|
||||
{
|
||||
SHA1_UPDATE_VALUE(ctx, layout->flags);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->data);
|
||||
|
|
@ -954,8 +966,10 @@ sha1_update_descriptor_set_binding_layout(struct mesa_sha1 *ctx,
|
|||
SHA1_UPDATE_VALUE(ctx, layout->descriptor_sampler_offset);
|
||||
|
||||
if (layout->immutable_samplers) {
|
||||
for (uint16_t i = 0; i < layout->array_size; i++)
|
||||
sha1_update_immutable_sampler(ctx, layout->immutable_samplers[i]);
|
||||
for (uint16_t i = 0; i < layout->array_size; i++) {
|
||||
sha1_update_immutable_sampler(ctx, embedded_samplers,
|
||||
layout->immutable_samplers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -972,8 +986,13 @@ sha1_update_descriptor_set_layout(struct mesa_sha1 *ctx,
|
|||
SHA1_UPDATE_VALUE(ctx, layout->descriptor_buffer_surface_size);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->descriptor_buffer_sampler_size);
|
||||
|
||||
for (uint16_t i = 0; i < layout->binding_count; i++)
|
||||
sha1_update_descriptor_set_binding_layout(ctx, &layout->binding[i]);
|
||||
bool embedded_samplers =
|
||||
layout->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT;
|
||||
|
||||
for (uint16_t i = 0; i < layout->binding_count; i++) {
|
||||
sha1_update_descriptor_set_binding_layout(ctx, embedded_samplers,
|
||||
&layout->binding[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue