On 03/22/2015 12:07 AM, Ilia Mirkin wrote:
Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
---

Not sure what kind of testing is needed here... thought I'd just send
this out though, as the extension is simple enough. Wasn't sure
whether mesa already handles the requirements re marking the texture
as incomplete if the sampler has funny settings.

Looks good to me, one thing that might need additional work or maybe just comments for now is the interaction with image load store for compute shaders, judging from the format checks in shaderimage.c, external textures would not work at the moment for BindImageTexture, I'm not sure if this extension is expected to work without compute shaders but just using GL_ARB_image_load_store (?)


2 little things below

  src/glsl/builtin_functions.cpp  | 17 +++++++++++++++++
  src/glsl/builtin_types.cpp      |  3 ++-
  src/glsl/glsl_lexer.ll          |  2 +-
  src/glsl/glsl_parser_extras.cpp |  1 +
  src/glsl/glsl_parser_extras.h   |  2 ++
  src/mesa/main/extensions.c      |  1 +
  6 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 84bbdc2..24fd4d6 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -147,6 +147,14 @@ texture_external(const _mesa_glsl_parse_state *state)
     return state->OES_EGL_image_external_enable;
  }

+static bool
+texture_external_es3(const _mesa_glsl_parse_state *state)
+{
+   return state->OES_EGL_image_external_essl3_enable &&
+      state->es_shader &&
+      state->is_version(0, 300);

is_version fits in to previous line

+}
+
  /** True if texturing functions with explicit LOD are allowed. */
  static bool
  lod_exists_in_stage(const _mesa_glsl_parse_state *state)
@@ -1387,6 +1395,8 @@ builtin_builder::create_builtins()

                  _texture(ir_tex, v130, glsl_type::float_type, 
glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),

+                _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  
glsl_type::samplerExternalOES_type, glsl_type::vec2_type),
+
                  _texture(ir_txb, v130_fs_only, glsl_type::vec4_type,  
glsl_type::sampler1D_type,  glsl_type::float_type),
                  _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, 
glsl_type::isampler1D_type, glsl_type::float_type),
                  _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, 
glsl_type::usampler1D_type, glsl_type::float_type),
@@ -1546,6 +1556,9 @@ builtin_builder::create_builtins()

                  _texture(ir_tex, v130, glsl_type::float_type, 
glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),

+                _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  
glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),
+                _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  
glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),
+
                  _texture(ir_txb, v130, glsl_type::vec4_type,  
glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT),
                  _texture(ir_txb, v130, glsl_type::ivec4_type, 
glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
                  _texture(ir_txb, v130, glsl_type::uvec4_type, 
glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
@@ -1604,8 +1617,12 @@ builtin_builder::create_builtins()
                  _texelFetch(texture_multisample, glsl_type::vec4_type,  
glsl_type::sampler2DMSArray_type,  glsl_type::ivec3_type),
                  _texelFetch(texture_multisample, glsl_type::ivec4_type, 
glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),
                  _texelFetch(texture_multisample, glsl_type::uvec4_type, 
glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),
+
+                _texelFetch(texture_external_es3, glsl_type::vec4_type,  
glsl_type::samplerExternalOES_type, glsl_type::ivec2_type),
+
                  NULL);

+

remove extra line

     add_function("texelFetchOffset",
                  _texelFetch(v130, glsl_type::vec4_type,  
glsl_type::sampler1D_type,  glsl_type::int_type, glsl_type::int_type),
                  _texelFetch(v130, glsl_type::ivec4_type, 
glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),
diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp
index fef86df..c1a52b5 100644
--- a/src/glsl/builtin_types.cpp
+++ b/src/glsl/builtin_types.cpp
@@ -328,7 +328,8 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state 
*state)
        add_type(symbols, glsl_type::sampler2DArrayShadow_type);
     }

-   if (state->OES_EGL_image_external_enable) {
+   if (state->OES_EGL_image_external_enable ||
+       state->OES_EGL_image_external_essl3_enable) {
        add_type(symbols, glsl_type::samplerExternalOES_type);
     }

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 8dc3d10..30867cd 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -339,7 +339,7 @@ usamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, 
yyextra->ARB_texture_cube_map
  samplerCubeArrayShadow   KEYWORD_WITH_ALT(400, 0, 400, 0, 
yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW);

  samplerExternalOES            {
-                         if (yyextra->OES_EGL_image_external_enable)
+                         if (yyextra->OES_EGL_image_external_enable || 
yyextra->OES_EGL_image_external_essl3_enable)
                             return SAMPLEREXTERNALOES;
                          else
                             return IDENTIFIER;
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 59a1b8c..663f366 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -571,6 +571,7 @@ static const _mesa_glsl_extension 
_mesa_glsl_supported_extensions[] = {
     /* OES extensions go here, sorted alphabetically.
      */
     EXT(OES_EGL_image_external,         false, true,      
OES_EGL_image_external),
+   EXT(OES_EGL_image_external_essl3,   false, true,      
OES_EGL_image_external),
     EXT(OES_standard_derivatives,       false, true,      
OES_standard_derivatives),
     EXT(OES_texture_3D,                 false, true,      EXT_texture3D),

diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 9e7df4f..35bc588 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -467,6 +467,8 @@ struct _mesa_glsl_parse_state {
      */
     bool OES_EGL_image_external_enable;
     bool OES_EGL_image_external_warn;
+   bool OES_EGL_image_external_essl3_enable;
+   bool OES_EGL_image_external_essl3_warn;
     bool OES_standard_derivatives_enable;
     bool OES_standard_derivatives_warn;
     bool OES_texture_3D_enable;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0cee5a3..9a5792a 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -300,6 +300,7 @@ static const struct extension extension_table[] = {
     /*  FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL 
contexts. */
     { "GL_OES_EGL_image",                           o(OES_EGL_image),          
                 GL | ES1 | ES2, 2006 },
     { "GL_OES_EGL_image_external",                  o(OES_EGL_image_external), 
                      ES1 | ES2, 2010 },
+   { "GL_OES_EGL_image_external_essl3",            o(OES_EGL_image_external),  
                           ES3, 2010 },
     { "GL_OES_element_index_uint",                  o(dummy_true),             
                      ES1 | ES2, 2005 },
     { "GL_OES_fbo_render_mipmap",                   o(dummy_true),             
                      ES1 | ES2, 2005 },
     { "GL_OES_fixed_point",                         o(dummy_true),             
                      ES1,       2002 },

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

Reply via email to