mesa: add EXT_dsa glMultiTexImage1D/2D/3DEXT + glGetMultiTexImageEXT
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 30 Apr 2019 11:45:15 +0000 (13:45 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 6 Aug 2019 21:03:15 +0000 (17:03 -0400)
Reviewed-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/dlist.c
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/texgetimage.c
src/mesa/main/texgetimage.h
src/mesa/main/teximage.c
src/mesa/main/teximage.h

index a22ad73ed74cdd1e1c494d5481111ad5b7c7535c..10142414fbcf17d89904f3006b2e60e1057af96b 100644 (file)
       <param name="param" type="const GLfloat*" />
    </function>
 
+   <function name="GetMultiTexImageEXT">
+      <param name="texunit" type="GLenum" />
+      <param name="target" type="GLenum" />
+      <param name="level" type="GLint" />
+      <param name="format" type="GLenum" />
+      <param name="type" type="GLenum" />
+      <param name="pixels" type="GLvoid*" />
+   </function>
+
+   <function name="MultiTexImage1DEXT">
+      <param name="texunit" type="GLenum" />
+      <param name="target" type="GLenum" />
+      <param name="level" type="GLint" />
+      <param name="internalformat" type="GLint" />
+      <param name="width" type="GLsizei" />
+      <param name="border" type="GLint" />
+      <param name="format" type="GLenum" />
+      <param name="type" type="GLenum" />
+      <param name="pixels" type="const GLvoid*" />
+   </function>
+
+   <function name="MultiTexImage2DEXT">
+      <param name="texunit" type="GLenum" />
+      <param name="target" type="GLenum" />
+      <param name="level" type="GLint" />
+      <param name="internalformat" type="GLint" />
+      <param name="width" type="GLsizei" />
+      <param name="height" type="GLsizei" />
+      <param name="border" type="GLint" />
+      <param name="format" type="GLenum" />
+      <param name="type" type="GLenum" />
+      <param name="pixels" type="const GLvoid*" />
+   </function>
+
+   <function name="MultiTexImage3DEXT">
+      <param name="texunit" type="GLenum" />
+      <param name="target" type="GLenum" />
+      <param name="level" type="GLint" />
+      <param name="internalformat" type="GLint" />
+      <param name="width" type="GLsizei" />
+      <param name="height" type="GLsizei" />
+      <param name="depth" type="GLsizei" />
+      <param name="border" type="GLint" />
+      <param name="format" type="GLenum" />
+      <param name="type" type="GLenum" />
+      <param name="pixels" type="const GLvoid*" />
+   </function>
+
    <!-- OpenGL 1.3 -->
 
    <function name="MatrixLoadTransposefEXT" offset="assign">
index 73688de9c3e9e674da27f7cbdec75b14123b43f4..2d243c479bff340cdbdaa3e5ca47d68b46ff2bb2 100644 (file)
@@ -1527,6 +1527,10 @@ offsets = {
     "MultiTexParameterivEXT": 1491,
     "MultiTexParameterfEXT": 1492,
     "MultiTexParameterfvEXT": 1493,
+    "GetMultiTexImageEXT": 1494,
+    "MultiTexImage1DEXT": 1495,
+    "MultiTexImage2DEXT": 1496,
+    "MultiTexImage3DEXT": 1497,
 }
 
 functions = [
index 5c37668e2074f33a9d3dbf04b2ece786cae45d2d..ab83546bf74fd1deb85932bd8557adf93a9d1c73 100644 (file)
@@ -584,6 +584,9 @@ typedef enum
    OPCODE_BIND_MULTITEXTURE,
    OPCODE_MULTITEXPARAMETER_F,
    OPCODE_MULTITEXPARAMETER_I,
+   OPCODE_MULTITEX_IMAGE1D,
+   OPCODE_MULTITEX_IMAGE2D,
+   OPCODE_MULTITEX_IMAGE3D,
    OPCODE_MULTITEXENV,
    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
 
@@ -1221,12 +1224,15 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
             free(get_pointer(&n[3]));
             break;
          case OPCODE_TEXTURE_IMAGE1D:
+         case OPCODE_MULTITEX_IMAGE1D:
             free(get_pointer(&n[9]));
             break;
          case OPCODE_TEXTURE_IMAGE2D:
+         case OPCODE_MULTITEX_IMAGE2D:
             free(get_pointer(&n[10]));
             break;
          case OPCODE_TEXTURE_IMAGE3D:
+         case OPCODE_MULTITEX_IMAGE3D:
             free(get_pointer(&n[11]));
             break;
          case OPCODE_TEXTURE_SUB_IMAGE1D:
@@ -9578,7 +9584,7 @@ save_TextureImage1DEXT(GLuint texture, GLenum target,
       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE1D, 8 + POINTER_DWORDS);
       if (n) {
-         n[1].e = texture;
+         n[1].ui = texture;
          n[2].e = target;
          n[3].i = level;
          n[4].i = components;
@@ -9992,6 +9998,124 @@ save_MultiTexParameteriEXT(GLenum texunit, GLenum target, GLenum pname, GLint pa
 }
 
 
+static void GLAPIENTRY
+save_MultiTexImage1DEXT(GLenum texunit, GLenum target,
+                        GLint level, GLint components,
+                        GLsizei width, GLint border,
+                        GLenum format, GLenum type, const GLvoid * pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   if (target == GL_PROXY_TEXTURE_1D) {
+      /* don't compile, execute immediately */
+      CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
+                                         border, format, type, pixels));
+   }
+   else {
+      Node *n;
+      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+      n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE1D, 8 + POINTER_DWORDS);
+      if (n) {
+         n[1].e = texunit;
+         n[2].e = target;
+         n[3].i = level;
+         n[4].i = components;
+         n[5].i = (GLint) width;
+         n[6].i = border;
+         n[7].e = format;
+         n[8].e = type;
+         save_pointer(&n[9],
+                      unpack_image(ctx, 1, width, 1, 1, format, type,
+                                   pixels, &ctx->Unpack));
+      }
+      if (ctx->ExecuteFlag) {
+         CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
+                                            border, format, type, pixels));
+      }
+   }
+}
+
+
+static void GLAPIENTRY
+save_MultiTexImage2DEXT(GLenum texunit, GLenum target,
+                       GLint level, GLint components,
+                       GLsizei width, GLsizei height, GLint border,
+                       GLenum format, GLenum type, const GLvoid * pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   if (target == GL_PROXY_TEXTURE_2D) {
+      /* don't compile, execute immediately */
+      CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
+                                         height, border, format, type, pixels));
+   }
+   else {
+      Node *n;
+      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+      n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE2D, 9 + POINTER_DWORDS);
+      if (n) {
+         n[1].e = texunit;
+         n[2].e = target;
+         n[3].i = level;
+         n[4].i = components;
+         n[5].i = (GLint) width;
+         n[6].i = (GLint) height;
+         n[7].i = border;
+         n[8].e = format;
+         n[9].e = type;
+         save_pointer(&n[10],
+                      unpack_image(ctx, 2, width, height, 1, format, type,
+                                   pixels, &ctx->Unpack));
+      }
+      if (ctx->ExecuteFlag) {
+         CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
+                                            height, border, format, type, pixels));
+      }
+   }
+}
+
+
+static void GLAPIENTRY
+save_MultiTexImage3DEXT(GLenum texunit, GLenum target,
+                       GLint level, GLint internalFormat,
+                       GLsizei width, GLsizei height, GLsizei depth,
+                       GLint border,
+                       GLenum format, GLenum type, const GLvoid * pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   if (target == GL_PROXY_TEXTURE_3D) {
+      /* don't compile, execute immediately */
+      CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat, width,
+                                         height, depth, border, format, type,
+                                         pixels));
+   }
+   else {
+      Node *n;
+      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+      n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE3D, 10 + POINTER_DWORDS);
+      if (n) {
+         n[1].e = texunit;
+         n[2].e = target;
+         n[3].i = level;
+         n[4].i = (GLint) internalFormat;
+         n[5].i = (GLint) width;
+         n[6].i = (GLint) height;
+         n[7].i = (GLint) depth;
+         n[8].i = border;
+         n[9].e = format;
+         n[10].e = type;
+         save_pointer(&n[11],
+                      unpack_image(ctx, 3, width, height, depth, format, type,
+                                   pixels, &ctx->Unpack));
+      }
+      if (ctx->ExecuteFlag) {
+         CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat,
+                                            width, height, depth, border, format,
+                                            type, pixels));
+      }
+   }
+}
+
+
+
 static void GLAPIENTRY
 save_MultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
 {
@@ -11809,6 +11933,57 @@ execute_list(struct gl_context *ctx, GLuint list)
                CALL_MultiTexParameterivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
             }
             break;
