mesa: add support for glTextureSubImage2DEXT()
authorTimothy Arceri <tarceri@itsqueeze.com>
Sun, 2 Sep 2018 23:53:31 +0000 (09:53 +1000)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 28 Jun 2019 19:41:19 +0000 (15:41 -0400)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/mapi/glapi/gen/EXT_direct_state_access.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/teximage.c
src/mesa/main/teximage.h

index 6a6a118a2bddf8d7be036081e015bad219c19b43..53c6aa7d5634588ce7e76bb13acd34f3b00461bc 100644 (file)
       <param name="matrixMode" type="GLenum" />
    </function>
 
+   <!-- OpenGL 1.1 -->
+
+   <function name="TextureSubImage2DEXT">
+      <param name="texture" type="GLuint" />
+      <param name="target" type="GLenum" />
+      <param name="level" type="GLint" />
+      <param name="xoffset" type="GLint" />
+      <param name="yoffset" type="GLint" />
+      <param name="width" type="GLsizei" />
+      <param name="height" type="GLsizei" />
+      <param name="format" type="GLenum" />
+      <param name="type" type="GLenum" />
+      <param name="pixels" type="const GLvoid *" />
+   </function>
+
    <!-- OpenGL 1.2.1 -->
 
   <function name="BindMultiTextureEXT">
index 3970452b0cbe33806b1fd1ce0e7dd3cec9193350..e7b1e12650887fadac9e9eaad923584ff1b1f738 100644 (file)
@@ -1478,6 +1478,7 @@ offsets = {
     "NamedBufferSubDataEXT": 1442,
     "NamedBufferStorageEXT": 1443,
     "MapNamedBufferRangeEXT": 1444,
+    "TextureSubImage2DEXT": 1445,
 }
 
 functions = [
index 8813e945bfcfb53b16a58e77c912ddf201c4ae1d..fa41aa66e38dc314afbdc4fcac80bc79b9f60c28 100644 (file)
@@ -1041,7 +1041,7 @@ const struct function common_desktop_functions_possible[] = {
    //{ "glTextureImage1DEXT", 11, -1 },
    //{ "glTextureImage2DEXT", 11, -1 },
    //{ "glTextureSubImage1DEXT", 11, -1 },
-   //{ "glTextureSubImage2DEXT", 11, -1 },
+   { "glTextureSubImage2DEXT", 11, -1 },
    //{ "glCopyTextureImage1DEXT", 11, -1 },
    //{ "glCopyTextureImage2DEXT", 11, -1 },
    //{ "glCopyTextureSubImage1DEXT", 11, -1 },
index 4b33403bfaaacc20ed3b6e42d35df03838595acd..8508fbb711ee01ac8e646b801c4e0b84c26e628c 100644 (file)
@@ -3276,6 +3276,68 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
 }
 
 
+static struct gl_texture_object *
+lookup_texture_ext_dsa(struct gl_context *ctx, GLenum target, GLuint texture,
+                       const char *caller)
+{
+   GLenum boundTarget;
+   switch (target) {
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+      boundTarget = GL_TEXTURE_CUBE_MAP;
+      break;
+   default:
+      boundTarget = target;
+      break;
+   }
+
+   int targetIndex = _mesa_tex_target_to_index(ctx, boundTarget);
+   if (targetIndex < 0) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target = %s)", caller,
+                  _mesa_enum_to_string(target));
+            return NULL;
+   }
+   assert(targetIndex < NUM_TEXTURE_TARGETS);
+
+   struct gl_texture_object *texObj;
+   if (texture == 0) {
+      /* Use a default texture object */
+      texObj = ctx->Shared->DefaultTex[targetIndex];
+      assert(texObj);
+   } else {
+      texObj = _mesa_lookup_texture(ctx, texture);
+      if (!texObj && ctx->API == API_OPENGL_CORE) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-gen name)", caller);
+         return NULL;
+      }
+
+      if (!texObj) {
+         texObj = ctx->Driver.NewTextureObject(ctx, texture, boundTarget);
+         if (!texObj) {
+            _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
+            return NULL;
+         }
+
+         /* insert into hash table */
+         _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
+      }
+
+      if (texObj->Target != boundTarget) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(%s != %s)",
+                     caller, _mesa_enum_to_string(texObj->Target),
+                     _mesa_enum_to_string(target));
+         return NULL;
+      }
+   }
+
+   return texObj;
+}
+
+
 /**
  * Helper that implements the glTexSubImage1/2/3D()
  * and glTextureSubImage1/2/3D() functions.
@@ -3399,11 +3461,11 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
  */
 static ALWAYS_INLINE void
 texturesubimage(struct gl_context *ctx, GLuint dims,
-                GLuint texture, GLint level,
+                GLuint texture, GLenum target, GLint level,
                 GLint xoffset, GLint yoffset, GLint zoffset,
                 GLsizei width, GLsizei height, GLsizei depth,
                 GLenum format, GLenum type, const GLvoid *pixels,
-                const char *callerName, bool no_error)
+                const char *callerName, bool no_error, bool ext_dsa)
 {
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
@@ -3419,7 +3481,11 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
 
    /* Get the texture object by Name. */
    if (!no_error) {
-      texObj = _mesa_lookup_texture_err(ctx, texture, callerName);
+      if (!ext_dsa) {
+         texObj = _mesa_lookup_texture_err(ctx, texture, callerName);
+      } else {
+         texObj = lookup_texture_ext_dsa(ctx, target, texture, callerName);
+      }
       if (!texObj)
          return;
    } else {
@@ -3510,29 +3576,29 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
 
 static void
 texturesubimage_error(struct gl_context *ctx, GLuint dims,
-                      GLuint texture, GLint level,
+                      GLuint texture, GLenum target, GLint level,
                       GLint xoffset, GLint yoffset, GLint zoffset,
                       GLsizei width, GLsizei height, GLsizei depth,
                       GLenum format, GLenum type, const GLvoid *pixels,
-                      const char *callerName)
+                      const char *callerName, bool ext_dsa)
 {
-   texturesubimage(ctx, dims, texture, level, xoffset, yoffset, zoffset,
-                   width, height, depth, format, type, pixels, callerName,
-                   false);
+   texturesubimage(ctx, dims, texture, target, level, xoffset, yoffset,
+                   zoffset, width, height, depth, format, type, pixels,
+                   callerName, false, ext_dsa);
 }
 
 
 static void
 texturesubimage_no_error(struct gl_context *ctx, GLuint dims,
-                         GLuint texture, GLint level,
+                         GLuint texture, GLenum target, GLint level,
                          GLint xoffset, GLint yoffset, GLint zoffset,
                          GLsizei width, GLsizei height, GLsizei depth,
                          GLenum format, GLenum type, const GLvoid *pixels,
-                         const char *callerName)
+                         const char *callerName, bool ext_dsa)
 {
-   texturesubimage(ctx, dims, texture, level, xoffset, yoffset, zoffset,
-                   width, height, depth, format, type, pixels, callerName,
-                   true);
+   texturesubimage(ctx, dims, texture, target, level, xoffset, yoffset,
+                   zoffset, width, height, depth, format, type, pixels,
+                   callerName, true, ext_dsa);
 }
 
 
