st_api_destroy_drawable(struct st_api *stapi,
struct st_framebuffer_iface *stfbi)
{
- if (stfbi)
+ if (!stfbi)
return;
st_framebuffer_iface_remove(stfbi->state_manager, stfbi);
st_flush(st, fence, pipe_flags);
- if ((flags & ST_FLUSH_WAIT) && fence) {
+ if ((flags & ST_FLUSH_WAIT) && fence && *fence) {
st->pipe->screen->fence_finish(st->pipe->screen, NULL, *fence,
PIPE_TIMEOUT_INFINITE);
st->pipe->screen->fence_reference(st->pipe->screen, fence, NULL);
if (flags & ST_FLUSH_FRONT)
st_manager_flush_frontbuffer(st);
+
+ /* DRI3 changes the framebuffer after SwapBuffers, but we need to invoke
+ * st_manager_validate_framebuffers to notice that.
+ *
+ * Set gfx_shaders_may_be_dirty to invoke st_validate_state in the next
+ * draw call, which will invoke st_manager_validate_framebuffers, but it
+ * won't dirty states if there is no change.
+ */
+ if (flags & ST_FLUSH_END_OF_FRAME)
+ st->gfx_shaders_may_be_dirty = true;
}
static boolean
stObj = st_texture_object(texObj);
/* switch to surface based */
if (!stObj->surface_based) {
- _mesa_clear_texture_object(ctx, texObj);
+ _mesa_clear_texture_object(ctx, texObj, NULL);
stObj->surface_based = GL_TRUE;
}
if (stfb)
strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
- if (!strb)
- return;
- /* never a dummy fb */
- stfb->iface->flush_front(&st->iface, stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
+ /* Do we have a front color buffer and has it been drawn to since last
+ * frontbuffer flush?
+ */
+ if (strb && strb->defined) {
+ stfb->iface->flush_front(&st->iface, stfb->iface,
+ ST_ATTACHMENT_FRONT_LEFT);
+ strb->defined = GL_FALSE;
+
+ /* Trigger an update of strb->defined on next draw */
+ st->dirty |= ST_NEW_FB_STATE;
+ }
}
/**
st_context_validate(st, stdraw, stread);
}
+
+/**
+ * Flush any outstanding swapbuffers on the current draw framebuffer.
+ */
+void
+st_manager_flush_swapbuffers(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct st_context *st = (ctx) ? ctx->st : NULL;
+ struct st_framebuffer *stfb;
+
+ if (!st)
+ return;
+
+ stfb = st_ws_framebuffer(ctx->DrawBuffer);
+ if (!stfb || !stfb->iface->flush_swapbuffers)
+ return;
+
+ stfb->iface->flush_swapbuffers(&st->iface, stfb->iface);
+}
+
+
/**
* Add a color renderbuffer on demand. The FBO must correspond to a window,
* not a user-created FBO.
_mesa_init_extensions(&extensions);
st_init_limits(screen, &consts, &extensions);
- st_init_extensions(screen, &consts, &extensions, options, GL_TRUE);
+ st_init_extensions(screen, &consts, &extensions, options);
return _mesa_get_version(&extensions, &consts, api);
}