diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 28 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 9 |
3 files changed, 39 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 99c59f77a37..443bb7b5869 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -154,6 +154,8 @@ st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target) DBG("%s\n", __func__); _mesa_initialize_texture_object(ctx, &obj->base, name, target); + obj->needs_validation = true; + return &obj->base; } @@ -606,6 +608,8 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, assert(!stImage->pt); /* xxx this might be wrong */ + stObj->needs_validation = true; + etc_fallback_allocate(st, stImage); /* Look if the parent texture object has space for this image */ @@ -2485,6 +2489,16 @@ st_finalize_texture(struct gl_context *ctx, firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace][stObj->base.BaseLevel]); assert(firstImage); + /* Skip the loop over images in the common case of no images having + * changed. But if the GL_BASE_LEVEL or GL_MAX_LEVEL change to something we + * haven't looked at, then we do need to look at those new images. + */ + if (!stObj->needs_validation && + stObj->base.BaseLevel >= stObj->validated_first_level && + stObj->lastLevel <= stObj->validated_last_level) { + return GL_TRUE; + } + /* If both firstImage and stObj point to a texture which can contain * all active images, favour firstImage. Note that because of the * completeness requirement, we know that the image dimensions @@ -2631,6 +2645,10 @@ st_finalize_texture(struct gl_context *ctx, } } + stObj->validated_first_level = stObj->base.BaseLevel; + stObj->validated_last_level = stObj->lastLevel; + stObj->needs_validation = false; + return GL_TRUE; } @@ -2712,6 +2730,11 @@ st_AllocTextureStorage(struct gl_context *ctx, } } + /* The texture is in a validated state, so no need to check later. */ + stObj->needs_validation = false; + stObj->validated_first_level = 0; + stObj->validated_last_level = levels - 1; + return GL_TRUE; } @@ -2810,6 +2833,11 @@ st_TextureView(struct gl_context *ctx, */ st_texture_release_all_sampler_views(st, tex); + /* The texture is in a validated state, so no need to check later. */ + tex->needs_validation = false; + tex->validated_first_level = 0; + tex->validated_last_level = numLevels - 1; + return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index f4c78aeced2..085f54efaa6 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -592,6 +592,8 @@ st_context_teximage(struct st_context_iface *stctxi, pipe_resource_reference(&stImage->pt, tex); stObj->surface_format = pipe_format; + stObj->needs_validation = true; + _mesa_dirty_texobj(ctx, texObj); _mesa_unlock_texture(ctx, texObj); diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 1b4d1a3ea23..c02d13598ba 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -84,6 +84,9 @@ struct st_texture_object */ GLuint lastLevel; + unsigned int validated_first_level; + unsigned int validated_last_level; + /* On validation any active images held in main memory or in other * textures will be copied to this texture and the old storage freed. */ @@ -121,6 +124,12 @@ struct st_texture_object unsigned prev_glsl_version; /** The value of the sampler's sRGBDecode state at the previous validation */ GLenum prev_sRGBDecode; + + /** + * Set when the texture images of this texture object might not all be in + * the pipe_resource *pt above. + */ + bool needs_validation; }; |