Re: [Mesa-dev] [PATCH 1/2] glsl: add a mechanism to allow #extension directives in the middle of shaders

2014-07-14 Thread Kenneth Graunke
On Tuesday, July 08, 2014 08:29:44 PM Marek Olšák wrote:
 From: Marek Olšák marek.ol...@amd.com
 
 This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work
 with sample shading.
 
 Also, if this is disabled, the error message at least makes sense now.
 ---
  src/glsl/glsl_parser.yy | 8 
  src/glsl/glsl_parser_extras.cpp | 2 ++
  src/glsl/glsl_parser_extras.h   | 2 ++
  src/mesa/main/mtypes.h  | 5 +
  4 files changed, 17 insertions(+)
 
 diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
 index b989749..4c87163 100644
 --- a/src/glsl/glsl_parser.yy
 +++ b/src/glsl/glsl_parser.yy
 @@ -376,6 +376,14 @@ external_declaration_list:
if ($2 != NULL)
   state-translation_unit.push_tail( $2-link);
 }
 +   | external_declaration_list extension_statement {
 +  if (!state-allow_extension_directive_midshader) {
 + _mesa_glsl_error( @2, state,
 +  #extension directive is not allowed 
 +  in the middle of a shader);
 + YYERROR;
 +  }
 +   }
 ;
  
  variable_identifier:
 diff --git a/src/glsl/glsl_parser_extras.cpp 
b/src/glsl/glsl_parser_extras.cpp
 index b327c2b..890123a 100644
 --- a/src/glsl/glsl_parser_extras.cpp
 +++ b/src/glsl/glsl_parser_extras.cpp
 @@ -210,6 +210,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
 this-early_fragment_tests = false;
 memset(this-atomic_counter_offsets, 0,
sizeof(this-atomic_counter_offsets));
 +   this-allow_extension_directive_midshader =
 +  ctx-Const.AllowGLSLExtensionDirectiveMidShader;
  }
  
  /**
 diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
 index 1791816..f720d6a 100644
 --- a/src/glsl/glsl_parser_extras.h
 +++ b/src/glsl/glsl_parser_extras.h
 @@ -490,6 +490,8 @@ struct _mesa_glsl_parse_state {
  
 /** Atomic counter offsets by binding */
 unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
 +
 +   bool allow_extension_directive_midshader;
  };
  
  # define YYLLOC_DEFAULT(Current, Rhs, N) \
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index a7126fd..b42a175 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3349,6 +3349,11 @@ struct gl_constants
 GLuint ForceGLSLVersion;
  
 /**
 +* Allow GLSL #extension directives in the middle of shaders.
 +*/
 +   GLboolean AllowGLSLExtensionDirectiveMidShader;
 +
 +   /**
  * Does the driver support real 32-bit integers?  (Otherwise, integers 
are
  * simulated via floats.)
  */
 

Looks great to me, Marek - thanks for doing this.

I'd written a similar patch, but introduced shift/reduce conflicts while doing 
it.  Looks like you avoided that - nice :)

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 1/2] glsl: add a mechanism to allow #extension directives in the middle of shaders

2014-07-14 Thread Ian Romanick
Looks good to me.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

On 07/08/2014 11:29 AM, Marek Olšák wrote:
 From: Marek Olšák marek.ol...@amd.com
 
 This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work
 with sample shading.
 
 Also, if this is disabled, the error message at least makes sense now.
 ---
  src/glsl/glsl_parser.yy | 8 
  src/glsl/glsl_parser_extras.cpp | 2 ++
  src/glsl/glsl_parser_extras.h   | 2 ++
  src/mesa/main/mtypes.h  | 5 +
  4 files changed, 17 insertions(+)
 
 diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
 index b989749..4c87163 100644
 --- a/src/glsl/glsl_parser.yy
 +++ b/src/glsl/glsl_parser.yy
 @@ -376,6 +376,14 @@ external_declaration_list:
