radv: reduce the combined image/sampler desc size on GFX11+

From 96 to 64 due to the 32 bytes descriptor alignment.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36762>
This commit is contained in:
Samuel Pitoiset
2025-08-13 16:50:35 +02:00
committed by Marge Bot
parent 897201d710
commit 0ac7f1888f
9 changed files with 42 additions and 20 deletions
@@ -19,6 +19,8 @@
typedef struct {
enum amd_gfx_level gfx_level;
uint32_t address32_hi;
uint32_t combined_image_sampler_desc_size;
uint32_t combined_image_sampler_offset;
bool disable_aniso_single_level;
bool has_image_load_dcc_bug;
bool disable_tg4_trunc_coord;
@@ -235,18 +237,18 @@ get_sampler_desc(nir_builder *b, apply_layout_state *state, nir_deref_instr *der
offset += 32;
break;
case AC_DESC_PLANE_1:
offset += RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE;
offset += state->combined_image_sampler_desc_size;
break;
case AC_DESC_SAMPLER:
size = RADV_SAMPLER_DESC_SIZE / 4;
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset += RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
offset += state->combined_image_sampler_offset;
break;
case AC_DESC_BUFFER:
size = RADV_BUFFER_DESC_SIZE / 4;
break;
case AC_DESC_PLANE_2:
offset += 2 * RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE;
offset += 2 * state->combined_image_sampler_desc_size;
break;
}
@@ -549,6 +551,8 @@ radv_nir_apply_pipeline_layout(nir_shader *shader, struct radv_device *device, c
apply_layout_state state = {
.gfx_level = pdev->info.gfx_level,
.address32_hi = pdev->info.address32_hi,
.combined_image_sampler_desc_size = radv_get_combined_image_sampler_desc_size(pdev),
.combined_image_sampler_offset = radv_get_combined_image_sampler_offset(pdev),
.disable_aniso_single_level = instance->drirc.disable_aniso_single_level,
.has_image_load_dcc_bug = pdev->info.has_image_load_dcc_bug,
.disable_tg4_trunc_coord = !pdev->info.conformant_trunc_coord && !instance->drirc.disable_trunc_coord,
-3
View File
@@ -142,12 +142,9 @@
#define RADV_VERT_ATTRIB_MAX MAX2(VERT_ATTRIB_MAX, VERT_ATTRIB_GENERIC0 + MAX_VERTEX_ATTRIBS)
/* Descriptor sizes */
#define RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE 96
#define RADV_SAMPLER_DESC_SIZE 16
#define RADV_STORAGE_IMAGE_DESC_SIZE 32
#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 */
+1 -1
View File
@@ -119,7 +119,7 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
}
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
bo_size += RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE * pCreateInfo->pPoolSizes[i].descriptorCount;
bo_size += pCreateInfo->pPoolSizes[i].descriptorCount * radv_get_combined_image_sampler_desc_size(pdev);
break;
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK:
bo_size += pCreateInfo->pPoolSizes[i].descriptorCount;
+7 -4
View File
@@ -160,7 +160,8 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
set_layout->binding[b].size = radv_get_sampled_image_desc_size(pdev);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
set_layout->binding[b].size = max_sampled_image_descriptors * RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE;
set_layout->binding[b].size =
max_sampled_image_descriptors * radv_get_combined_image_sampler_desc_size(pdev);
break;
case VK_DESCRIPTOR_TYPE_SAMPLER:
set_layout->binding[b].size = RADV_SAMPLER_DESC_SIZE;
@@ -318,7 +319,7 @@ radv_GetDescriptorSetLayoutSupport(VkDevice _device, const VkDescriptorSetLayout
descriptor_size = radv_get_sampled_image_desc_size(pdev);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
descriptor_size = RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE;
descriptor_size = radv_get_combined_image_sampler_desc_size(pdev);
break;
case VK_DESCRIPTOR_TYPE_SAMPLER:
descriptor_size = RADV_SAMPLER_DESC_SIZE;
@@ -376,6 +377,8 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
struct radv_descriptor_set_layout *layout, const uint32_t variable_count,
struct radv_descriptor_set **out_set)
{
const struct radv_physical_device *pdev = radv_device_physical(device);
if (pool->entry_count == pool->max_entry_count)
return VK_ERROR_OUT_OF_POOL_MEMORY;
@@ -471,7 +474,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_SAMPLER_DESC_SAMPLER_OFFSET / 4;
offset += radv_get_combined_image_sampler_offset(pdev) / 4;
const uint32_t *samplers =
(const uint32_t *)((const char *)layout + layout->binding[i].immutable_samplers_offset);
@@ -639,7 +642,7 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
}
if (copy_immutable_samplers) {
const uint32_t sampler_offset = RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
const uint32_t sampler_offset = radv_get_combined_image_sampler_offset(pdev);
const unsigned idx = writeset->dstArrayElement + j;
memcpy((char *)ptr + sampler_offset, samplers + 4 * idx, RADV_SAMPLER_DESC_SIZE);
@@ -174,7 +174,7 @@ radv_update_descriptor_set_with_template_impl(struct radv_device *device, struct
}
if (cmd_buffer && templ->entry[i].immutable_samplers) {
const uint32_t sampler_offset = RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
const uint32_t sampler_offset = radv_get_combined_image_sampler_offset(pdev);
memcpy((char *)pDst + sampler_offset, templ->entry[i].immutable_samplers + 4 * j,
RADV_SAMPLER_DESC_SIZE);
+3 -3
View File
@@ -132,15 +132,15 @@ radv_GetDescriptorEXT(VkDevice _device, const VkDescriptorGetInfoEXT *pDescripto
VK_FROM_HANDLE(radv_sampler, sampler, pDescriptorInfo->data.pCombinedImageSampler->sampler);
if (sampler->vk.ycbcr_conversion) {
radv_write_image_descriptor_ycbcr(pDescriptor, pDescriptorInfo->data.pCombinedImageSampler);
radv_write_image_descriptor_ycbcr(device, pDescriptor, pDescriptorInfo->data.pCombinedImageSampler);
} else {
radv_write_image_descriptor(pDescriptor, radv_get_sampled_image_desc_size(pdev), pDescriptorInfo->type,
pDescriptorInfo->data.pCombinedImageSampler);
radv_write_sampler_descriptor((uint32_t *)pDescriptor + RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET / 4,
radv_write_sampler_descriptor((uint32_t *)pDescriptor + radv_get_combined_image_sampler_offset(pdev) / 4,
pDescriptorInfo->data.pCombinedImageSampler->sampler);
}
} else {
memset(pDescriptor, 0, RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE);
memset(pDescriptor, 0, radv_get_combined_image_sampler_desc_size(pdev));
}
break;
}
+7 -4
View File
@@ -205,8 +205,9 @@ radv_write_image_descriptor_impl(struct radv_device *device, struct radv_cmd_buf
}
static ALWAYS_INLINE void
radv_write_image_descriptor_ycbcr(unsigned *dst, const VkDescriptorImageInfo *image_info)
radv_write_image_descriptor_ycbcr(struct radv_device *device, unsigned *dst, const VkDescriptorImageInfo *image_info)
{
const struct radv_physical_device *pdev = radv_device_physical(device);
struct radv_image_view *iview = NULL;
if (image_info)
@@ -218,10 +219,12 @@ radv_write_image_descriptor_ycbcr(unsigned *dst, const VkDescriptorImageInfo *im
}
const uint32_t plane_count = vk_format_get_plane_count(iview->vk.format);
const uint32_t stride = radv_get_combined_image_sampler_desc_size(pdev) / 4;
for (uint32_t i = 0; i < plane_count; i++) {
memcpy(dst, iview->descriptor.plane_descriptors[i], 32);
dst += RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE / 4;
dst += stride;
}
}
@@ -231,7 +234,7 @@ radv_write_image_descriptor_ycbcr_impl(struct radv_device *device, struct radv_c
{
VK_FROM_HANDLE(radv_image_view, iview, image_info->imageView);
radv_write_image_descriptor_ycbcr(dst, image_info);
radv_write_image_descriptor_ycbcr(device, dst, image_info);
if (device->use_global_bo_list)
return;
@@ -273,7 +276,7 @@ radv_write_combined_image_sampler_descriptor(struct radv_device *device, struct
radv_write_image_descriptor_impl(device, cmd_buffer, desc_size, dst, buffer_list, descriptor_type, image_info);
/* copy over sampler state */
if (has_sampler) {
const uint32_t sampler_offset = RADV_COMBINED_IMAGE_SAMPLER_DESC_SAMPLER_OFFSET;
const uint32_t sampler_offset = radv_get_combined_image_sampler_offset(pdev);
radv_write_sampler_descriptor(dst + sampler_offset / sizeof(*dst), image_info->sampler);
}
+1 -1
View File
@@ -1935,7 +1935,7 @@ radv_get_physical_device_properties(struct radv_physical_device *pdev)
.samplerCaptureReplayDescriptorDataSize = 1,
.accelerationStructureCaptureReplayDescriptorDataSize = 1,
.samplerDescriptorSize = RADV_SAMPLER_DESC_SIZE,
.combinedImageSamplerDescriptorSize = RADV_COMBINED_IMAGE_SAMPLER_DESC_SIZE,
.combinedImageSamplerDescriptorSize = radv_get_combined_image_sampler_desc_size(pdev),
.sampledImageDescriptorSize = radv_get_sampled_image_desc_size(pdev),
.storageImageDescriptorSize = RADV_STORAGE_IMAGE_DESC_SIZE,
.uniformTexelBufferDescriptorSize = RADV_BUFFER_DESC_SIZE,
+15
View File
@@ -16,6 +16,7 @@
#include "ac_uvd_dec.h"
#include "ac_vcn_enc.h"
#include "radv_constants.h"
#include "radv_instance.h"
#include "radv_queue.h"
#include "radv_radeon_winsys.h"
@@ -287,4 +288,18 @@ radv_get_sampled_image_desc_size(const struct radv_physical_device *pdev)
return 32 + (pdev->use_fmask ? 32 : 0);
}
static inline uint32_t
radv_get_combined_image_sampler_desc_size(const struct radv_physical_device *pdev)
{
const uint32_t image_desc_size = radv_get_sampled_image_desc_size(pdev);
return align(image_desc_size + RADV_SAMPLER_DESC_SIZE, 32);
}
static inline uint32_t
radv_get_combined_image_sampler_offset(const struct radv_physical_device *pdev)
{
return radv_get_combined_image_sampler_desc_size(pdev) - RADV_SAMPLER_DESC_SIZE;
}
#endif /* RADV_PHYSICAL_DEVICE_H */