+         case OPCODE_MULTITEX_IMAGE1D:
+            {
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
+               CALL_MultiTexImage1DEXT(ctx->Exec, (n[1].e, /* texture */
+                                                  n[2].e,  /* target */
+                                                  n[3].i,  /* level */
+                                                  n[4].i,  /* components */
+                                                  n[5].i,  /* width */
+                                                  n[6].e,  /* border */
+                                                  n[7].e,  /* format */
+                                                  n[8].e,  /* type */
+                                                  get_pointer(&n[9])));
+               ctx->Unpack = save;      /* restore */
+            }
+            break;
+         case OPCODE_MULTITEX_IMAGE2D:
+            {
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
+               CALL_MultiTexImage2DEXT(ctx->Exec, (n[1].e, /* texture */
+                                                  n[2].e,  /* target */
+                                                  n[3].i,  /* level */
+                                                  n[4].i,  /* components */
+                                                  n[5].i,  /* width */
+                                                  n[6].i,  /* height */
+                                                  n[7].e,  /* border */
+                                                  n[8].e,  /* format */
+                                                  n[9].e,  /* type */
+                                                  get_pointer(&n[10])));
+               ctx->Unpack = save;      /* restore */
+            }
+            break;
+         case OPCODE_MULTITEX_IMAGE3D:
+            {
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
+               CALL_MultiTexImage3DEXT(ctx->Exec, (n[1].e, /* texture */
+                                                  n[2].e,  /* target */
+                                                  n[3].i,  /* level */
+                                                  n[4].i,  /* components */
+                                                  n[5].i,  /* width */
+                                                  n[6].i,  /* height */
+                                                  n[7].i,  /* depth  */
+                                                  n[8].e,  /* border */
+                                                  n[9].e,  /* format */
+                                                  n[10].e, /* type */
+                                                  get_pointer(&n[11])));
+               ctx->Unpack = save;      /* restore */
+            }
+            break;
          case OPCODE_MULTITEXENV:
             {
                GLfloat params[4];
@@ -12837,6 +13012,9 @@ _mesa_initialize_save_table(const struct gl_context *ctx)
    SET_MultiTexParameterivEXT(table, save_MultiTexParameterivEXT);
    SET_MultiTexParameterfEXT(table, save_MultiTexParameterfEXT);
    SET_MultiTexParameterfvEXT(table, save_MultiTexParameterfvEXT);
+   SET_MultiTexImage1DEXT(table, save_MultiTexImage1DEXT);
+   SET_MultiTexImage2DEXT(table, save_MultiTexImage2DEXT);
+   SET_MultiTexImage3DEXT(table, save_MultiTexImage3DEXT);
    SET_MultiTexEnvfEXT(table, save_MultiTexEnvfEXT);
    SET_MultiTexEnvfvEXT(table, save_MultiTexEnvfvEXT);
    SET_MultiTexEnviEXT(table, save_MultiTexEnviEXT);
index 661f275af7fd3130251b406460543eb6f875919c..b1e80fd5dfbc34f263b71b8b8dc995a842c2cd55 100644 (file)
@@ -1076,20 +1076,20 @@ const struct function common_desktop_functions_possible[] = {
    { "glMultiTexParameterfvEXT", 12, -1 },
    { "glMultiTexParameteriEXT", 12, -1 },
    { "glMultiTexParameterivEXT", 12, -1 },
-   //{ "glMultiTexImage1DEXT", 12, -1 },
-   //{ "glMultiTexImage2DEXT", 12, -1 },
+   { "glMultiTexImage1DEXT", 12, -1 },
+   { "glMultiTexImage2DEXT", 12, -1 },
    //{ "glMultiTexSubImage1DEXT", 12, -1 },
    //{ "glMultiTexSubImage2DEXT", 12, -1 },
    //{ "glCopyMultiTexImage1DEXT", 12, -1 },
    //{ "glCopyMultiTexImage2DEXT", 12, -1 },
    //{ "glCopyMultiTexSubImage1DEXT", 12, -1 },
    //{ "glCopyMultiTexSubImage2DEXT", 12, -1 },
-   //{ "glGetMultiTexImageEXT", 12, -1 },
+   { "glGetMultiTexImageEXT", 12, -1 },
    //{ "glGetMultiTexParameterfvEXT", 12, -1 },
    //{ "glGetMultiTexParameterivEXT", 12, -1 },
    //{ "glGetMultiTexLevelParameterfvEXT", 12, -1 },
    //{ "glGetMultiTexLevelParameterivEXT", 12, -1 },
-   //{ "glMultiTexImage3DEXT", 12, -1 },
+   { "glMultiTexImage3DEXT", 12, -1 },
    //{ "glMultiTexSubImage3DEXT", 12, -1 },
    //{ "glCopyMultiTexSubImage3DEXT", 12, -1 },
    { "glEnableClientStateIndexedEXT", 12, -1 },
index fcaaf3eee69ecd36d68e978d549dbe69c7c1fe6e..693077e19932c0fcff56d6d3ea5ba72e9b5d5574 100644 (file)
@@ -1559,6 +1559,44 @@ _mesa_GetTextureImageEXT(GLuint texture, GLenum target, GLint level,
 }
 
 
+void GLAPIENTRY
+_mesa_GetMultiTexImageEXT(GLenum texunit, GLenum target, GLint level,
+                          GLenum format, GLenum type, GLvoid *pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLsizei width, height, depth;
+   static const char *caller = "glGetMultiTexImageEXT";
+
+   struct gl_texture_object *texObj =
+      _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                             texunit - GL_TEXTURE0,
+                                             false,
+                                             caller);
+
+   if (!texObj) {
+      return;
+   }
+
+   if (!legal_getteximage_target(ctx, texObj->Target, true)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+      return;
+   }
+
+   get_texture_image_dims(texObj, texObj->Target, level,
+                          &width, &height, &depth);
+
+   if (getteximage_error_check(ctx, texObj, texObj->Target, level,
+                               width, height, depth,
+                               format, type, INT_MAX, pixels, caller)) {
+      return;
+   }
+
+   get_texture_image(ctx, texObj, texObj->Target, level,
+                     0, 0, 0, width, height, depth,
+                     format, type, pixels, caller);
+}
+
+
 void GLAPIENTRY
 _mesa_GetTextureSubImage(GLuint texture, GLint level,
                          GLint xoffset, GLint yoffset, GLint zoffset,
index 0ab154a9c42096b1adf6a03b8ff7f487f6db3750..9a27aacc0404a0abcd64d978da3992df9ba309c1 100644 (file)
@@ -65,6 +65,10 @@ extern void GLAPIENTRY
 _mesa_GetTextureImageEXT( GLuint texture, GLenum target, GLint level,
                           GLenum format, GLenum type, GLvoid *pixels);
 
+extern void GLAPIENTRY
+_mesa_GetMultiTexImageEXT(GLenum texunit, GLenum target, GLint level,
+                          GLenum format, GLenum type, GLvoid *pixels);
+
 extern void GLAPIENTRY
 _mesa_GetTextureSubImage(GLuint texture, GLint level,
                          GLint xoffset, GLint yoffset, GLint zoffset,
index 5c28c21234e806fa03cda11bd70ef08b7f10a66e..ac950c2051bd7bfd638a9fa109508e6f93fc1c10 100644 (file)
@@ -3210,6 +3210,24 @@ _mesa_TextureImage1DEXT(GLuint texture, GLenum target, GLint level,
             width, 1, 1, border, format, type, 0, pixels, false);
 }
 
+void GLAPIENTRY
+_mesa_MultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
+                         GLint internalFormat, GLsizei width, GLint border,
+                         GLenum format, GLenum type, const GLvoid *pixels )
+{
+   struct gl_texture_object*  texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glMultiTexImage1DEXT");
+   if (!texObj)
+      return;
+   teximage(ctx, GL_FALSE, 1, texObj, target, level, internalFormat, width, 1, 1,
+                border, format, type, 0, pixels, false);
+}
+
 void GLAPIENTRY
 _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
                   GLsizei width, GLsizei height, GLint border,
@@ -3238,6 +3256,25 @@ _mesa_TextureImage2DEXT(GLuint texture, GLenum target, GLint level,
             width, height, 1, border, format, type, 0, pixels, false);
 }
 