if ($2 != NULL)
   state-translation_unit.push_tail( $2-link);
 }
 +   | external_declaration_list extension_statement {
 +  if (!state-allow_extension_directive_midshader) {
 + _mesa_glsl_error( @2, state,
 +  #extension directive is not allowed 
 +  in the middle of a shader);
 + YYERROR;
 +  }
 +   }
 ;
  
  variable_identifier:
 diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
 index b327c2b..890123a 100644
 --- a/src/glsl/glsl_parser_extras.cpp
 +++ b/src/glsl/glsl_parser_extras.cpp
 @@ -210,6 +210,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
 gl_context *_ctx,
 this-early_fragment_tests = false;
 memset(this-atomic_counter_offsets, 0,
sizeof(this-atomic_counter_offsets));
 +   this-allow_extension_directive_midshader =
 +  ctx-Const.AllowGLSLExtensionDirectiveMidShader;
  }
  
  /**
 diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
 index 1791816..f720d6a 100644
 --- a/src/glsl/glsl_parser_extras.h
 +++ b/src/glsl/glsl_parser_extras.h
 @@ -490,6 +490,8 @@ struct _mesa_glsl_parse_state {
  
 /** Atomic counter offsets by binding */
 unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
 +
 +   bool allow_extension_directive_midshader;
  };
  
  # define YYLLOC_DEFAULT(Current, Rhs, N) \
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index a7126fd..b42a175 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3349,6 +3349,11 @@ struct gl_constants
 GLuint ForceGLSLVersion;
  
 /**
 +* Allow GLSL #extension directives in the middle of shaders.
 +*/
 +   GLboolean AllowGLSLExtensionDirectiveMidShader;
 +
 +   /**
  * Does the driver support real 32-bit integers?  (Otherwise, integers are
  * simulated via floats.)
  */
 

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


Re: [Mesa-dev] [PATCH 1/2] glsl: add a mechanism to allow #extension directives in the middle of shaders

2014-07-11 Thread Marek Olšák
Hi,

Could somebody from Intel please have a look at this?

Thanks,

Marek

On Tue, Jul 8, 2014 at 8:29 PM, Marek Olšák mar...@gmail.com wrote:
 From: Marek Olšák marek.ol...@amd.com

 This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work
 with sample shading.

 Also, if this is disabled, the error message at least makes sense now.
 ---
  src/glsl/glsl_parser.yy | 8 
  src/glsl/glsl_parser_extras.cpp | 2 ++
  src/glsl/glsl_parser_extras.h   | 2 ++
  src/mesa/main/mtypes.h  | 5 +
  4 files changed, 17 insertions(+)

 diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
 index b989749..4c87163 100644
 --- a/src/glsl/glsl_parser.yy
 +++ b/src/glsl/glsl_parser.yy
 @@ -376,6 +376,14 @@ external_declaration_list:
if ($2 != NULL)
   state-translation_unit.push_tail( $2-link);
 }
 +   | external_declaration_list extension_statement {
 +  if (!state-allow_extension_directive_midshader) {
 + _mesa_glsl_error( @2, state,
 +  #extension directive is not allowed 
 +  in the middle of a shader);
 + YYERROR;
 +  }
 +   }
 ;

  variable_identifier:
 diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
 index b327c2b..890123a 100644
 --- a/src/glsl/glsl_parser_extras.cpp
 +++ b/src/glsl/glsl_parser_extras.cpp
 @@ -210,6 +210,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
 gl_context *_ctx,
 this-early_fragment_tests = false;
 memset(this-atomic_counter_offsets, 0,
sizeof(this-atomic_counter_offsets));
 +   this-allow_extension_directive_midshader =
 +  ctx-Const.AllowGLSLExtensionDirectiveMidShader;
  }

  /**
 diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
 index 1791816..f720d6a 100644
 --- a/src/glsl/glsl_parser_extras.h
 +++ b/src/glsl/glsl_parser_extras.h
 @@ -490,6 +490,8 @@ struct _mesa_glsl_parse_state {

 /** Atomic counter offsets by binding */
 unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
 +
 +   bool allow_extension_directive_midshader;
  };

  # define YYLLOC_DEFAULT(Current, Rhs, N)   \
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index a7126fd..b42a175 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3349,6 +3349,11 @@ struct gl_constants
 GLuint ForceGLSLVersion;

 /**
 +* Allow GLSL #extension directives in the middle of shaders.
 +*/
 +   GLboolean AllowGLSLExtensionDirectiveMidShader;
 +
 +   /**
  * Does the driver support real 32-bit integers?  (Otherwise, integers are
  * simulated via floats.)
  */
 --
 1.9.1

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