@@ -3630,8 +3696,9 @@ _mesa_TextureSubImage1D_no_error(GLuint texture, GLint level, GLint xoffset,
                                  const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_no_error(ctx, 1, texture, level, xoffset, 0, 0, width, 1, 1,
-                            format, type, pixels, "glTextureSubImage1D");
+   texturesubimage_no_error(ctx, 1, texture, 0, level, xoffset, 0, 0, width,
+                            1, 1, format, type, pixels, "glTextureSubImage1D",
+                            false);
 }
 
 
@@ -3642,8 +3709,9 @@ _mesa_TextureSubImage1D(GLuint texture, GLint level,
                         const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_error(ctx, 1, texture, level, xoffset, 0, 0, width, 1, 1,
-                         format, type, pixels, "glTextureSubImage1D");
+   texturesubimage_error(ctx, 1, texture, 0, level, xoffset, 0, 0, width, 1,
+                         1, format, type, pixels, "glTextureSubImage1D",
+                         false);
 }
 
 
@@ -3654,9 +3722,22 @@ _mesa_TextureSubImage2D_no_error(GLuint texture, GLint level, GLint xoffset,
                                  const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_no_error(ctx, 2, texture, level, xoffset, yoffset, 0, width,
-                            height, 1, format, type, pixels,
-                            "glTextureSubImage2D");
+   texturesubimage_no_error(ctx, 2, texture, 0, level, xoffset, yoffset, 0,
+                            width, height, 1, format, type, pixels,
+                            "glTextureSubImage2D", false);
+}
+
+
+void GLAPIENTRY
+_mesa_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
+                           GLint xoffset, GLint yoffset, GLsizei width,
+                           GLsizei height, GLenum format, GLenum type,
+                           const GLvoid *pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   texturesubimage_error(ctx, 2, texture, target, level, xoffset, yoffset, 0,
+                         width, height, 1, format, type, pixels,
+                         "glTextureSubImage2DEXT", true);
 }
 
 
@@ -3668,9 +3749,9 @@ _mesa_TextureSubImage2D(GLuint texture, GLint level,
                         const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_error(ctx, 2, texture, level, xoffset, yoffset, 0, width,
-                         height, 1, format, type, pixels,
-                         "glTextureSubImage2D");
+   texturesubimage_error(ctx, 2, texture, 0, level, xoffset, yoffset, 0,
+                         width, height, 1, format, type, pixels,
+                         "glTextureSubImage2D", false);
 }
 
 
@@ -3681,9 +3762,9 @@ _mesa_TextureSubImage3D_no_error(GLuint texture, GLint level, GLint xoffset,
                                  GLenum type, const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_no_error(ctx, 3, texture, level, xoffset, yoffset, zoffset,
-                            width, height, depth, format, type, pixels,
-                            "glTextureSubImage3D");
+   texturesubimage_no_error(ctx, 3, texture, 0, level, xoffset, yoffset,
+                            zoffset, width, height, depth, format, type,
+                            pixels, "glTextureSubImage3D", false);
 }
 
 
@@ -3695,9 +3776,9 @@ _mesa_TextureSubImage3D(GLuint texture, GLint level,
                         const GLvoid *pixels)
 {
    GET_CURRENT_CONTEXT(ctx);
-   texturesubimage_error(ctx, 3, texture, level, xoffset, yoffset, zoffset,
+   texturesubimage_error(ctx, 3, texture, 0, level, xoffset, yoffset, zoffset,
                          width, height, depth, format, type, pixels,
-                         "glTextureSubImage3D");
+                         "glTextureSubImage3D", false);
 }
 
 
index 261daae39486935bf02e95cd129dae815a80163b..494b167e2d51f2291160e9d8fae27dd0bfe12ef1 100644 (file)
@@ -350,6 +350,12 @@ _mesa_TextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
                         GLenum format, GLenum type,
                         const GLvoid *pixels);
 
+void GLAPIENTRY
+_mesa_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
+                           GLint xoffset, GLint yoffset, GLsizei width,
+                           GLsizei height, GLenum format, GLenum type,
+                           const GLvoid *pixels);
+
 void GLAPIENTRY
 _mesa_TextureSubImage2D_no_error(GLuint texture, GLint level, GLint xoffset,
                                  GLint yoffset, GLsizei width, GLsizei height,