glsl: Correct several built-in functions availability

Submitted by Vadym Shovkoplias on Oct. 31, 2018, 4:05 p.m.

Details

Message ID 20181031160523.583-1-vadym.shovkoplias@globallogic.com
State New
Headers show
Series "glsl: Correct several built-in functions availability" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Vadym Shovkoplias Oct. 31, 2018, 4:05 p.m.
In GLSL versions 1.00 ES, 1.10 and 1.20, Mesa includes
some built-in functions which shouldn't be present in
that version, namely:

   genIType abs(genIType x)
   genIType sign(genIType x)
   genIType min(genIType x, genIType y)
   genIType min(genIType x, int y)
   genIType max(genIType x, genIType y)
   genIType max(genIType x, int y)
   genIType clamp(genIType x, genIType minVal, genIType maxVal)
   genIType clamp(genIType x, int minVal, int maxVal)
   genType trunc(genType x)
   genType round(genType x)
   genType roundEven(genType x)
   genType modf(genType x, out genType i)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108160
Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
---
 src/compiler/glsl/builtin_functions.cpp | 57 ++++++++++++++++++-------
 1 file changed, 41 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 5650365d1d..2b549312b5 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -144,6 +144,12 @@  v130(const _mesa_glsl_parse_state *state)
    return state->is_version(130, 300);
 }
 
+static bool
+v150(const _mesa_glsl_parse_state *state)
+{
+   return state->is_version(150, 300);
+}
+
 static bool
 v130_desktop(const _mesa_glsl_parse_state *state)
 {
@@ -1439,10 +1445,10 @@  builtin_builder::create_builtins()
                 _##NAME(always_available, glsl_type::vec2_type),  \
                 _##NAME(always_available, glsl_type::vec3_type),  \
                 _##NAME(always_available, glsl_type::vec4_type),  \
-                _##NAME(always_available, glsl_type::int_type),   \
-                _##NAME(always_available, glsl_type::ivec2_type), \
-                _##NAME(always_available, glsl_type::ivec3_type), \
-                _##NAME(always_available, glsl_type::ivec4_type), \
+                _##NAME(v130, glsl_type::int_type),   \
+                _##NAME(v130, glsl_type::ivec2_type), \
+                _##NAME(v130, glsl_type::ivec3_type), \
+                _##NAME(v130, glsl_type::ivec4_type), \
                 _##NAME(fp64, glsl_type::double_type), \
                 _##NAME(fp64, glsl_type::dvec2_type),  \
                 _##NAME(fp64, glsl_type::dvec3_type),  \
@@ -1534,14 +1540,14 @@  builtin_builder::create_builtins()
                 _##NAME(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),  \
                 _##NAME(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),  \
                                                                                          \
-                _##NAME(always_available, glsl_type::int_type,   glsl_type::int_type),   \
-                _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type),   \
-                _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type),   \
-                _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type),   \
+                _##NAME(v130, glsl_type::int_type,   glsl_type::int_type),   \
+                _##NAME(v130, glsl_type::ivec2_type, glsl_type::int_type),   \
+                _##NAME(v130, glsl_type::ivec3_type, glsl_type::int_type),   \
+                _##NAME(v130, glsl_type::ivec4_type, glsl_type::int_type),   \
                                                                                          \
-                _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
-                _##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::ivec2_type, glsl_type::ivec2_type), \
+                _##NAME(v130, glsl_type::ivec3_type, glsl_type::ivec3_type), \
+                _##NAME(v130, 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),              \
@@ -1609,11 +1615,30 @@  builtin_builder::create_builtins()
    FD(sqrt)
    FD(inversesqrt)
    FI64(abs)
-   FI64(sign)
+
+   add_function("sign",                          \
+                _sign(always_available, glsl_type::float_type), \
+                _sign(always_available, glsl_type::vec2_type),  \
+                _sign(always_available, glsl_type::vec3_type),  \
+                _sign(always_available, glsl_type::vec4_type),  \
+                _sign(v150, glsl_type::int_type),   \
+                _sign(v150, glsl_type::ivec2_type), \
+                _sign(v150, glsl_type::ivec3_type), \
+                _sign(v150, glsl_type::ivec4_type), \
+                _sign(fp64, glsl_type::double_type), \
+                _sign(fp64, glsl_type::dvec2_type),  \
+                _sign(fp64, glsl_type::dvec3_type),  \
+                _sign(fp64, glsl_type::dvec4_type),  \
+                _sign(int64, glsl_type::int64_t_type), \
+                _sign(int64, glsl_type::i64vec2_type),  \
+                _sign(int64, glsl_type::i64vec3_type),  \
+                _sign(int64, glsl_type::i64vec4_type),  \
+                0);
+
    FD(floor)
-   FD(trunc)
-   FD(round)
-   FD(roundEven)
+   FD130(trunc)
+   FD130(round)
+   FD130(roundEven)
    FD(ceil)
    FD(fract)
 
@@ -1637,7 +1662,7 @@  builtin_builder::create_builtins()
                 _mod(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
                 NULL);
 
-   FD(modf)
+   FD130(modf)
 
    FIUD2_MIXED(min)
    FIUD2_MIXED(max)

Comments

Sorry, wrong mailing list. It was intended for Mesa
Please ignore this.


ср, 31 окт. 2018 г. в 18:05, Vadym Shovkoplias <vadim.shovkoplias@gmail.com
>:

