gallium: add PIPE_CAP_MAX_TEXTURE_MB
Allows driver to override the default value (1024) from mesa.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6754>
diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst
index 8ae3de0..01d5fb3 100644
--- a/docs/gallium/screen.rst
+++ b/docs/gallium/screen.rst
@@ -591,6 +591,7 @@
* ``PIPE_CAP_BLEND_EQUATION_ADVANCED``: Driver supports blend equation advanced without necessarily supporting FBFETCH.
* ``PIPE_CAP_NIR_ATOMICS_AS_DEREF``: Whether NIR atomics instructions should reference atomics as NIR derefs instead of by indices.
* ``PIPE_CAP_NO_CLIP_ON_COPY_TEX``: Driver doesn't want x/y/width/height clipped based on src size when doing a copy texture operation (eg: may want out-of-bounds reads that produce 0 instead of leaving the texture content undefined)
+* ``PIPE_CAP_MAX_TEXTURE_MB``: Maximum texture size in MB (default is 1024)
.. _pipe_capf:
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index cb06acf..8990908 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -436,9 +436,8 @@
case PIPE_CAP_SYSTEM_SVM:
case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL:
- return 0;
-
case PIPE_CAP_NO_CLIP_ON_COPY_TEX:
+ case PIPE_CAP_MAX_TEXTURE_MB:
return 0;
default:
diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c
index d0d3af8..169cf7e 100644
--- a/src/gallium/drivers/radeonsi/si_get.c
+++ b/src/gallium/drivers/radeonsi/si_get.c
@@ -216,6 +216,8 @@
case PIPE_CAP_MAX_SHADER_BUFFER_SIZE:
/* Align it down to 256 bytes. I've chosen the number randomly. */
return ROUND_DOWN_TO(MIN2(sscreen->info.max_alloc_size, INT_MAX), 256);
+ case PIPE_CAP_MAX_TEXTURE_MB:
+ return sscreen->info.max_alloc_size / (1024 * 1024);
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 7eb7c70..83910d2 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -967,6 +967,7 @@
PIPE_CAP_BLEND_EQUATION_ADVANCED,
PIPE_CAP_NIR_ATOMICS_AS_DEREF,
PIPE_CAP_NO_CLIP_ON_COPY_TEX,
+ PIPE_CAP_MAX_TEXTURE_MB,
};
/**
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 1769d27..f74ad56 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -87,6 +87,8 @@
c->MaxTextureSize = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
c->MaxTextureSize = MIN2(c->MaxTextureSize, 1 << (MAX_TEXTURE_LEVELS - 1));
+ c->MaxTextureMbytes = MAX2(c->MaxTextureMbytes,
+ screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_MB));
c->Max3DTextureLevels
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),