intel_batchbuffer_flush(brw);
intel_flush_front(ctx);
- if (brw->is_front_buffer_rendering)
+ if (brw_is_front_buffer_drawing(ctx->DrawBuffer))
brw->need_throttle = true;
}
void
intel_prepare_render(struct brw_context *brw)
{
+ struct gl_context *ctx = &brw->ctx;
__DRIcontext *driContext = brw->driContext;
__DRIdrawable *drawable;
* that will happen next will probably dirty the front buffer. So
* mark it as dirty here.
*/
- if (brw->is_front_buffer_rendering)
+ if (brw_is_front_buffer_drawing(ctx->DrawBuffer))
brw->front_buffer_dirty = true;
/* Wait for the swapbuffers before the one we just emitted, so we
back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
memset(attachments, 0, sizeof(attachments));
- if ((brw->is_front_buffer_rendering ||
- brw->is_front_buffer_reading ||
+ if ((brw_is_front_buffer_drawing(fb) ||
+ brw_is_front_buffer_reading(fb) ||
!back_rb) && front_rb) {
/* If a fake front buffer is in use, then querying for
* __DRI_BUFFER_FRONT_LEFT will cause the server to copy the image from
const char *buffer_name)
{
struct intel_region *region = NULL;
+ struct gl_framebuffer *fb = drawable->driverPrivate;
if (!rb)
return;
intel_update_winsys_renderbuffer_miptree(brw, rb, region);
- if (brw->is_front_buffer_rendering &&
+ if (brw_is_front_buffer_drawing(fb) &&
(buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
buffer->attachment == __DRI_BUFFER_FAKE_FRONT_LEFT) &&
rb->Base.Base.NumSamples > 1) {
enum __DRIimageBufferMask buffer_type)
{
struct intel_region *region = buffer->region;
+ struct gl_framebuffer *fb = drawable->driverPrivate;
if (!rb || !region)
return;
intel_update_winsys_renderbuffer_miptree(intel, rb, region);
- if (intel->is_front_buffer_rendering &&
+ if (brw_is_front_buffer_drawing(fb) &&
buffer_type == __DRI_IMAGE_BUFFER_FRONT &&
rb->Base.Base.NumSamples > 1) {
intel_renderbuffer_upsample(intel, rb);
else
return;
- if ((brw->is_front_buffer_rendering || brw->is_front_buffer_reading || !back_rb) && front_rb)
+ if (front_rb && (brw_is_front_buffer_drawing(fb) ||
+ brw_is_front_buffer_reading(fb) || !back_rb)) {
buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
+ }
if (back_rb)
buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
*/
bool front_buffer_dirty;
- /**
- * Track whether front-buffer rendering is currently enabled
- *
- * A separate flag is used to track this in order to support MRT more
- * easily.
- */
- bool is_front_buffer_rendering;
-
- /**
- * Track whether front-buffer is the current read target.
- *
- * This is closely associated with is_front_buffer_rendering, but may
- * be set separately. The DRI2 fake front buffer must be referenced
- * either way.
- */
- bool is_front_buffer_reading;
-
/** Framerate throttling: @{ */
drm_intel_bo *first_post_swapbuffers_batch;
bool need_throttle;
#include "brw_state.h"
#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
#include "intel_fbo.h"
#include "intel_mipmap_tree.h"
#include "intel_regions.h"
struct intel_renderbuffer *stencil_irb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
struct gl_renderbuffer_attachment *depth_att = &fb->Attachment[BUFFER_DEPTH];
- if (brw->is_front_buffer_rendering)
+ if (brw_is_front_buffer_drawing(fb))
front_irb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
if (front_irb)
}
}
+bool
+brw_is_front_buffer_reading(struct gl_framebuffer *fb)
+{
+ if (!fb || _mesa_is_user_fbo(fb))
+ return false;
+
+ return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT;
+}
+
+bool
+brw_is_front_buffer_drawing(struct gl_framebuffer *fb)
+{
+ if (!fb || _mesa_is_user_fbo(fb))
+ return false;
+
+ return (fb->_NumColorDrawBuffers >= 1 &&
+ fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
+}
+
static void
intelDrawBuffer(struct gl_context * ctx, GLenum mode)
{
- if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) {
struct brw_context *const brw = brw_context(ctx);
- const bool was_front_buffer_rendering = brw->is_front_buffer_rendering;
- brw->is_front_buffer_rendering = (mode == GL_FRONT_LEFT)
- || (mode == GL_FRONT) || (mode == GL_FRONT_AND_BACK);
-
- /* If we weren't front-buffer rendering before but we are now,
- * invalidate our DRI drawable so we'll ask for new buffers
+ /* If we might be front-buffer rendering on this buffer for the first
+ * time, invalidate our DRI drawable so we'll ask for new buffers
* (including the fake front) before we start rendering again.
*/
- if (!was_front_buffer_rendering && brw->is_front_buffer_rendering)
- dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
+ dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
}
}
static void
intelReadBuffer(struct gl_context * ctx, GLenum mode)
{
- if (ctx->ReadBuffer && _mesa_is_winsys_fbo(ctx->ReadBuffer)) {
+ if (brw_is_front_buffer_reading(ctx->ReadBuffer)) {
struct brw_context *const brw = brw_context(ctx);
- const bool was_front_buffer_reading = brw->is_front_buffer_reading;
-
- brw->is_front_buffer_reading = mode == GL_FRONT_LEFT || mode == GL_FRONT;
- /* If we weren't front-buffer reading before but we are now,
- * invalidate our DRI drawable so we'll ask for new buffers
+ /* If we might be front-buffer reading on this buffer for the first
+ * time, invalidate our DRI drawable so we'll ask for new buffers
* (including the fake front) before we start reading again.
*/
- if (!was_front_buffer_reading && brw->is_front_buffer_reading)
- dri2InvalidateDrawable(brw->driContext->driReadablePriv);
+ dri2InvalidateDrawable(brw->driContext->driReadablePriv);
}
}
extern void intelInitBufferFuncs(struct dd_function_table *functions);
+bool brw_is_front_buffer_reading(struct gl_framebuffer *fb);
+bool brw_is_front_buffer_drawing(struct gl_framebuffer *fb);
+
#endif /* INTEL_BUFFERS_H */