tu: Hash pipeline layout contents
Mostly adapted from anv. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16147>
This commit is contained in:
parent
3e3f8b1639
commit
410d59943d
|
@ -381,6 +381,50 @@ out:
|
|||
pSupport->supported = supported;
|
||||
}
|
||||
|
||||
/* Note: we must hash any values used in tu_lower_io(). */
|
||||
|
||||
#define SHA1_UPDATE_VALUE(ctx, x) _mesa_sha1_update(ctx, &(x), sizeof(x));
|
||||
|
||||
static void
|
||||
sha1_update_ycbcr_sampler(struct mesa_sha1 *ctx,
|
||||
const struct tu_sampler_ycbcr_conversion *sampler)
|
||||
{
|
||||
SHA1_UPDATE_VALUE(ctx, sampler->ycbcr_model);
|
||||
SHA1_UPDATE_VALUE(ctx, sampler->ycbcr_range);
|
||||
SHA1_UPDATE_VALUE(ctx, sampler->format);
|
||||
}
|
||||
|
||||
static void
|
||||
sha1_update_descriptor_set_binding_layout(struct mesa_sha1 *ctx,
|
||||
const struct tu_descriptor_set_binding_layout *layout,
|
||||
const struct tu_descriptor_set_layout *set_layout)
|
||||
{
|
||||
SHA1_UPDATE_VALUE(ctx, layout->type);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->offset);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->size);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->array_size);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->dynamic_offset_offset);
|
||||
SHA1_UPDATE_VALUE(ctx, layout->immutable_samplers_offset);
|
||||
|
||||
const struct tu_sampler_ycbcr_conversion *ycbcr_samplers =
|
||||
tu_immutable_ycbcr_samplers(set_layout, layout);
|
||||
|
||||
if (ycbcr_samplers) {
|
||||
for (unsigned i = 0; i < layout->array_size; i++)
|
||||
sha1_update_ycbcr_sampler(ctx, ycbcr_samplers + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sha1_update_descriptor_set_layout(struct mesa_sha1 *ctx,
|
||||
const struct tu_descriptor_set_layout *layout)
|
||||
{
|
||||
for (uint16_t i = 0; i < layout->binding_count; i++)
|
||||
sha1_update_descriptor_set_binding_layout(ctx, &layout->binding[i],
|
||||
layout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pipeline layouts. These have nothing to do with the pipeline. They are
|
||||
* just multiple descriptor set layouts pasted together.
|
||||
|
@ -428,6 +472,19 @@ tu_CreatePipelineLayout(VkDevice _device,
|
|||
}
|
||||
|
||||
layout->push_constant_size = align(layout->push_constant_size, 16);
|
||||
|
||||
struct mesa_sha1 ctx;
|
||||
_mesa_sha1_init(&ctx);
|
||||
for (unsigned s = 0; s < layout->num_sets; s++) {
|
||||
sha1_update_descriptor_set_layout(&ctx, layout->set[s].layout);
|
||||
_mesa_sha1_update(&ctx, &layout->set[s].dynamic_offset_start,
|
||||
sizeof(layout->set[s].dynamic_offset_start));
|
||||
}
|
||||
_mesa_sha1_update(&ctx, &layout->num_sets, sizeof(layout->num_sets));
|
||||
_mesa_sha1_update(&ctx, &layout->push_constant_size,
|
||||
sizeof(layout->push_constant_size));
|
||||
_mesa_sha1_final(&ctx, layout->sha1);
|
||||
|
||||
*pPipelineLayout = tu_pipeline_layout_to_handle(layout);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
|
@ -124,6 +124,8 @@ struct tu_pipeline_layout
|
|||
uint32_t num_sets;
|
||||
uint32_t push_constant_size;
|
||||
uint32_t dynamic_offset_size;
|
||||
|
||||
unsigned char sha1[20];
|
||||
};
|
||||
|
||||
static inline const struct tu_sampler *
|
||||
|
|
Loading…
Reference in New Issue