ilo: switch to ilo states for CLIP and SF stages
authorChia-I Wu <olvaffe@gmail.com>
Wed, 29 May 2013 06:42:13 +0000 (14:42 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 7 Jun 2013 03:13:14 +0000 (11:13 +0800)
Define and use

 struct ilo_viewport_state;
 struct ilo_scissor_state;

in ilo_context.

src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_blit.c
src/gallium/drivers/ilo/ilo_context.h
src/gallium/drivers/ilo/ilo_gpe.h
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/ilo/ilo_state.c

index e725df8c9c6584c44eb9a28613fc1f3b09fee2f3..e0ce20711dab3af85681b9d12d6cb22fb5971ef2 100644 (file)
@@ -598,6 +598,7 @@ gen6_pipeline_clip(struct ilo_3d_pipeline *p,
    /* 3DSTATE_CLIP */
    if (DIRTY(RASTERIZER) || DIRTY(FS) ||
        DIRTY(VIEWPORT) || DIRTY(FRAMEBUFFER)) {
+      const struct pipe_viewport_state *vp = &ilo->viewport.states[0];
       bool enable_guardband;
       float x1, x2, y1, y2;
 
@@ -605,10 +606,10 @@ gen6_pipeline_clip(struct ilo_3d_pipeline *p,
        * We do not do 2D clipping yet.  Guard band test should only be enabled
        * when the viewport is larger than the framebuffer.
        */
-      x1 = fabs(ilo->viewport.scale[0]) * -1.0f + ilo->viewport.translate[0];
-      x2 = fabs(ilo->viewport.scale[0]) *  1.0f + ilo->viewport.translate[0];
-      y1 = fabs(ilo->viewport.scale[1]) * -1.0f + ilo->viewport.translate[1];
-      y2 = fabs(ilo->viewport.scale[1]) *  1.0f + ilo->viewport.translate[1];
+      x1 = fabs(vp->scale[0]) * -1.0f + vp->translate[0];
+      x2 = fabs(vp->scale[0]) *  1.0f + vp->translate[0];
+      y1 = fabs(vp->scale[1]) * -1.0f + vp->translate[1];
+      y2 = fabs(vp->scale[1]) *  1.0f + vp->translate[1];
       enable_guardband =
          (x1 <= 0.0f && x2 >= (float) ilo->framebuffer.width &&
           y1 <= 0.0f && y2 >= (float) ilo->framebuffer.height);
@@ -778,23 +779,23 @@ gen6_pipeline_state_viewports(struct ilo_3d_pipeline *p,
    /* SF_CLIP_VIEWPORT and CC_VIEWPORT */
    if (p->dev->gen >= ILO_GEN(7) && DIRTY(VIEWPORT)) {
       p->state.SF_CLIP_VIEWPORT = p->gen7_SF_CLIP_VIEWPORT(p->dev,
-            &ilo->viewport, 1, p->cp);
+            ilo->viewport.states, ilo->viewport.count, p->cp);
 
       p->state.CC_VIEWPORT = p->gen6_CC_VIEWPORT(p->dev,
-            &ilo->viewport, 1, p->cp);
+            ilo->viewport.states, ilo->viewport.count, p->cp);
 
       session->viewport_state_changed = true;
    }
    /* SF_VIEWPORT, CLIP_VIEWPORT, and CC_VIEWPORT */
    else if (DIRTY(VIEWPORT)) {
       p->state.CLIP_VIEWPORT = p->gen6_CLIP_VIEWPORT(p->dev,
-            &ilo->viewport, 1, p->cp);
+            ilo->viewport.states, ilo->viewport.count, p->cp);
 
       p->state.SF_VIEWPORT = p->gen6_SF_VIEWPORT(p->dev,
-            &ilo->viewport, 1, p->cp);
+            ilo->viewport.states, ilo->viewport.count, p->cp);
 
       p->state.CC_VIEWPORT = p->gen6_CC_VIEWPORT(p->dev,
-            &ilo->viewport, 1, p->cp);
+            ilo->viewport.states, ilo->viewport.count, p->cp);
 
       session->viewport_state_changed = true;
    }
