From 1f7d8f97867d6311efe7862242be3c9980319ac6 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 4 Jun 2019 16:05:53 +0200 Subject: [PATCH] mesa: add display list support for gl(Compressed)TextureSubImage2DEXT MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Signed-off-by: Marek Olšák --- src/mesa/main/dlist.c | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index b07449b2133..dc05ab7521d 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -570,6 +570,8 @@ typedef enum OPCODE_MATRIX_POP, OPCODE_TEXTUREPARAMETER_F, OPCODE_TEXTUREPARAMETER_I, + OPCODE_TEXTURE_SUB_IMAGE2D, + OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D, /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ @@ -1203,6 +1205,10 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) case OPCODE_WINDOW_RECTANGLES: free(get_pointer(&n[3])); break; + case OPCODE_TEXTURE_SUB_IMAGE2D: + case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D: + free(get_pointer(&n[10])); + break; case OPCODE_CONTINUE: n = (Node *) get_pointer(&n[1]); free(block); @@ -9525,6 +9531,70 @@ save_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint par save_TextureParameterivEXT(texture, target, pname, fparam); } +static void GLAPIENTRY +save_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); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE2D, 9 + POINTER_DWORDS); + if (n) { + n[1].ui = texture; + n[2].e = target; + n[3].i = level; + n[4].i = xoffset; + n[5].i = yoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + 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_TextureSubImage2DEXT(ctx->Exec, (texture, target, level, xoffset, yoffset, + width, height, format, type, pixels)); + } +} + +static void GLAPIENTRY +save_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid * data) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D, + 9 + POINTER_DWORDS); + if (n) { + n[1].ui = texture; + n[2].e = target; + n[3].i = level; + n[4].i = xoffset; + n[5].i = yoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].e = format; + n[9].i = imageSize; + save_pointer(&n[10], + copy_data(data, imageSize, "glCompressedTextureSubImage2DEXT")); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTextureSubImage2DEXT(ctx->Exec, + (texture, target, level, xoffset, yoffset, + width, height, format, imageSize, data)); + } +} + /** * Save an error-generating command into display list. @@ -11111,6 +11181,23 @@ execute_list(struct gl_context *ctx, GLuint list) CALL_TextureParameterivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params)); } break; + case OPCODE_TEXTURE_SUB_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i, + n[4].i, n[5].i, n[6].e, + n[7].i, n[8].e, n[9].e, + get_pointer(&n[10]))); + ctx->Unpack = save; + } + break; + case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D: + CALL_CompressedTextureSubImage2DEXT(ctx->Exec, + (n[1].ui, n[2].e, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].e, + n[9].i, get_pointer(&n[10]))); + break; case OPCODE_CONTINUE: n = (Node *) get_pointer(&n[1]); @@ -12107,6 +12194,8 @@ _mesa_initialize_save_table(const struct gl_context *ctx) SET_TextureParameterivEXT(table, save_TextureParameterivEXT); SET_TextureParameterfEXT(table, save_TextureParameterfEXT); SET_TextureParameterfvEXT(table, save_TextureParameterfvEXT); + SET_TextureSubImage2DEXT(table, save_TextureSubImage2DEXT); + SET_CompressedTextureSubImage2DEXT(table, save_CompressedTextureSubImage2DEXT); } -- 2.30.2