iris: Enable guardband clipping
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 3 Dec 2018 10:08:23 +0000 (02:08 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:10 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_state.c

index d86107fad58db10bb331f625efe153f7c0cd9710..86e41b690dbdeda7cae9cb6c1c51144b8dc60f4e 100644 (file)
@@ -1890,7 +1890,6 @@ viewport_extent(const struct pipe_viewport_state *state, int axis, float sign)
    return copysignf(state->scale[axis], sign) + state->translate[axis];
 }
 
-#if 0
 static void
 calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
                          float m00, float m11, float m30, float m31,
@@ -1970,7 +1969,6 @@ calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
       *ymax = 0.0f;
    }
 }
-#endif
 
 /**
  * The pipe->set_viewport_states() driver hook.
@@ -3952,12 +3950,18 @@ iris_upload_dirty_render_state(struct iris_context *ice,
 
       for (unsigned i = 0; i < ice->state.num_viewports; i++) {
          const struct pipe_viewport_state *state = &ice->state.viewports[i];
+         float gb_xmin, gb_xmax, gb_ymin, gb_ymax;
 
          float vp_xmin = viewport_extent(state, 0, -1.0f);
          float vp_xmax = viewport_extent(state, 0,  1.0f);
          float vp_ymin = viewport_extent(state, 1, -1.0f);
          float vp_ymax = viewport_extent(state, 1,  1.0f);
 
+         calculate_guardband_size(cso_fb->width, cso_fb->height,
+                                  state->scale[0], state->scale[1],
+                                  state->translate[0], state->translate[1],
+                                  &gb_xmin, &gb_xmax, &gb_ymin, &gb_ymax);
+
          iris_pack_state(GENX(SF_CLIP_VIEWPORT), vp_map, vp) {
             vp.ViewportMatrixElementm00 = state->scale[0];
             vp.ViewportMatrixElementm11 = state->scale[1];
@@ -3965,13 +3969,10 @@ iris_upload_dirty_render_state(struct iris_context *ice,
             vp.ViewportMatrixElementm30 = state->translate[0];
             vp.ViewportMatrixElementm31 = state->translate[1];
             vp.ViewportMatrixElementm32 = state->translate[2];
-            /* XXX: in i965 this is computed based on the drawbuffer size,
-             * but we don't have that here...
-             */
-            vp.XMinClipGuardband = -1.0;
-            vp.XMaxClipGuardband = 1.0;
-            vp.YMinClipGuardband = -1.0;
-            vp.YMaxClipGuardband = 1.0;
+            vp.XMinClipGuardband = gb_xmin;
+            vp.XMaxClipGuardband = gb_xmax;
+            vp.YMinClipGuardband = gb_ymin;
+            vp.YMaxClipGuardband = gb_ymax;
             vp.XMinViewPort = MAX2(vp_xmin, 0);
             vp.XMaxViewPort = MIN2(vp_xmax, cso_fb->width) - 1;
             vp.YMinViewPort = MAX2(vp_ymin, 0);