[Mesa-dev] [RFC-PATCH 11/11] st/mesa: add support for GL_OES_EGL_image_external

Chia-I Wu olvaffe at gmail.com
Sun Oct 30 12:07:37 PDT 2011


From: Chia-I Wu <olv at lunarg.com>

To pipe drivers, external textures are just 2D textures.
---
 src/mesa/state_tracker/st_cb_texture.c     |    2 ++
 src/mesa/state_tracker/st_extensions.c     |    2 ++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    3 +++
 src/mesa/state_tracker/st_mesa_to_tgsi.c   |    1 +
 src/mesa/state_tracker/st_texture.c        |    1 +
 5 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index f82346b..73167d0 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -75,6 +75,7 @@ gl_target_to_pipe(GLenum target)
    case GL_TEXTURE_1D:
       return PIPE_TEXTURE_1D;
    case GL_TEXTURE_2D:
+   case GL_TEXTURE_EXTERNAL_OES:
       return PIPE_TEXTURE_2D;
    case GL_TEXTURE_RECTANGLE_NV:
       return PIPE_TEXTURE_RECT;
@@ -310,6 +311,7 @@ get_texture_dims(GLenum target)
    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
    case GL_TEXTURE_RECTANGLE_NV:
    case GL_TEXTURE_2D_ARRAY_EXT:
+   case GL_TEXTURE_EXTERNAL_OES:
       return 2;
    case GL_TEXTURE_3D:
       return 3;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 6b9ff6b..505163f 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -301,6 +301,8 @@ void st_init_extensions(struct st_context *st)
 
 #if FEATURE_OES_EGL_image
    ctx->Extensions.OES_EGL_image = GL_TRUE;
+   if (ctx->API != API_OPENGL)
+      ctx->Extensions.OES_EGL_image_external = GL_TRUE;
 #endif
 #if FEATURE_OES_draw_texture
    ctx->Extensions.OES_draw_texture = GL_TRUE;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 67a1b51..6b841f1 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2725,6 +2725,9 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
    case GLSL_SAMPLER_DIM_BUF:
       assert(!"FINISHME: Implement ARB_texture_buffer_object");
       break;
+   case GLSL_SAMPLER_DIM_EXTERNAL:
+      inst->tex_target = TEXTURE_EXTERNAL_INDEX;
+      break;
    default:
       assert(!"Should not get here.");
    }
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index b4111b0..27ebb1a 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -290,6 +290,7 @@ translate_texture_target( GLuint textarget,
    case TEXTURE_RECT_INDEX: return TGSI_TEXTURE_RECT;
    case TEXTURE_1D_ARRAY_INDEX:   return TGSI_TEXTURE_1D_ARRAY;
    case TEXTURE_2D_ARRAY_INDEX:   return TGSI_TEXTURE_2D_ARRAY;
+   case TEXTURE_EXTERNAL_INDEX:   return TGSI_TEXTURE_2D;
    default:
       debug_assert( 0 );
       return TGSI_TEXTURE_1D;
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index ca8106b..3323bbb 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -133,6 +133,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
       break;
    case GL_TEXTURE_2D:
    case GL_TEXTURE_RECTANGLE:
+   case GL_TEXTURE_EXTERNAL_OES:
       assert(depthIn == 1);
       *widthOut = widthIn;
       *heightOut = heightIn;
-- 
1.7.6.3



More information about the mesa-dev mailing list