[Mesa-dev] [PATCH 3/3] mesa: implement GL_OES_texture_view

Francesco Ansanelli francians at gmail.com
Sun Aug 28 14:24:46 UTC 2016


XXX still need to figure how to treat the removed VIEW_CLASS*
and formats.

Signed-off-by: Francesco Ansanelli <francians at gmail.com>
---
 src/mesa/main/textureview.c |   69 +++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 28 deletions(-)

diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index ed66c17..1a65923 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -387,8 +387,10 @@ target_valid(struct gl_context *ctx, GLenum origTarget, GLenum newTarget)
    switch (origTarget) {
    case GL_TEXTURE_1D:
    case GL_TEXTURE_1D_ARRAY:
-      RETURN_IF_SUPPORTED(TEXTURE_1D);
-      RETURN_IF_SUPPORTED(TEXTURE_1D_ARRAY);
+      if (!_mesa_is_gles3(ctx)) {
+         RETURN_IF_SUPPORTED(TEXTURE_1D);
+         RETURN_IF_SUPPORTED(TEXTURE_1D_ARRAY);
+      }
       break;
    case GL_TEXTURE_2D:
       RETURN_IF_SUPPORTED(TEXTURE_2D);
@@ -398,7 +400,8 @@ target_valid(struct gl_context *ctx, GLenum origTarget, GLenum newTarget)
       RETURN_IF_SUPPORTED(TEXTURE_3D);
       break;
    case GL_TEXTURE_RECTANGLE:
-      RETURN_IF_SUPPORTED(TEXTURE_RECTANGLE);
+      if (!_mesa_is_gles3(ctx))
+         RETURN_IF_SUPPORTED(TEXTURE_RECTANGLE);
       break;
    case GL_TEXTURE_CUBE_MAP:
    case GL_TEXTURE_2D_ARRAY:
@@ -415,7 +418,8 @@ target_valid(struct gl_context *ctx, GLenum origTarget, GLenum newTarget)
       break;
    }
    _mesa_error(ctx, GL_INVALID_OPERATION,
-               "glTextureView(illegal target=%s)",
+               "glTextureView%s(illegal target=%s)",
+               _mesa_is_gles3(ctx) ? "OES" : "",
                _mesa_enum_to_string(newTarget));
    return false;
 }
@@ -514,7 +518,7 @@ _mesa_set_texture_view_state(struct gl_context *ctx,
 }
 
 /**
- * glTextureView (ARB_texture_view)
+ * glTextureView (ARB_texture_view / OES_texture_view)
  * If an error is found, record it with _mesa_error()
  * \return none.
  */
@@ -537,14 +541,15 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE))
-      _mesa_debug(ctx, "glTextureView %d %s %d %s %d %d %d %d\n",
+      _mesa_debug(ctx, "glTextureView%s %d %s %d %s %d %d %d %d\n",
+                  _mesa_is_gles3(ctx) ? "OES" : "",
                   texture, _mesa_enum_to_string(target), origtexture,
                   _mesa_enum_to_string(internalformat),
                   minlevel, numlevels, minlayer, numlayers);
 
    if (origtexture == 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)",
-                  origtexture);
+      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView%s(origtexture = %u)",
+                  _mesa_is_gles3(ctx) ? "OES" : "", origtexture);
       return;
    }
 
@@ -555,8 +560,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
     * is generated.
     */
    if (!origTexObj) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)",
-                  origtexture);
+      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView%s(origtexture = %u)",
+                  _mesa_is_gles3(ctx) ? "OES" : "", origtexture);
       return;
    }
 
@@ -565,13 +570,15 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
     */
    if (!origTexObj->Immutable) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(origtexture not immutable)");
+                  "glTextureView%s(origtexture not immutable)",
+                  _mesa_is_gles3(ctx) ? "OES" : "");
       return;
    }
 
    /* If <texture> is 0, INVALID_VALUE is generated. */
    if (texture == 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(texture = 0)");
+      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView%s(texture = 0)",
+      _mesa_is_gles3(ctx) ? "OES" : "");
       return;
    }
 
@@ -581,7 +588,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    texObj = _mesa_lookup_texture(ctx, texture);
    if (texObj == NULL) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(texture = %u non-gen name)", texture);
