From: Pierre-Eric Pelloux-Prayer Date: Fri, 24 Apr 2020 16:14:40 +0000 (+0200) Subject: gallium: add a new cap PIPE_CAP_GLSL_ZERO_INIT X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ee1a724bf78baa3fe514036d77d3e96abc998f7;p=mesa.git gallium: add a new cap PIPE_CAP_GLSL_ZERO_INIT Allows driver to select a zero init mode between the 3 possible values. Reviewed-by: Marek Olšák Part-of: --- diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index ae024f0e650..a7fb85ca27b 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -345,6 +345,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_SHADER_SAMPLES_IDENTICAL: case PIPE_CAP_TGSI_ATOMINC_WRAP: case PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE: + case PIPE_CAP_GLSL_ZERO_INIT: return 0; case PIPE_CAP_MAX_GS_INVOCATIONS: diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index e006ef19568..6832b999357 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -579,6 +579,7 @@ The integer capabilities: * ``PIPE_CAP_SYSTEM_SVM``: True if all application memory can be shared with the GPU without explicit mapping. * ``PIPE_CAP_VIEWPORT_MASK``: Whether ``TGSI_SEMANTIC_VIEWPORT_MASK`` and ``TGSI_PROPERTY_LAYER_VIEWPORT_RELATIVE`` are supported (see GL_NV_viewport_array2). * ``PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE``: Whether mapping a buffer as unsynchronized from any thread is safe. +* ``PIPE_CAP_GLSL_ZERO_INIT``: Choose a default zero initialization some glsl variables. If `1`, then all glsl shader variables and gl_FragColor are initialized to zero. If `2`, then shader out variables are not initialized but function out variables are. .. _pipe_capf: diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 9a10a82e052..fad46fa09ce 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -164,6 +164,9 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE: return 1; + case PIPE_CAP_GLSL_ZERO_INIT: + return 2; + case PIPE_CAP_QUERY_SO_OVERFLOW: return !sscreen->use_ngg_streamout; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index dd0c7331b69..f1524b0cdb7 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -947,6 +947,7 @@ enum pipe_cap PIPE_CAP_VIEWPORT_MASK, PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL, PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE, + PIPE_CAP_GLSL_ZERO_INIT, }; /** diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7046e8adfa3..2fa06e7a570 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3868,9 +3868,13 @@ struct gl_constants GLboolean ForceGLSLAbsSqrt; /** - * Types of variable to default initialized to zero. + * Types of variable to default initialized to zero. Supported values are: + * - 0: no zero initialization + * - 1: all shader variables and gl_FragColor are initialiazed to 0 + * - 2: same as 1, but shader out variables are *not* initialized, while + * function out variables are now initialized. */ - GLuint GLSLZeroInit; + GLchar GLSLZeroInit; /** * Treat integer textures using GL_LINEAR filters as GL_NEAREST. diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 2403bd60a8c..f13ded7c19d 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1205,6 +1205,8 @@ void st_init_extensions(struct pipe_screen *screen, if (options->glsl_zero_init) { consts->GLSLZeroInit = 1; + } else { + consts->GLSLZeroInit = screen->get_param(screen, PIPE_CAP_GLSL_ZERO_INIT); } consts->ForceIntegerTexNearest = options->force_integer_tex_nearest;