/[packages]/updates/8/mesa/current/SOURCES/0029-radv-Don-t-hash-ycbcr-sampler-base-object.patch
ViewVC logotype

Contents of /updates/8/mesa/current/SOURCES/0029-radv-Don-t-hash-ycbcr-sampler-base-object.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1799982 - (show annotations) (download)
Sat Mar 19 09:57:35 2022 UTC (2 years, 1 month ago) by tmb
File size: 9543 byte(s)
add fixes from staging/21.3
1 From 06b4d97799402835e3bed99803360109d928fd46 Mon Sep 17 00:00:00 2001
2 From: Georg Lehmann <dadschoorse@gmail.com>
3 Date: Fri, 18 Mar 2022 14:10:21 +0100
4 Subject: [PATCH 29/29] radv: Don't hash ycbcr sampler base object.
5
6 Stops gamescope from recompiling pipelines on every start.
7
8 Cc: mesa-stable
9
10 Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
11 Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
12 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15454>
13 (cherry picked from commit 4f6c7a6025628fe14e06ac864986ab95bdd25457)
14 ---
15 .pick_status.json | 2 +-
16 src/amd/vulkan/radv_descriptor_set.c | 28 +++++++++----------
17 src/amd/vulkan/radv_descriptor_set.h | 4 +--
18 .../vulkan/radv_nir_lower_ycbcr_textures.c | 8 +++---
19 src/amd/vulkan/radv_private.h | 9 ++++--
20 5 files changed, 28 insertions(+), 23 deletions(-)
21
22 diff --git a/.pick_status.json b/.pick_status.json
23 index 61d75c64193..3fc0b04a8ae 100644
24 --- a/.pick_status.json
25 +++ b/.pick_status.json
26 @@ -22,7 +22,7 @@
27 "description": "radv: Don't hash ycbcr sampler base object.",
28 "nominated": true,
29 "nomination_type": 0,
30 - "resolution": 0,
31 + "resolution": 1,
32 "main_sha": null,
33 "because_sha": null
34 },
35 diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
36 index 81cf394375e..e2f1267a7a2 100644
37 --- a/src/amd/vulkan/radv_descriptor_set.c
38 +++ b/src/amd/vulkan/radv_descriptor_set.c
39 @@ -129,8 +129,8 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
40 /* Store block of offsets first, followed by the conversion descriptors (padded to the struct
41 * alignment) */
42 size += num_bindings * sizeof(uint32_t);
43 - size = ALIGN(size, alignof(struct radv_sampler_ycbcr_conversion));
44 - size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion);
45 + size = ALIGN(size, alignof(struct radv_sampler_ycbcr_conversion_state));
46 + size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion_state);
47 }
48
49 set_layout =
50 @@ -145,7 +145,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
51
52 /* We just allocate all the samplers at the end of the struct */
53 uint32_t *samplers = (uint32_t *)&set_layout->binding[num_bindings];
54 - struct radv_sampler_ycbcr_conversion *ycbcr_samplers = NULL;
55 + struct radv_sampler_ycbcr_conversion_state *ycbcr_samplers = NULL;
56 uint32_t *ycbcr_sampler_offsets = NULL;
57
58 if (ycbcr_sampler_count > 0) {
59 @@ -155,8 +155,8 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
60 uintptr_t first_ycbcr_sampler_offset =
61 (uintptr_t)ycbcr_sampler_offsets + sizeof(uint32_t) * num_bindings;
62 first_ycbcr_sampler_offset =
63 - ALIGN(first_ycbcr_sampler_offset, alignof(struct radv_sampler_ycbcr_conversion));
64 - ycbcr_samplers = (struct radv_sampler_ycbcr_conversion *)first_ycbcr_sampler_offset;
65 + ALIGN(first_ycbcr_sampler_offset, alignof(struct radv_sampler_ycbcr_conversion_state));
66 + ycbcr_samplers = (struct radv_sampler_ycbcr_conversion_state *)first_ycbcr_sampler_offset;
67 } else
68 set_layout->ycbcr_sampler_offsets_offset = 0;
69
70 @@ -198,7 +198,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
71 if (conversion) {
72 has_ycbcr_sampler = true;
73 max_sampled_image_descriptors = MAX2(max_sampled_image_descriptors,
74 - vk_format_get_plane_count(conversion->format));
75 + vk_format_get_plane_count(conversion->state.format));
76 }
77 }
78 }
79 @@ -311,7 +311,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
80 for (uint32_t i = 0; i < binding->descriptorCount; i++) {
81 if (radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler)
82 ycbcr_samplers[i] =
83 - *radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler;
84 + radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler->state;
85 else
86 ycbcr_samplers[i].format = VK_FORMAT_UNDEFINED;
87 }
88 @@ -1522,13 +1522,13 @@ radv_CreateSamplerYcbcrConversion(VkDevice _device,
89
90 vk_object_base_init(&device->vk, &conversion->base, VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
91
92 - conversion->format = pCreateInfo->format;
93 - conversion->ycbcr_model = pCreateInfo->ycbcrModel;
94 - conversion->ycbcr_range = pCreateInfo->ycbcrRange;
95 - conversion->components = pCreateInfo->components;
96 - conversion->chroma_offsets[0] = pCreateInfo->xChromaOffset;
97 - conversion->chroma_offsets[1] = pCreateInfo->yChromaOffset;
98 - conversion->chroma_filter = pCreateInfo->chromaFilter;
99 + conversion->state.format = pCreateInfo->format;
100 + conversion->state.ycbcr_model = pCreateInfo->ycbcrModel;
101 + conversion->state.ycbcr_range = pCreateInfo->ycbcrRange;
102 + conversion->state.components = pCreateInfo->components;
103 + conversion->state.chroma_offsets[0] = pCreateInfo->xChromaOffset;
104 + conversion->state.chroma_offsets[1] = pCreateInfo->yChromaOffset;
105 + conversion->state.chroma_filter = pCreateInfo->chromaFilter;
106
107 *pYcbcrConversion = radv_sampler_ycbcr_conversion_to_handle(conversion);
108 return VK_SUCCESS;
109 diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h
110 index 65d33f19dc3..2d8509fa1b6 100644
111 --- a/src/amd/vulkan/radv_descriptor_set.h
112 +++ b/src/amd/vulkan/radv_descriptor_set.h
113 @@ -116,7 +116,7 @@ radv_combined_image_descriptor_sampler_offset(
114 return binding->size - ((!binding->immutable_samplers_equal) ? 16 : 0);
115 }
116
117 -static inline const struct radv_sampler_ycbcr_conversion *
118 +static inline const struct radv_sampler_ycbcr_conversion_state *
119 radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsigned binding_index)
120 {
121 if (!set->ycbcr_sampler_offsets_offset)
122 @@ -127,7 +127,7 @@ radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsi
123
124 if (offsets[binding_index] == 0)
125 return NULL;
126 - return (const struct radv_sampler_ycbcr_conversion *)((const char *)set +
127 + return (const struct radv_sampler_ycbcr_conversion_state *)((const char *)set +
128 offsets[binding_index]);
129 }
130 #endif /* RADV_DESCRIPTOR_SET_H */
131 diff --git a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
132 index 8695f3bd04b..e5a38b23f3e 100644
133 --- a/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
134 +++ b/src/amd/vulkan/radv_nir_lower_ycbcr_textures.c
135 @@ -33,7 +33,7 @@ struct ycbcr_state {
136 nir_ssa_def *image_size;
137 nir_tex_instr *origin_tex;
138 nir_deref_instr *tex_deref;
139 - const struct radv_sampler_ycbcr_conversion *conversion;
140 + const struct radv_sampler_ycbcr_conversion_state *conversion;
141 bool unnormalized_coordinates;
142 };
143
144 @@ -80,7 +80,7 @@ static nir_ssa_def *
145 implicit_downsampled_coords(struct ycbcr_state *state, nir_ssa_def *old_coords)
146 {
147 nir_builder *b = state->builder;
148 - const struct radv_sampler_ycbcr_conversion *conversion = state->conversion;
149 + const struct radv_sampler_ycbcr_conversion_state *conversion = state->conversion;
150 nir_ssa_def *image_size = NULL;
151 nir_ssa_def *comp[4] = {
152 NULL,
153 @@ -230,7 +230,7 @@ try_lower_tex_ycbcr(const struct radv_pipeline_layout *layout, nir_builder *buil
154 layout->set[var->data.descriptor_set].layout;
155 const struct radv_descriptor_set_binding_layout *binding =
156 &set_layout->binding[var->data.binding];
157 - const struct radv_sampler_ycbcr_conversion *ycbcr_samplers =
158 + const struct radv_sampler_ycbcr_conversion_state *ycbcr_samplers =
159 radv_immutable_ycbcr_samplers(set_layout, var->data.binding);
160
161 if (!ycbcr_samplers)
162 @@ -255,7 +255,7 @@ try_lower_tex_ycbcr(const struct radv_pipeline_layout *layout, nir_builder *buil
163 array_index = nir_src_as_uint(deref->arr.index);
164 array_index = MIN2(array_index, binding->array_size - 1);
165 }
166 - const struct radv_sampler_ycbcr_conversion *ycbcr_sampler = ycbcr_samplers + array_index;
167 + const struct radv_sampler_ycbcr_conversion_state *ycbcr_sampler = ycbcr_samplers + array_index;
168
169 if (ycbcr_sampler->format == VK_FORMAT_UNDEFINED)
170 return false;
171 diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
172 index 972a2c6854f..25354936bb7 100644
173 --- a/src/amd/vulkan/radv_private.h
174 +++ b/src/amd/vulkan/radv_private.h
175 @@ -2338,8 +2338,7 @@ void radv_image_view_finish(struct radv_image_view *iview);
176
177 VkFormat radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask);
178
179 -struct radv_sampler_ycbcr_conversion {
180 - struct vk_object_base base;
181 +struct radv_sampler_ycbcr_conversion_state {
182 VkFormat format;
183 VkSamplerYcbcrModelConversion ycbcr_model;
184 VkSamplerYcbcrRange ycbcr_range;
185 @@ -2348,6 +2347,12 @@ struct radv_sampler_ycbcr_conversion {
186 VkFilter chroma_filter;
187 };
188
189 +struct radv_sampler_ycbcr_conversion {
190 + struct vk_object_base base;
191 + /* The state is hashed for the descriptor set layout. */
192 + struct radv_sampler_ycbcr_conversion_state state;
193 +};
194 +
195 struct radv_buffer_view {
196 struct vk_object_base base;
197 struct radeon_winsys_bo *bo;
198 --
199 2.30.2
200

  ViewVC Help
Powered by ViewVC 1.1.30