@@ -840,9 +841,10 @@ gen6_pipeline_state_scissors(struct ilo_3d_pipeline *p,
                              struct gen6_pipeline_session *session)
 {
    /* SCISSOR_RECT */
-   if (DIRTY(SCISSOR)) {
+   if (DIRTY(SCISSOR) || DIRTY(VIEWPORT)) {
+      /* there should be as many scissors as there are viewports */
       p->state.SCISSOR_RECT = p->gen6_SCISSOR_RECT(p->dev,
-            &ilo->scissor, 1, p->cp);
+            ilo->scissor.states, ilo->viewport.count, p->cp);
 
       session->scissor_state_changed = true;
    }
index 4c851fcef6307f4297f8ac1fdfa338538d9697e1..899ccace9c37cd76e0a4ed160690c09394ea0313 100644 (file)
@@ -554,7 +554,7 @@ ilo_blitter_begin(struct ilo_context *ilo, enum ilo_blitter_op op)
    util_blitter_save_blend(ilo->blitter, ilo->blend);
 
    /* undocumented? */
-   util_blitter_save_viewport(ilo->blitter, &ilo->viewport);
+   util_blitter_save_viewport(ilo->blitter, &ilo->viewport.states[0]);
    util_blitter_save_stencil_ref(ilo->blitter, &ilo->stencil_ref);
    util_blitter_save_sample_mask(ilo->blitter, ilo->sample_mask);
 
index 52225c8eaccfc86690cc4240df817808063375c8..6bd3e48ef9081b8c3a9786b9ee075353ece7559d 100644 (file)
@@ -62,6 +62,10 @@ struct ilo_context {
 
    struct ilo_so_state so;
 
+   struct pipe_clip_state clip;
+   struct ilo_viewport_state viewport;
+   struct ilo_scissor_state scissor;
+
    struct pipe_blend_state *blend;
    struct pipe_rasterizer_state *rasterizer;
    struct pipe_depth_stencil_alpha_state *depth_stencil_alpha;
@@ -72,11 +76,8 @@ struct ilo_context {
    struct pipe_blend_color blend_color;
    struct pipe_stencil_ref stencil_ref;
    unsigned sample_mask;
-   struct pipe_clip_state clip;
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
-   struct pipe_scissor_state scissor;
-   struct pipe_viewport_state viewport;
 
    struct {
       struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
index 468398e2e4b442b569ae901cfdbdc266acd2aa4d..9bf1114e9dc9c857d8d92baa2d2be9a39dffd61d 100644 (file)
@@ -39,6 +39,7 @@
 #define ILO_MAX_SAMPLERS        16
 #define ILO_MAX_SO_BINDINGS     64
 #define ILO_MAX_SO_BUFFERS      4
+#define ILO_MAX_VIEWPORTS       1
 
 #define ILO_MAX_VS_SURFACES        (ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS)
 #define ILO_VS_CONST_SURFACE(i)    (i)
@@ -74,4 +75,13 @@ struct ilo_so_state {
    bool enabled;
 };
 
+struct ilo_viewport_state {
+   struct pipe_viewport_state states[ILO_MAX_VIEWPORTS];
+   unsigned count;
+};
+
+struct ilo_scissor_state {
+   struct pipe_scissor_state states[ILO_MAX_VIEWPORTS];
+};
+
 #endif /* ILO_GPE_H */
index 264c338816a9eeac0980e6dd69b831b8c4d20dd1..c4a5e9444b69c3d8d171abd08f30c3d023177e6d 100644 (file)
@@ -421,6 +421,8 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
       /* a BRW_SURFACE_BUFFER can have up to 2^27 elements */
       return 1 << 27;
+   case PIPE_CAP_MAX_VIEWPORTS:
+      return ILO_MAX_VIEWPORTS;
 
    default:
       return 0;
index 76a82ac7a9c25a083ae1c4fccf41a7def641ba76..dfee07f4825f00a4fd6b8d7e73684e0dc82af284 100644 (file)
@@ -568,11 +568,13 @@ static void
 ilo_set_scissor_states(struct pipe_context *pipe,
                        unsigned start_slot,
                        unsigned num_scissors,
-                       const struct pipe_scissor_state *state)
+                       const struct pipe_scissor_state *scissors)
 {
    struct ilo_context *ilo = ilo_context(pipe);
+   unsigned i;
 
-   ilo->scissor = *state;
+   for (i = 0; i < num_scissors; i++)
+      ilo->scissor.states[start_slot + i] = scissors[i];
 
    ilo->dirty |= ILO_DIRTY_SCISSOR;
 }
@@ -581,11 +583,24 @@ static void
 ilo_set_viewport_states(struct pipe_context *pipe,
                         unsigned start_slot,
                         unsigned num_viewports,
-                        const struct pipe_viewport_state *state)
+                        const struct pipe_viewport_state *viewports)
 {
    struct ilo_context *ilo = ilo_context(pipe);
 
-   ilo->viewport = *state;
+   if (viewports) {
+      unsigned i;
+
+      for (i = 0; i < num_viewports; i++)
+         ilo->viewport.states[start_slot + i] = viewports[i];
+
+      if (ilo->viewport.count < start_slot + num_viewports)
+         ilo->viewport.count = start_slot + num_viewports;
+   }
+   else {
+      if (ilo->viewport.count <= start_slot + num_viewports &&
+          ilo->viewport.count > start_slot)
+         ilo->viewport.count = start_slot;
+   }
 
    ilo->dirty |= ILO_DIRTY_VIEWPORT;
 }