nouveau/vieux: finish != flush, how about we do that..
authorBen Skeggs <bskeggs@redhat.com>
Thu, 10 May 2012 17:02:13 +0000 (03:02 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Sat, 12 May 2012 02:42:47 +0000 (12:42 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nouveau_context.h
src/mesa/drivers/dri/nouveau/nouveau_driver.c

index 2625b76d14fb6e596c659b95daa80f4a143321fe..d7d5a04e6921a1cf41cdfec0bc0a3895866cbc38 100644 (file)
@@ -83,6 +83,13 @@ nouveau_context_create(gl_api api,
           return GL_FALSE;
        }
 
+       if (nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, 4096,
+                          NULL, &nctx->fence)) {
+               nouveau_context_destroy(dri_ctx);
+               *error = __DRI_CTX_ERROR_NO_MEMORY;
+               return GL_FALSE;
+       }
+
        *error = __DRI_CTX_ERROR_SUCCESS;
        return GL_TRUE;
 }
@@ -209,6 +216,7 @@ nouveau_context_destroy(__DRIcontext *dri_ctx)
        struct nouveau_context *nctx = dri_ctx->driverPrivate;
        struct gl_context *ctx = &nctx->base;
 
+       nouveau_bo_ref(NULL, &nctx->fence);
        context_drv(ctx)->context_destroy(ctx);
 }
 
index 8bba51e8091118ffcd1dfe39067b1df8d267fadc..2bcc1e12782f9799a1a9fabfac98469e87ca3e71 100644 (file)
@@ -72,6 +72,8 @@ struct nouveau_context {
        BITSET_DECLARE(dirty, MAX_NOUVEAU_STATE);
        enum nouveau_fallback fallback;
 
+       struct nouveau_bo *fence;
+
        struct nouveau_hw_state hw;
        struct nouveau_render_state render;
        struct nouveau_scratch_state scratch;
index 69e5cac426afe922a05b6f12c2d052aa2e708351..e824d1072af7c729343620a9943952299c627e55 100644 (file)
@@ -76,7 +76,20 @@ nouveau_flush(struct gl_context *ctx)
 static void
 nouveau_finish(struct gl_context *ctx)
 {
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_pushbuf *push = context_push(ctx);
+       struct nouveau_pushbuf_refn refn =
+               { nctx->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR };
+
        nouveau_flush(ctx);
+
+       if (!nouveau_pushbuf_space(push, 16, 0, 0) &&
+           !nouveau_pushbuf_refn(push, &refn, 1)) {
+               PUSH_DATA(push, 0);
+               PUSH_KICK(push);
+       }
+
+       nouveau_bo_wait(nctx->fence, NOUVEAU_BO_RDWR, context_client(ctx));
 }
 
 void