From e8e0de6a8f11be85cd52e2bda08fa32e5b148f22 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 30 Apr 2019 15:42:39 +0200 Subject: [PATCH] mesa: add EXT_dsa glCopyMultiTexImage* and glCopyMultiTexSubImage* MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- .../glapi/gen/EXT_direct_state_access.xml | 58 ++++++ src/mapi/glapi/gen/static_data.py | 5 + src/mesa/main/dlist.c | 173 ++++++++++++++++++ src/mesa/main/tests/dispatch_sanity.cpp | 10 +- src/mesa/main/teximage.c | 104 +++++++++++ src/mesa/main/teximage.h | 26 +++ 6 files changed, 371 insertions(+), 5 deletions(-) diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml b/src/mapi/glapi/gen/EXT_direct_state_access.xml index 8d567bd8816..0cb4a47ef57 100644 --- a/src/mapi/glapi/gen/EXT_direct_state_access.xml +++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml @@ -512,6 +512,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 5d92f61b4ea..a74de70897a 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1536,6 +1536,11 @@ offsets = { "MultiTexSubImage3DEXT": 1500, "GetMultiTexParameterivEXT": 1501, "GetMultiTexParameterfvEXT": 1502, + "CopyMultiTexImage1DEXT": 1503, + "CopyMultiTexImage2DEXT": 1504, + "CopyMultiTexSubImage1DEXT": 1505, + "CopyMultiTexSubImage2DEXT": 1506, + "CopyMultiTexSubImage3DEXT": 1507, } functions = [ diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index d62c87bcd59..be77c386d62 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -590,6 +590,11 @@ typedef enum OPCODE_MULTITEX_SUB_IMAGE1D, OPCODE_MULTITEX_SUB_IMAGE2D, OPCODE_MULTITEX_SUB_IMAGE3D, + OPCODE_COPY_MULTITEX_IMAGE1D, + OPCODE_COPY_MULTITEX_IMAGE2D, + OPCODE_COPY_MULTITEX_SUB_IMAGE1D, + OPCODE_COPY_MULTITEX_SUB_IMAGE2D, + OPCODE_COPY_MULTITEX_SUB_IMAGE3D, OPCODE_MULTITEXENV, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D, @@ -10221,6 +10226,143 @@ save_MultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, } +static void GLAPIENTRY +save_CopyMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE1D, 8); + if (n) { + n[1].e = texunit; + n[2].e = target; + n[3].i = level; + n[4].e = internalformat; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyMultiTexImage1DEXT(ctx->Exec, (texunit, target, level, + internalformat, x, y, + width, border)); + } +} + + +static void GLAPIENTRY +save_CopyMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE2D, 9); + if (n) { + n[1].e = texunit; + n[2].e = target; + n[3].i = level; + n[4].e = internalformat; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = height; + n[9].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyMultiTexImage2DEXT(ctx->Exec, (texunit, target, level, + internalformat, x, y, + width, height, border)); + } +} + + +static void GLAPIENTRY +save_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE1D, 7); + if (n) { + n[1].e = texunit; + n[2].e = target; + n[3].i = level; + n[4].i = xoffset; + n[5].i = x; + n[6].i = y; + n[7].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyMultiTexSubImage1DEXT(ctx->Exec, + (texunit, target, level, xoffset, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE2D, 9); + if (n) { + n[1].e = texunit; + n[2].e = target; + n[3].i = level; + n[4].i = xoffset; + n[5].i = yoffset; + n[6].i = x; + n[7].i = y; + n[8].i = width; + n[9].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level, + xoffset, yoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE3D, 10); + if (n) { + n[1].e = texunit; + n[2].e = target; + n[3].i = level; + n[4].i = xoffset; + n[5].i = yoffset; + n[6].i = zoffset; + n[7].i = x; + n[8].i = y; + n[9].i = width; + n[10].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level, + xoffset, yoffset, zoffset, + x, y, width, height)); + } +} + + static void GLAPIENTRY save_MultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params) { @@ -12122,6 +12264,32 @@ execute_list(struct gl_context *ctx, GLuint list) ctx->Unpack = save; /* restore */ } break; + case OPCODE_COPY_MULTITEX_IMAGE1D: + CALL_CopyMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i, + n[4].e, n[5].i, n[6].i, + n[7].i, n[8].i)); + break; + case OPCODE_COPY_MULTITEX_IMAGE2D: + CALL_CopyMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i, + n[4].e, n[5].i, n[6].i, + n[7].i, n[8].i, n[9].i)); + break; + case OPCODE_COPY_MULTITEX_SUB_IMAGE1D: + CALL_CopyMultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i, + n[4].i, n[5].i, n[6].i, + n[7].i)); + break; + case OPCODE_COPY_MULTITEX_SUB_IMAGE2D: + CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].i, n[9].i)); + break; + case OPCODE_COPY_MULTITEX_SUB_IMAGE3D: + CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].i, n[9].i, + n[10].i)); + break; case OPCODE_MULTITEXENV: { GLfloat params[4]; @@ -13156,6 +13324,11 @@ _mesa_initialize_save_table(const struct gl_context *ctx) SET_MultiTexSubImage1DEXT(table, save_MultiTexSubImage1DEXT); SET_MultiTexSubImage2DEXT(table, save_MultiTexSubImage2DEXT); SET_MultiTexSubImage3DEXT(table, save_MultiTexSubImage3DEXT); + SET_CopyMultiTexImage1DEXT(table, save_CopyMultiTexImage1DEXT); + SET_CopyMultiTexImage2DEXT(table, save_CopyMultiTexImage2DEXT); + SET_CopyMultiTexSubImage1DEXT(table, save_CopyMultiTexSubImage1DEXT); + SET_CopyMultiTexSubImage2DEXT(table, save_CopyMultiTexSubImage2DEXT); + SET_CopyMultiTexSubImage3DEXT(table, save_CopyMultiTexSubImage3DEXT); SET_MultiTexEnvfEXT(table, save_MultiTexEnvfEXT); SET_MultiTexEnvfvEXT(table, save_MultiTexEnvfvEXT); SET_MultiTexEnviEXT(table, save_MultiTexEnviEXT); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index a0e7bc58f75..3653597bb2e 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -1080,10 +1080,10 @@ const struct function common_desktop_functions_possible[] = { { "glMultiTexImage2DEXT", 12, -1 }, { "glMultiTexSubImage1DEXT", 12, -1 }, { "glMultiTexSubImage2DEXT", 12, -1 }, - //{ "glCopyMultiTexImage1DEXT", 12, -1 }, - //{ "glCopyMultiTexImage2DEXT", 12, -1 }, - //{ "glCopyMultiTexSubImage1DEXT", 12, -1 }, - //{ "glCopyMultiTexSubImage2DEXT", 12, -1 }, + { "glCopyMultiTexImage1DEXT", 12, -1 }, + { "glCopyMultiTexImage2DEXT", 12, -1 }, + { "glCopyMultiTexSubImage1DEXT", 12, -1 }, + { "glCopyMultiTexSubImage2DEXT", 12, -1 }, { "glGetMultiTexImageEXT", 12, -1 }, { "glGetMultiTexParameterfvEXT", 12, -1 }, { "glGetMultiTexParameterivEXT", 12, -1 }, @@ -1091,7 +1091,7 @@ const struct function common_desktop_functions_possible[] = { //{ "glGetMultiTexLevelParameterivEXT", 12, -1 }, { "glMultiTexImage3DEXT", 12, -1 }, { "glMultiTexSubImage3DEXT", 12, -1 }, - //{ "glCopyMultiTexSubImage3DEXT", 12, -1 }, + { "glCopyMultiTexSubImage3DEXT", 12, -1 }, { "glEnableClientStateIndexedEXT", 12, -1 }, { "glDisableClientStateIndexedEXT", 12, -1 }, { "glGetPointerIndexedvEXT", 12, -1 }, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index fdb9ae886b8..352ccf2d660 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4381,6 +4381,25 @@ _mesa_CopyTextureImage1DEXT( GLuint texture, GLenum target, GLint level, } +void GLAPIENTRY +_mesa_CopyMultiTexImage1DEXT( GLenum texunit, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_object* texObj = + _mesa_get_texobj_by_target_and_texunit(ctx, target, + texunit - GL_TEXTURE0, + false, + "glCopyMultiTexImage1DEXT"); + if (!texObj) + return; + copyteximage(ctx, 1, texObj, target, level, internalFormat, x, y, width, 1, + border, false); +} + + void GLAPIENTRY _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, @@ -4410,6 +4429,25 @@ _mesa_CopyTextureImage2DEXT( GLuint texture, GLenum target, GLint level, } +void GLAPIENTRY +_mesa_CopyMultiTexImage2DEXT( GLenum texunit, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_object* texObj = + _mesa_get_texobj_by_target_and_texunit(ctx, target, + texunit - GL_TEXTURE0, + false, + "glCopyMultiTexImage2DEXT"); + if (!texObj) + return; + copyteximage(ctx, 2, texObj, target, level, internalFormat, x, y, width, height, + border, false); +} + + void GLAPIENTRY _mesa_CopyTexImage1D_no_error(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border) @@ -4560,6 +4598,25 @@ _mesa_CopyTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, } +void GLAPIENTRY +_mesa_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) +{ + struct gl_texture_object* texObj; + const char *self = "glCopyMultiTexSubImage1DEXT"; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target, + texunit - GL_TEXTURE0, + false, self); + if (!texObj) + return; + + copy_texture_sub_image_err(ctx, 1, texObj, texObj->Target, level, xoffset, 0, + 0, x, y, width, 1, self); +} + + void GLAPIENTRY _mesa_CopyTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, @@ -4610,6 +4667,25 @@ _mesa_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, } +void GLAPIENTRY +_mesa_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + struct gl_texture_object* texObj; + const char *self = "glCopyMultiTexSubImage2DEXT"; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target, + texunit - GL_TEXTURE0, + false, self); + if (!texObj) + return; + + copy_texture_sub_image_err(ctx, 2, texObj, texObj->Target, level, xoffset, + yoffset, 0, x, y, width, height, self); +} + void GLAPIENTRY _mesa_CopyTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, @@ -4676,6 +4752,34 @@ _mesa_CopyTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, } +void GLAPIENTRY +_mesa_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + struct gl_texture_object* texObj; + const char *self = "glCopyMultiTexSubImage3D"; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target, + texunit - GL_TEXTURE0, + false, self); + if (!texObj) + return; + + if (texObj->Target == GL_TEXTURE_CUBE_MAP) { + /* Act like CopyTexSubImage2D */ + copy_texture_sub_image_err(ctx, 2, texObj, + GL_TEXTURE_CUBE_MAP_POSITIVE_X + zoffset, + level, xoffset, yoffset, 0, x, y, width, height, + self); + } + else + copy_texture_sub_image_err(ctx, 3, texObj, texObj->Target, level, xoffset, + yoffset, zoffset, x, y, width, height, self); +} + + void GLAPIENTRY _mesa_CopyTexSubImage1D_no_error(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 57af2f40142..891fa16565c 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -449,12 +449,21 @@ extern void GLAPIENTRY _mesa_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +extern void GLAPIENTRY +_mesa_CopyMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLint border); extern void GLAPIENTRY _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); +extern void GLAPIENTRY +_mesa_CopyMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei hright, GLint border); + extern void GLAPIENTRY _mesa_CopyTextureImage1DEXT( GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, @@ -501,6 +510,11 @@ _mesa_CopyTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +extern void GLAPIENTRY +_mesa_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, + GLint level, GLint xoffset, GLint x, GLint y, + GLsizei width); + extern void GLAPIENTRY _mesa_CopyTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, @@ -513,6 +527,12 @@ _mesa_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height); +extern void GLAPIENTRY +_mesa_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height); + extern void GLAPIENTRY _mesa_CopyTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, @@ -525,6 +545,12 @@ _mesa_CopyTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height); +extern void GLAPIENTRY +_mesa_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height); + extern void GLAPIENTRY _mesa_CopyTexSubImage1D_no_error(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); -- 2.30.2