diff options
author | Ilia Mirkin <[email protected]> | 2016-11-16 21:25:12 -0500 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2016-11-23 20:33:50 -0500 |
commit | 1a80ec0cd1f3f66a33fc708e0112c88f4fba122d (patch) | |
tree | 967af42f2d040c6edb68b818e63f77af805f7f9e /src | |
parent | cec515999ccf224a967f00c4bc2c3e47d782d65e (diff) |
swr: [rasterizer core] pipe renderTargetArrayIndex through to clears
Currently clears only operate on the 0th array index (ignoring surface
layout parameters). Instead normalize to take a RTAI like all the
load/store tile logic does, and use ComputeSurfaceAddress to properly
take the surface state's lod/array index into account.
Signed-off-by: Ilia Mirkin <[email protected]>
Reviewed-by: Tim Rowley <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/api.cpp | 3 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/api.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/backend.cpp | 20 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp | 20 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_clear.cpp | 2 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_memory.h | 4 |
7 files changed, 35 insertions, 20 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index 6ade65ac610..383a7ad65be 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -1476,6 +1476,7 @@ void SWR_API SwrStoreTiles( /// @brief SwrClearRenderTarget - Clear attached render targets / depth / stencil /// @param hContext - Handle passed back from SwrCreateContext /// @param attachmentMask - combination of SWR_ATTACHMENT_*_BIT attachments to clear +/// @param renderTargetArrayIndex - the RT array index to clear /// @param clearColor - color use for clearing render targets /// @param z - depth value use for clearing depth buffer /// @param stencil - stencil value used for clearing stencil buffer @@ -1483,6 +1484,7 @@ void SWR_API SwrStoreTiles( void SWR_API SwrClearRenderTarget( HANDLE hContext, uint32_t attachmentMask, + uint32_t renderTargetArrayIndex, const float clearColor[4], float z, uint8_t stencil, @@ -1503,6 +1505,7 @@ void SWR_API SwrClearRenderTarget( pDC->FeWork.desc.clear.rect = clearRect; pDC->FeWork.desc.clear.rect &= g_MaxScissorRect; pDC->FeWork.desc.clear.attachmentMask = attachmentMask; + pDC->FeWork.desc.clear.renderTargetArrayIndex = renderTargetArrayIndex; pDC->FeWork.desc.clear.clearDepth = z; pDC->FeWork.desc.clear.clearRTColor[0] = clearColor[0]; pDC->FeWork.desc.clear.clearRTColor[1] = clearColor[1]; diff --git a/src/gallium/drivers/swr/rasterizer/core/api.h b/src/gallium/drivers/swr/rasterizer/core/api.h index 1a416373716..d0f29dd7333 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.h +++ b/src/gallium/drivers/swr/rasterizer/core/api.h @@ -137,10 +137,11 @@ typedef void(SWR_API *PFN_STORE_TILE)(HANDLE hPrivateContext, SWR_FORMAT srcForm /// @param renderTargetIndex - render target to store, can be color, depth or stencil /// @param x - destination x coordinate /// @param y - destination y coordinate +/// @param renderTargetArrayIndex - render target array offset from arrayIndex /// @param pClearColor - pointer to the hot tile's clear value typedef void(SWR_API *PFN_CLEAR_TILE)(HANDLE hPrivateContext, SWR_RENDERTARGET_ATTACHMENT rtIndex, - uint32_t x, uint32_t y, const float* pClearColor); + uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex, const float* pClearColor); ////////////////////////////////////////////////////////////////////////// /// @brief Callback to allow driver to update their copy of streamout write offset. @@ -559,6 +560,7 @@ void SWR_API SwrStoreTiles( /// @brief SwrClearRenderTarget - Clear attached render targets / depth / stencil /// @param hContext - Handle passed back from SwrCreateContext /// @param attachmentMask - combination of SWR_ATTACHMENT_*_BIT attachments to clear +/// @param renderTargetArrayIndex - the RT array index to clear /// @param clearColor - color use for clearing render targets /// @param z - depth value use for clearing depth buffer /// @param stencil - stencil value used for clearing stencil buffer @@ -566,6 +568,7 @@ void SWR_API SwrStoreTiles( void SWR_API SwrClearRenderTarget( HANDLE hContext, uint32_t attachmentMask, + uint32_t renderTargetArrayIndex, const float clearColor[4], float z, uint8_t stencil, diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.cpp b/src/gallium/drivers/swr/rasterizer/core/backend.cpp index c4e1dfdb90c..911dd5efe6e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/backend.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/backend.cpp @@ -37,7 +37,7 @@ #include <algorithm> -typedef void(*PFN_CLEAR_TILES)(DRAW_CONTEXT*, SWR_RENDERTARGET_ATTACHMENT rt, uint32_t, DWORD[4], const SWR_RECT& rect); +typedef void(*PFN_CLEAR_TILES)(DRAW_CONTEXT*, SWR_RENDERTARGET_ATTACHMENT rt, uint32_t, uint32_t, DWORD[4], const SWR_RECT& rect); static PFN_CLEAR_TILES sClearTilesTable[NUM_SWR_FORMATS]; ////////////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ void ClearRasterTile(uint8_t *pTileBuffer, simd16vector &value) #endif template<SWR_FORMAT format> -INLINE void ClearMacroTile(DRAW_CONTEXT *pDC, SWR_RENDERTARGET_ATTACHMENT rt, uint32_t macroTile, DWORD clear[4], const SWR_RECT& rect) +INLINE void ClearMacroTile(DRAW_CONTEXT *pDC, SWR_RENDERTARGET_ATTACHMENT rt, uint32_t macroTile, uint32_t renderTargetArrayIndex, DWORD clear[4], const SWR_RECT& rect) { // convert clear color to hottile format // clear color is in RGBA float/uint32 @@ -204,7 +204,7 @@ INLINE void ClearMacroTile(DRAW_CONTEXT *pDC, SWR_RENDERTARGET_ATTACHMENT rt, ui const uint32_t macroTileRowStep = (KNOB_MACROTILE_X_DIM / KNOB_TILE_X_DIM) * rasterTileStep; const uint32_t pitch = (FormatTraits<format>::bpp * KNOB_MACROTILE_X_DIM / 8); - HOTTILE *pHotTile = pDC->pContext->pHotTileMgr->GetHotTile(pDC->pContext, pDC, macroTile, rt, true, numSamples); + HOTTILE *pHotTile = pDC->pContext->pHotTileMgr->GetHotTile(pDC->pContext, pDC, macroTile, rt, true, numSamples, renderTargetArrayIndex); uint32_t rasterTileStartOffset = (ComputeTileOffset2D< TilingTraits<SWR_TILE_SWRZ, FormatTraits<format>::bpp > >(pitch, clearTile.xmin, clearTile.ymin)) * numSamples; uint8_t* pRasterTileRow = pHotTile->pBuffer + rasterTileStartOffset; //(ComputeTileOffset2D< TilingTraits<SWR_TILE_SWRZ, FormatTraits<format>::bpp > >(pitch, x, y)) * numSamples; @@ -249,7 +249,7 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo { mask &= ~(1 << rt); - HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, (SWR_RENDERTARGET_ATTACHMENT)rt, true, numSamples); + HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, (SWR_RENDERTARGET_ATTACHMENT)rt, true, numSamples, pClear->renderTargetArrayIndex); // All we want to do here is to mark the hot tile as being in a "needs clear" state. pHotTile->clearData[0] = *(DWORD*)&(pClear->clearRTColor[0]); @@ -262,14 +262,14 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo if (pClear->attachmentMask & SWR_ATTACHMENT_DEPTH_BIT) { - HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, SWR_ATTACHMENT_DEPTH, true, numSamples); + HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, SWR_ATTACHMENT_DEPTH, true, numSamples, pClear->renderTargetArrayIndex); pHotTile->clearData[0] = *(DWORD*)&pClear->clearDepth; pHotTile->state = HOTTILE_CLEAR; } if (pClear->attachmentMask & SWR_ATTACHMENT_STENCIL_BIT) { - HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, SWR_ATTACHMENT_STENCIL, true, numSamples); + HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, SWR_ATTACHMENT_STENCIL, true, numSamples, pClear->renderTargetArrayIndex); pHotTile->clearData[0] = pClear->clearStencil; pHotTile->state = HOTTILE_CLEAR; @@ -300,7 +300,7 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo { mask &= ~(1 << rt); - pfnClearTiles(pDC, (SWR_RENDERTARGET_ATTACHMENT)rt, macroTile, clearData, pClear->rect); + pfnClearTiles(pDC, (SWR_RENDERTARGET_ATTACHMENT)rt, macroTile, pClear->renderTargetArrayIndex, clearData, pClear->rect); } } @@ -311,7 +311,7 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo PFN_CLEAR_TILES pfnClearTiles = sClearTilesTable[KNOB_DEPTH_HOT_TILE_FORMAT]; SWR_ASSERT(pfnClearTiles != nullptr); - pfnClearTiles(pDC, SWR_ATTACHMENT_DEPTH, macroTile, clearData, pClear->rect); + pfnClearTiles(pDC, SWR_ATTACHMENT_DEPTH, macroTile, pClear->renderTargetArrayIndex, clearData, pClear->rect); } if (pClear->attachmentMask & SWR_ATTACHMENT_STENCIL_BIT) @@ -320,7 +320,7 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo clearData[0] = pClear->clearStencil; PFN_CLEAR_TILES pfnClearTiles = sClearTilesTable[KNOB_STENCIL_HOT_TILE_FORMAT]; - pfnClearTiles(pDC, SWR_ATTACHMENT_STENCIL, macroTile, clearData, pClear->rect); + pfnClearTiles(pDC, SWR_ATTACHMENT_STENCIL, macroTile, pClear->renderTargetArrayIndex, clearData, pClear->rect); } AR_END(BEClear, 1); @@ -363,7 +363,7 @@ void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile PFN_CLEAR_TILES pfnClearTiles = sClearTilesTable[srcFormat]; SWR_ASSERT(pfnClearTiles != nullptr); - pfnClearTiles(pDC, attachment, macroTile, pHotTile->clearData, pDesc->rect); + pfnClearTiles(pDC, attachment, macroTile, pHotTile->renderTargetArrayIndex, pHotTile->clearData, pDesc->rect); } if (pHotTile->state == HOTTILE_DIRTY || pDesc->postStoreTileState == (SWR_TILE_STATE)HOTTILE_DIRTY) diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h index 21ea827983f..6e596b4900d 100644 --- a/src/gallium/drivers/swr/rasterizer/core/context.h +++ b/src/gallium/drivers/swr/rasterizer/core/context.h @@ -104,6 +104,7 @@ struct CLEAR_DESC { SWR_RECT rect; uint32_t attachmentMask; + uint32_t renderTargetArrayIndex; float clearRTColor[4]; // RGBA_32F float clearDepth; // [0..1] uint8_t clearStencil; diff --git a/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp b/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp index d001cb6b5cb..717d12cef9d 100644 --- a/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp +++ b/src/gallium/drivers/swr/rasterizer/memory/ClearTile.cpp @@ -33,7 +33,7 @@ #include "memory/tilingtraits.h" #include "memory/Convert.h" -typedef void(*PFN_STORE_TILES_CLEAR)(const float*, SWR_SURFACE_STATE*, UINT, UINT); +typedef void(*PFN_STORE_TILES_CLEAR)(const float*, SWR_SURFACE_STATE*, UINT, UINT, uint32_t); ////////////////////////////////////////////////////////////////////////// /// Clear Raster Tile Function Tables. @@ -57,11 +57,16 @@ struct StoreRasterTileClear const uint8_t* dstFormattedColor, UINT dstBytesPerPixel, SWR_SURFACE_STATE* pDstSurface, - UINT x, UINT y) // (x, y) pixel coordinate to start of raster tile. + UINT x, UINT y, // (x, y) pixel coordinate to start of raster tile. + uint32_t renderTargetArrayIndex) { // Compute destination address for raster tile. - uint8_t* pDstTile = (uint8_t*)pDstSurface->pBaseAddress + - (y * pDstSurface->pitch) + (x * dstBytesPerPixel); + uint8_t* pDstTile = (uint8_t*)ComputeSurfaceAddress<false, false>( + x, y, pDstSurface->arrayIndex + renderTargetArrayIndex, + pDstSurface->arrayIndex + renderTargetArrayIndex, + 0, // sampleNum + pDstSurface->lod, + pDstSurface); // start of first row uint8_t* pDst = pDstTile; @@ -106,7 +111,7 @@ struct StoreMacroTileClear static void StoreClear( const float *pColor, SWR_SURFACE_STATE* pDstSurface, - UINT x, UINT y) + UINT x, UINT y, uint32_t renderTargetArrayIndex) { UINT dstBytesPerPixel = (FormatTraits<DstFormat>::bpp / 8); @@ -129,7 +134,7 @@ struct StoreMacroTileClear { for (UINT col = 0; col < KNOB_MACROTILE_X_DIM; col += KNOB_TILE_X_DIM) { - StoreRasterTileClear<SrcFormat, DstFormat>::StoreClear(dstFormattedColor, dstBytesPerPixel, pDstSurface, (x + col), (y + row)); + StoreRasterTileClear<SrcFormat, DstFormat>::StoreClear(dstFormattedColor, dstBytesPerPixel, pDstSurface, (x + col), (y + row), renderTargetArrayIndex); } } } @@ -146,6 +151,7 @@ void StoreHotTileClear( SWR_RENDERTARGET_ATTACHMENT renderTargetIndex, UINT x, UINT y, + uint32_t renderTargetArrayIndex, const float* pClearColor) { PFN_STORE_TILES_CLEAR pfnStoreTilesClear = NULL; @@ -167,7 +173,7 @@ void StoreHotTileClear( /// @todo Once all formats are supported then if check can go away. This is to help us near term to make progress. if (pfnStoreTilesClear != NULL) { - pfnStoreTilesClear(pClearColor, pDstSurface, x, y); + pfnStoreTilesClear(pClearColor, pDstSurface, x, y, renderTargetArrayIndex); } } diff --git a/src/gallium/drivers/swr/swr_clear.cpp b/src/gallium/drivers/swr/swr_clear.cpp index ff3eca85f00..d47ad003393 100644 --- a/src/gallium/drivers/swr/swr_clear.cpp +++ b/src/gallium/drivers/swr/swr_clear.cpp @@ -59,7 +59,7 @@ swr_clear(struct pipe_context *pipe, #endif swr_update_draw_context(ctx); - SwrClearRenderTarget(ctx->swrContext, clearMask, color->f, depth, stencil, + SwrClearRenderTarget(ctx->swrContext, clearMask, 0, color->f, depth, stencil, ctx->swr_scissor); } diff --git a/src/gallium/drivers/swr/swr_memory.h b/src/gallium/drivers/swr/swr_memory.h index 9ef468a90d4..b8ce27f4d96 100644 --- a/src/gallium/drivers/swr/swr_memory.h +++ b/src/gallium/drivers/swr/swr_memory.h @@ -42,6 +42,7 @@ void StoreHotTileClear( SWR_RENDERTARGET_ATTACHMENT renderTargetIndex, UINT x, UINT y, + uint32_t renderTargetArrayIndex, const float* pClearColor); INLINE void @@ -77,13 +78,14 @@ swr_StoreHotTileClear(HANDLE hPrivateContext, SWR_RENDERTARGET_ATTACHMENT renderTargetIndex, UINT x, UINT y, + uint32_t renderTargetArrayIndex, const float* pClearColor) { // Grab destination surface state from private context swr_draw_context *pDC = (swr_draw_context*)hPrivateContext; SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex]; - StoreHotTileClear(pDstSurface, renderTargetIndex, x, y, pClearColor); + StoreHotTileClear(pDstSurface, renderTargetIndex, x, y, renderTargetArrayIndex, pClearColor); } void InitSimLoadTilesTable(); |