> In GLSL versions 1.00 ES, 1.10 and 1.20, Mesa includes
> some built-in functions which shouldn't be present in
> that version, namely:
>
>    genIType abs(genIType x)
>    genIType sign(genIType x)
>    genIType min(genIType x, genIType y)
>    genIType min(genIType x, int y)
>    genIType max(genIType x, genIType y)
>    genIType max(genIType x, int y)
>    genIType clamp(genIType x, genIType minVal, genIType maxVal)
>    genIType clamp(genIType x, int minVal, int maxVal)
>    genType trunc(genType x)
>    genType round(genType x)
>    genType roundEven(genType x)
>    genType modf(genType x, out genType i)
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108160
> Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
> ---
>  src/compiler/glsl/builtin_functions.cpp | 57 ++++++++++++++++++-------
>  1 file changed, 41 insertions(+), 16 deletions(-)
>
> diff --git a/src/compiler/glsl/builtin_functions.cpp
> b/src/compiler/glsl/builtin_functions.cpp
> index 5650365d1d..2b549312b5 100644
> --- a/src/compiler/glsl/builtin_functions.cpp
> +++ b/src/compiler/glsl/builtin_functions.cpp
> @@ -144,6 +144,12 @@ v130(const _mesa_glsl_parse_state *state)
>     return state->is_version(130, 300);
>  }
>
> +static bool
> +v150(const _mesa_glsl_parse_state *state)
> +{
> +   return state->is_version(150, 300);
> +}
> +
>  static bool
>  v130_desktop(const _mesa_glsl_parse_state *state)
>  {
> @@ -1439,10 +1445,10 @@ builtin_builder::create_builtins()
>                  _##NAME(always_available, glsl_type::vec2_type),  \
>                  _##NAME(always_available, glsl_type::vec3_type),  \
>                  _##NAME(always_available, glsl_type::vec4_type),  \
> -                _##NAME(always_available, glsl_type::int_type),   \
> -                _##NAME(always_available, glsl_type::ivec2_type), \
> -                _##NAME(always_available, glsl_type::ivec3_type), \
> -                _##NAME(always_available, glsl_type::ivec4_type), \
> +                _##NAME(v130, glsl_type::int_type),   \
> +                _##NAME(v130, glsl_type::ivec2_type), \
> +                _##NAME(v130, glsl_type::ivec3_type), \
> +                _##NAME(v130, glsl_type::ivec4_type), \
>                  _##NAME(fp64, glsl_type::double_type), \
>                  _##NAME(fp64, glsl_type::dvec2_type),  \
>                  _##NAME(fp64, glsl_type::dvec3_type),  \
> @@ -1534,14 +1540,14 @@ builtin_builder::create_builtins()
>                  _##NAME(always_available, glsl_type::vec3_type,
> glsl_type::vec3_type),  \
>                  _##NAME(always_available, glsl_type::vec4_type,
> glsl_type::vec4_type),  \
>
>                 \
> -                _##NAME(always_available, glsl_type::int_type,
>  glsl_type::int_type),   \
> -                _##NAME(always_available, glsl_type::ivec2_type,
> glsl_type::int_type),   \
> -                _##NAME(always_available, glsl_type::ivec3_type,
> glsl_type::int_type),   \
> -                _##NAME(always_available, glsl_type::ivec4_type,
> glsl_type::int_type),   \
> +                _##NAME(v130, glsl_type::int_type,
>  glsl_type::int_type),   \
> +                _##NAME(v130, glsl_type::ivec2_type,
> glsl_type::int_type),   \
> +                _##NAME(v130, glsl_type::ivec3_type,
> glsl_type::int_type),   \
> +                _##NAME(v130, glsl_type::ivec4_type,
> glsl_type::int_type),   \
>
>                 \
> -                _##NAME(always_available, glsl_type::ivec2_type,
> glsl_type::ivec2_type), \
> -                _##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::ivec2_type,
> glsl_type::ivec2_type), \
> +                _##NAME(v130, glsl_type::ivec3_type,
> glsl_type::ivec3_type), \
> +                _##NAME(v130, 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),              \
> @@ -1609,11 +1615,30 @@ builtin_builder::create_builtins()
>     FD(sqrt)
>     FD(inversesqrt)
>     FI64(abs)
> -   FI64(sign)
> +
> +   add_function("sign",                          \
> +                _sign(always_available, glsl_type::float_type), \
> +                _sign(always_available, glsl_type::vec2_type),  \
> +                _sign(always_available, glsl_type::vec3_type),  \
> +                _sign(always_available, glsl_type::vec4_type),  \
> +                _sign(v150, glsl_type::int_type),   \
> +                _sign(v150, glsl_type::ivec2_type), \
> +                _sign(v150, glsl_type::ivec3_type), \
> +                _sign(v150, glsl_type::ivec4_type), \
> +                _sign(fp64, glsl_type::double_type), \
> +                _sign(fp64, glsl_type::dvec2_type),  \
> +                _sign(fp64, glsl_type::dvec3_type),  \
> +                _sign(fp64, glsl_type::dvec4_type),  \
> +                _sign(int64, glsl_type::int64_t_type), \
> +                _sign(int64, glsl_type::i64vec2_type),  \
> +                _sign(int64, glsl_type::i64vec3_type),  \
> +                _sign(int64, glsl_type::i64vec4_type),  \
> +                0);
> +
>     FD(floor)
> -   FD(trunc)
> -   FD(round)
> -   FD(roundEven)
> +   FD130(trunc)
> +   FD130(round)
> +   FD130(roundEven)
>     FD(ceil)
>     FD(fract)
>
> @@ -1637,7 +1662,7 @@ builtin_builder::create_builtins()
>                  _mod(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
>                  NULL);
>
> -   FD(modf)
> +   FD130(modf)
>
>     FIUD2_MIXED(min)
>     FIUD2_MIXED(max)
> --
> 2.19.1
>
>