2017-12-02 02:44:37 +08:00
|
|
|
/*==============================================================================
|
|
|
|
Copyright(c) 2017 Intel Corporation
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
copy of this software and associated documentation files(the "Software"),
|
|
|
|
to deal in the Software without restriction, including without limitation
|
|
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
and / or sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#include "Internal/Common/GmmLibInc.h"
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// This function does any special-case conversion from client-provided pseudo creation
|
|
|
|
/// parameters to actual parameters for Hiz, CCS, SeparateStencil and Depth buffers.
|
|
|
|
///
|
|
|
|
/// @param[in] pTexInfo: Reference to ::GMM_TEXTURE_INFO
|
|
|
|
///
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
2018-01-25 08:33:45 +08:00
|
|
|
GMM_STATUS GmmLib::GmmTextureCalc::PreProcessTexSpecialCases(GMM_TEXTURE_INFO *pTexInfo)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
GMM_STATUS Status = GMM_SUCCESS;
|
|
|
|
const GMM_PLATFORM_INFO *pPlatform = GMM_OVERRIDE_PLATFORM_INFO(pTexInfo);
|
|
|
|
|
|
|
|
if(!pTexInfo->Flags.Gpu.CCS &&
|
|
|
|
!pTexInfo->Flags.Gpu.MCS &&
|
|
|
|
!pTexInfo->Flags.Gpu.HiZ &&
|
|
|
|
!pTexInfo->Flags.Gpu.SeparateStencil &&
|
|
|
|
!pTexInfo->Flags.Gpu.MMC)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
// Fast-out for non-special-cases.
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
2018-01-25 08:33:45 +08:00
|
|
|
else if(pTexInfo->Flags.Gpu.HiZ) // ######################################
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2017-12-09 03:19:18 +08:00
|
|
|
// With HiZ surface creation, clients send the size/etc. parameters of
|
|
|
|
// the associated Depth Buffer--and here we convert to the appropriate
|
2017-12-02 02:44:37 +08:00
|
|
|
// HiZ creation parameters...
|
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if((pTexInfo->BaseWidth > 0) &&
|
|
|
|
(pTexInfo->BaseWidth <= pPlatform->HiZ.MaxWidth) &&
|
|
|
|
(pTexInfo->BaseHeight > 0) &&
|
|
|
|
(pTexInfo->BaseHeight <= pPlatform->HiZ.MaxHeight) &&
|
|
|
|
(pTexInfo->Depth <= ((pTexInfo->Type == RESOURCE_3D) ?
|
|
|
|
pPlatform->HiZ.MaxDepth :
|
|
|
|
1)) &&
|
|
|
|
(pTexInfo->ArraySize <= ((pTexInfo->Type == RESOURCE_3D) ?
|
|
|
|
1 :
|
|
|
|
(pTexInfo->Type == RESOURCE_CUBE) ?
|
|
|
|
pPlatform->HiZ.MaxArraySize / 6 :
|
|
|
|
pPlatform->HiZ.MaxArraySize)) &&
|
|
|
|
// SKL+ does not support HiZ surfaces for 1D and 3D surfaces
|
|
|
|
((GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) < IGFX_GEN9_CORE) ||
|
|
|
|
(pTexInfo->Type != RESOURCE_1D && pTexInfo->Type != RESOURCE_3D)))
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2017-12-09 03:19:18 +08:00
|
|
|
uint32_t Z_Width, Z_Height, Z_Depth;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
|
|
|
// Latch Z_[Width/Height/Depth]...
|
2018-01-25 08:33:45 +08:00
|
|
|
Z_Width = GFX_ULONG_CAST(pTexInfo->BaseWidth);
|
2017-12-02 02:44:37 +08:00
|
|
|
Z_Height = pTexInfo->BaseHeight;
|
2018-01-25 08:33:45 +08:00
|
|
|
if((pTexInfo->Type == RESOURCE_1D) ||
|
|
|
|
(pTexInfo->Type == RESOURCE_2D))
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
Z_Depth = GFX_MAX(pTexInfo->ArraySize, 1);
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
2018-01-25 08:33:45 +08:00
|
|
|
else if(pTexInfo->Type == RESOURCE_3D)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
Z_Depth = pTexInfo->Depth;
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
2018-01-25 08:33:45 +08:00
|
|
|
else if(pTexInfo->Type == RESOURCE_CUBE)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2017-12-09 03:19:18 +08:00
|
|
|
// HW doesn't allow HiZ cube arrays, but GMM is allowing because
|
2017-12-02 02:44:37 +08:00
|
|
|
// clients will redescribe depth/HiZ cube arrays as 2D arrays.
|
|
|
|
Z_Depth = 6 * GFX_MAX(pTexInfo->ArraySize, 1);
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
|
|
|
else
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
__GMM_ASSERT(0); // Illegal--Should have caught at upper IF check.
|
|
|
|
Z_Depth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// HZ_[Width/Height/QPitch] Calculation...
|
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
uint32_t h0, h1, hL, i, NumSamples, QPitch, Z_HeightL;
|
|
|
|
uint32_t HZ_HAlign = 16, HZ_VAlign = 8;
|
2018-03-26 14:54:39 +08:00
|
|
|
uint8_t HZ_DepthRows = pPlatform->HiZPixelsPerByte;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
|
|
|
// HZ operates in pixel space starting from SKL. So, it does not care
|
|
|
|
// whether the depth buffer is in MSAA mode or not.
|
2017-12-09 03:19:18 +08:00
|
|
|
NumSamples =
|
2018-01-25 08:33:45 +08:00
|
|
|
(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN9_CORE) ?
|
|
|
|
1 :
|
|
|
|
pTexInfo->MSAA.NumSamples;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
|
|
|
pTexInfo->BaseWidth = ExpandWidth(Z_Width, HZ_HAlign, NumSamples);
|
|
|
|
|
|
|
|
h0 = ExpandHeight(Z_Height, HZ_VAlign, NumSamples);
|
|
|
|
|
2018-01-11 18:11:18 +08:00
|
|
|
Z_Height = GmmTexGetMipHeight(pTexInfo, 1);
|
2018-01-25 08:33:45 +08:00
|
|
|
h1 = ExpandHeight(Z_Height, HZ_VAlign, NumSamples);
|
2017-12-09 03:19:18 +08:00
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN8_CORE)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
if(pTexInfo->Type == RESOURCE_3D)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
for(i = 0, Z_HeightL = 0; i <= pTexInfo->MaxLod; i++)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-11 18:11:18 +08:00
|
|
|
Z_Height = GmmTexGetMipHeight(pTexInfo, i);
|
2018-01-25 08:33:45 +08:00
|
|
|
hL = ExpandHeight(Z_Height, HZ_VAlign, NumSamples);
|
2017-12-02 02:44:37 +08:00
|
|
|
Z_HeightL += (hL * GFX_MAX(1, (Z_Depth / GFX_2_TO_POWER_OF(i))));
|
|
|
|
}
|
|
|
|
|
|
|
|
pTexInfo->ArraySize = 0;
|
|
|
|
pTexInfo->BaseHeight = Z_HeightL / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
for(i = 2, Z_HeightL = 0; i <= pTexInfo->MaxLod; i++)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-11 18:11:18 +08:00
|
|
|
Z_Height = GmmTexGetMipHeight(pTexInfo, i);
|
2017-12-02 02:44:37 +08:00
|
|
|
Z_HeightL += ExpandHeight(Z_Height, HZ_VAlign, NumSamples);
|
|
|
|
}
|
2017-12-09 03:19:18 +08:00
|
|
|
|
|
|
|
QPitch =
|
2018-01-25 08:33:45 +08:00
|
|
|
(pTexInfo->MaxLod > 0) ?
|
|
|
|
(h0 + GFX_MAX(h1, Z_HeightL)) :
|
|
|
|
h0;
|
2018-03-26 14:54:39 +08:00
|
|
|
QPitch /= HZ_DepthRows;
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->ArraySize = Z_Depth;
|
2017-12-02 02:44:37 +08:00
|
|
|
pTexInfo->BaseHeight = QPitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTexInfo->Alignment.HAlign = HZ_HAlign;
|
2018-03-26 14:54:39 +08:00
|
|
|
pTexInfo->Alignment.VAlign = HZ_VAlign / HZ_DepthRows;
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
|
|
|
else //if (GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN7_CORE)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
if(pTexInfo->Type == RESOURCE_3D)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-25 08:33:45 +08:00
|
|
|
for(i = 0, Z_HeightL = 0; i <= pTexInfo->MaxLod; i++)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
hL = ExpandHeight(Z_Height >> i, HZ_VAlign, NumSamples);
|
|
|
|
Z_HeightL += (hL * GFX_MAX(1, (Z_Depth / GFX_2_TO_POWER_OF(i))));
|
|
|
|
}
|
|
|
|
|
|
|
|
pTexInfo->BaseHeight = Z_HeightL / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QPitch = h0 + h1 + 12 * HZ_VAlign;
|
|
|
|
|
|
|
|
pTexInfo->BaseHeight = GFX_CEIL_DIV((QPitch * Z_Depth / 2), 8) * 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTexInfo->ArraySize = 1;
|
2017-12-09 03:19:18 +08:00
|
|
|
}
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Native HZ Params //////////////////////////////////////////////////
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->BitsPerPixel = 8;
|
|
|
|
pTexInfo->Depth = 1;
|
|
|
|
pTexInfo->Format = GMM_FORMAT_GENERIC_8BIT;
|
|
|
|
pTexInfo->MaxLod = 0;
|
|
|
|
pTexInfo->MSAA.NumSamples = 1;
|
2017-12-02 02:44:37 +08:00
|
|
|
pTexInfo->MSAA.SamplePattern = GMM_MSAA_DISABLED;
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Type = RESOURCE_2D;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
|
|
|
// HiZ Always Tile-Y
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.Linear = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledW = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledX = 0;
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Info.TiledYf = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledYs = 0;
|
2018-09-29 06:02:49 +08:00
|
|
|
|
|
|
|
GMM_SET_4KB_TILE(pTexInfo->Flags, 1);
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
2017-12-09 03:19:18 +08:00
|
|
|
else
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
GMM_ASSERTDPF(0, "Illegal HiZ creation parameters!");
|
|
|
|
Status = GMM_ERROR;
|
|
|
|
}
|
|
|
|
} // HiZ
|
2018-01-25 08:33:45 +08:00
|
|
|
else if(pTexInfo->Flags.Gpu.CCS ||
|
|
|
|
pTexInfo->Flags.Gpu.MCS) // ######################################
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2017-12-09 03:19:18 +08:00
|
|
|
// With CCS surface creation, clients send height, width, depth, etc. of
|
2017-12-02 02:44:37 +08:00
|
|
|
// the associated RenderTarget--and here we convert to the appropriate CCS
|
|
|
|
// creation parameters...
|
|
|
|
__GMM_ASSERT((pTexInfo->Flags.Info.Linear + pTexInfo->Flags.Info.TiledW + pTexInfo->Flags.Info.TiledX + pTexInfo->Flags.Info.TiledY) == 1);
|
|
|
|
__GMM_ASSERT((pTexInfo->MSAA.NumSamples == 1) || (pTexInfo->MSAA.NumSamples == 2) || (pTexInfo->MSAA.NumSamples == 4) ||
|
|
|
|
(pTexInfo->MSAA.NumSamples == 8) || (pTexInfo->MSAA.NumSamples == 16));
|
|
|
|
|
2019-01-16 04:27:15 +08:00
|
|
|
Status = pGmmGlobalContext->GetTextureCalc()->MSAACCSUsage(pTexInfo);
|
2017-12-02 02:44:37 +08:00
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if(!pTexInfo->Flags.Gpu.__NonMsaaLinearCCS)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
// CCS Always Tile-Y (Even for Non-MSAA FastClear.)
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.Linear = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledW = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledX = 0;
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Info.TiledYf = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledYs = 0;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
2018-09-29 06:02:49 +08:00
|
|
|
GMM_SET_4KB_TILE(pTexInfo->Flags, 1);
|
|
|
|
|
2017-12-02 02:44:37 +08:00
|
|
|
//Clear compression request in CCS
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Info.RenderCompressed = 0;
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.MediaCompressed = 0;
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
} // CCS
|
|
|
|
else if(pTexInfo->Flags.Gpu.SeparateStencil) // ##########################
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
// Seperate stencil sizing is based on the associated depth buffer
|
|
|
|
// size, however UMD manages this sizing, and GMM will allocate any
|
|
|
|
// arbitrarily sized stencil. Stencils do have specific tiling
|
|
|
|
// requirements however, which is handled below.
|
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if((pTexInfo->BaseWidth > 0) &&
|
|
|
|
(pTexInfo->BaseHeight > 0))
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
__GMM_ASSERT(pTexInfo->BitsPerPixel == 8);
|
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) < IGFX_GEN7_CORE)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
GMM_ASSERTDPF((pTexInfo->MaxLod == 0), "Stencil Buffer LOD's not supported!");
|
|
|
|
}
|
|
|
|
|
2018-06-16 02:48:35 +08:00
|
|
|
// Separate Stencil Tile-W Gen8-Gen11, otherwise Tile-Y
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.Linear = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledX = 0;
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Info.TiledYf = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledYs = 0;
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.TiledW = 0;
|
|
|
|
pTexInfo->Flags.Info.TiledY = 0;
|
2017-12-02 02:44:37 +08:00
|
|
|
|
2018-01-25 08:33:45 +08:00
|
|
|
if(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN8_CORE &&
|
2018-06-16 02:48:35 +08:00
|
|
|
GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) <= IGFX_GEN11_CORE)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Info.TiledW = 1;
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 06:02:49 +08:00
|
|
|
GMM_SET_4KB_TILE(pTexInfo->Flags, 1);
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
|
|
|
}
|
2017-12-09 03:19:18 +08:00
|
|
|
else
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
|
|
|
GMM_ASSERTDPF(0, "Illegal Separate Stencil creation parameters!");
|
|
|
|
Status = GMM_ERROR;
|
|
|
|
}
|
|
|
|
} // Separate Stencil
|
2018-01-25 08:33:45 +08:00
|
|
|
else if(pTexInfo->Flags.Gpu.MMC && pTexInfo->Flags.Gpu.UnifiedAuxSurface)
|
2017-12-02 02:44:37 +08:00
|
|
|
{
|
2018-01-11 18:11:18 +08:00
|
|
|
pTexInfo->Flags.Gpu.__NonMsaaLinearCCS = 1;
|
2018-01-25 08:33:45 +08:00
|
|
|
pTexInfo->Flags.Info.Linear = 1;
|
2017-12-02 02:44:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
2018-03-29 18:41:02 +08:00
|
|
|
}
|