From b122beaff362ad9601d063b0d047b66b01df8a20 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 5 Apr 2021 12:13:04 -0400 Subject: [PATCH] gallium: split PIPE_CAP_SAMPLER_REDUCTION_MINMAX into modes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this enables detection for the EXT vs the ARB extension, which have different specifications regarding which formats must be supported Reviewed-by: Ilia Mirkin Reviewed-by: Marek Olšák Part-of: --- docs/gallium/screen.rst | 3 ++- src/gallium/auxiliary/util/u_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/include/pipe/p_defines.h | 1 + src/mesa/main/extensions_table.h | 2 +- src/mesa/main/mtypes.h | 1 + src/mesa/main/samplerobj.c | 15 ++++++++++----- src/mesa/main/texparam.c | 9 ++++++--- src/mesa/state_tracker/st_extensions.c | 5 +++++ 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index cdc1467c78a..fc57e4a0e9e 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -612,7 +612,8 @@ The integer capabilities: * ``PIPE_CAP_PREFER_REAL_BUFFER_IN_CONSTBUF0``: The state tracker is encouraged to upload constants into a real buffer and bind it into constant buffer 0 instead of binding a user pointer. This may enable a faster codepath in a gallium frontend for drivers that really prefer a real buffer. * ``PIPE_CAP_GL_CLAMP``: Driver natively supports GL_CLAMP. Required for non-NIR drivers with the GL frontend. NIR drivers with the cap unavailable will have GL_CLAMP lowered to txd/txl with a saturate on the coordinates. * ``PIPE_CAP_TEXRECT``: Driver supports rectangle textures. Required for OpenGL on `!prefers_nir` drivers. If this cap is not present, st/mesa will lower the NIR to use normal 2D texture sampling by using either `txs` or `nir_intrinsic_load_texture_scaling` to normalize the texture coordinates. -* ``PIPE_CAP_SAMPLER_REDUCTION_MINMAX``: Driver support min/max sampler reduction. +* ``PIPE_CAP_SAMPLER_REDUCTION_MINMAX``: Driver supports EXT min/max sampler reduction. +* ``PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB``: Driver supports ARB min/max sampler reduction with format queries. .. _pipe_capf: diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 6e6aadbfd6a..32a35c1a8e9 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -460,6 +460,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, return 0; case PIPE_CAP_SAMPLER_REDUCTION_MINMAX: + case PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB: return 0; case PIPE_CAP_ALLOW_DYNAMIC_VAO_FASTPATH: diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 5ecba978c28..6cc9c830c55 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -413,6 +413,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_BLEND_EQUATION_ADVANCED: case PIPE_CAP_NO_CLIP_ON_COPY_TEX: case PIPE_CAP_DEVICE_PROTECTED_CONTENT: + case PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 47d26275f7a..08bb63ebbc5 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -987,6 +987,7 @@ enum pipe_cap PIPE_CAP_GL_CLAMP, PIPE_CAP_TEXRECT, PIPE_CAP_SAMPLER_REDUCTION_MINMAX, + PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB, PIPE_CAP_ALLOW_DYNAMIC_VAO_FASTPATH, PIPE_CAP_LAST, diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 45b4bda48ea..0afa5d365b3 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -161,7 +161,7 @@ EXT(ARB_texture_env_combine , ARB_texture_env_combine EXT(ARB_texture_env_crossbar , ARB_texture_env_crossbar , GLL, x , x , x , 2001) EXT(ARB_texture_env_dot3 , ARB_texture_env_dot3 , GLL, x , x , x , 2001) EXT(ARB_texture_filter_anisotropic , ARB_texture_filter_anisotropic , GLL, GLC, x , x , 2017) -EXT(ARB_texture_filter_minmax , EXT_texture_filter_minmax , GLL, GLC, x , x , 2015) +EXT(ARB_texture_filter_minmax , ARB_texture_filter_minmax , GLL, GLC, x , x , 2015) EXT(ARB_texture_float , ARB_texture_float , GLL, GLC, x , x , 2004) EXT(ARB_texture_gather , ARB_texture_gather , GLL, GLC, x , x , 2009) EXT(ARB_texture_mirror_clamp_to_edge , ARB_texture_mirror_clamp_to_edge , GLL, GLC, x , x , 2013) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8d8799102d7..ab95ef2fe50 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4392,6 +4392,7 @@ struct gl_extensions GLboolean ARB_texture_env_crossbar; GLboolean ARB_texture_env_dot3; GLboolean ARB_texture_filter_anisotropic; + GLboolean ARB_texture_filter_minmax; GLboolean ARB_texture_float; GLboolean ARB_texture_gather; GLboolean ARB_texture_mirror_clamp_to_edge; diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index 43f832fdab1..5aaae79a2c7 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -877,7 +877,8 @@ static GLuint set_sampler_reduction_mode(struct gl_context *ctx, struct gl_sampler_object *samp, GLenum param) { - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) return INVALID_PNAME; if (samp->Attrib.ReductionMode == param) @@ -1530,7 +1531,8 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) *params = (GLenum) sampObj->Attrib.sRGBDecode; break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = (GLenum) sampObj->Attrib.ReductionMode; break; @@ -1607,7 +1609,8 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) *params = (GLfloat) sampObj->Attrib.sRGBDecode; break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = (GLfloat) sampObj->Attrib.ReductionMode; break; @@ -1684,7 +1687,8 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) *params = (GLenum) sampObj->Attrib.sRGBDecode; break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = (GLenum) sampObj->Attrib.ReductionMode; break; @@ -1761,7 +1765,8 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) *params = (GLenum) sampObj->Attrib.sRGBDecode; break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = (GLenum) sampObj->Attrib.ReductionMode; break; diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 16c0f282b7f..89ad8abe3e3 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -597,7 +597,8 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (ctx->Extensions.EXT_texture_filter_minmax) { + if (ctx->Extensions.EXT_texture_filter_minmax || + _mesa_has_ARB_texture_filter_minmax(ctx)) { GLenum mode = params[0]; if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) @@ -2377,7 +2378,8 @@ get_tex_parameterfv(struct gl_context *ctx, break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = (GLfloat) obj->Sampler.Attrib.ReductionMode; break; @@ -2649,7 +2651,8 @@ get_tex_parameteriv(struct gl_context *ctx, break; case GL_TEXTURE_REDUCTION_MODE_EXT: - if (!ctx->Extensions.EXT_texture_filter_minmax) + if (!ctx->Extensions.EXT_texture_filter_minmax && + !_mesa_has_ARB_texture_filter_minmax(ctx)) goto invalid_pname; *params = obj->Sampler.Attrib.ReductionMode; break; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 5c87f6e5677..85c56c057df 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -811,6 +811,7 @@ void st_init_extensions(struct pipe_screen *screen, { o(ARB_spirv_extensions), PIPE_CAP_GL_SPIRV }, { o(ARB_texture_buffer_object), PIPE_CAP_TEXTURE_BUFFER_OBJECTS }, { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY }, + { o(ARB_texture_filter_minmax), PIPE_CAP_SAMPLER_REDUCTION_MINMAX_ARB }, { o(ARB_texture_gather), PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS }, { o(ARB_texture_mirror_clamp_to_edge), PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE }, { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE }, @@ -1139,6 +1140,10 @@ void st_init_extensions(struct pipe_screen *screen, } } + /* EXT implies ARB here */ + if (extensions->EXT_texture_filter_minmax) + extensions->ARB_texture_filter_minmax = GL_TRUE; + /* Expose the extensions which directly correspond to gallium formats. */ init_format_extensions(screen, extensions, rendertarget_mapping, ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D,