[Mesa-dev] [PATCH] anv: Port the guardband setting code from i965
Jason Ekstrand
jason at jlekstrand.net
Tue Dec 6 00:36:57 UTC 2016
---
src/intel/vulkan/gen8_cmd_buffer.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c
index 3e4aa9b..6b56d06 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -44,6 +44,22 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
for (uint32_t i = 0; i < count; i++) {
const VkViewport *vp = &viewports[i];
+ /* According to the "Vertex X,Y Clamping and Quantization" section of
+ * the Strips and Fans documentation, objects must not have a
+ * screen-space extents of over 8192 pixels, or they may be
+ * mis-rasterized. The maximum screen space coordinates of a small
+ * object may larger, but we have no way to enforce the object size
+ * other than through clipping.
+ *
+ * If you're surprised that we set clip to -gbx to +gbx and it seems
+ * like we'll end up with 16384 wide, note that for a 8192-wide render
+ * target, we'll end up with a normal (-1, 1) clip volume that just
+ * covers the drawable.
+ */
+ const float maximum_guardband_extent = 8192;
+ const float gbx = maximum_guardband_extent / vp->width;
+ const float gby = maximum_guardband_extent / vp->height;
+
/* The gen7 state struct has just the matrix and guardband fields, the
* gen8 struct adds the min/max viewport fields. */
struct GENX(SF_CLIP_VIEWPORT) sf_clip_viewport = {
@@ -53,10 +69,10 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
.ViewportMatrixElementm30 = vp->x + vp->width / 2,
.ViewportMatrixElementm31 = vp->y + vp->height / 2,
.ViewportMatrixElementm32 = 0.0,
- .XMinClipGuardband = -1.0f,
- .XMaxClipGuardband = 1.0f,
- .YMinClipGuardband = -1.0f,
- .YMaxClipGuardband = 1.0f,
+ .XMinClipGuardband = -gbx,
+ .XMaxClipGuardband = gbx,
+ .YMinClipGuardband = -gbx,
+ .YMaxClipGuardband = gbx,
.XMinViewPort = vp->x,
.XMaxViewPort = vp->x + vp->width - 1,
.YMinViewPort = vp->y,
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list