From 10d21d410068f2ca32fe898f6b4b690993d90daa Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 14 Nov 2019 12:37:01 -0500 Subject: [PATCH] mesa: Enable EXT_shadow_samplers for GLES2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I thought this was just the funny GLES spelling of the extn name, but there's also some ESSL bits you need to add. Most of which you could probably yoink from the old Unity glsl-optimizer (which itself yoinked most of the GLSL compiler from Mesa): https://github.com/aras-p/glsl-optimizer/commit/94a9b2959b885dba4e355aa344adb4d472b00f18 Signed-off-by: Adam Jackson Co-authored-by: Mike Blumenkrantz Acked-by: Marek Olšák Part-of: --- src/compiler/glsl/builtin_functions.cpp | 17 +++++++++++++++++ src/compiler/glsl/glsl_parser_extras.cpp | 1 + src/compiler/glsl/glsl_parser_extras.h | 2 ++ src/compiler/glsl/standalone_scaffolding.cpp | 1 + src/mesa/main/consts_exts.h | 1 + src/mesa/main/extensions.c | 1 + src/mesa/main/extensions_table.h | 1 + 7 files changed, 24 insertions(+) diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index ea74fd42120..031a1ac4067 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -230,6 +230,13 @@ texture_external_es3(const _mesa_glsl_parse_state *state) state->is_version(0, 300); } +static bool +texture_shadow2Dext(const _mesa_glsl_parse_state *state) +{ + return state->es_shader && + state->EXT_shadow_samplers_enable; +} + /** True if texturing functions with explicit LOD are allowed. */ static bool lod_exists_in_stage(const _mesa_glsl_parse_state *state) @@ -4008,6 +4015,11 @@ builtin_builder::create_builtins() _texture(ir_txb, v110_derivatives_only_deprecated_texture, &glsl_type_builtin_vec4, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec3), NULL); + add_function("shadow2DEXT", + _texture(ir_tex, texture_shadow2Dext, &glsl_type_builtin_float, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec3), + _texture(ir_txb, texture_shadow2Dext, &glsl_type_builtin_float, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec3), + NULL); + add_function("shadow2DArray", _texture(ir_tex, texture_array, &glsl_type_builtin_vec4, &glsl_type_builtin_sampler2DArrayShadow, &glsl_type_builtin_vec4), _texture(ir_txb, texture_array_derivs_only, &glsl_type_builtin_vec4, &glsl_type_builtin_sampler2DArrayShadow, &glsl_type_builtin_vec4), @@ -4033,6 +4045,11 @@ builtin_builder::create_builtins() _texture(ir_txb, v110_derivatives_only_deprecated_texture, &glsl_type_builtin_vec4, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec4, TEX_PROJECT), NULL); + add_function("shadow2DProjEXT", + _texture(ir_tex, texture_shadow2Dext, &glsl_type_builtin_float, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec4, TEX_PROJECT), + _texture(ir_txb, texture_shadow2Dext, &glsl_type_builtin_float, &glsl_type_builtin_sampler2DShadow, &glsl_type_builtin_vec4, TEX_PROJECT), + NULL); + add_function("shadow1DLod", _texture(ir_txl, v110_lod_deprecated_texture, &glsl_type_builtin_vec4, &glsl_type_builtin_sampler1DShadow, &glsl_type_builtin_vec3), NULL); diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 008bd0ff74c..62107f415ec 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -771,6 +771,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(EXT_shader_integer_mix), EXT_AEP(EXT_shader_io_blocks), EXT(EXT_shader_samples_identical), + EXT(EXT_shadow_samplers), EXT(EXT_tessellation_point_size), EXT_AEP(EXT_tessellation_shader), EXT(EXT_texture_array), diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index f91b88d0b7b..b202b0d2036 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -880,6 +880,8 @@ struct _mesa_glsl_parse_state { bool EXT_shader_io_blocks_warn; bool EXT_shader_samples_identical_enable; bool EXT_shader_samples_identical_warn; + bool EXT_shadow_samplers_enable; + bool EXT_shadow_samplers_warn; bool EXT_tessellation_point_size_enable; bool EXT_tessellation_point_size_warn; bool EXT_tessellation_shader_enable; diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp index 996a3995b8f..834a65d5852 100644 --- a/src/compiler/glsl/standalone_scaffolding.cpp +++ b/src/compiler/glsl/standalone_scaffolding.cpp @@ -239,6 +239,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.EXT_gpu_shader4 = true; ctx->Extensions.EXT_shader_integer_mix = true; + ctx->Extensions.EXT_shadow_samplers = true; ctx->Extensions.EXT_texture_array = true; ctx->Extensions.MESA_shader_integer_functions = true; diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h index 3e8a2844a44..d14b9185f12 100644 --- a/src/mesa/main/consts_exts.h +++ b/src/mesa/main/consts_exts.h @@ -189,6 +189,7 @@ struct gl_extensions GLboolean EXT_shader_samples_identical; GLboolean EXT_sRGB; GLboolean EXT_stencil_two_side; + GLboolean EXT_shadow_samplers; GLboolean EXT_texture_array; GLboolean EXT_texture_buffer_object; GLboolean EXT_texture_compression_latc; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index e007fed65eb..920ea5cef33 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -284,6 +284,7 @@ _mesa_init_extensions(struct gl_extensions *extensions) extensions->EXT_EGL_image_storage = GL_TRUE; extensions->EXT_gpu_program_parameters = GL_TRUE; extensions->EXT_provoking_vertex = GL_TRUE; + extensions->EXT_shadow_samplers = GL_TRUE; extensions->EXT_stencil_two_side = GL_TRUE; extensions->EXT_texture_env_dot3 = GL_TRUE; diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index a5f47a69d64..d219b740e2c 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -301,6 +301,7 @@ EXT(EXT_shader_integer_mix , EXT_shader_integer_mix EXT(EXT_shader_io_blocks , dummy_true , x , x , x , 31, 2014) EXT(EXT_shader_samples_identical , EXT_shader_samples_identical , GLL, GLC, x , 31, 2015) EXT(EXT_shadow_funcs , ARB_shadow , GLL, x , x , x , 2002) +EXT(EXT_shadow_samplers , ARB_shadow , x , x , x , ES2, 2012) EXT(EXT_stencil_two_side , EXT_stencil_two_side , GLL, x , x , x , 2001) EXT(EXT_stencil_wrap , dummy_true , GLL, x , x , x , 2002) EXT(EXT_subtexture , dummy_true , GLL, x , x , x , 1995)