svga: Support accelerated conditional blitting
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 12 Apr 2017 08:38:23 +0000 (10:38 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Fri, 16 Jun 2017 06:40:26 +0000 (08:40 +0200)
The blitter has functions to save and restore the conditional rendering state,
but we currently don't save the needed info.

Since also the copy_region_vgpu10 path supports conditional blitting,
we instead use the same function as the clearing routines and move
that function to svga_pipe_query.c

Note that we still haven't implemented conditional blitting with
the software fallbacks.

Fixes piglit nv_conditional_render::copyteximage

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_blit.c
src/gallium/drivers/svga/svga_pipe_clear.c
src/gallium/drivers/svga/svga_pipe_query.c

index a268635d6af4d9ee1bc57ee7776e762c5240b161..2987c709ac974755daae392a47ab079e1d58105a 100644 (file)
@@ -675,6 +675,9 @@ struct pipe_context *
 svga_context_create(struct pipe_screen *screen,
                     void *priv, unsigned flags);
 
+void svga_toggle_render_condition(struct svga_context *svga,
+                                  boolean render_condition_enabled,
+                                  boolean on);
 
 /***********************************************************************
  * Inline conversion functions.  These are better-typed than the
index 13788fd59c15e911b4acddc4d55d57ca8851a29e..3d7196dddd2a633ab615b4c3b9a6b637acd2a125 100644 (file)
@@ -286,9 +286,6 @@ can_blit_via_svga_copy_region(struct svga_context *svga,
       blit_info->mask != (PIPE_MASK_ZS))
      return false;
 
-   if (svga->render_condition && blit_info->render_condition_enable)
-      return false;
-
    return check_blending_and_srgb_cond(svga, blit_info);
 }
 
@@ -334,6 +331,9 @@ can_blit_via_surface_copy(struct svga_context *svga,
 {
    struct svga_texture *dtex, *stex;
 
+   if (svga->render_condition && blit_info->render_condition_enable)
+      return false;
+
    /* can't copy between different resource types */
    if (svga_resource_type(blit_info->src.resource->target) !=
        svga_resource_type(blit_info->dst.resource->target))
@@ -372,6 +372,8 @@ try_copy_region(struct svga_context *svga,
                   &dst_face, &dst_z);
 
    if (can_blit_via_copy_region_vgpu10(svga, blit)) {
+      svga_toggle_render_condition(svga, blit->render_condition_enable, FALSE);
+
       copy_region_vgpu10(svga,
                          blit->src.resource,
                          blit->src.box.x, blit->src.box.y, src_z,
@@ -381,6 +383,9 @@ try_copy_region(struct svga_context *svga,
                          blit->dst.level, dst_face,
                          blit->src.box.width, blit->src.box.height,
                          blit->src.box.depth);
+
+      svga_toggle_render_condition(svga, blit->render_condition_enable, TRUE);
+
       return true;
    }
 
@@ -511,8 +516,6 @@ try_blit(struct svga_context *svga, const struct pipe_blit_info *blit_info)
    util_blitter_save_fragment_sampler_views(svga->blitter,
                      svga->curr.num_sampler_views[PIPE_SHADER_FRAGMENT],
                      svga->curr.sampler_views[PIPE_SHADER_FRAGMENT]);
-   /*util_blitter_save_render_condition(svga->blitter, svga->render_cond_query,
-                                      svga->render_cond_cond, svga->render_cond_mode);*/
 
    if (!can_create_src_view) {
       struct pipe_resource template;
@@ -574,8 +577,12 @@ try_blit(struct svga_context *svga, const struct pipe_blit_info *blit_info)
       blit.dst.resource = newDst;
    }
 
+   svga_toggle_render_condition(svga, blit.render_condition_enable, FALSE);
+
    util_blitter_blit(svga->blitter, &blit);
 
+   svga_toggle_render_condition(svga, blit.render_condition_enable, TRUE);
+
    if (blit.dst.resource != dst) {
       struct pipe_blit_info copy_region_blit;
 
@@ -619,6 +626,13 @@ try_cpu_copy_region(struct svga_context *svga,
 {
    if (util_can_blit_via_copy_region(blit, TRUE) ||
        util_can_blit_via_copy_region(blit, FALSE)) {
+
+      if (svga->render_condition && blit->render_condition_enable) {
+         debug_warning("CPU copy_region doesn't support "
+                       "conditional rendering.\n");
+         return false;
+      }
+
       copy_region_fallback(svga, blit->dst.resource,
                            blit->dst.level,
                            blit->dst.box.x, blit->dst.box.y,
index 56db713cfc95c419eabc30ba506733348e76496a..e234ef58715907c7600b9b155e7568eb09979071 100644 (file)
@@ -504,44 +504,6 @@ svga_blitter_clear_render_target(struct svga_context *svga,
                                     dstx, dsty, width, height);
 }
 
-/**
- * \brief Toggle conditional rendering if already enabled
- *
- * \param svga[in]  The svga context
- * \param render_condition_enabled[in]  Whether to ignore requests to turn
- * conditional rendering off
- * \param on[in]  Whether to turn conditional rendering on or off
- */
-static void
-svga_toggle_render_condition(struct svga_context *svga,
-                             boolean render_condition_enabled,
-                             boolean on)
-{
-   SVGA3dQueryId query_id;
-   enum pipe_error ret;
-
-   if (render_condition_enabled ||
-       svga->pred.query_id == SVGA3D_INVALID_ID) {
-      return;
-   }
-
-   /*
-    * If we get here, it means that the system supports
-    * conditional rendering since svga->pred.query_id has already been
-    * modified for this context and thus support has already been
-    * verified.
-    */
-   query_id = on ? svga->pred.query_id : SVGA3D_INVALID_ID;
-
-   ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
-                                      (uint32) svga->pred.cond);
-   if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
-      svga_context_flush(svga, NULL);
-      ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
-                                         (uint32) svga->pred.cond);
-      assert(ret == PIPE_OK);
-   }
-}
 
 /**
  * \brief Clear render target pipe callback
index 06c0c811ec96e8fa5797afbb8ceb9c85113c7e08..76360fdd4d0dc6524f4311935dd6d80b9e15a75e 100644 (file)
@@ -1272,6 +1272,46 @@ svga_set_active_query_state(struct pipe_context *pipe, boolean enable)
 }
 
 
+/**
+ * \brief Toggle conditional rendering if already enabled
+ *
+ * \param svga[in]  The svga context
+ * \param render_condition_enabled[in]  Whether to ignore requests to turn
+ * conditional rendering off
+ * \param on[in]  Whether to turn conditional rendering on or off
+ */
+void
+svga_toggle_render_condition(struct svga_context *svga,
+                             boolean render_condition_enabled,
+                             boolean on)
+{
+   SVGA3dQueryId query_id;
+   enum pipe_error ret;
+
+   if (render_condition_enabled ||
+       svga->pred.query_id == SVGA3D_INVALID_ID) {
+      return;
+   }
+
+   /*
+    * If we get here, it means that the system supports
+    * conditional rendering since svga->pred.query_id has already been
+    * modified for this context and thus support has already been
+    * verified.
+    */
+   query_id = on ? svga->pred.query_id : SVGA3D_INVALID_ID;
+
+   ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
+                                      (uint32) svga->pred.cond);
+   if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
+      svga_context_flush(svga, NULL);
+      ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
+                                         (uint32) svga->pred.cond);
+      assert(ret == PIPE_OK);
+   }
+}
+
+
 void
 svga_init_query_functions(struct svga_context *svga)
 {