<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div style="">
<blockquote type="cite" class="">
<div class="">On Nov 19, 2016, at 9:48 AM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>><br class="">
---<br class="">
src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp | 10 ++++++++--<br class="">
1 file changed, 8 insertions(+), 2 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp b/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp<br class="">
index 31a40a3..ee13f55 100644<br class="">
--- a/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp<br class="">
+++ b/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp<br class="">
@@ -60,6 +60,12 @@ struct StoreRasterTileClear<br class="">
UINT x, UINT y, // (x, y) pixel coordinate to start of raster tile.<br class="">
uint32_t renderTargetArrayIndex)<br class="">
{<br class="">
+ // If we're outside of the surface, stop.<br class="">
+ uint32_t lodWidth = std::max<uint32_t>(pDstSurface->width >> pDstSurface->lod, 1U);<br class="">
+ uint32_t lodHeight = std::max<uint32_t>(pDstSurface->height >> pDstSurface->lod, 1U);<br class="">
+ if (x >= lodWidth || y >= lodHeight)<br class="">
+ return;<br class="">
+<br class="">
// Compute destination address for raster tile.<br class="">
uint8_t* pDstTile = (uint8_t*)ComputeSurfaceAddress<false, false>(<br class="">
x, y, pDstSurface->arrayIndex + renderTargetArrayIndex,<br class="">
@@ -73,7 +79,7 @@ struct StoreRasterTileClear<br class="">
UINT dstBytesPerRow = 0;<br class="">
<br class="">
// For each raster tile pixel in row 0 (rx, 0)<br class="">
- for (UINT rx = 0; (rx < KNOB_TILE_X_DIM) && ((x + rx) < pDstSurface->width); ++rx)<br class="">
+ for (UINT rx = 0; (rx < KNOB_TILE_X_DIM) && ((x + rx) < lodWidth); ++rx)<br class="">
{<br class="">
memcpy(pDst, dstFormattedColor, dstBytesPerPixel);<br class="">
<br class="">
@@ -86,7 +92,7 @@ struct StoreRasterTileClear<br class="">
pDst = pDstTile + pDstSurface->pitch;<br class="">
<br class="">
// For each remaining row in the rest of the raster tile<br class="">
- for (UINT ry = 1; (ry < KNOB_TILE_Y_DIM) && ((y + ry) < pDstSurface->height); ++ry)<br class="">
+ for (UINT ry = 1; (ry < KNOB_TILE_Y_DIM) && ((y + ry) < lodHeight); ++ry)<br class="">
{<br class="">
// copy row<br class="">
memcpy(pDst, pDstTile, dstBytesPerRow);<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>