From 173e3045a9a176d95be1b4d3fbf7ba0230293842 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 14 Jan 2016 12:07:02 -0800 Subject: [PATCH] meta: Track temporary textures using gl_texture_object instead of GL API object handle MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Ian Romanick Reviewed-by: Tapani Pälli --- src/mesa/drivers/common/meta.c | 43 ++++++++++++++++++++--------- src/mesa/drivers/common/meta.h | 2 +- src/mesa/drivers/common/meta_blit.c | 8 ++++-- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 52d959a710f..be490d565bd 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1228,6 +1228,8 @@ invert_z(GLfloat normZ) static void init_temp_texture(struct gl_context *ctx, struct temp_texture *tex) { + GLuint texObj; + /* prefer texture rectangle */ if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle) { tex->Target = GL_TEXTURE_RECTANGLE; @@ -1243,16 +1245,22 @@ init_temp_texture(struct gl_context *ctx, struct temp_texture *tex) tex->MinSize = 16; /* 16 x 16 at least */ assert(tex->MaxSize > 0); - _mesa_GenTextures(1, &tex->TexObj); + _mesa_GenTextures(1, &texObj); + tex->tex_obj = NULL; + + if (texObj == 0) + return; + + tex->tex_obj = _mesa_lookup_texture(ctx, texObj); } static void cleanup_temp_texture(struct temp_texture *tex) { - if (!tex->TexObj) + if (tex->tex_obj == NULL) return; - _mesa_DeleteTextures(1, &tex->TexObj); - tex->TexObj = 0; + _mesa_DeleteTextures(1, &tex->tex_obj->Name); + tex->tex_obj = NULL; } @@ -1265,7 +1273,7 @@ _mesa_meta_get_temp_texture(struct gl_context *ctx) { struct temp_texture *tex = &ctx->Meta->TempTex; - if (!tex->TexObj) { + if (tex->tex_obj == NULL) { init_temp_texture(ctx, tex); } @@ -1283,7 +1291,7 @@ get_bitmap_temp_texture(struct gl_context *ctx) { struct temp_texture *tex = &ctx->Meta->Bitmap.Tex; - if (!tex->TexObj) { + if (tex->tex_obj == NULL) { init_temp_texture(ctx, tex); } @@ -1299,7 +1307,7 @@ _mesa_meta_get_temp_depth_texture(struct gl_context *ctx) { struct temp_texture *tex = &ctx->Meta->Blit.depthTex; - if (!tex->TexObj) { + if (tex->tex_obj == NULL) { init_temp_texture(ctx, tex); } @@ -1378,9 +1386,11 @@ _mesa_meta_setup_copypix_texture(struct gl_context *ctx, { bool newTex; - _mesa_BindTexture(tex->Target, tex->TexObj); - _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter); - _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter); + _mesa_BindTexture(tex->Target, tex->tex_obj->Name); + _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER, + (GLint *) &filter, false); + _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER, + (GLint *) &filter, false); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); newTex = _mesa_meta_alloc_texture(tex, width, height, intFormat); @@ -1422,9 +1432,16 @@ _mesa_meta_setup_drawpix_texture(struct gl_context *ctx, GLenum format, GLenum type, const GLvoid *pixels) { - _mesa_BindTexture(tex->Target, tex->TexObj); - _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + /* GLint so the compiler won't complain about type signedness mismatch in + * the call to _mesa_texture_parameteriv below. + */ + static const GLint filter = GL_NEAREST; + + _mesa_BindTexture(tex->Target, tex->tex_obj->Name); + _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER, &filter, + false); + _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER, &filter, + false); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); /* copy pixel data to texture */ diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 252b2367163..6d5185492d4 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -200,7 +200,7 @@ struct save_state */ struct temp_texture { - GLuint TexObj; + struct gl_texture_object *tex_obj; GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */ GLsizei MinSize; /**< Min texture size to allocate */ GLsizei MaxSize; /**< Max possible texture size */ diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 0c08109e107..95dfa64c051 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -674,7 +674,7 @@ blitframebuffer_texture(struct gl_context *ctx, } srcLevel = 0; - texObj = _mesa_lookup_texture(ctx, meta_temp_texture->TexObj); + texObj = meta_temp_texture->tex_obj; if (texObj == NULL) { return false; } @@ -1056,8 +1056,10 @@ _mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit) _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_with_depth); _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_without_depth); - _mesa_DeleteTextures(1, &blit->depthTex.TexObj); - blit->depthTex.TexObj = 0; + if (blit->depthTex.tex_obj != NULL) { + _mesa_DeleteTextures(1, &blit->depthTex.tex_obj->Name); + blit->depthTex.tex_obj = NULL; + } } void -- 2.30.2