ilo: clean up ilo_blitter_pipe_begin()
authorChia-I Wu <olvaffe@gmail.com>
Fri, 12 Jul 2013 21:54:25 +0000 (05:54 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 12 Jul 2013 22:43:53 +0000 (06:43 +0800)
Document why certain states need to be saved, and fix a bug when blitting with
scissor enabled.

src/gallium/drivers/ilo/ilo_blitter_pipe.c
src/gallium/drivers/ilo/ilo_gpe.h
src/gallium/drivers/ilo/ilo_gpe_gen6.c

index 8ca8f08e466fa3bf34d60477a430f9c4eb11a874..b4dd3ad91c5196fae2d883488612fcf8981de153 100644 (file)
@@ -41,38 +41,38 @@ enum ilo_blitter_pipe_op {
 
 static void
 ilo_blitter_pipe_begin(struct ilo_blitter *blitter,
-                       enum ilo_blitter_pipe_op op)
+                       enum ilo_blitter_pipe_op op,
+                       bool scissor_enable)
 {
    struct blitter_context *b = blitter->pipe_blitter;
    struct ilo_context *ilo = blitter->ilo;
 
-   /* as documented in util/u_blitter.h */
+   /* vertex states */
    util_blitter_save_vertex_buffer_slot(b, ilo->vb.states);
    util_blitter_save_vertex_elements(b, (void *) ilo->ve);
    util_blitter_save_vertex_shader(b, ilo->vs);
    util_blitter_save_geometry_shader(b, ilo->gs);
    util_blitter_save_so_targets(b, ilo->so.count, ilo->so.states);
+   util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
 
+   /* fragment states */
    util_blitter_save_fragment_shader(b, ilo->fs);
    util_blitter_save_depth_stencil_alpha(b, (void *) ilo->dsa);
    util_blitter_save_blend(b, (void *) ilo->blend);
-
-   /* undocumented? */
-   util_blitter_save_viewport(b, &ilo->viewport.viewport0);
-   util_blitter_save_stencil_ref(b, &ilo->stencil_ref);
    util_blitter_save_sample_mask(b, ilo->sample_mask);
+   util_blitter_save_stencil_ref(b, &ilo->stencil_ref);
+   util_blitter_save_viewport(b, &ilo->viewport.viewport0);
+
+   if (scissor_enable)
+      util_blitter_save_scissor(b, &ilo->scissor.scissor0);
 
    switch (op) {
    case ILO_BLITTER_PIPE_BLIT:
    case ILO_BLITTER_PIPE_COPY:
-      util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
-      util_blitter_save_framebuffer(b, &ilo->fb.state);
-
-      util_blitter_save_render_condition(b,
-            ilo->hw3d->render_condition.query,
-            ilo->hw3d->render_condition.cond,
-            ilo->hw3d->render_condition.mode);
-
+      /*
+       * we are about to call util_blitter_blit() or
+       * util_blitter_copy_texture()
+       */
       util_blitter_save_fragment_sampler_states(b,
             ilo->sampler[PIPE_SHADER_FRAGMENT].count,
             (void **) ilo->sampler[PIPE_SHADER_FRAGMENT].cso);
@@ -81,16 +81,23 @@ ilo_blitter_pipe_begin(struct ilo_blitter *blitter,
             ilo->view[PIPE_SHADER_FRAGMENT].count,
             ilo->view[PIPE_SHADER_FRAGMENT].states);
 
-      /* disable render condition? */
+      util_blitter_save_framebuffer(b, &ilo->fb.state);
+
+      /* resource_copy_region() or blit() does not honor render condition */
+      util_blitter_save_render_condition(b,
+            ilo->hw3d->render_condition.query,
+            ilo->hw3d->render_condition.cond,
+            ilo->hw3d->render_condition.mode);
       break;
    case ILO_BLITTER_PIPE_CLEAR:
-      util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
+      /*
+       * we are about to call util_blitter_clear_render_target() or
+       * util_blitter_clear_depth_stencil()
+       */
       util_blitter_save_framebuffer(b, &ilo->fb.state);
-
-      /* disable render condition? */
       break;
    case ILO_BLITTER_PIPE_CLEAR_FB:
-      util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
+      /* we are about to call util_blitter_clear() */
       break;
    default:
       break;
@@ -131,7 +138,8 @@ ilo_blitter_pipe_blit(struct ilo_blitter *blitter,
       }
    }
 
-   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_BLIT);
+   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_BLIT,
+         info->scissor_enable);
    util_blitter_blit(b, info);
    ilo_blitter_pipe_end(blitter);
 
@@ -155,7 +163,7 @@ ilo_blitter_pipe_copy_resource(struct ilo_blitter *blitter,
    if (!util_blitter_is_copy_supported(blitter->pipe_blitter, dst, src, mask))
       return false;
 
-   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_COPY);
+   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_COPY, false);
 
    util_blitter_copy_texture(blitter->pipe_blitter,
          dst, dst_level, dst_x, dst_y, dst_z,
@@ -174,7 +182,7 @@ ilo_blitter_pipe_clear_rt(struct ilo_blitter *blitter,
                           unsigned x, unsigned y,
                           unsigned width, unsigned height)
 {
-   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR);
+   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR, false);
 
    util_blitter_clear_render_target(blitter->pipe_blitter,
          rt, color, x, y, width, height);
@@ -192,7 +200,7 @@ ilo_blitter_pipe_clear_zs(struct ilo_blitter *blitter,
                           unsigned x, unsigned y,
                           unsigned width, unsigned height)
 {
-   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR);
+   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR, false);
 
    util_blitter_clear_depth_stencil(blitter->pipe_blitter,
          zs, clear_flags, depth, stencil, x, y, width, height);
@@ -209,7 +217,7 @@ ilo_blitter_pipe_clear_fb(struct ilo_blitter *blitter,
                           double depth, unsigned stencil)
 {
    /* TODO we should pause/resume some queries */
-   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR_FB);
+   ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR_FB, false);
 
    util_blitter_clear(blitter->pipe_blitter,
          blitter->ilo->fb.state.width, blitter->ilo->fb.state.height,
index 67674768e356f69e5f29d48165609b29a882723b..27fa57e2d38cc4b1f580bbe1fcb75af004d38146 100644 (file)
@@ -113,6 +113,8 @@ struct ilo_viewport_state {
 struct ilo_scissor_state {
    /* SCISSOR_RECT */
    uint32_t payload[ILO_MAX_VIEWPORTS * 2];
+
+   struct pipe_scissor_state scissor0;
 };
 
 struct ilo_rasterizer_clip {
index 4fb3507917253b99529ad7cb9a38f265f5b36835..4e1bd55343bf2773d5cbb420085ed1437517cb0d 100644 (file)
@@ -3811,10 +3811,12 @@ ilo_gpe_set_scissor(const struct ilo_dev_info *dev,
          max_y = 0;
       }
 
-      scissor->payload[start_slot * 2 + 0] = min_y << 16 | min_x;
-      scissor->payload[start_slot * 2 + 1] = max_y << 16 | max_x;
-      start_slot++;
+      scissor->payload[(start_slot + i) * 2 + 0] = min_y << 16 | min_x;
+      scissor->payload[(start_slot + i) * 2 + 1] = max_y << 16 | max_x;
    }
+
+   if (!start_slot && num_states)
+      scissor->scissor0 = states[0];
 }
 
 void