diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-24 17:22:34 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-24 17:29:19 +0100 |
commit | 1099a3515b6a69e2ff360d8e6b1df71e3ea5c213 (patch) | |
tree | 3e09efea0b5a62c414b0535ba829553c4170dc68 | |
parent | fb6a00571c818c738d66bc04dc75e79491878f78 (diff) |
drm/intel: Fix common off-by-one by rewriting the [XY]MAX macro.
Many rectangles in the command stream are specified as inclusive rects,
i.e. the max values are (width-1, height-1), which is easy to neglect.
-rw-r--r-- | src/drm/cairo-drm-i915-private.h | 2 | ||||
-rw-r--r-- | src/drm/cairo-drm-i915-surface.c | 24 | ||||
-rw-r--r-- | src/drm/cairo-drm-i965-shader.c | 12 | ||||
-rw-r--r-- | src/drm/cairo-drm-intel-command-private.h | 4 |
4 files changed, 15 insertions, 27 deletions
diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h index f03d5d76..1581cab8 100644 --- a/src/drm/cairo-drm-i915-private.h +++ b/src/drm/cairo-drm-i915-private.h @@ -705,7 +705,7 @@ struct i915_device { cairo_list_t image_caches[2]; - uint32_t batch_header[18]; + uint32_t batch_header[13]; uint32_t batch_base[I915_BATCH_SIZE / sizeof (uint32_t)]; uint8_t vbo_base[I915_VBO_SIZE]; }; diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c index b9adf92a..f80612cf 100644 --- a/src/drm/cairo-drm-i915-surface.c +++ b/src/drm/cairo-drm-i915-surface.c @@ -136,12 +136,6 @@ static const uint32_t i915_batch_setup[] = { CSB_TCB (6, 6) | CSB_TCB (7, 7), - _3DSTATE_RASTER_RULES_CMD | - ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE | - ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX (1) | - ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX (2) | - ENABLE_TEXKILL_3D_4D | TEXKILL_4D, - _3DSTATE_MODES_4_CMD | ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC (LOGICOP_COPY), _3DSTATE_LOAD_STATE_IMMEDIATE_1 | @@ -165,16 +159,10 @@ static const uint32_t i915_batch_setup[] = { S6_COLOR_WRITE_ENABLE, _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT, - _3DSTATE_DEPTH_SUBRECT_DISABLE, /* disable indirect state */ _3DSTATE_LOAD_INDIRECT, 0, - - _3DSTATE_STIPPLE, - 0, - - _3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE, }; static const cairo_surface_backend_t i915_surface_backend; @@ -559,7 +547,7 @@ i915_batch_flush (i915_device_t *device) return CAIRO_STATUS_SUCCESS; i915_batch_emit_dword (device, MI_BATCH_BUFFER_END); - if ((device->batch.used & 1) != (sizeof (device->batch_header) & 4)) + if ((device->batch.used & 1) != ((sizeof (device->batch_header)>>2) & 1)) i915_batch_emit_dword (device, MI_NOOP); length = (device->batch.used << 2) + sizeof (device->batch_header); @@ -1091,7 +1079,7 @@ i915_blt (i915_surface_t *src, OUT_DWORD (cmd); OUT_DWORD (br13); OUT_DWORD ((dst_y << 16) | dst_x); - OUT_DWORD (((dst_y + height) << 16) | (dst_x + width)); + OUT_DWORD (((dst_y + height - 1) << 16) | (dst_x + width - 1)); OUT_RELOC_FENCED (dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); OUT_DWORD ((src_y << 16) | src_x); OUT_DWORD (src->intel.drm.stride); @@ -1198,7 +1186,7 @@ i915_clear_boxes (i915_surface_t *dst, OUT_DWORD (cmd); OUT_DWORD (br13); OUT_DWORD ((y1 << 16) | x1); - OUT_DWORD ((y2 << 16) | x2); + OUT_DWORD (((y2 - 1) << 16) | (x2 - 1)); OUT_RELOC_FENCED (dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); OUT_DWORD (clear); } @@ -1393,7 +1381,7 @@ i915_blt_boxes (i915_surface_t *dst, OUT_DWORD (cmd); OUT_DWORD (br13); OUT_DWORD ((y1 << 16) | x1); - OUT_DWORD ((y2 << 16) | x2); + OUT_DWORD (((y2 - 1) << 16) | (x2 - 1)); OUT_RELOC_FENCED (dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); OUT_DWORD (((y1 + ty) << 16) | (x1 + tx)); OUT_DWORD (src->intel.drm.stride); @@ -1712,8 +1700,8 @@ i915_surface_clear (i915_surface_t *dst) OUT_DWORD (cmd); OUT_DWORD (br13); OUT_DWORD (0); - OUT_DWORD ((dst->intel.drm.height << 16) | - dst->intel.drm.width); + OUT_DWORD (((dst->intel.drm.height - 1) << 16) | + (dst->intel.drm.width - 1)); OUT_RELOC_FENCED (dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); OUT_DWORD (clear); diff --git a/src/drm/cairo-drm-i965-shader.c b/src/drm/cairo-drm-i965-shader.c index b58b8e4e..515b4a63 100644 --- a/src/drm/cairo-drm-i965-shader.c +++ b/src/drm/cairo-drm-i965-shader.c @@ -2527,8 +2527,8 @@ i965_emit_composite (i965_device_t *device, /* The drawing rectangle clipping is always on. Set it to values that * shouldn't do any clipping. */ - draw_rectangle = DRAW_YMAX (shader->target->intel.drm.height - 1) | - DRAW_XMAX (shader->target->intel.drm.width - 1); + draw_rectangle = DRAW_YMAX (shader->target->intel.drm.height) | + DRAW_XMAX (shader->target->intel.drm.width); if (draw_rectangle != device->draw_rectangle) { OUT_BATCH (BRW_3DSTATE_DRAWING_RECTANGLE | 2); OUT_BATCH (0x00000000); /* ymin, xmin */ @@ -2789,8 +2789,8 @@ i965_clipped_vertices (i965_device_t *device, /* XXX scissor? */ OUT_BATCH (BRW_3DSTATE_DRAWING_RECTANGLE | 2); OUT_BATCH (DRAW_YMIN (rect.y) | DRAW_XMIN (rect.x)); - OUT_BATCH (DRAW_YMAX (rect.y + rect.height - 1) | - DRAW_XMIN (rect.x + rect.width - 1)); + OUT_BATCH (DRAW_YMAX (rect.y + rect.height) | + DRAW_XMAX (rect.x + rect.width)); OUT_BATCH (0x00000000); /* yorigin, xorigin */ OUT_BATCH (BRW_3DPRIMITIVE | @@ -2826,8 +2826,8 @@ i965_clipped_vertices (i965_device_t *device, /* XXX scissor? */ OUT_BATCH (BRW_3DSTATE_DRAWING_RECTANGLE | 2); OUT_BATCH (DRAW_YMIN (rect.y) | DRAW_XMIN (rect.x)); - OUT_BATCH (DRAW_YMAX (rect.y + rect.height - 1) | - DRAW_XMIN (rect.x + rect.width - 1)); + OUT_BATCH (DRAW_YMAX (rect.y + rect.height) | + DRAW_XMAX (rect.x + rect.width)); OUT_BATCH (0x00000000); /* yorigin, xorigin */ OUT_BATCH (BRW_3DPRIMITIVE | diff --git a/src/drm/cairo-drm-intel-command-private.h b/src/drm/cairo-drm-intel-command-private.h index 3860c3f2..a93ac12a 100644 --- a/src/drm/cairo-drm-intel-command-private.h +++ b/src/drm/cairo-drm-intel-command-private.h @@ -203,8 +203,8 @@ #define DRAW_YMIN(x) ((x)<<16) #define DRAW_XMIN(x) (x) /* Dword 3 */ -#define DRAW_YMAX(x) ((x)<<16) -#define DRAW_XMAX(x) (x) +#define DRAW_YMAX(x) ((x-1)<<16) +#define DRAW_XMAX(x) (x-1) /* Dword 4 */ #define DRAW_YORG(x) ((x)<<16) #define DRAW_XORG(x) (x) |