gallium/st: reserve space in default uniform block for lowered constants

If we don't reserve these, we risk these lowering passes eating up more
uniforms than we have available.

This fixes a crash due to an assert in Zink, because we end up trying to
use a too large UBO after lowering.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9631>
This commit is contained in:
Erik Faye-Lund 2021-03-16 18:40:01 +01:00
parent 78de2de8f3
commit 0b090d8e67
2 changed files with 24 additions and 2 deletions

View file

@ -25,8 +25,6 @@ glx@glx_ext_import_context@query context info,Fail
shaders@glsl-bug-110796,Fail
shaders@glsl-fs-flat-color,Fail
shaders@glsl-fs-pointcoord,Fail
shaders@glsl-uniform-interstage-limits@subdivide 5,Crash
shaders@glsl-uniform-interstage-limits@subdivide 5- statechanges,Crash
shaders@point-vertex-id divisor,Fail
shaders@point-vertex-id gl_instanceid,Fail
shaders@point-vertex-id gl_instanceid divisor,Fail

View file

@ -221,6 +221,30 @@ void st_init_limits(struct pipe_screen *screen,
pc->MaxUniformComponents =
screen->get_shader_param(screen, sh,
PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / 4;
/* reserve space in the default-uniform for lowered state */
if (sh == PIPE_SHADER_VERTEX ||
sh == PIPE_SHADER_TESS_EVAL ||
sh == PIPE_SHADER_GEOMETRY) {
if (!screen->get_param(screen, PIPE_CAP_CLIP_PLANES))
pc->MaxUniformComponents -= 4 * MAX_CLIP_PLANES;
if (!screen->get_param(screen, PIPE_CAP_POINT_SIZE_FIXED))
pc->MaxUniformComponents -= 4;
if (screen->get_param(screen, PIPE_CAP_DEPTH_CLIP_DISABLE) == 2)
pc->MaxUniformComponents -= 4;
} else if (sh == PIPE_SHADER_FRAGMENT) {
if (screen->get_param(screen, PIPE_CAP_DEPTH_CLIP_DISABLE) == 2)
pc->MaxUniformComponents -= 4;
if (!screen->get_param(screen, PIPE_CAP_ALPHA_TEST))
pc->MaxUniformComponents -= 4;
}
pc->MaxUniformComponents = MIN2(pc->MaxUniformComponents,
MAX_UNIFORMS * 4);