radv: replace radv_combined_image_descriptor_sampler_offset() by a constant

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35457>
This commit is contained in:
Samuel Pitoiset
2025-06-11 11:06:23 +02:00
committed by Marge Bot
parent 8160d0b80e
commit 4f37876c7b
4 changed files with 13 additions and 15 deletions

View File

@@ -237,7 +237,7 @@ get_sampler_desc(nir_builder *b, apply_layout_state *state, nir_deref_instr *der
case AC_DESC_SAMPLER:
size = RADV_SAMPLER_DESC_SIZE / 4;
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset += radv_combined_image_descriptor_sampler_offset(binding);
offset += RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
break;
case AC_DESC_BUFFER:
size = RADV_BUFFER_DESC_SIZE / 4;

View File

@@ -170,4 +170,6 @@
#define RADV_BUFFER_DESC_SIZE 16
#define RADV_ACCEL_STRUCT_DESC_SIZE 16
#define RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET (RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE - RADV_SAMPLER_DESC_SIZE)
#endif /* RADV_CONSTANTS_H */

View File

@@ -689,7 +689,7 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
unsigned offset = layout->binding[i].offset / 4;
if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset += radv_combined_image_descriptor_sampler_offset(layout->binding + i) / 4;
offset += RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET / 4;
const uint32_t *samplers =
(const uint32_t *)((const char *)layout + layout->binding[i].immutable_samplers_offset);
@@ -1288,7 +1288,8 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
writeset->descriptorType, writeset->pImageInfo + j);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: {
unsigned sampler_offset = radv_combined_image_descriptor_sampler_offset(binding_layout);
const uint32_t sampler_offset = RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
write_combined_image_sampler_descriptor(device, cmd_buffer, sampler_offset, ptr, buffer_list,
writeset->descriptorType, writeset->pImageInfo + j,
!binding_layout->immutable_samplers_offset);
@@ -1494,7 +1495,6 @@ radv_CreateDescriptorUpdateTemplate(VkDevice _device, const VkDescriptorUpdateTe
.dst_stride = dst_stride,
.buffer_offset = buffer_offset,
.has_sampler = !binding_layout->immutable_samplers_offset,
.sampler_offset = radv_combined_image_descriptor_sampler_offset(binding_layout),
.immutable_samplers = immutable_samplers};
}
@@ -1563,15 +1563,18 @@ radv_update_descriptor_set_with_template_impl(struct radv_device *device, struct
write_image_descriptor_impl(device, cmd_buffer, radv_get_sampled_image_desc_size(pdev), pDst, buffer_list,
templ->entry[i].descriptor_type, (struct VkDescriptorImageInfo *)pSrc);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
write_combined_image_sampler_descriptor(device, cmd_buffer, templ->entry[i].sampler_offset, pDst,
buffer_list, templ->entry[i].descriptor_type,
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: {
const uint32_t sampler_offset = RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
write_combined_image_sampler_descriptor(device, cmd_buffer, sampler_offset, pDst, buffer_list,
templ->entry[i].descriptor_type,
(struct VkDescriptorImageInfo *)pSrc, templ->entry[i].has_sampler);
if (cmd_buffer && templ->entry[i].immutable_samplers) {
memcpy((char *)pDst + templ->entry[i].sampler_offset, templ->entry[i].immutable_samplers + 4 * j,
memcpy((char *)pDst + sampler_offset, templ->entry[i].immutable_samplers + 4 * j,
RADV_SAMPLER_DESC_SIZE);
}
break;
}
case VK_DESCRIPTOR_TYPE_SAMPLER:
if (templ->entry[i].has_sampler) {
const VkDescriptorImageInfo *pImageInfo = (struct VkDescriptorImageInfo *)pSrc;

View File

@@ -150,7 +150,6 @@ struct radv_descriptor_update_template_entry {
/* Only valid for combined image samplers and samplers */
uint8_t has_sampler;
uint8_t sampler_offset;
/* In bytes */
size_t src_offset;
@@ -196,12 +195,6 @@ radv_immutable_samplers(const struct radv_descriptor_set_layout *set,
return (const uint32_t *)((const char *)set + binding->immutable_samplers_offset);
}
static inline unsigned
radv_combined_image_descriptor_sampler_offset(const struct radv_descriptor_set_binding_layout *binding)
{
return binding->size - RADV_SAMPLER_DESC_SIZE;
}
static inline const struct vk_ycbcr_conversion_state *
radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsigned binding_index)
{