rb->Format = image->format;
rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
image->internal_format);
+ rb->NeedsFinishRenderTexture = true;
}
/**
struct gl_renderbuffer_attachment *att)
{
struct intel_context *intel = intel_context(ctx);
- struct gl_texture_object *tex_obj = att->Texture;
- struct gl_texture_image *image =
- tex_obj->Image[att->CubeMapFace][att->TextureLevel];
- struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
- DBG("Finish render %s texture tex=%u\n",
- _mesa_get_format_name(image->TexFormat), att->Texture->Name);
+ DBG("Finish render %s texture\n", _mesa_get_format_name(rb->Format));
if (irb)
irb->tex_image = NULL;
image->dri_format = intel_dri_format(image->format);
image->has_depthstencil = irb->mt->stencil_mt? true : false;
+ rb->NeedsFinishRenderTexture = true;
return image;
}
rb->Format = image->format;
rb->_BaseFormat = _mesa_base_fbo_format(&radeon->glCtx,
image->internal_format);
+ rb->NeedsFinishRenderTexture = GL_TRUE;
}
/**
struct gl_renderbuffer_attachment *att)
{
struct gl_texture_object *tex_obj = att->Texture;
- struct gl_texture_image *image =
- tex_obj->Image[att->CubeMapFace][att->TextureLevel];
- radeon_texture_image *radeon_image = (radeon_texture_image *)image;
-
+ radeon_texture_image *radeon_image = NULL;
+
+ if (tex_obj)
+ radeon_image = (radeon_texture_image *)_mesa_get_attachment_teximage(att);
+
if (radeon_image)
radeon_image->used_as_render_target = GL_FALSE;
_mesa_remove_attachment(struct gl_context *ctx,
struct gl_renderbuffer_attachment *att)
{
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+
+ /* tell driver that we're done rendering to this texture. */
+ if (rb && rb->NeedsFinishRenderTexture)
+ ctx->Driver.FinishRenderTexture(ctx, att);
+
if (att->Type == GL_TEXTURE) {
ASSERT(att->Texture);
- if (ctx->Driver.FinishRenderTexture) {
- /* tell driver that we're done rendering to this texture. */
- ctx->Driver.FinishRenderTexture(ctx, att);
- }
_mesa_reference_texobj(&att->Texture, NULL); /* unbind */
ASSERT(!att->Texture);
}
* for clarity compared to user renderbuffers.
*/
rb->AllocStorage = NULL;
+
+ rb->NeedsFinishRenderTexture = ctx->Driver.FinishRenderTexture != NULL;
}
rb->_BaseFormat = texImage->_BaseFormat;
GLenum texTarget, GLuint level, GLuint zoffset,
GLboolean layered)
{
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+
+ if (rb && rb->NeedsFinishRenderTexture)
+ ctx->Driver.FinishRenderTexture(ctx, att);
+
if (att->Texture == texObj) {
/* re-attaching same texture */
ASSERT(att->Type == GL_TEXTURE);
- if (ctx->Driver.FinishRenderTexture)
- ctx->Driver.FinishRenderTexture(ctx, att);
}
else {
/* new attachment */
- if (ctx->Driver.FinishRenderTexture && att->Texture)
- ctx->Driver.FinishRenderTexture(ctx, att);
_mesa_remove_attachment(ctx, att);
att->Type = GL_TEXTURE;
assert(!att->Texture);
GLuint i;
for (i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer_attachment *att = fb->Attachment + i;
- if (att->Texture && att->Renderbuffer) {
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ if (rb && rb->NeedsFinishRenderTexture) {
ctx->Driver.FinishRenderTexture(ctx, att);
}
}
GLuint Depth;
GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
+ /**
+ * True for renderbuffers that wrap textures, giving the driver a chance to
+ * flush render caches through the FinishRenderTexture hook.
+ *
+ * Drivers may also set this on renderbuffers other than those generated by
+ * glFramebufferTexture(), though it means FinishRenderTexture() would be
+ * called without a rb->TexImage.
+ */
+ GLboolean NeedsFinishRenderTexture;
GLubyte NumSamples;
GLenum InternalFormat; /**< The user-specified format */
GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or