}
+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
*/
drb->Base.AllocStorage = driRenderbufferStorage;
- /* using default Delete function */
-
+ drb->Base.Delete = driDeleteRenderbuffer;
/* DRI renderbuffer-specific fields: */
drb->offset = offset;
/**
- * 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;
+ }
}
}
/* 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;
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 */