summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Lehmann <dadschoorse@gmail.com>2022-03-18 14:10:21 +0100
committerEric Engestrom <eric@engestrom.ch>2022-03-19 18:11:13 +0000
commit45b4a998d6667612bef930c3b6587c4ddbe1e370 (patch)
tree2a4f2ad314b94be5f74735d993c382a13ccc9afd
parente6d82a08972dfb1d82cf11e4cc7bc83069734500 (diff)
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 4f6c7a6025628fe14e06ac864986ab95bdd25457)
-rw-r--r--.pick_status.json2
-rw-r--r--src/amd/vulkan/radv_descriptor_set.c28
-rw-r--r--src/amd/vulkan/radv_descriptor_set.h4
-rw-r--r--src/amd/vulkan/radv_nir_lower_ycbcr_textures.c8
-rw-r--r--src/amd/vulkan/radv_private.h9
5 files changed, 28 insertions, 23 deletions
diff --git a/.pick_status.json b/.pick_status.json
index cb72b1cb72f..9ef746cd9d8 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -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
},
diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index 81cf394375e..e2f1267a7a2 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -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;
diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h
index 65d33f19dc3..2d8509fa1b6 100644
--- a/src/amd/vulkan/radv_descriptor_set.h
+++ b/src/amd/vulkan/radv_descriptor_set.h
@@ -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 */
diff --git a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
index 8695f3bd04b..e5a38b23f3e 100644
--- a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
+++ b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
@@ -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;
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 972a2c6854f..25354936bb7 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -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;