radv: initialize image properties earlier

This is less error prone and it removes redundant code.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37974>
This commit is contained in:
Samuel Pitoiset 2025-10-21 09:01:37 +02:00 committed by Marge Bot
parent 3678437ca0
commit bcde1a6650
3 changed files with 52 additions and 24 deletions

View file

@ -893,7 +893,6 @@ radv_get_image_format_properties(struct radv_physical_device *pdev, const VkPhys
uint32_t maxArraySize;
VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT;
const struct util_format_description *desc = radv_format_description(format);
enum amd_gfx_level gfx_level = pdev->info.gfx_level;
VkImageTiling tiling = info->tiling;
const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *mod_info =
vk_find_struct_const(info->pNext, PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
@ -922,33 +921,28 @@ radv_get_image_format_properties(struct radv_physical_device *pdev, const VkPhys
default:
UNREACHABLE("bad vkimage type\n");
case VK_IMAGE_TYPE_1D:
maxExtent.width = 16384;
maxExtent.width = pdev->image_props.max_dims.width;
maxExtent.height = 1;
maxExtent.depth = 1;
maxMipLevels = 15; /* log2(maxWidth) + 1 */
maxArraySize = gfx_level >= GFX10 ? 8192 : 2048;
maxArraySize = pdev->image_props.max_array_layers;
break;
case VK_IMAGE_TYPE_2D:
maxExtent.width = 16384;
maxExtent.height = 16384;
maxExtent.width = pdev->image_props.max_dims.width;
maxExtent.height = pdev->image_props.max_dims.height;
maxExtent.depth = 1;
maxMipLevels = 15; /* log2(maxWidth) + 1 */
maxArraySize = gfx_level >= GFX10 ? 8192 : 2048;
maxArraySize = pdev->image_props.max_array_layers;
break;
case VK_IMAGE_TYPE_3D:
if (gfx_level >= GFX10) {
maxExtent.width = 8192;
maxExtent.height = 8192;
maxExtent.depth = 8192;
} else {
maxExtent.width = 2048;
maxExtent.height = 2048;
maxExtent.depth = 2048;
}
maxMipLevels = util_logbase2(maxExtent.width) + 1;
case VK_IMAGE_TYPE_3D: {
const uint32_t extent = pdev->image_props.max_dims.depth;
maxExtent.width = extent;
maxExtent.height = extent;
maxExtent.depth = extent;
maxArraySize = 1;
break;
}
}
maxMipLevels = util_logbase2(maxExtent.width) + 1;
if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
/* Might be able to support but the entire format support is

View file

@ -1475,6 +1475,27 @@ radv_get_compiler_string(struct radv_physical_device *pdev)
#endif
}
static void
radv_init_image_properties(struct radv_physical_device *pdev)
{
uint32_t width, height, depth;
if (pdev->info.gfx_level >= GFX10) {
width = 16384;
height = 16384;
depth = 8192;
} else {
width = 16384;
height = 16384;
depth = 2048;
}
pdev->image_props.max_dims.width = width;
pdev->image_props.max_dims.height = height;
pdev->image_props.max_dims.depth = depth;
pdev->image_props.max_array_layers = pdev->info.gfx_level >= GFX10 ? 8192 : 2048;
}
static void
radv_get_physical_device_properties(struct radv_physical_device *pdev)
{
@ -1504,6 +1525,8 @@ radv_get_physical_device_properties(struct radv_physical_device *pdev)
uint64_t os_page_size = 4096;
os_get_page_size(&os_page_size);
radv_init_image_properties(pdev);
pdev->vk.properties = (struct vk_properties){
#ifdef ANDROID_STRICT
.apiVersion = RADV_API_VERSION,
@ -1514,11 +1537,12 @@ radv_get_physical_device_properties(struct radv_physical_device *pdev)
.vendorID = ATI_VENDOR_ID,
.deviceID = pdev->info.pci_id,
.deviceType = device_type,
.maxImageDimension1D = (1 << 14),
.maxImageDimension2D = (1 << 14),
.maxImageDimension3D = pdev->info.gfx_level >= GFX10 ? (1 << 13) : (1 << 11),
.maxImageDimensionCube = (1 << 14),
.maxImageArrayLayers = pdev->info.gfx_level >= GFX10 ? (1 << 13) : (1 << 11),
.maxImageDimension1D = pdev->image_props.max_dims.width,
.maxImageDimension2D = MIN2(pdev->image_props.max_dims.width, pdev->image_props.max_dims.height),
.maxImageDimension3D =
MIN3(pdev->image_props.max_dims.width, pdev->image_props.max_dims.height, pdev->image_props.max_dims.depth),
.maxImageDimensionCube = MIN2(pdev->image_props.max_dims.width, pdev->image_props.max_dims.height),
.maxImageArrayLayers = pdev->image_props.max_array_layers,
.maxTexelBufferElements = UINT32_MAX,
.maxUniformBufferRange = UINT32_MAX,
.maxStorageBufferRange = UINT32_MAX,

View file

@ -214,6 +214,16 @@ struct radv_physical_device {
struct radv_physical_device_cache_key cache_key;
uint32_t tess_distribution_mode;
struct {
struct {
uint32_t width;
uint32_t height;
uint32_t depth;
} max_dims;
uint32_t max_array_layers;
} image_props;
};
VK_DEFINE_HANDLE_CASTS(radv_physical_device, vk.base, VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE)