intel/guardband: Take min/max instead of total size

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14961>
This commit is contained in:
Jason Ekstrand 2022-02-28 14:17:59 -06:00
parent d89d6c7a4d
commit 12d815bcac
4 changed files with 11 additions and 10 deletions

View File

@ -5967,7 +5967,7 @@ crocus_upload_dirty_render_state(struct crocus_context *ice,
float vp_ymin = viewport_extent(state, 1, -1.0f);
float vp_ymax = viewport_extent(state, 1, 1.0f);
#endif
intel_calculate_guardband_size(cso_fb->width, cso_fb->height,
intel_calculate_guardband_size(0, cso_fb->width, 0, cso_fb->height,
state->scale[0], state->scale[1],
state->translate[0], state->translate[1],
&gb_xmin, &gb_xmax, &gb_ymin, &gb_ymax);

View File

@ -5850,7 +5850,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
float vp_ymin = viewport_extent(state, 1, -1.0f);
float vp_ymax = viewport_extent(state, 1, 1.0f);
intel_calculate_guardband_size(cso_fb->width, cso_fb->height,
intel_calculate_guardband_size(0, cso_fb->width, 0, cso_fb->height,
state->scale[0], state->scale[1],
state->translate[0], state->translate[1],
&gb_xmin, &gb_xmax, &gb_ymin, &gb_ymax);

View File

@ -24,7 +24,8 @@
#define INTEL_GUARDBAND_H
static inline void
intel_calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
intel_calculate_guardband_size(uint32_t x_min, uint32_t x_max,
uint32_t y_min, uint32_t y_max,
float m00, float m11, float m30, float m31,
float *xmin, float *xmax,
float *ymin, float *ymax)
@ -70,7 +71,7 @@ intel_calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
/* Workaround: prevent gpu hangs on SandyBridge
* by disabling guardband clipping for odd dimensions.
*/
if (GFX_VER == 6 && (fb_width & 1 || fb_height & 1)) {
if (GFX_VER == 6 && (x_min & 1 || x_max & 1 || y_min & 1 || y_max & 1)) {
*xmin = -1.0f;
*xmax = 1.0f;
*ymin = -1.0f;
@ -80,10 +81,10 @@ intel_calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
if (m00 != 0 && m11 != 0) {
/* First, we compute the screen-space render area */
const float ss_ra_xmin = MIN3( 0, m30 + m00, m30 - m00);
const float ss_ra_xmax = MAX3( fb_width, m30 + m00, m30 - m00);
const float ss_ra_ymin = MIN3( 0, m31 + m11, m31 - m11);
const float ss_ra_ymax = MAX3(fb_height, m31 + m11, m31 - m11);
const float ss_ra_xmin = MIN3(x_min, m30 + m00, m30 - m00);
const float ss_ra_xmax = MAX3(x_max, m30 + m00, m30 - m00);
const float ss_ra_ymin = MIN3(y_min, m31 + m11, m31 - m11);
const float ss_ra_ymax = MAX3(y_max, m31 + m11, m31 - m11);
/* We want the guardband to be centered on that */
const float ss_gb_xmin = (ss_ra_xmin + ss_ra_xmax) / 2 - gb_size;

View File

@ -77,9 +77,9 @@ gfx8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
* framebuffer at the time we emit the packet. Otherwise, we have
* fall back to a worst-case guardband of [-1, 1].
*/
intel_calculate_guardband_size(gfx->render_area.offset.x +
intel_calculate_guardband_size(0, gfx->render_area.offset.x +
gfx->render_area.extent.width,
gfx->render_area.offset.y +
0, gfx->render_area.offset.y +
gfx->render_area.extent.height,
sfv.ViewportMatrixElementm00,
sfv.ViewportMatrixElementm11,