summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel/intel_context.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-02-17 21:17:55 -0500
committerKristian Høgsberg <krh@bitplanet.net>2010-02-17 21:53:16 -0500
commitd449627829e1a4a3250a1a723af2f4e3cd5fd194 (patch)
treeea9e91cf3579d3d941a1815f6f8033a25e2f8be6 /src/mesa/drivers/dri/intel/intel_context.c
parent56dcd011b5ec33190f268cf546a4c68f81f5ebd0 (diff)
intel: Implement the DRI2 invalidate function properly
This uses a stamp mechanisms to mark the DRI drawable as invalid. Instead of immediately updating the buffers we just bump the drawable stamp and call out to DRI2GetBuffers "later". "Later" used to be at LOCK_HARDWARE time, and this patch brings back callouts at the points where we used to call LOCK_HARDWARE. A new function, intel_prepare_render(), is called where we used to call LOCK_HARDWARE, and if the buffers are invalid, we call out to DRI2GetBuffers there. This lets us invalidate buffers only when notified instead of on every glViewport() call. If the loader calls the DRI invalidate entrypoint, we disable viewport triggered buffer invalidation. Additionally, we can clean up the old viewport mechanism a bit, since we can just invalidate the buffers and not worry about reentrancy and whatnot.
Diffstat (limited to 'src/mesa/drivers/dri/intel/intel_context.c')
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 81d5a32476..8f37fb82c1 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -197,6 +197,15 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
unsigned int attachments[10];
const char *region_name;
+ /* If we're rendering to the fake front buffer, make sure all the
+ * pending drawing has landed on the real front buffer. Otherwise
+ * when we eventually get to DRI2GetBuffersWithFormat the stale
+ * real front buffer contents will get copied to the new fake front
+ * buffer.
+ */
+ if (intel->is_front_buffer_rendering)
+ intel_flush(&intel->ctx, GL_FALSE);
+
if (INTEL_DEBUG & DEBUG_DRI)
fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
@@ -371,36 +380,40 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
}
void
+intel_prepare_render(struct intel_context *intel)
+{
+ __DRIcontext *driContext = intel->driContext;
+ __DRIdrawable *drawable;
+
+ drawable = intel->driDrawable;
+ if (drawable->dri2.stamp != driContext->dri2.draw_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
+ driContext->dri2.draw_stamp = drawable->dri2.stamp;
+ }
+
+ drawable = intel->driReadDrawable;
+ if (drawable->dri2.stamp != driContext->dri2.read_stamp) {
+ if (drawable->lastStamp != drawable->dri2.stamp)
+ intel_update_renderbuffers(driContext, drawable);
+ driContext->dri2.read_stamp = drawable->dri2.stamp;
+ }
+}
+
+void
intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
struct intel_context *intel = intel_context(ctx);
__DRIcontext *driContext = intel->driContext;
- void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
- GLsizei w, GLsizei h);
-
- if (!intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) {
- /* If we're rendering to the fake front buffer, make sure all the pending
- * drawing has landed on the real front buffer. Otherwise when we
- * eventually get to DRI2GetBuffersWithFormat the stale real front
- * buffer contents will get copied to the new fake front buffer.
- */
- if (intel->is_front_buffer_rendering) {
- intel_flush(ctx, GL_FALSE);
- }
- intel_update_renderbuffers(driContext, driContext->driDrawablePriv);
- if (driContext->driDrawablePriv != driContext->driReadablePriv)
- intel_update_renderbuffers(driContext, driContext->driReadablePriv);
+ if (!intel->using_dri2_swapbuffers &&
+ !intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) {
+ dri2InvalidateDrawable(driContext->driDrawablePriv);
+ dri2InvalidateDrawable(driContext->driReadablePriv);
}
-
- old_viewport = ctx->Driver.Viewport;
- ctx->Driver.Viewport = NULL;
- intel->driDrawable = driContext->driDrawablePriv;
- intel_draw_buffer(ctx, intel->ctx.DrawBuffer);
- ctx->Driver.Viewport = old_viewport;
}
-
static const struct dri_debug_control debug_control[] = {
{ "tex", DEBUG_TEXTURE},
{ "state", DEBUG_STATE},
@@ -860,22 +873,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
if (driContextPriv) {
struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
-
- intel_update_renderbuffers(driContextPriv, driDrawPriv);
- if (driDrawPriv != driReadPriv)
- intel_update_renderbuffers(driContextPriv, driReadPriv);
-
- /* set GLframebuffer size to match window, if needed */
- driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
-
- if (driReadPriv != driDrawPriv) {
- driUpdateFramebufferSize(&intel->ctx, driReadPriv);
- }
_mesa_make_current(&intel->ctx, fb, readFb);
intel->driReadDrawable = driReadPriv;
intel->driDrawable = driDrawPriv;
- intel_draw_buffer(&intel->ctx, fb);
+ driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
+ driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
}
else {
_mesa_make_current(NULL, NULL, NULL);