summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/common
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-09-03 16:42:19 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-09-03 16:42:19 +0000
commite6925b51e1e71dc45079636ce336a09806356999 (patch)
tree9aedd34db3089a49b11fb5835cd660aaafcf34f4 /src/mesa/drivers/dri/common
parentc6262cd8c5e1ca8f702e9694c81749601287fb10 (diff)
added flippedData field for page flipping, code to flip stereo color buffers
Diffstat (limited to 'src/mesa/drivers/dri/common')
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.c70
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.h12
2 files changed, 54 insertions, 28 deletions
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c
index 45c81e293c..8376fa2717 100644
--- a/src/mesa/drivers/dri/common/drirenderbuffer.c
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.c
@@ -22,6 +22,16 @@ driRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
}
+static void
+driDeleteRenderbuffer(struct gl_renderbuffer *rb)
+{
+ /* don't free rb->Data Chances are it's a memory mapped region for
+ * the dri drivers.
+ */
+ _mesa_free(rb);
+}
+
+
/**
* Allocate a new driRenderbuffer object.
* Individual drivers are free to implement different versions of
@@ -86,8 +96,7 @@ driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch)
*/
drb->Base.AllocStorage = driRenderbufferStorage;
- /* using default Delete function */
-
+ drb->Base.Delete = driDeleteRenderbuffer;
/* DRI renderbuffer-specific fields: */
drb->offset = offset;
@@ -103,32 +112,43 @@ driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch)
/**
- * Update the front and back renderbuffers' flippedPitch/Offset fields.
+ * Update the front and back renderbuffers' flippedPitch/Offset/Data fields.
+ * If stereo, flip both the left and right pairs.
* This is used when we do double buffering via page flipping.
+ * \param fb the framebuffer we're page flipping
+ * \param flipped if true, set flipped values, else set non-flipped values
*/
void
-driFlipRenderbuffers(struct gl_framebuffer *fb, GLenum flipped)
+driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped)
{
- driRenderbuffer *front_drb
- = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
- driRenderbuffer *back_drb
- = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
-
- /* If this fails, it means we're trying to do page flipping for a
- * single-buffered window!
- */
- assert(back_drb);
-
- if (flipped) {
- front_drb->flippedOffset = back_drb->offset;
- front_drb->flippedPitch = back_drb->pitch;
- back_drb->flippedOffset = front_drb->offset;
- back_drb->flippedPitch = front_drb->pitch;
- }
- else {
- front_drb->flippedOffset = front_drb->offset;
- front_drb->flippedPitch = front_drb->pitch;
- back_drb->flippedOffset = back_drb->offset;
- back_drb->flippedPitch = back_drb->pitch;
+ const GLuint count = fb->Visual.stereoMode ? 2 : 1;
+ GLuint lr; /* left or right */
+
+ ASSERT(fb->Visual.doubleBufferMode);
+
+ for (lr = 0; lr < count; lr++) {
+ GLuint frontBuf = (lr == 0) ? BUFFER_FRONT_LEFT : BUFFER_FRONT_RIGHT;
+ GLuint backBuf = (lr == 0) ? BUFFER_BACK_LEFT : BUFFER_BACK_RIGHT;
+ driRenderbuffer *front_drb
+ = (driRenderbuffer *) fb->Attachment[frontBuf].Renderbuffer;
+ driRenderbuffer *back_drb
+ = (driRenderbuffer *) fb->Attachment[backBuf].Renderbuffer;
+
+ if (flipped) {
+ front_drb->flippedOffset = back_drb->offset;
+ front_drb->flippedPitch = back_drb->pitch;
+ front_drb->flippedData = back_drb->Base.Data;
+ back_drb->flippedOffset = front_drb->offset;
+ back_drb->flippedPitch = front_drb->pitch;
+ back_drb->flippedData = front_drb->Base.Data;
+ }
+ else {
+ front_drb->flippedOffset = front_drb->offset;
+ front_drb->flippedPitch = front_drb->pitch;
+ front_drb->flippedData = front_drb->Base.Data;
+ back_drb->flippedOffset = back_drb->offset;
+ back_drb->flippedPitch = back_drb->pitch;
+ back_drb->flippedData = back_drb->Base.Data;
+ }
}
}
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.h b/src/mesa/drivers/dri/common/drirenderbuffer.h
index 67affa06e1..bd07bc790f 100644
--- a/src/mesa/drivers/dri/common/drirenderbuffer.h
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.h
@@ -32,17 +32,23 @@ typedef struct {
/* If the driver can do page flipping (full-screen double buffering)
* the current front/back buffers may get swapped.
* If page flipping is disabled, these fields will be identical to
- * the offset/pitch above.
+ * the offset/pitch/Data above.
* If page flipping is enabled, and this is the front(back) renderbuffer,
- * flippedOffset/Pitch will have the back(front) renderbuffer's values.
+ * flippedOffset/Pitch/Data will have the back(front) renderbuffer's values.
*/
GLint flippedOffset;
GLint flippedPitch;
+ GLubyte *flippedData; /* mmap'd memory, if used */
/* XXX this is for radeon/r200 only. We should really create a new
* r200Renderbuffer class, derived from this class... not a huge deal.
*/
GLboolean depthHasSurface;
+
+ /* XXX this is for s3v only. A handy flag to know if this is the back
+ * color buffer.
+ */
+ GLboolean backBuffer;
} driRenderbuffer;
@@ -50,6 +56,6 @@ extern driRenderbuffer *
driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch);
extern void
-driFlipRenderbuffers(struct gl_framebuffer *fb, GLenum flipped);
+driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped);
#endif /* DRIRENDERBUFFER_H */