From 8dbe23c8c69c1ad0f8914970b110bbd30ff76b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 7 Aug 2018 21:31:09 -0400 Subject: [PATCH] glsl: add arithmetic builtin functions for EXT_gpu_shader4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Timothy Arceri Reviewed-by: Ian Romanick Tested-by: Dieter Nützel Reviewed-by: Eric Anholt --- src/compiler/glsl/builtin_functions.cpp | 48 ++++++++++++++++++------- 1 file 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 @@ -280,6 +280,18 @@ shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state) state->is_version(400, 300); } +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) { @@ -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)