From f6bf120d02f3539f34beb2bb488e310d422ad801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 26 Nov 2025 15:39:52 -0500 Subject: [PATCH] radeonsi: reject textures that don't fit in the CPU address space Reviewed-by: Qiang Yu Part-of: --- src/gallium/drivers/radeonsi/si_texture.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index c7c0a29a836..68b740668d2 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -1059,6 +1059,18 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen, return NULL; } + /* Fail to allocate or import textures greater than 4GB on 32-bit CPU targets because Mesa + * uses size_t for all image addressing and size computations, which doesn't work with + * textures bigger than 4GB. + * + * Due to a limitation in glCompressedTex* functions, compressed textures can only occupy + * at most 2GB on all CPU targets because the maximum value of the imageSize parameter is + * INT_MAX. Bigger textures are automatically rejected by the imageSize checking in the GL + * frontend. This could be fixed with a new GL extension. + */ + if (alloc_size > SIZE_MAX) + return NULL; + tex = CALLOC_STRUCT_CL(si_texture); if (!tex) goto error;