summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2013-08-28 18:01:39 -0700
committerMatt Turner <[email protected]>2013-09-09 15:01:08 -0700
commit56fff7063dd05232cf86aef9d2ae1c04c52a8360 (patch)
tree2be41e9db05029a329484e18cfb35cdcc2ded843 /src
parentfd183fa02c4430e439faf6a5195f5008d34db987 (diff)
glsl: Implement MESA_shader_integer_mix extension.
Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/builtin_functions.cpp39
-rw-r--r--src/glsl/glcpp/glcpp-parse.y3
-rw-r--r--src/glsl/glsl_parser_extras.cpp1
-rw-r--r--src/glsl/glsl_parser_extras.h2
-rw-r--r--src/mesa/main/extensions.c1
-rw-r--r--src/mesa/main/mtypes.h3
6 files changed, 41 insertions, 8 deletions
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 0139b6ff01f..eca41aacefb 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -188,6 +188,12 @@ shader_bit_encoding(const _mesa_glsl_parse_state *state)
}
static bool
+shader_integer_mix(const _mesa_glsl_parse_state *state)
+{
+ return v130(state) && state->MESA_shader_integer_mix_enable;
+}
+
+static bool
shader_packing(const _mesa_glsl_parse_state *state)
{
return state->ARB_shading_language_packing_enable ||
@@ -415,7 +421,9 @@ private:
BA2(max)
BA2(clamp)
B2(mix_lrp)
- B2(mix_sel)
+ ir_function_signature *_mix_sel(builtin_available_predicate avail,
+ const glsl_type *val_type,
+ const glsl_type *blend_type);
B2(step)
B2(smoothstep)
B1(isnan)
@@ -773,10 +781,25 @@ builtin_builder::create_builtins()
_mix_lrp(glsl_type::vec3_type, glsl_type::vec3_type),
_mix_lrp(glsl_type::vec4_type, glsl_type::vec4_type),
- _mix_sel(glsl_type::float_type, glsl_type::bool_type),
- _mix_sel(glsl_type::vec2_type, glsl_type::bvec2_type),
- _mix_sel(glsl_type::vec3_type, glsl_type::bvec3_type),
- _mix_sel(glsl_type::vec4_type, glsl_type::bvec4_type),
+ _mix_sel(v130, glsl_type::float_type, glsl_type::bool_type),
+ _mix_sel(v130, glsl_type::vec2_type, glsl_type::bvec2_type),
+ _mix_sel(v130, glsl_type::vec3_type, glsl_type::bvec3_type),
+ _mix_sel(v130, glsl_type::vec4_type, glsl_type::bvec4_type),
+
+ _mix_sel(shader_integer_mix, glsl_type::int_type, glsl_type::bool_type),
+ _mix_sel(shader_integer_mix, glsl_type::ivec2_type, glsl_type::bvec2_type),
+ _mix_sel(shader_integer_mix, glsl_type::ivec3_type, glsl_type::bvec3_type),
+ _mix_sel(shader_integer_mix, glsl_type::ivec4_type, glsl_type::bvec4_type),
+
+ _mix_sel(shader_integer_mix, glsl_type::uint_type, glsl_type::bool_type),
+ _mix_sel(shader_integer_mix, glsl_type::uvec2_type, glsl_type::bvec2_type),
+ _mix_sel(shader_integer_mix, glsl_type::uvec3_type, glsl_type::bvec3_type),
+ _mix_sel(shader_integer_mix, glsl_type::uvec4_type, glsl_type::bvec4_type),
+
+ _mix_sel(shader_integer_mix, glsl_type::bool_type, glsl_type::bool_type),
+ _mix_sel(shader_integer_mix, glsl_type::bvec2_type, glsl_type::bvec2_type),
+ _mix_sel(shader_integer_mix, glsl_type::bvec3_type, glsl_type::bvec3_type),
+ _mix_sel(shader_integer_mix, glsl_type::bvec4_type, glsl_type::bvec4_type),
NULL);
add_function("step",
@@ -2255,12 +2278,14 @@ builtin_builder::_mix_lrp(const glsl_type *val_type, const glsl_type *blend_type
}
ir_function_signature *
-builtin_builder::_mix_sel(const glsl_type *val_type, const glsl_type *blend_type)
+builtin_builder::_mix_sel(builtin_available_predicate avail,
+ const glsl_type *val_type,
+ const glsl_type *blend_type)
{
ir_variable *x = in_var(val_type, "x");
ir_variable *y = in_var(val_type, "y");
ir_variable *a = in_var(blend_type, "a");
- MAKE_SIG(val_type, v130, 3, x, y, a);
+ MAKE_SIG(val_type, avail, 3, x, y, a);
/* csel matches the ternary operator in that a selector of true choses the
* first argument. This differs from mix(x, y, false) which choses the
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index ff5bdfe5db5..fb1c1d0466d 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1245,6 +1245,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
if (extensions->ARB_shading_language_420pack)
add_builtin_define(parser, "GL_ARB_shading_language_420pack", 1);
+
+ if (extensions->MESA_shader_integer_mix)
+ add_builtin_define(parser, "GL_MESA_shader_integer_mix", 1);
}
}
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index cd3907ae2bb..1e4d7c7abf0 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -517,6 +517,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(ARB_texture_query_lod, true, false, ARB_texture_query_lod),
EXT(ARB_gpu_shader5, true, false, ARB_gpu_shader5),
EXT(AMD_vertex_shader_layer, true, false, AMD_vertex_shader_layer),
+ EXT(MESA_shader_integer_mix, true, true, MESA_shader_integer_mix),
};
#undef EXT
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index c4443ac485e..15abbbc9916 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -315,6 +315,8 @@ struct _mesa_glsl_parse_state {
bool AMD_vertex_shader_layer_warn;
bool ARB_shading_language_420pack_enable;
bool ARB_shading_language_420pack_warn;
+ bool MESA_shader_integer_mix_enable;
+ bool MESA_shader_integer_mix_warn;
/*@}*/
/** Extensions supported by the OpenGL implementation. */
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index f60157f8cce..88fcde3b90b 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -311,6 +311,7 @@ static const struct extension extension_table[] = {
{ "GL_IBM_texture_mirrored_repeat", o(dummy_true), GLL, 1998 },
{ "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 },
{ "GL_MESA_pack_invert", o(MESA_pack_invert), GL, 2002 },
+ { "GL_MESA_shader_integer_mix", o(MESA_shader_integer_mix), GL | ES3, 2013 },
{ "GL_MESA_texture_array", o(MESA_texture_array), GLL, 2007 },
{ "GL_MESA_texture_signed_rgba", o(EXT_texture_snorm), GL, 2009 },
{ "GL_MESA_window_pos", o(dummy_true), GLL, 2000 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ef16c5910a6..ca7111e509b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3154,8 +3154,9 @@ struct gl_extensions
GLboolean ATI_fragment_shader;
GLboolean ATI_separate_stencil;
GLboolean MESA_pack_invert;
- GLboolean MESA_ycbcr_texture;
+ GLboolean MESA_shader_integer_mix;
GLboolean MESA_texture_array;
+ GLboolean MESA_ycbcr_texture;
GLboolean NV_conditional_render;
GLboolean NV_fog_distance;
GLboolean NV_fragment_program_option;