Mesa (main): radeonsi: compute PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT correctly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 8 10:54:35 UTC 2022


Module: Mesa
Branch: main
Commit: b75084431927ad07ebfd92068b97e1638d136f50
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b75084431927ad07ebfd92068b97e1638d136f50

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Jun  5 20:26:30 2022 -0400

radeonsi: compute PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT correctly

Reviewed-by: Mihai Preda <mhpreda at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16901>

---

 src/gallium/drivers/radeonsi/si_get.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c
index b737c80c1fb..0efb817191c 100644
--- a/src/gallium/drivers/radeonsi/si_get.c
+++ b/src/gallium/drivers/radeonsi/si_get.c
@@ -233,7 +233,25 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE:
       return 4096 * 1024;
 
-   case PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT:
+   case PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT: {
+      unsigned max_texels =
+         pscreen->get_param(pscreen, PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT);
+
+      /* FYI, BUF_RSRC_WORD2.NUM_RECORDS field limit is UINT32_MAX. */
+
+      /* Gfx8 and older use the size in bytes for bounds checking, and the max element size
+       * is 16B. Gfx9 and newer use the VGPR index for bounds checking.
+       */
+      if (sscreen->info.gfx_level <= GFX8)
+         max_texels = MIN2(max_texels, UINT32_MAX / 16);
+      else
+         /* Gallium has a limitation that it can only bind UINT32_MAX bytes, not texels.
+          * TODO: Remove this after the gallium interface is changed. */
+         max_texels = MIN2(max_texels, UINT32_MAX / 16);
+
+      return max_texels;
+   }
+
    case PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT: {
       /* Return 1/4th of the heap size as the maximum because the max size is not practically
        * allocatable. Also, this can only return UINT32_MAX at most.



More information about the mesa-commit mailing list