12b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley/****************************************************************************
22b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * Copyright (C) 2015 Intel Corporation.   All Rights Reserved.
32b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley *
42b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * Permission is hereby granted, free of charge, to any person obtaining a
52b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * copy of this software and associated documentation files (the "Software"),
62b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * to deal in the Software without restriction, including without limitation
72b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * the rights to use, copy, modify, merge, publish, distribute, sublicense,
82b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * and/or sell copies of the Software, and to permit persons to whom the
92b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * Software is furnished to do so, subject to the following conditions:
102b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley *
112b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * The above copyright notice and this permission notice (including the next
122b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * paragraph) shall be included in all copies or substantial portions of the
132b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * Software.
142b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley *
152b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
162b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
172b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
182b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
192b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
202b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
212b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley * IN THE SOFTWARE.
222b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley ***************************************************************************/
232b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
242b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley#pragma once
252b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
262b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyvoid LoadHotTile(
27ec089cd987212566da146f0ddaf11dc28efec7adTim Rowley    const SWR_SURFACE_STATE *pSrcSurface,
282b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_FORMAT dstFormat,
292b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
302b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    UINT x, UINT y, uint32_t renderTargetArrayIndex,
3184f857bef79d66d229a001554719e9299ebe0881Tim Rowley    uint8_t *pDstHotTile);
322b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
332550b04179614da4c71dbef195d06a7f53273438Tim Rowleyvoid StoreHotTileToSurface(
342b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_SURFACE_STATE *pDstSurface,
352b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_FORMAT srcFormat,
362b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
372b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    UINT x, UINT y, uint32_t renderTargetArrayIndex,
3884f857bef79d66d229a001554719e9299ebe0881Tim Rowley    uint8_t *pSrcHotTile);
392b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
402b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyvoid StoreHotTileClear(
412b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_SURFACE_STATE *pDstSurface,
422b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
432b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    UINT x,
442b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    UINT y,
451a80ec0cd1f3f66a33fc708e0112c88f4fba122dIlia Mirkin    uint32_t renderTargetArrayIndex,
462b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley    const float* pClearColor);
472b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
482b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim RowleyINLINE void
492b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyswr_LoadHotTile(HANDLE hPrivateContext,
502b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                SWR_FORMAT dstFormat,
512b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
522b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                UINT x, UINT y,
5384f857bef79d66d229a001554719e9299ebe0881Tim Rowley                uint32_t renderTargetArrayIndex, uint8_t* pDstHotTile)
542b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley{
552b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   // Grab source surface state from private context
562b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
572b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   SWR_SURFACE_STATE *pSrcSurface = &pDC->renderTargets[renderTargetIndex];
582b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
592b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   LoadHotTile(pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile);
602b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley}
612b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
622b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim RowleyINLINE void
632b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyswr_StoreHotTile(HANDLE hPrivateContext,
642b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                 SWR_FORMAT srcFormat,
652b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
662b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                 UINT x, UINT y,
6784f857bef79d66d229a001554719e9299ebe0881Tim Rowley                 uint32_t renderTargetArrayIndex, uint8_t* pSrcHotTile)
682b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley{
692b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   // Grab destination surface state from private context
702b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
712b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex];
722b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
732550b04179614da4c71dbef195d06a7f53273438Tim Rowley   StoreHotTileToSurface(pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile);
742b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley}
752b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
762b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim RowleyINLINE void
772b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyswr_StoreHotTileClear(HANDLE hPrivateContext,
782b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                      SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
792b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                      UINT x,
802b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                      UINT y,
811a80ec0cd1f3f66a33fc708e0112c88f4fba122dIlia Mirkin                      uint32_t renderTargetArrayIndex,
822b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley                      const float* pClearColor)
832b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley{
842b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   // Grab destination surface state from private context
852b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
862b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex];
872b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
881a80ec0cd1f3f66a33fc708e0112c88f4fba122dIlia Mirkin   StoreHotTileClear(pDstSurface, renderTargetIndex, x, y, renderTargetArrayIndex, pClearColor);
892b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley}
902b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
912b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyvoid InitSimLoadTilesTable();
922b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyvoid InitSimStoreTilesTable();
932b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowleyvoid InitSimClearTilesTable();
942b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley
952b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley/* Init Load/Store/ClearTiles Tables */
962b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim RowleyINLINE void swr_InitMemoryModule()
972b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley{
982b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   InitSimLoadTilesTable();
992b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   InitSimStoreTilesTable();
1002b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley   InitSimClearTilesTable();
1012b2d3680bf164ec4f8b50436b96c3fc195318ea5Tim Rowley}
102