radv: Don't hash ycbcr sampler base object.

Stops gamescope from recompiling pipelines on every start.

Cc: mesa-stable

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15454>
(cherry picked from commit 4f6c7a6025)
This commit is contained in:
Georg Lehmann 2022-03-18 14:10:21 +01:00 committed by Eric Engestrom
parent e6d82a0897
commit 45b4a998d6
5 changed files with 28 additions and 23 deletions

View file

@ -22,7 +22,7 @@
"description": "radv: Don't hash ycbcr sampler base object.",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -129,8 +129,8 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
/* Store block of offsets first, followed by the conversion descriptors (padded to the struct
* alignment) */
size += num_bindings * sizeof(uint32_t);
size = ALIGN(size, alignof(struct radv_sampler_ycbcr_conversion));
size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion);
size = ALIGN(size, alignof(struct radv_sampler_ycbcr_conversion_state));
size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion_state);
}
set_layout =
@ -145,7 +145,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
/* We just allocate all the samplers at the end of the struct */
uint32_t *samplers = (uint32_t *)&set_layout->binding[num_bindings];
struct radv_sampler_ycbcr_conversion *ycbcr_samplers = NULL;
struct radv_sampler_ycbcr_conversion_state *ycbcr_samplers = NULL;
uint32_t *ycbcr_sampler_offsets = NULL;
if (ycbcr_sampler_count > 0) {
@ -155,8 +155,8 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
uintptr_t first_ycbcr_sampler_offset =
(uintptr_t)ycbcr_sampler_offsets + sizeof(uint32_t) * num_bindings;
first_ycbcr_sampler_offset =
ALIGN(first_ycbcr_sampler_offset, alignof(struct radv_sampler_ycbcr_conversion));
ycbcr_samplers = (struct radv_sampler_ycbcr_conversion *)first_ycbcr_sampler_offset;
ALIGN(first_ycbcr_sampler_offset, alignof(struct radv_sampler_ycbcr_conversion_state));
ycbcr_samplers = (struct radv_sampler_ycbcr_conversion_state *)first_ycbcr_sampler_offset;
} else
set_layout->ycbcr_sampler_offsets_offset = 0;
@ -198,7 +198,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
if (conversion) {
has_ycbcr_sampler = true;
max_sampled_image_descriptors = MAX2(max_sampled_image_descriptors,
vk_format_get_plane_count(conversion->format));
vk_format_get_plane_count(conversion->state.format));
}
}
}
@ -311,7 +311,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
for (uint32_t i = 0; i < binding->descriptorCount; i++) {
if (radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler)
ycbcr_samplers[i] =
*radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler;
radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler->state;
else
ycbcr_samplers[i].format = VK_FORMAT_UNDEFINED;
}
@ -1522,13 +1522,13 @@ radv_CreateSamplerYcbcrConversion(VkDevice _device,
vk_object_base_init(&device->vk, &conversion->base, VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
conversion->format = pCreateInfo->format;
conversion->ycbcr_model = pCreateInfo->ycbcrModel;
conversion->ycbcr_range = pCreateInfo->ycbcrRange;
conversion->components = pCreateInfo->components;
conversion->chroma_offsets[0] = pCreateInfo->xChromaOffset;
conversion->chroma_offsets[1] = pCreateInfo->yChromaOffset;
conversion->chroma_filter = pCreateInfo->chromaFilter;
conversion->state.format = pCreateInfo->format;
conversion->state.ycbcr_model = pCreateInfo->ycbcrModel;
conversion->state.ycbcr_range = pCreateInfo->ycbcrRange;
conversion->state.components = pCreateInfo->components;
conversion->state.chroma_offsets[0] = pCreateInfo->xChromaOffset;
conversion->state.chroma_offsets[1] = pCreateInfo->yChromaOffset;
conversion->state.chroma_filter = pCreateInfo->chromaFilter;
*pYcbcrConversion = radv_sampler_ycbcr_conversion_to_handle(conversion);
return VK_SUCCESS;

View file

@ -116,7 +116,7 @@ radv_combined_image_descriptor_sampler_offset(
return binding->size - ((!binding->immutable_samplers_equal) ? 16 : 0);
}
static inline const struct radv_sampler_ycbcr_conversion *
static inline const struct radv_sampler_ycbcr_conversion_state *
radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsigned binding_index)
{
if (!set->ycbcr_sampler_offsets_offset)
@ -127,7 +127,7 @@ radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsi
if (offsets[binding_index] == 0)
return NULL;
return (const struct radv_sampler_ycbcr_conversion *)((const char *)set +
return (const struct radv_sampler_ycbcr_conversion_state *)((const char *)set +
offsets[binding_index]);
}
#endif /* RADV_DESCRIPTOR_SET_H */

View file

@ -33,7 +33,7 @@ struct ycbcr_state {
nir_ssa_def *image_size;
nir_tex_instr *origin_tex;
nir_deref_instr *tex_deref;
const struct radv_sampler_ycbcr_conversion *conversion;
const struct radv_sampler_ycbcr_conversion_state *conversion;
bool unnormalized_coordinates;
};
@ -80,7 +80,7 @@ static nir_ssa_def *
implicit_downsampled_coords(struct ycbcr_state *state, nir_ssa_def *old_coords)
{
nir_builder *b = state->builder;
const struct radv_sampler_ycbcr_conversion *conversion = state->conversion;
const struct radv_sampler_ycbcr_conversion_state *conversion = state->conversion;
nir_ssa_def *image_size = NULL;
nir_ssa_def *comp[4] = {
NULL,
@ -230,7 +230,7 @@ try_lower_tex_ycbcr(const struct radv_pipeline_layout *layout, nir_builder *buil
layout->set[var->data.descriptor_set].layout;
const struct radv_descriptor_set_binding_layout *binding =
&set_layout->binding[var->data.binding];
const struct radv_sampler_ycbcr_conversion *ycbcr_samplers =
const struct radv_sampler_ycbcr_conversion_state *ycbcr_samplers =
radv_immutable_ycbcr_samplers(set_layout, var->data.binding);
if (!ycbcr_samplers)
@ -255,7 +255,7 @@ try_lower_tex_ycbcr(const struct radv_pipeline_layout *layout, nir_builder *buil
array_index = nir_src_as_uint(deref->arr.index);
array_index = MIN2(array_index, binding->array_size - 1);
}
const struct radv_sampler_ycbcr_conversion *ycbcr_sampler = ycbcr_samplers + array_index;
const struct radv_sampler_ycbcr_conversion_state *ycbcr_sampler = ycbcr_samplers + array_index;
if (ycbcr_sampler->format == VK_FORMAT_UNDEFINED)
return false;

View file

@ -2338,8 +2338,7 @@ void radv_image_view_finish(struct radv_image_view *iview);
VkFormat radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask);
struct radv_sampler_ycbcr_conversion {
struct vk_object_base base;
struct radv_sampler_ycbcr_conversion_state {
VkFormat format;
VkSamplerYcbcrModelConversion ycbcr_model;
VkSamplerYcbcrRange ycbcr_range;
@ -2348,6 +2347,12 @@ struct radv_sampler_ycbcr_conversion {
VkFilter chroma_filter;
};
struct radv_sampler_ycbcr_conversion {
struct vk_object_base base;
/* The state is hashed for the descriptor set layout. */
struct radv_sampler_ycbcr_conversion_state state;
};
struct radv_buffer_view {
struct vk_object_base base;
struct radeon_winsys_bo *bo;