Re: [Mesa-dev] [PATCH v2 08/10] glsl: A shader cannot redefine or overload built-in functions in GLSL ES 3.00

2015-02-19 Thread Kenneth Graunke
On Thursday, February 19, 2015 09:55:35 AM Samuel Iglesias Gonsalvez wrote:
 Create a new search function to look for matching built-in functions by name
 and use it for built-in function redefinition or overload in GLSL ES 3.00.
 
 GLSL ES 3.0 spec, chapter 6.1 Function Definitions, page 71
 
   A shader cannot redefine or overload built-in functions.
 
 While in GLSL ES 1.0 specification, chapter 8 Built-in Functions
 
   User code can overload the built-in functions but cannot redefine them.
 
 So this check is specific to GLSL ES 3.00.
 
 This patch fixes the following dEQP tests:
 
 dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_vertex
 dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_fragment
 dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_vertex
 dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_fragment
 
 No piglit regressions.
 
 Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
 ---
  src/glsl/ast_to_hir.cpp| 21 +
  src/glsl/builtin_functions.cpp | 11 +++
  src/glsl/ir.h  |  4 
  3 files changed, 36 insertions(+)

This looks great - thanks!

Reviewed-by: Kenneth Graunke kenn...@whitecape.org


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 08/10] glsl: A shader cannot redefine or overload built-in functions in GLSL ES 3.00

2015-02-19 Thread Samuel Iglesias Gonsálvez
On Thursday 19 February 2015 00:59:56 Kenneth Graunke wrote:
 On Thursday, February 19, 2015 09:55:35 AM Samuel Iglesias Gonsalvez wrote:
  Create a new search function to look for matching built-in functions by
  name and use it for built-in function redefinition or overload in GLSL ES
  3.00.
  
  GLSL ES 3.0 spec, chapter 6.1 Function Definitions, page 71
  
A shader cannot redefine or overload built-in functions.
  
  While in GLSL ES 1.0 specification, chapter 8 Built-in Functions
  
User code can overload the built-in functions but cannot redefine
them.
  
  So this check is specific to GLSL ES 3.00.
  
  This patch fixes the following dEQP tests:
  
  dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_
  vertex
  dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function
  _fragment
  dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function
  _vertex
  dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function
  _fragment
  
  No piglit regressions.
  
  Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
  ---
  
   src/glsl/ast_to_hir.cpp| 21 +
   src/glsl/builtin_functions.cpp | 11 +++
   src/glsl/ir.h  |  4 
   3 files changed, 36 insertions(+)
 
 This looks great - thanks!
 
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

Thanks!! pushed!

Sam

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 08/10] glsl: A shader cannot redefine or overload built-in functions in GLSL ES 3.00

2015-02-19 Thread Samuel Iglesias Gonsalvez
Create a new search function to look for matching built-in functions by name
and use it for built-in function redefinition or overload in GLSL ES 3.00.

GLSL ES 3.0 spec, chapter 6.1 Function Definitions, page 71

  A shader cannot redefine or overload built-in functions.

While in GLSL ES 1.0 specification, chapter 8 Built-in Functions

  User code can overload the built-in functions but cannot redefine them.

So this check is specific to GLSL ES 3.00.

This patch fixes the following dEQP tests:

dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_vertex
dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_fragment
dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_vertex
dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_fragment

No piglit regressions.

Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
---
 src/glsl/ast_to_hir.cpp| 21 +
 src/glsl/builtin_functions.cpp | 11 +++
 src/glsl/ir.h  |  4 
 3 files changed, 36 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 2c63de0..acb5c76 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4205,6 +4205,27 @@ ast_function::hir(exec_list *instructions,
   emit_function(state, f);
}
 
+   /* From GLSL ES 3.0 spec, chapter 6.1 Function Definitions, page 71:
+*
+* A shader cannot redefine or overload built-in functions.
+*
+* While in GLSL ES 1.0 specification, chapter 8 Built-in Functions:
+*
+* User code can overload the built-in functions but cannot redefine
+* them.
+*/
+   if (state-es_shader  state-language_version = 300) {
+  /* Local shader has no exact candidates; check the built-ins. */
+  _mesa_glsl_initialize_builtin_functions();
+  if (_mesa_glsl_find_builtin_function_by_name(state, name)) {
+ YYLTYPE loc = this-get_location();
+ _mesa_glsl_error( loc, state,
+  A shader cannot redefine or overload built-in 
+  function `%s' in GLSL ES 3.00, name);
+ return NULL;
+  }
+   }
+
/* Verify that this function's signature either doesn't match a previously
 * seen signature for a function with the same name, or, if a match is 
found,
 * that the previously seen signature does not have an associated 
definition.
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index fb31dad..b643927 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -4851,6 +4851,17 @@ _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state 
*state,
return s;
 }
 
+ir_function *
+_mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state,
+ const char *name)
+{
+   ir_function *f;
+   mtx_lock(builtins_lock);
+   f = builtins.shader-symbols-get_function(name);
+   mtx_unlock(builtins_lock);
+   return f;
+}
+
 gl_shader *
 _mesa_glsl_get_builtin_function_shader()
 {
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 8c3845f..ce35b2b 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -2439,6 +2439,10 @@ extern ir_function_signature *
 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
  const char *name, exec_list 
*actual_parameters);
 
+extern ir_function *
+_mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state,
+ const char *name);
+
 extern gl_shader *
 _mesa_glsl_get_builtin_function_shader(void);
 
-- 
2.1.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev