summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2018-08-07 21:31:09 -0400
committerMarek Olšák <marek.olsak@amd.com>2019-04-24 20:45:15 -0400
commit8dbe23c8c69c1ad0f8914970b110bbd30ff76b0d (patch)
treec21fbe3c32612bed8152385d858d2f3584c171f5
parent7004114102332acbf899c1bd291240d357d29e7c (diff)
glsl: add arithmetic builtin functions for EXT_gpu_shader4
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--src/compiler/glsl/builtin_functions.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 2849be8992e..cea307bff48 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -281,6 +281,18 @@ shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state)
}
static bool
+gpu_shader4(const _mesa_glsl_parse_state *state)
+{
+ return state->EXT_gpu_shader4_enable;
+}
+
+static bool
+v130_or_gpu_shader4(const _mesa_glsl_parse_state *state)
+{
+ return state->is_version(130, 300) || state->EXT_gpu_shader4_enable;
+}
+
+static bool
gpu_shader5(const _mesa_glsl_parse_state *state)
{
return state->is_version(400, 0) || state->ARB_gpu_shader5_enable;
@@ -874,6 +886,7 @@ private:
BA1(abs)
BA1(sign)
BA1(floor)
+ BA1(truncate)
BA1(trunc)
BA1(round)
BA1(roundEven)
@@ -1488,9 +1501,9 @@ builtin_builder::create_builtins()
_##NAME(always_available, glsl_type::ivec3_type), \
_##NAME(always_available, glsl_type::ivec4_type), \
\
- _##NAME(v130, glsl_type::uvec2_type), \
- _##NAME(v130, glsl_type::uvec3_type), \
- _##NAME(v130, glsl_type::uvec4_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
_##NAME(fp64, glsl_type::dvec2_type), \
_##NAME(fp64, glsl_type::dvec3_type), \
_##NAME(fp64, glsl_type::dvec4_type), \
@@ -1527,9 +1540,9 @@ builtin_builder::create_builtins()
_##NAME(always_available, glsl_type::ivec3_type), \
_##NAME(always_available, glsl_type::ivec4_type), \
\
- _##NAME(v130, glsl_type::uvec2_type), \
- _##NAME(v130, glsl_type::uvec3_type), \
- _##NAME(v130, glsl_type::uvec4_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
\
_##NAME(always_available, glsl_type::bvec2_type), \
_##NAME(always_available, glsl_type::bvec3_type), \
@@ -1568,14 +1581,14 @@ builtin_builder::create_builtins()
_##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
_##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
\
- _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
- _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
- _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
- _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uint_type, glsl_type::uint_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type), \
\
- _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
- _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
- _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \
+ _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \
\
_##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
_##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
@@ -1642,6 +1655,14 @@ builtin_builder::create_builtins()
FD(ceil)
FD(fract)
+ add_function("truncate",
+ _truncate(gpu_shader4, glsl_type::float_type),
+ _truncate(gpu_shader4, glsl_type::vec2_type),
+ _truncate(gpu_shader4, glsl_type::vec3_type),
+ _truncate(gpu_shader4, glsl_type::vec4_type),
+ NULL);
+
+
add_function("mod",
_mod(always_available, glsl_type::float_type, glsl_type::float_type),
_mod(always_available, glsl_type::vec2_type, glsl_type::float_type),
@@ -4203,6 +4224,7 @@ UNOPA(inversesqrt, ir_unop_rsq)
UNOPA(abs, ir_unop_abs)
UNOPA(sign, ir_unop_sign)
UNOPA(floor, ir_unop_floor)
+UNOPA(truncate, ir_unop_trunc)
UNOPA(trunc, ir_unop_trunc)
UNOPA(round, ir_unop_round_even)
UNOPA(roundEven, ir_unop_round_even)