+void GLAPIENTRY
+_mesa_MultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
+                         GLint internalFormat, GLsizei width, GLsizei height,
+                         GLint border,
+                         GLenum format, GLenum type, const GLvoid *pixels )
+{
+   struct gl_texture_object*  texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glMultiTexImage2DEXT");
+   if (!texObj)
+      return;
+   teximage(ctx, GL_FALSE, 2, texObj, target, level, internalFormat, width, height, 1,
+                border, format, type, 0, pixels, false);
+}
+
 /*
  * Called by the API or display list executor.
  * Note that width and height include the border.
@@ -3271,6 +3308,26 @@ _mesa_TextureImage3DEXT(GLuint texture, GLenum target, GLint level,
 }
 
 
+void GLAPIENTRY
+_mesa_MultiTexImage3DEXT(GLenum texunit, GLenum target, GLint level,
+                         GLint internalFormat, GLsizei width, GLsizei height,
+                         GLsizei depth, GLint border, GLenum format, GLenum type,
+                         const GLvoid *pixels )
+{
+   struct gl_texture_object*  texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+                                                   texunit - GL_TEXTURE0,
+                                                   true,
+                                                   "glMultiTexImage3DEXT");
+   if (!texObj)
+      return;
+   teximage(ctx, GL_FALSE, 3, texObj, target, level, internalFormat,
+                width, height, depth, border, format, type, 0, pixels, false);
+}
+
+
 void GLAPIENTRY
 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat,
                      GLsizei width, GLsizei height, GLsizei depth,
index 5f3dc0383a47f46290c6e66a18f45ffe813c656e..49f0937ca20f80045bb5bdc13c8ea26277a2c115 100644 (file)
@@ -266,6 +266,11 @@ _mesa_TextureImage1DEXT( GLuint texture, GLenum target, GLint level,
                          GLint internalformat, GLsizei width, GLint border,
                          GLenum format, GLenum type, const GLvoid *pixels );
 
+extern void GLAPIENTRY
+_mesa_MultiTexImage1DEXT( GLenum texture, GLenum target, GLint level,
+                          GLint internalformat, GLsizei width, GLint border,
+                          GLenum format, GLenum type, const GLvoid *pixels );
+
 extern void GLAPIENTRY
 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
                   GLsizei width, GLsizei height, GLint border,
@@ -277,6 +282,12 @@ _mesa_TextureImage2DEXT( GLuint texture, GLenum target, GLint level,
                          GLint border, GLenum format, GLenum type,
                          const GLvoid *pixels );
 
+extern void GLAPIENTRY
+_mesa_MultiTexImage2DEXT(GLenum texture, GLenum target, GLint level,
+                         GLint internalFormat, GLsizei width, GLsizei height,
+                         GLint border, GLenum format, GLenum type,
+                         const GLvoid *pixels );
+
 extern void GLAPIENTRY
 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
                   GLsizei width, GLsizei height, GLsizei depth, GLint border,
@@ -294,6 +305,12 @@ _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
                      GLint border, GLenum format, GLenum type,
                      const GLvoid *pixels );
 
+extern void GLAPIENTRY
+_mesa_MultiTexImage3DEXT(GLenum texture, GLenum target, GLint level,
+                         GLint internalFormat, GLsizei width, GLsizei height,
+                         GLsizei depth, GLint border, GLenum format, GLenum type,
+                         const GLvoid *pixels );
+
 extern void GLAPIENTRY
 _mesa_TexImage1D_no_error(GLenum target, GLint level, GLint internalformat,
                           GLsizei width, GLint border,