[Mesa-dev] [PATCH 1/2] glsl: add a mechanism to allow #extension directives in the middle of shaders

2014-07-08 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work
with sample shading.

Also, if this is disabled, the error message at least makes sense now.
---
 src/glsl/glsl_parser.yy | 8 
 src/glsl/glsl_parser_extras.cpp | 2 ++
 src/glsl/glsl_parser_extras.h   | 2 ++
 src/mesa/main/mtypes.h  | 5 +
 4 files changed, 17 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b989749..4c87163 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -376,6 +376,14 @@ external_declaration_list:
   if ($2 != NULL)
  state-translation_unit.push_tail( $2-link);
}
+   | external_declaration_list extension_statement {
+  if (!state-allow_extension_directive_midshader) {
+ _mesa_glsl_error( @2, state,
+  #extension directive is not allowed 
+  in the middle of a shader);
+ YYERROR;
+  }
+   }
;
 
 variable_identifier:
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index b327c2b..890123a 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -210,6 +210,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this-early_fragment_tests = false;
memset(this-atomic_counter_offsets, 0,
   sizeof(this-atomic_counter_offsets));
+   this-allow_extension_directive_midshader =
+  ctx-Const.AllowGLSLExtensionDirectiveMidShader;
 }
 
 /**
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 1791816..f720d6a 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -490,6 +490,8 @@ struct _mesa_glsl_parse_state {
 
/** Atomic counter offsets by binding */
unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
+
+   bool allow_extension_directive_midshader;
 };
 
 # define YYLLOC_DEFAULT(Current, Rhs, N)   \
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a7126fd..b42a175 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3349,6 +3349,11 @@ struct gl_constants
GLuint ForceGLSLVersion;
 
/**
+* Allow GLSL #extension directives in the middle of shaders.
+*/
+   GLboolean AllowGLSLExtensionDirectiveMidShader;
+
+   /**
 * Does the driver support real 32-bit integers?  (Otherwise, integers are
 * simulated via floats.)
 */
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 1/2] glsl: add a mechanism to allow #extension directives in the middle of shaders

2014-07-08 Thread Brian Paul

On 07/08/2014 12:29 PM, Marek Olšák wrote:

From: Marek Olšák marek.ol...@amd.com

This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work
with sample shading.

Also, if this is disabled, the error message at least makes sense now.
---
  src/glsl/glsl_parser.yy | 8 
  src/glsl/glsl_parser_extras.cpp | 2 ++
  src/glsl/glsl_parser_extras.h   | 2 ++
  src/mesa/main/mtypes.h  | 5 +
  4 files changed, 17 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b989749..4c87163 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -376,6 +376,14 @@ external_declaration_list:
if ($2 != NULL)
   state-translation_unit.push_tail( $2-link);
 }
+   | external_declaration_list extension_statement {
+  if (!state-allow_extension_directive_midshader) {
+ _mesa_glsl_error( @2, state,
+  #extension directive is not allowed 
+  in the middle of a shader);
+ YYERROR;
+  }
+   }
 ;

  variable_identifier:
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index b327c2b..890123a 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -210,6 +210,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
 this-early_fragment_tests = false;
 memset(this-atomic_counter_offsets, 0,
sizeof(this-atomic_counter_offsets));
+   this-allow_extension_directive_midshader =
+  ctx-Const.AllowGLSLExtensionDirectiveMidShader;
  }

  /**
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 1791816..f720d6a 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -490,6 +490,8 @@ struct _mesa_glsl_parse_state {

 /** Atomic counter offsets by binding */
 unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
+
+   bool allow_extension_directive_midshader;
  };

  # define YYLLOC_DEFAULT(Current, Rhs, N)  \
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a7126fd..b42a175 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3349,6 +3349,11 @@ struct gl_constants
 GLuint ForceGLSLVersion;

 /**
+* Allow GLSL #extension directives in the middle of shaders.
+*/
+   GLboolean AllowGLSLExtensionDirectiveMidShader;
+
+   /**
  * Does the driver support real 32-bit integers?  (Otherwise, integers are
  * simulated via floats.)
  */




For both, Reviewed-by: Brian Paul bri...@vmware.com

There was a thread about this a few months ago.  Photoshop is another 
app that has this issue.


-Brian

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