[Mesa-dev] [PATCH 3/3] glsl: add ARB_ES3_1_compatibility support
Ilia Mirkin
imirkin at alum.mit.edu
Fri Feb 19 19:13:44 UTC 2016
Oddly a bunch of the features it adds are actually from ESSL 3.20. But
the spec is quite clear, oh well.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/compiler/glsl/builtin_functions.cpp | 66 +++++++++++++++++++++++++++++++-
src/compiler/glsl/builtin_variables.cpp | 16 ++++----
src/compiler/glsl/glcpp/glcpp-parse.y | 3 ++
src/compiler/glsl/glsl_parser_extras.cpp | 3 +-
src/compiler/glsl/glsl_parser_extras.h | 2 +
5 files changed, 81 insertions(+), 9 deletions(-)
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index f488434..6576650 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -214,6 +214,7 @@ static bool
shader_integer_mix(const _mesa_glsl_parse_state *state)
{
return state->is_version(450, 310) ||
+ state->ARB_ES3_1_compatibility_enable ||
(v130(state) && state->EXT_shader_integer_mix_enable);
}
@@ -453,6 +454,13 @@ shader_image_atomic(const _mesa_glsl_parse_state *state)
}
static bool
+shader_image_atomic_float(const _mesa_glsl_parse_state *state)
+{
+ return (state->is_version(450, 320) ||
+ state->ARB_ES3_1_compatibility_enable);
+}
+
+static bool
shader_image_size(const _mesa_glsl_parse_state *state)
{
return state->is_version(430, 310) ||
@@ -585,7 +593,8 @@ private:
IMAGE_FUNCTION_READ_ONLY = (1 << 4),
IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
- IMAGE_FUNCTION_MS_ONLY = (1 << 7),
+ IMAGE_FUNCTION_AVAIL_ATOMIC_FLOAT = (1 << 7),
+ IMAGE_FUNCTION_MS_ONLY = (1 << 8),
};
/**
@@ -599,6 +608,15 @@ private:
unsigned flags);
/**
+ * Same as add_image_function, but only for float formats
+ */
+ void add_float_image_function(const char *name,
+ const char *intrinsic_name,
+ image_prototype_ctr prototype,
+ unsigned num_arguments,
+ unsigned flags);
+
+ /**
* Create new functions for all known image built-ins and types.
* If \p glsl is \c true, use the GLSL built-in names and emit code
* to call into the actual compiler intrinsic. If \p glsl is
@@ -2933,6 +2951,42 @@ builtin_builder::add_image_function(const char *name,
}
void
+builtin_builder::add_float_image_function(const char *name,
+ const char *intrinsic_name,
+ image_prototype_ctr prototype,
+ unsigned num_arguments,
+ unsigned flags)
+{
+ static const glsl_type *const types[] = {
+ glsl_type::image1D_type,
+ glsl_type::image2D_type,
+ glsl_type::image3D_type,
+ glsl_type::image2DRect_type,
+ glsl_type::imageCube_type,
+ glsl_type::imageBuffer_type,
+ glsl_type::image1DArray_type,
+ glsl_type::image2DArray_type,
+ glsl_type::imageCubeArray_type,
+ glsl_type::image2DMS_type,
+ glsl_type::image2DMSArray_type,
+ };
+
+ ir_function *f = shader->symbols->get_function(name);
+ if (!f) {
+ f = new(mem_ctx) ir_function(name);
+ shader->symbols->add_function(f);
+ }
+
+ for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) {
+ if ((types[i]->sampler_dimensionality == GLSL_SAMPLER_DIM_MS ||
+ !(flags & IMAGE_FUNCTION_MS_ONLY)))
+ f->add_signature(_image(prototype, types[i], intrinsic_name,
+ num_arguments, flags));
+ }
+}
+
+
+void
builtin_builder::add_image_functions(bool glsl)
{
const unsigned flags = (glsl ? IMAGE_FUNCTION_EMIT_STUB : 0);
@@ -2953,6 +3007,9 @@ builtin_builder::add_image_functions(bool glsl)
IMAGE_FUNCTION_WRITE_ONLY));
const unsigned atom_flags = flags | IMAGE_FUNCTION_AVAIL_ATOMIC;
+ const unsigned atom_float_flags = flags |
+ IMAGE_FUNCTION_AVAIL_ATOMIC_FLOAT |
+ IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE;
add_image_function(glsl ? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
"__intrinsic_image_atomic_add",
@@ -2983,6 +3040,12 @@ builtin_builder::add_image_functions(bool glsl)
"__intrinsic_image_atomic_exchange",
&builtin_builder::_image_prototype, 1, atom_flags);
+ add_float_image_function((glsl ? "imageAtomicExchange" :
+ "__intrinsic_image_atomic_exchange"),
+ "__intrinsic_image_atomic_exchange",
+ &builtin_builder::_image_prototype, 1,
+ atom_float_flags);
+
add_image_function((glsl ? "imageAtomicCompSwap" :
"__intrinsic_image_atomic_comp_swap"),
"__intrinsic_image_atomic_comp_swap",
@@ -5251,6 +5314,7 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
const builtin_available_predicate avail =
(flags & IMAGE_FUNCTION_AVAIL_ATOMIC ? shader_image_atomic :
+ flags & IMAGE_FUNCTION_AVAIL_ATOMIC_FLOAT ? shader_image_atomic_float :
shader_image_load_store);
ir_function_signature *sig = new_sig(ret_type, avail, 2, image, coord);
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 8d41213..6885f30 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -834,11 +834,6 @@ builtin_variable_generator::generate_constants()
state->Const.MaxImageSamples);
}
- if (state->is_version(450, 310)) {
- add_const("gl_MaxCombinedShaderOutputResources",
- state->Const.MaxCombinedShaderOutputResources);
- }
-
if (state->is_version(400, 0) ||
state->ARB_tessellation_shader_enable) {
add_const("gl_MaxTessControlImageUniforms",
@@ -848,6 +843,12 @@ builtin_variable_generator::generate_constants()
}
}
+ if (state->is_version(450, 310) ||
+ state->ARB_ES3_1_compatibility_enable) {
+ add_const("gl_MaxCombinedShaderOutputResources",
+ state->Const.MaxCombinedShaderOutputResources);
+ }
+
if (state->is_version(410, 0) ||
state->ARB_viewport_array_enable)
add_const("gl_MaxViewports", state->Const.MaxViewports);
@@ -868,7 +869,8 @@ builtin_variable_generator::generate_constants()
add_const("gl_MaxTessEvaluationUniformComponents", state->Const.MaxTessEvaluationUniformComponents);
}
- if (state->is_version(450, 320))
+ if (state->is_version(450, 320) ||
+ state->ARB_ES3_1_compatibility_enable)
add_const("gl_MaxSamples", state->Const.MaxSamples);
}
@@ -1156,7 +1158,7 @@ builtin_variable_generator::generate_fs_special_vars()
var->data.interpolation = INTERP_QUALIFIER_FLAT;
}
- if (state->is_version(450, 310)/* || state->ARB_ES3_1_compatibility_enable*/)
+ if (state->is_version(450, 310) || state->ARB_ES3_1_compatibility_enable)
add_system_value(SYSTEM_VALUE_HELPER_INVOCATION, bool_t, "gl_HelperInvocation");
}
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index 70951a0..e047515 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -2409,6 +2409,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (extensions->EXT_texture_array)
add_builtin_define(parser, "GL_EXT_texture_array", 1);
+ if (extensions->ARB_ES3_1_compatibility)
+ add_builtin_define(parser, "GL_ARB_ES3_1_compatibility", 1);
+
if (extensions->ARB_arrays_of_arrays)
add_builtin_define(parser, "GL_ARB_arrays_of_arrays", 1);
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index c05668f..a5915fa 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -222,7 +222,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->supported_versions[this->num_supported_versions].es = true;
this->num_supported_versions++;
}
- if (_mesa_is_gles31(ctx)) {
+ if (_mesa_is_gles31(ctx) || ctx->Extensions.ARB_ES3_1_compatibility) {
this->supported_versions[this->num_supported_versions].ver = 310;
this->supported_versions[this->num_supported_versions].es = true;
this->num_supported_versions++;
@@ -561,6 +561,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
/* ARB extensions go here, sorted alphabetically.
*/
+ EXT(ARB_ES3_1_compatibility, true, false, ARB_ES3_1_compatibility),
EXT(ARB_arrays_of_arrays, true, false, ARB_arrays_of_arrays),
EXT(ARB_compute_shader, true, false, ARB_compute_shader),
EXT(ARB_conservative_depth, true, false, ARB_conservative_depth),
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index faf5134..adab5bb 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -506,6 +506,8 @@ struct _mesa_glsl_parse_state {
/*@{*/
/* ARB extensions go here, sorted alphabetically.
*/
+ bool ARB_ES3_1_compatibility_enable;
+ bool ARB_ES3_1_compatibility_warn;
bool ARB_arrays_of_arrays_enable;
bool ARB_arrays_of_arrays_warn;
bool ARB_compute_shader_enable;
--
2.4.10
More information about the mesa-dev
mailing list