+                  "glTextureView%s(texture = %u non-gen name)",
+                  _mesa_is_gles3(ctx) ? "OES" : "", texture);
       return;
    }
 
@@ -590,7 +598,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
     */
    if (texObj->Target) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(texture = %u already bound)", texture);
+                  "glTextureView%s(texture = %u already bound)",
+                  _mesa_is_gles3(ctx) ? "OES" : "", texture);
       return;
    }
 
@@ -607,16 +616,16 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    newViewMinLayer = origTexObj->MinLayer + minlayer;
    if (newViewMinLevel >= (origTexObj->MinLevel + origTexObj->NumLevels)) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glTextureView(new minlevel (%d) > orig minlevel (%d)"
-                  " + orig numlevels (%d))",
+                  "glTextureView%s(new minlevel (%d) > orig minlevel (%d)"
+                  " + orig numlevels (%d))", _mesa_is_gles3(ctx) ? "OES" : "",
                   newViewMinLevel, origTexObj->MinLevel, origTexObj->NumLevels);
       return;
    }
 
    if (newViewMinLayer >= (origTexObj->MinLayer + origTexObj->NumLayers)) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glTextureView(new minlayer (%d) > orig minlayer (%d)"
-                  " + orig numlayers (%d))",
+                  "glTextureView%s(new minlayer (%d) > orig minlayer (%d)"
+                  " + orig numlayers (%d))", _mesa_is_gles3(ctx) ? "OES" : "",
                   newViewMinLayer, origTexObj->MinLayer, origTexObj->NumLayers);
       return;
    }
@@ -625,8 +634,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
                                    origTexObj->Image[0][0]->InternalFormat,
                                    internalformat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-          "glTextureView(internalformat %s not compatible with origtexture %s)",
-          _mesa_enum_to_string(internalformat),
+          "glTextureView%s(internalformat %s not compatible with origtexture %s)",
+          _mesa_is_gles3(ctx) ? "OES" : "", _mesa_enum_to_string(internalformat),
           _mesa_enum_to_string(origTexObj->Image[0][0]->InternalFormat));
       return;
    }
@@ -671,8 +680,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
        */
       if (newViewNumLayers != 6) {
          _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glTextureView(clamped numlayers %d != 6)",
-                     newViewNumLayers);
+                     "glTextureView%s(clamped numlayers %d != 6)",
+                     _mesa_is_gles3(ctx) ? "OES" : "", newViewNumLayers);
          return;
       }
       depth = 1;
@@ -690,8 +699,9 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
        */
       if ((newViewNumLayers % 6) != 0) {
          _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glTextureView(clamped numlayers %d is not"
+                     "glTextureView%s(clamped numlayers %d is not"
                      " a multiple of 6)",
+                     _mesa_is_gles3(ctx) ? "OES" : "",
                      newViewNumLayers);
          return;
       }
@@ -710,7 +720,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
                                                  width, height, depth, 0);
    if (!dimensionsOK) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(invalid width or height or depth)");
+                  "glTextureView%s(invalid width or height or depth)",
+                  _mesa_is_gles3(ctx) ? "OES" : "");
       return;
    }
 
@@ -719,7 +730,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
                                           width, height, depth);
    if (!sizeOK) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(invalid texture size)");
+                  "glTextureView%s(invalid texture size)",
+                  _mesa_is_gles3(ctx) ? "OES" : "");
       return;
    }
 
@@ -734,8 +746,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    case GL_TEXTURE_RECTANGLE:
    case GL_TEXTURE_2D_MULTISAMPLE:
       if (numlayers != 1) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(numlayers %d != 1)",
-                     numlayers);
+         _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView%s(numlayers %d != 1)",
+                     _mesa_is_gles3(ctx) ? "OES" : "", numlayers);
          return;
       }
       break;
@@ -752,7 +764,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    if ((target == GL_TEXTURE_CUBE_MAP || target == GL_TEXTURE_CUBE_MAP_ARRAY) &&
        (origTexImage->Width != origTexImage->Height)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glTextureView(origtexture width (%d) != height (%d))",
+                  "glTextureView%s(origtexture width (%d) != height (%d))",
+                  _mesa_is_gles3(ctx) ? "OES" : "",
                   origTexImage->Width, origTexImage->Height);
       return;
    }
-- 
1.7.9.5



More information about the mesa-dev mailing list