nvc0: Handle ARB_conditional_render_inverted and enable it
authorTobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Sat, 16 Aug 2014 01:44:26 +0000 (03:44 +0200)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 19 Aug 2014 13:02:29 +0000 (09:02 -0400)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
src/gallium/drivers/nouveau/nvc0/nvc0_context.h
src/gallium/drivers/nouveau/nvc0/nvc0_query.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_surface.c

index ebeb8c48fbaf4d52b6731e31b450ab08e6614dec..8ae78e9f3280c7b64206a1a5a685c432c0aabc04 100644 (file)
@@ -196,8 +196,9 @@ struct nvc0_context {
    unsigned num_tfbbufs;
 
    struct pipe_query *cond_query;
-   boolean cond_cond;
+   boolean cond_cond; /* inverted rendering condition */
    uint cond_mode;
+   uint32_t cond_condmode; /* the calculated condition */
 
    struct nvc0_blitctx *blit;
 
index 50cef1e96c478ec721d63299138d3fd9b4f4fad2..007f8c47914523307b6efb0b893f267717c99983 100644 (file)
@@ -542,46 +542,51 @@ nvc0_render_condition(struct pipe_context *pipe,
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
    struct nvc0_query *q;
    uint32_t cond;
-   boolean negated = FALSE;
    boolean wait =
       mode != PIPE_RENDER_COND_NO_WAIT &&
       mode != PIPE_RENDER_COND_BY_REGION_NO_WAIT;
 
+   if (!pq) {
+      cond = NVC0_3D_COND_MODE_ALWAYS;
+   }
+   else {
+      q = nvc0_query(pq);
+      /* NOTE: comparison of 2 queries only works if both have completed */
+      switch (q->type) {
+      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+         cond = condition ? NVC0_3D_COND_MODE_EQUAL :
+                          NVC0_3D_COND_MODE_NOT_EQUAL;
+         wait = TRUE;
+         break;
+      case PIPE_QUERY_OCCLUSION_COUNTER:
+      case PIPE_QUERY_OCCLUSION_PREDICATE:
+         if (likely(!condition)) {
+            if (unlikely(q->nesting))
+               cond = wait ? NVC0_3D_COND_MODE_NOT_EQUAL :
+                             NVC0_3D_COND_MODE_ALWAYS;
+            else
+               cond = NVC0_3D_COND_MODE_RES_NON_ZERO;
+         } else {
+            cond = wait ? NVC0_3D_COND_MODE_EQUAL : NVC0_3D_COND_MODE_ALWAYS;
+         }
+         break;
+      default:
+         assert(!"render condition query not a predicate");
+         cond = NVC0_3D_COND_MODE_ALWAYS;
+         break;
+      }
+   }
+
    nvc0->cond_query = pq;
    nvc0->cond_cond = condition;
+   nvc0->cond_condmode = cond;
    nvc0->cond_mode = mode;
 
    if (!pq) {
       PUSH_SPACE(push, 1);
-      IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
+      IMMED_NVC0(push, NVC0_3D(COND_MODE), cond);
       return;
    }
-   q = nvc0_query(pq);
-
-   /* NOTE: comparison of 2 queries only works if both have completed */
-   switch (q->type) {
-   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      cond = negated ? NVC0_3D_COND_MODE_EQUAL :
-                       NVC0_3D_COND_MODE_NOT_EQUAL;
-      wait = TRUE;
-      break;
-   case PIPE_QUERY_OCCLUSION_COUNTER:
-   case PIPE_QUERY_OCCLUSION_PREDICATE:
-      if (likely(!negated)) {
-         if (unlikely(q->nesting))
-            cond = wait ? NVC0_3D_COND_MODE_NOT_EQUAL :
-                          NVC0_3D_COND_MODE_ALWAYS;
-         else
-            cond = NVC0_3D_COND_MODE_RES_NON_ZERO;
-      } else {
-         cond = wait ? NVC0_3D_COND_MODE_EQUAL : NVC0_3D_COND_MODE_ALWAYS;
-      }
-      break;
-   default:
-      assert(!"render condition query not a predicate");
-      mode = NVC0_3D_COND_MODE_ALWAYS;
-      break;
-   }
 
    if (wait)
       nvc0_query_fifo_wait(push, pq);
index 7c2f11ab07e0cfc32819875b0365a6af18dd9cc8..84025ef976f5e5d8d9b9fd8358f994a019ecf277 100644 (file)
@@ -167,13 +167,12 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
+   case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
       return 1;
    case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
       return (class_3d >= NVE4_3D_CLASS) ? 1 : 0;
    case PIPE_CAP_COMPUTE:
       return (class_3d == NVE4_3D_CLASS) ? 1 : 0;
-   case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
-     return 0;
 
    /* unsupported caps */
    case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
index a29f0cc771318926c7cee36842b3dbd1f07b6018..17fe66d58dbaf8c2305bc7ea76ce1481fa71be5c 100644 (file)
@@ -1236,7 +1236,7 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info)
    }
 
    if (nvc0->cond_query && info->render_condition_enable)
-      IMMED_NVC0(push, NVC0_2D(COND_MODE), NVC0_2D_COND_MODE_RES_NON_ZERO);
+      IMMED_NVC0(push, NVC0_2D(COND_MODE), nvc0->cond_condmode);
 
    if (mask != 0xffffffff) {
       IMMED_NVC0(push, NVC0_2D(ROP), 0xca); /* DPSDxax */