Mesa (master): nv50,nvc0: fix pipe context switch

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sun Mar 13 12:25:29 UTC 2011


Module: Mesa
Branch: master
Commit: e864ccb3f20e58acb31572708ea6fcc696cf6ace
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e864ccb3f20e58acb31572708ea6fcc696cf6ace

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sat Mar 12 17:11:44 2011 +0100

nv50,nvc0: fix pipe context switch

---

 src/gallium/drivers/nv50/nv50_state_validate.c |   37 ++++++++++++++++++++---
 src/gallium/drivers/nvc0/nvc0_state_validate.c |   37 ++++++++++++++++++++---
 2 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c
index 4ae58b1..f3d45eb 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -254,6 +254,35 @@ nv50_validate_rasterizer(struct nv50_context *nv50)
    OUT_RINGp(chan, nv50->rast->state, nv50->rast->size);
 }
 
+static void
+nv50_switch_pipe_context(struct nv50_context *ctx_to)
+{
+   struct nv50_context *ctx_from = ctx_to->screen->cur_ctx;
+
+   if (ctx_from)
+      ctx_to->state = ctx_from->state;
+
+   ctx_to->dirty = ~0;
+
+   if (!ctx_to->vertex)
+      ctx_to->dirty &= ~(NV50_NEW_VERTEX | NV50_NEW_ARRAYS);
+
+   if (!ctx_to->vertprog)
+      ctx_to->dirty &= ~NV50_NEW_VERTPROG;
+   if (!ctx_to->fragprog)
+      ctx_to->dirty &= ~NV50_NEW_FRAGPROG;
+
+   if (!ctx_to->blend)
+      ctx_to->dirty &= ~NV50_NEW_BLEND;
+   if (!ctx_to->rast)
+      ctx_to->dirty &= ~NV50_NEW_RASTERIZER;
+   if (!ctx_to->zsa)
+      ctx_to->dirty &= ~NV50_NEW_ZSA;
+
+   ctx_to->screen->base.channel->user_private = ctx_to->screen->cur_ctx =
+      ctx_to;
+}
+
 static struct state_validate {
     void (*func)(struct nv50_context *);
     uint32_t states;
@@ -293,11 +322,9 @@ boolean
 nv50_state_validate(struct nv50_context *nv50)
 {
    unsigned i;
-#if 0
-   if (nv50->screen->cur_ctx != nv50) /* FIXME: not everything is valid */
-      nv50->dirty = 0xffffffff;
-#endif
-   nv50->screen->cur_ctx = nv50;
+
+   if (nv50->screen->cur_ctx != nv50)
+      nv50_switch_pipe_context(nv50);
 
    if (nv50->dirty) {
       for (i = 0; i < validate_list_len; ++i) {
diff --git a/src/gallium/drivers/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nvc0/nvc0_state_validate.c
index b38d2d9..bb81480 100644
--- a/src/gallium/drivers/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nvc0/nvc0_state_validate.c
@@ -402,6 +402,35 @@ nvc0_validate_derived_1(struct nvc0_context *nvc0)
    }
 }
 
+static void
+nvc0_switch_pipe_context(struct nvc0_context *ctx_to)
+{
+   struct nvc0_context *ctx_from = ctx_to->screen->cur_ctx;
+
+   if (ctx_from)
+      ctx_to->state = ctx_from->state;
+
+   ctx_to->dirty = ~0;
+
+   if (!ctx_to->vertex)
+      ctx_to->dirty &= ~(NVC0_NEW_VERTEX | NVC0_NEW_ARRAYS);
+
+   if (!ctx_to->vertprog)
+      ctx_to->dirty &= ~NVC0_NEW_VERTPROG;
+   if (!ctx_to->fragprog)
+      ctx_to->dirty &= ~NVC0_NEW_FRAGPROG;
+
+   if (!ctx_to->blend)
+      ctx_to->dirty &= ~NVC0_NEW_BLEND;
+   if (!ctx_to->rast)
+      ctx_to->dirty &= ~NVC0_NEW_RASTERIZER;
+   if (!ctx_to->zsa)
+      ctx_to->dirty &= ~NVC0_NEW_ZSA;
+
+   ctx_to->screen->base.channel->user_private = ctx_to->screen->cur_ctx =
+      ctx_to;
+}
+
 static struct state_validate {
     void (*func)(struct nvc0_context *);
     uint32_t states;
@@ -434,11 +463,9 @@ boolean
 nvc0_state_validate(struct nvc0_context *nvc0)
 {
    unsigned i;
-#if 0
-   if (nvc0->screen->cur_ctx != nvc0) /* FIXME: not everything is valid */
-      nvc0->dirty = 0xffffffff;
-#endif
-   nvc0->screen->cur_ctx = nvc0;
+
+   if (nvc0->screen->cur_ctx != nvc0)
+      nvc0_switch_pipe_context(nvc0);
 
    if (nvc0->dirty) {
       for (i = 0; i < validate_list_len; ++i) {




More information about the mesa-commit mailing list