summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2011-03-06 05:26:12 +0100
committerMarek Olšák <maraeo@gmail.com>2011-06-12 05:57:26 +0200
commitb10abac70e9005799d0c9be2a089458f0703ce25 (patch)
tree6779287d530b0b9b45ede081a14aba7a32ac3878
parent7d30582c916bf6b88802f5bcc37e7f04ec32cbf5 (diff)
mesa: invalidate framebuffer if internal format of renderbuffer is changed
RenderTexture doesn't have to be called in invalidate_rb, I guess. (cherry picked from commit df818d572e4ddb1ceccd22a538bf98ce01caffee)
-rw-r--r--src/mesa/main/fbobject.c35
-rw-r--r--src/mesa/main/mtypes.h2
2 files changed, 31 insertions, 6 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 6c63047fda9..0f946a1d20a 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -359,6 +359,7 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
assert(att);
_mesa_set_renderbuffer_attachment(ctx, att, rb);
}
+ rb->AttachedAnytime = GL_TRUE;
}
else {
_mesa_remove_attachment(ctx, att);
@@ -1023,6 +1024,30 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
}
+/**
+ * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk().
+ */
+static void
+invalidate_rb(GLuint key, void *data, void *userData)
+{
+ struct gl_framebuffer *fb = (struct gl_framebuffer *) data;
+ struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData;
+
+ /* If this is a user-created FBO */
+ if (fb->Name) {
+ GLuint i;
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = fb->Attachment + i;
+ if (att->Type == GL_RENDERBUFFER &&
+ att->Renderbuffer == rb) {
+ /* Mark fb status as indeterminate to force re-validation */
+ fb->_Status = 0;
+ }
+ }
+ }
+}
+
+
/** sentinal value, see below */
#define NO_SAMPLES 1000
@@ -1115,12 +1140,10 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
rb->NumSamples = 0;
}
- /*
- test_framebuffer_completeness(ctx, fb);
- */
- /* XXX if this renderbuffer is attached anywhere, invalidate attachment
- * points???
- */
+ /* Invalidate the framebuffers the renderbuffer is attached in. */
+ if (rb->AttachedAnytime) {
+ _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb);
+ }
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 19724d9b57a..fad24ebdbdc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2352,6 +2352,8 @@ struct gl_renderbuffer
GLenum DataType; /**< Type of values passed to the Get/Put functions */
GLvoid *Data; /**< This may not be used by some kinds of RBs */
+ GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
+
/* Used to wrap one renderbuffer around another: */
struct gl_renderbuffer *Wrapped;