Mesa (main): gallium: add PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT for UBOs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 7 05:19:50 UTC 2022


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Jun  5 18:56:07 2022 -0400

gallium: add PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT for UBOs

We plan to report UINT32_MAX for UBOs.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16881>

---

 docs/gallium/screen.rst                | 1 +
 src/gallium/auxiliary/util/u_screen.c  | 4 ++++
 src/gallium/include/pipe/p_defines.h   | 1 +
 src/mesa/state_tracker/st_extensions.c | 7 +------
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst
index ad226d5ed18..98757ed8ac9 100644
--- a/docs/gallium/screen.rst
+++ b/docs/gallium/screen.rst
@@ -636,6 +636,7 @@ The integer capabilities:
 * ``PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY``: TRUE if shader sparse texture sample instruction could also return the residency information.
 * ``PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD``: TRUE if shader sparse texture sample instruction support clamp the minimal lod to prevent read from un-committed pages.
 * ``PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER``: TRUE if the driver allows the "draw out of order" optimization to be enabled. See _mesa_update_allow_draw_out_of_order for more details.
+* ``PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT``: Maximum bound constant buffer size in bytes. This is unsigned integer with the maximum of 4GB - 1. This applies to all constant buffers used by UBOs, unlike `PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE`, which is specifically for GLSL uniforms.
 
 .. _pipe_capf:
 
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index 4ab547befc8..b506b1833e7 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -488,6 +488,10 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD:
       return 0;
 
+   case PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT:
+      return pscreen->get_shader_param(pscreen, PIPE_SHADER_FRAGMENT,
+                                       PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE);
+
    default:
       unreachable("bad PIPE_CAP_*");
    }
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 5a0903b6b32..d538e61fb70 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1007,6 +1007,7 @@ enum pipe_cap
    PIPE_CAP_QUERY_SPARSE_TEXTURE_RESIDENCY,
    PIPE_CAP_CLAMP_SPARSE_TEXTURE_LOD,
    PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER,
+   PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT,
 
    PIPE_CAP_LAST,
    /* XXX do not add caps after PIPE_CAP_LAST! */
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 7e498340956..8300be8fb2d 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -156,12 +156,7 @@ void st_init_limits(struct pipe_screen *screen,
                         PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
 
    c->MaxUniformBlockSize =
-      screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
-                               PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE);
-   /* GL45-CTS.enhanced_layouts.ssb_member_invalid_offset_alignment fails if
-    * this is larger than INT_MAX - 100. Use a nicely aligned limit.
-    */
-   c->MaxUniformBlockSize = MIN2(c->MaxUniformBlockSize, INT_MAX - 127);
+      screen->get_param(screen, PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT);
 
    if (c->MaxUniformBlockSize < 16384) {
       can_ubo = false;



More information about the mesa-commit mailing list