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"
/////////////////////////////////////////////////////////////////////////////////////
2017-12-09 03:19:18 +08:00
/// Checks that clients only set Presentable flag during a resource allocation, ONLY
2017-12-02 02:44:37 +08:00
/// when a platform supported render target is selected in ::GMM_RESOURCE_FORMAT enum.
///
2017-12-09 03:19:18 +08:00
/// @return true if displayable, false otherwise.
2017-12-02 02:44:37 +08:00
/////////////////////////////////////////////////////////////////////////////////////
2017-12-09 03:19:18 +08:00
bool GmmLib : : GmmResourceInfoCommon : : IsPresentableformat ( )
2017-12-02 02:44:37 +08:00
{
2018-01-25 08:33:45 +08:00
const GMM_PLATFORM_INFO * pPlatform ;
const GMM_FORMAT_ENTRY * FormatTable = NULL ;
2017-12-02 02:44:37 +08:00
GMM_DPF_ENTER ;
2021-12-04 00:27:13 +08:00
__GMM_ASSERTPTR ( GetGmmLibContext ( ) , false ) ;
2017-12-09 03:19:18 +08:00
2021-12-04 00:27:13 +08:00
pPlatform = GMM_OVERRIDE_PLATFORM_INFO ( & Surf , GetGmmLibContext ( ) ) ;
2017-12-02 02:44:37 +08:00
FormatTable = & ( pPlatform - > FormatTable [ 0 ] ) ;
2018-01-25 08:33:45 +08:00
if ( Surf . Flags . Gpu . Presentable = = false )
2017-12-02 02:44:37 +08:00
{
// When Presentable flag is not set, no reason to check for valid RT
2017-12-09 03:19:18 +08:00
// platform supported format. Safe to return true.
return true ;
2017-12-02 02:44:37 +08:00
}
2018-01-25 08:33:45 +08:00
if ( ( Surf . Format > GMM_FORMAT_INVALID ) & &
( Surf . Format < GMM_RESOURCE_FORMATS ) )
2017-12-02 02:44:37 +08:00
{
2018-01-25 08:33:45 +08:00
if ( ( FormatTable [ Surf . Format ] . RenderTarget ) & &
( FormatTable [ Surf . Format ] . Supported ) )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
return true ;
2017-12-02 02:44:37 +08:00
}
else
{
2018-01-25 08:33:45 +08:00
GMM_ASSERTDPF ( 0 , " Present flag can only be set w/ a format! " ) ;
2017-12-09 03:19:18 +08:00
return false ;
2017-12-02 02:44:37 +08:00
}
}
2017-12-09 03:19:18 +08:00
return false ;
2017-12-02 02:44:37 +08:00
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the restrictions that a particular resource must follow on a particular
/// OS or hardware.
///
/// @param[out] Restrictions: restrictions that this resource must adhere to
/////////////////////////////////////////////////////////////////////////////////////
2018-01-25 08:33:45 +08:00
void GmmLib : : GmmResourceInfoCommon : : GetRestrictions ( __GMM_BUFFER_TYPE & Restrictions )
2017-12-02 02:44:37 +08:00
{
2019-01-30 07:41:43 +08:00
GMM_DPF_ENTER ;
2017-12-02 02:44:37 +08:00
2019-01-30 07:41:43 +08:00
GMM_TEXTURE_CALC * pTextureCalc = NULL ;
2021-12-04 00:27:13 +08:00
pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC ( & Surf , GetGmmLibContext ( ) ) ;
2019-01-30 07:41:43 +08:00
pTextureCalc - > GetResRestrictions ( & Surf , Restrictions ) ;
2017-12-02 02:44:37 +08:00
2019-01-30 07:41:43 +08:00
GMM_DPF_EXIT ;
2017-12-02 02:44:37 +08:00
}
2017-12-09 03:19:18 +08:00
2017-12-02 02:44:37 +08:00
//=============================================================================
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
// Function: GmmResGetRestrictions
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
// Desc: This routine returns resource restrictions
//
// Parameters:
// pPlatform: ptr to HW_DEVICE_EXTENSION
// pResourceInfo: ptr to GMM_RESOURCE_INFO
// pRestrictions: ptr to restrictions
//
// Returns:
2018-01-11 18:11:18 +08:00
// void
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
//-----------------------------------------------------------------------------
2018-01-25 08:33:45 +08:00
void GMM_STDCALL GmmResGetRestrictions ( GMM_RESOURCE_INFO * pResourceInfo ,
__GMM_BUFFER_TYPE * pRestrictions )
2017-12-02 02:44:37 +08:00
{
pResourceInfo - > GetRestrictions ( * pRestrictions ) ;
}
/////////////////////////////////////////////////////////////////////////////////////
2017-12-09 03:19:18 +08:00
/// Returns the best restrictions by comparing two buffer types. Each buffer type
2017-12-02 02:44:37 +08:00
/// carries alignment and size restrictions.
///
/// @param[in] pFirstBuffer: Contains surface alignment and size restrictions
/// @param[in] pSecondBuffer: Contains surface alignment and size restrictions
///
/// @return Best Restrictions based on the two parameters passed
/////////////////////////////////////////////////////////////////////////////////////
2019-01-30 07:41:43 +08:00
__GMM_BUFFER_TYPE * GmmLib : : GmmTextureCalc : : GetBestRestrictions ( __GMM_BUFFER_TYPE * pFirstBuffer ,
const __GMM_BUFFER_TYPE * pSecondBuffer )
2017-12-02 02:44:37 +08:00
{
GMM_DPF_ENTER ;
2018-01-25 08:33:45 +08:00
if ( IsRestrictionInvalid ( pFirstBuffer ) ) //default
2017-12-02 02:44:37 +08:00
{
* pFirstBuffer = * pSecondBuffer ;
return pFirstBuffer ;
}
2017-12-09 03:19:18 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > Alignment = GFX_MAX ( pFirstBuffer - > Alignment ,
pSecondBuffer - > Alignment ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > PitchAlignment = GFX_MAX ( pFirstBuffer - > PitchAlignment ,
pSecondBuffer - > PitchAlignment ) ;
2017-12-02 02:44:37 +08:00
pFirstBuffer - > RenderPitchAlignment = GFX_MAX ( pFirstBuffer - > RenderPitchAlignment ,
pSecondBuffer - > RenderPitchAlignment ) ;
2018-01-25 08:33:45 +08:00
pFirstBuffer - > LockPitchAlignment = GFX_MAX ( pFirstBuffer - > LockPitchAlignment ,
pSecondBuffer - > LockPitchAlignment ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MinPitch = GFX_MAX ( pFirstBuffer - > MinPitch ,
pSecondBuffer - > MinPitch ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MinAllocationSize = GFX_MAX ( pFirstBuffer - > MinAllocationSize ,
pSecondBuffer - > MinAllocationSize ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MinDepth = GFX_MAX ( pFirstBuffer - > MinDepth ,
pSecondBuffer - > MinDepth ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MinHeight = GFX_MAX ( pFirstBuffer - > MinHeight ,
pSecondBuffer - > MinHeight ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MinWidth = GFX_MAX ( pFirstBuffer - > MinWidth ,
pSecondBuffer - > MinWidth ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MaxDepth = GFX_MIN ( pFirstBuffer - > MaxDepth ,
pSecondBuffer - > MaxDepth ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MaxHeight = GFX_MIN ( pFirstBuffer - > MaxHeight ,
pSecondBuffer - > MaxHeight ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > MaxWidth = GFX_MIN ( pFirstBuffer - > MaxWidth ,
pSecondBuffer - > MaxWidth ) ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
pFirstBuffer - > NeedPow2LockAlignment = pFirstBuffer - > NeedPow2LockAlignment |
pSecondBuffer - > NeedPow2LockAlignment ;
2017-12-02 02:44:37 +08:00
GMM_DPF_EXIT ;
return pFirstBuffer ;
}
/////////////////////////////////////////////////////////////////////////////////////
2017-12-09 03:19:18 +08:00
/// Returns restrictions for 1D, 2D, 3D textures depending on how the surface
2017-12-02 02:44:37 +08:00
/// may possibliy be used.
///
/// @param[out] pBuff: Restrictions filled in this struct
/////////////////////////////////////////////////////////////////////////////////////
2019-01-30 07:41:43 +08:00
void GmmLib : : GmmTextureCalc : : GetGenericRestrictions ( GMM_TEXTURE_INFO * pTexInfo , __GMM_BUFFER_TYPE * pBuff )
2017-12-02 02:44:37 +08:00
{
GMM_DPF_ENTER ;
2021-12-04 00:27:13 +08:00
const GMM_PLATFORM_INFO * pPlatformResource = GMM_OVERRIDE_PLATFORM_INFO ( pTexInfo , pGmmLibContext ) ;
2017-12-02 02:44:37 +08:00
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . NoRestriction )
2017-12-02 02:44:37 +08:00
{
// Impose zero restrictions. Ignore any other GPU usage flags
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > NoRestriction ) ;
return ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Texture )
2017-12-09 03:19:18 +08:00
{
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Type = = RESOURCE_BUFFER )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > BufferType ;
}
2019-01-30 07:41:43 +08:00
else if ( pTexInfo - > Type = = RESOURCE_CUBE )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > CubeSurface ;
2017-12-09 03:19:18 +08:00
}
2019-01-30 07:41:43 +08:00
else if ( pTexInfo - > Type = = RESOURCE_3D )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > Texture3DSurface ;
}
else
{
* pBuff = pPlatformResource - > Texture2DSurface ;
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Info . Linear )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > Texture2DLinearSurface ;
}
2019-04-16 20:44:11 +08:00
if ( GmmIsReconstructableSurface ( pTexInfo - > Format ) )
{
pBuff - > MaxHeight = pPlatformResource - > ReconMaxHeight ;
pBuff - > MaxWidth = pPlatformResource - > ReconMaxWidth ;
}
2017-12-02 02:44:37 +08:00
}
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . RenderTarget | |
pTexInfo - > Flags . Gpu . CCS | |
pTexInfo - > Flags . Gpu . MCS )
2017-12-02 02:44:37 +08:00
{
// Gen7 onwards, bound by SURFACE_STATE constraints.
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Type = = RESOURCE_BUFFER )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > BufferType ;
}
2019-01-30 07:41:43 +08:00
else if ( pTexInfo - > Type = = RESOURCE_CUBE )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > CubeSurface ;
2017-12-09 03:19:18 +08:00
}
2019-01-30 07:41:43 +08:00
else if ( pTexInfo - > Type = = RESOURCE_3D )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > Texture3DSurface ;
}
else
{
* pBuff = pPlatformResource - > Texture2DSurface ;
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Info . Linear )
2017-12-02 02:44:37 +08:00
{
* pBuff = pPlatformResource - > Texture2DLinearSurface ;
}
2019-04-16 20:44:11 +08:00
if ( GmmIsReconstructableSurface ( pTexInfo - > Format ) )
{
pBuff - > MaxHeight = pPlatformResource - > ReconMaxHeight ;
pBuff - > MaxWidth = pPlatformResource - > ReconMaxWidth ;
}
2017-12-02 02:44:37 +08:00
}
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Depth )
2017-12-02 02:44:37 +08:00
{
// Z
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Depth ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Vertex )
2017-12-02 02:44:37 +08:00
{
// VertexData
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Vertex ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Index )
2017-12-02 02:44:37 +08:00
{
// Index buffer
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Index ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . FlipChain )
2017-12-02 02:44:37 +08:00
{
// Async Flip
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > ASyncFlipSurface ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . MotionComp )
2017-12-02 02:44:37 +08:00
{
// Media buffer
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > MotionComp ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . State | |
pTexInfo - > Flags . Gpu . InstructionFlat | |
pTexInfo - > Flags . Gpu . ScratchFlat )
2017-12-02 02:44:37 +08:00
{
// indirect state
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Vertex ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Query | |
pTexInfo - > Flags . Gpu . HistoryBuffer )
2017-12-02 02:44:37 +08:00
{
// Query
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > NoRestriction ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Constant )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Constant ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Stream )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Stream ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . InterlacedScan )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > InterlacedScan ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . TextApi )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > TextApi ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . SeparateStencil )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Stencil ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . HiZ )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > HiZ ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Video )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Video ) ;
2019-08-29 15:11:36 +08:00
if ( GmmIsReconstructableSurface ( pTexInfo - > Format ) )
{
pBuff - > MaxHeight = pPlatformResource - > ReconMaxHeight ;
pBuff - > MaxWidth = pPlatformResource - > ReconMaxWidth ;
}
2017-12-02 02:44:37 +08:00
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . StateDx9ConstantBuffer )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
//
2017-12-02 02:44:37 +08:00
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > StateDx9ConstantBuffer ) ;
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Gpu . Overlay )
2017-12-02 02:44:37 +08:00
{
// Overlay buffer use Async Flip values
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > Overlay ) ;
2019-01-30 07:41:43 +08:00
if ( ( pTexInfo - > Format = = GMM_FORMAT_YUY2 ) & & ( pTexInfo - > BaseWidth = = 640 ) )
2017-12-02 02:44:37 +08:00
{
// override the pitch alignment
pBuff - > PitchAlignment = 64 ;
}
}
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Info . XAdapter )
2017-12-02 02:44:37 +08:00
{
//Add Cross Adapter resource restriction for hybrid graphics.
pBuff = GetBestRestrictions ( pBuff , & pPlatformResource - > XAdapter ) ;
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Type = = RESOURCE_BUFFER )
2017-12-02 02:44:37 +08:00
{
2018-01-25 08:33:45 +08:00
pBuff - > MaxWidth = pPlatformResource - > SurfaceMaxSize ;
pBuff - > MaxPitch = pPlatformResource - > BufferType . MaxPitch ;
2017-12-02 02:44:37 +08:00
pBuff - > MaxHeight = 1 ;
}
}
2018-01-25 08:33:45 +08:00
//Non Aligned ExistingSysMem Special cases.
2019-01-30 07:41:43 +08:00
if ( ( pTexInfo - > Flags . Info . ExistingSysMem & &
( ! pTexInfo - > ExistingSysMem . IsGmmAllocated ) & &
( ! pTexInfo - > ExistingSysMem . IsPageAligned ) ) )
2017-12-02 02:44:37 +08:00
{
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Flags . Info . Linear | |
pTexInfo - > Flags . Info . SVM )
2017-12-02 02:44:37 +08:00
{
2019-01-30 07:41:43 +08:00
if ( pTexInfo - > Type = = RESOURCE_BUFFER )
2017-12-02 02:44:37 +08:00
{
//Use combination of BufferType, NoRestriction to support large buffer with minimal pitch alignment
2018-01-25 08:33:45 +08:00
* pBuff = pPlatformResource - > BufferType ;
2017-12-02 02:44:37 +08:00
pBuff - > PitchAlignment = pPlatformResource - > NoRestriction . PitchAlignment ;
2017-12-09 03:19:18 +08:00
pBuff - > LockPitchAlignment = pPlatformResource - > NoRestriction . LockPitchAlignment ;
2017-12-02 02:44:37 +08:00
pBuff - > RenderPitchAlignment = pPlatformResource - > NoRestriction . LockPitchAlignment ;
pBuff - > MinPitch = pPlatformResource - > NoRestriction . MinPitch ;
}
2017-12-09 03:19:18 +08:00
2017-12-02 02:44:37 +08:00
//[To DO] Handle other types when needed!
2017-12-09 03:19:18 +08:00
}
2017-12-02 02:44:37 +08:00
/*
else if ( Surf . Flags . Gpu . Texture )
{
//Override as and when required
}
else if ( Surf . Flags . Gpu . RenderTarget )
{
//Overide as and when Required
} */
}
GMM_DPF_EXIT ;
}
2021-04-21 22:36:34 +08:00
/////////////////////////////////////////////////////////////////////////////////////
/// Internal function resets the restrictions and puts the allocation in invalid state
///
/// @param[in] pTexInfo: ptr to ::GMM_TEXTURE_INFO,
/// @param[in] pRestrictions: reset the restrictions to invalid state.
///
/////////////////////////////////////////////////////////////////////////////////////
void GmmLib : : GmmTextureCalc : : ResetRestrictions ( __GMM_BUFFER_TYPE * pRestriction )
{
pRestriction - > MinDepth = 0xffffffff ;
}
2017-12-02 02:44:37 +08:00
/////////////////////////////////////////////////////////////////////////////////////
2017-12-09 03:19:18 +08:00
/// Internal function returns the best restrictions depending on how the surface may
2017-12-02 02:44:37 +08:00
/// possibly be used.
///
/// @param[in] pTexInfo: ptr to ::GMM_TEXTURE_INFO,
/// @param[in] pRestrictions: Reference to surface alignment and size restrictions
///
/////////////////////////////////////////////////////////////////////////////////////
2018-01-25 08:33:45 +08:00
void GmmLib : : GmmTextureCalc : : GetTexRestrictions ( GMM_TEXTURE_INFO * pTexInfo ,
__GMM_BUFFER_TYPE * pRestrictions )
2017-12-02 02:44:37 +08:00
{
GMM_DPF_ENTER ;
2019-01-30 07:41:43 +08:00
GetResRestrictions ( pTexInfo , * pRestrictions ) ;
2017-12-09 03:19:18 +08:00
2019-01-30 07:41:43 +08:00
GMM_DPF_EXIT ;
}
2017-12-09 03:19:18 +08:00
2019-01-30 07:41:43 +08:00
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the restrictions that a particular resource must follow on a particular
/// OS or hardware.
///
/// @param[out] Restrictions: restrictions that this resource must adhere to
/////////////////////////////////////////////////////////////////////////////////////
void GmmLib : : GmmTextureCalc : : GetResRestrictions ( GMM_TEXTURE_INFO * pTexinfo ,
__GMM_BUFFER_TYPE & Restrictions )
{
GMM_DPF_ENTER ;
const GMM_PLATFORM_INFO * pPlatform = NULL ;
GMM_RESOURCE_FLAG ZeroGpuFlags ;
2021-12-04 00:27:13 +08:00
__GMM_ASSERTPTR ( pGmmLibContext , VOIDRETURN ) ;
2019-01-30 07:41:43 +08:00
2021-12-04 00:27:13 +08:00
pPlatform = GMM_OVERRIDE_PLATFORM_INFO ( pTexinfo , pGmmLibContext ) ;
2019-01-30 07:41:43 +08:00
// Check that at least one usage flag is set for allocations other than
// Primary/Shadow/Staging.
memset ( & ZeroGpuFlags . Gpu , 0 , sizeof ( ZeroGpuFlags . Gpu ) ) ;
if ( ( pTexinfo - > Type < = RESOURCE_KMD_CHECK_START | |
pTexinfo - > Type > = RESOURCE_KMD_CHECK_END ) & &
! memcmp ( & pTexinfo - > Flags . Gpu , & ZeroGpuFlags . Gpu , sizeof ( ZeroGpuFlags . Gpu ) ) )
{
GMM_ASSERTDPF ( 0 , " No GPU Usage specified! " ) ;
return ;
}
2021-04-21 22:36:34 +08:00
ResetRestrictions ( & Restrictions ) ; //Set to Default
2019-01-30 07:41:43 +08:00
// Get worst case restrictions that match GPU flags set in resource
switch ( pTexinfo - > Type )
{
case RESOURCE_1D :
case RESOURCE_2D :
case RESOURCE_3D :
case RESOURCE_CUBE :
case RESOURCE_BUFFER :
case RESOURCE_SCRATCH :
case RESOURCE_GDI :
GetGenericRestrictions ( pTexinfo , & Restrictions ) ;
break ;
case RESOURCE_HW_CONTEXT :
case RESOURCE_TAG_PAGE :
if ( pTexinfo - > Flags . Info . TiledW | |
pTexinfo - > Flags . Info . TiledX | |
GMM_IS_4KB_TILE ( pTexinfo - > Flags ) )
{
GMM_ASSERTDPF ( 0 , " Tiled Pref specified for RESOURCE_LINEAR! " ) ;
return ;
}
GetLinearRestrictions ( pTexinfo , & Restrictions ) ;
break ;
case RESOURCE_PRIMARY :
case RESOURCE_SHADOW :
case RESOURCE_STAGING :
GetPrimaryRestrictions ( pTexinfo , & Restrictions ) ;
break ;
case RESOURCE_NNDI :
Restrictions = pPlatform - > Nndi ;
break ;
case RESOURCE_HARDWARE_MBM :
case RESOURCE_IFFS_MAPTOGTT :
//Hardware MBM resource request can come for overlay allocation or normal
//displayable allocation. So get the restrictions accordingly
if ( pTexinfo - > Flags . Gpu . Overlay )
{
Restrictions = pPlatform - > Overlay ;
}
else
{
Restrictions = pPlatform - > HardwareMBM ;
}
break ;
case RESOURCE_CURSOR :
case RESOURCE_PWR_CONTEXT :
case RESOURCE_KMD_BUFFER :
case RESOURCE_NULL_CONTEXT_INDIRECT_STATE :
case RESOURCE_PERF_DATA_QUEUE :
case RESOURCE_GLOBAL_BUFFER :
case RESOURCE_FBC :
case RESOURCE_GFX_CLIENT_BUFFER :
Restrictions = pPlatform - > Cursor ;
break ;
case RESOURCE_OVERLAY_DMA :
Restrictions = pPlatform - > NoRestriction ;
break ;
case RESOURCE_GTT_TRANSFER_REGION :
GetGenericRestrictions ( pTexinfo , & Restrictions ) ;
break ;
case RESOURCE_OVERLAY_INTERMEDIATE_SURFACE :
Restrictions = pPlatform - > Overlay ;
break ;
default :
GetGenericRestrictions ( pTexinfo , & Restrictions ) ;
GMM_ASSERTDPF ( 0 , " Unkown Resource type " ) ;
}
// Apply any specific WA
if ( ( ( pTexinfo - > Flags . Wa . ILKNeedAvcMprRowStore32KAlign ) ) | |
( ( pTexinfo - > Flags . Wa . ILKNeedAvcDmvBuffer32KAlign ) ) )
{
Restrictions . Alignment = GFX_ALIGN ( Restrictions . Alignment , GMM_KBYTE ( 32 ) ) ;
}
2021-12-04 00:27:13 +08:00
if ( pGmmLibContext - > GetWaTable ( ) . WaAlignContextImage & & ( pTexinfo - > Type = = RESOURCE_HW_CONTEXT ) )
2019-01-30 07:41:43 +08:00
{
Restrictions . Alignment = GFX_ALIGN ( Restrictions . Alignment , GMM_KBYTE ( 64 ) ) ;
}
if ( pTexinfo - > Flags . Gpu . S3d & &
pTexinfo - > Flags . Info . Linear & &
2021-12-04 00:27:13 +08:00
! pGmmLibContext - > GetSkuTable ( ) . FtrDisplayEngineS3d )
2019-01-30 07:41:43 +08:00
{
Restrictions . Alignment = PAGE_SIZE ;
Restrictions . PitchAlignment = PAGE_SIZE ;
}
if ( pTexinfo - > Flags . Gpu . TiledResource )
{
// Need at least 64KB alignment to track tile mappings (h/w or s/w tracking).
Restrictions . Alignment = GFX_ALIGN ( Restrictions . Alignment , GMM_KBYTE ( 64 ) ) ;
// Buffer tiled resources are trivially divided into 64KB tiles => Pitch must divide into 64KB tiles
if ( pTexinfo - > Type = = RESOURCE_BUFFER )
{
Restrictions . PitchAlignment = GFX_ALIGN ( Restrictions . PitchAlignment , GMM_KBYTE ( 64 ) ) ;
}
if ( GFX_GET_CURRENT_RENDERCORE ( pPlatform - > Platform ) > = IGFX_GEN9_CORE )
{
2021-12-04 00:27:13 +08:00
pGmmLibContext - > GetPlatformInfo ( ) . SurfaceMaxSize = GMM_TBYTE ( 1 ) ;
2019-01-30 07:41:43 +08:00
}
}
// SKL TileY Display needs 1MB alignment.
if ( ( ( pTexinfo - > Type = = RESOURCE_PRIMARY ) | |
pTexinfo - > Flags . Gpu . FlipChain ) & &
( GMM_IS_4KB_TILE ( pTexinfo - > Flags ) | |
pTexinfo - > Flags . Info . TiledYf ) )
{
Restrictions . Alignment = GMM_MBYTE ( 1 ) ;
}
if ( pTexinfo - > Flags . Info . RenderCompressed | |
pTexinfo - > Flags . Info . MediaCompressed )
{
2021-12-04 00:27:13 +08:00
if ( pGmmLibContext - > GetSkuTable ( ) . FtrFlatPhysCCS )
2021-04-21 22:36:34 +08:00
{
Restrictions . Alignment = GFX_ALIGN ( Restrictions . Alignment , GMM_KBYTE ( 64 ) ) ;
}
else // only for platforms having auxtable
{
2021-12-08 21:45:57 +08:00
Restrictions . Alignment = GFX_ALIGN ( Restrictions . Alignment , ( ! WA16K ( pGmmLibContext ) ? GMM_KBYTE ( 64 ) : GMM_KBYTE ( 16 ) ) ) ;
2021-12-04 20:14:40 +08:00
}
2019-01-30 07:41:43 +08:00
}
2017-12-02 02:44:37 +08:00
GMM_DPF_EXIT ;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Calculates surface size based on Non Aligned ExistingSysMem restrictions.
///
/// @return ::GMM_STATUS
/////////////////////////////////////////////////////////////////////////////////////
GMM_STATUS GmmLib : : GmmResourceInfoCommon : : ApplyExistingSysMemRestrictions ( )
{
2018-01-25 08:33:45 +08:00
const GMM_PLATFORM_INFO * pPlatform ;
2017-12-09 03:19:18 +08:00
2017-12-02 02:44:37 +08:00
// Handle Minimal Restriction ExistingSysMem Requirements...
2018-01-25 08:33:45 +08:00
GMM_GFX_SIZE_T AdditionalPaddingBytes = 0 ;
GMM_GFX_SIZE_T AdditionalPaddingRows = 0 ;
GMM_GFX_SIZE_T BaseAlignment = 1 ; // 1 = Byte Alignment
GMM_GFX_SIZE_T EndAlignment = 1 ; // 1 = Byte Alignment
GMM_GFX_SIZE_T SizePadding = 1 ; // 1 = Byte Padding
uint32_t CompressHeight , CompressWidth , CompressDepth ;
GMM_GFX_SIZE_T Width , Height ;
2017-12-02 02:44:37 +08:00
GMM_TEXTURE_INFO * pTexInfo = & Surf ;
GMM_TEXTURE_CALC * pTextureCalc ;
GMM_DPF_ENTER ;
2021-12-04 00:27:13 +08:00
pPlatform = GMM_OVERRIDE_PLATFORM_INFO ( pTexInfo , GetGmmLibContext ( ) ) ;
pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC ( pTexInfo , GetGmmLibContext ( ) ) ;
2017-12-02 02:44:37 +08:00
Height = pTexInfo - > BaseHeight ;
2018-01-25 08:33:45 +08:00
Width = pTexInfo - > BaseWidth ;
2017-12-02 02:44:37 +08:00
2018-01-25 08:33:45 +08:00
# define UPDATE_BASE_ALIGNMENT(a) \
{ \
2017-12-02 02:44:37 +08:00
__GMM_ASSERT ( ( GFX_MAX ( BaseAlignment , a ) % GFX_MIN ( BaseAlignment , a ) ) = = 0 ) ; /* Revisit if ever have to support complex alignments. */ \
2018-01-25 08:33:45 +08:00
BaseAlignment = GFX_MAX ( BaseAlignment , a ) ; \
2017-12-02 02:44:37 +08:00
}
2018-01-25 08:33:45 +08:00
# define UPDATE_PADDING(p) \
{ \
SizePadding = GFX_MAX ( SizePadding , p ) ; \
2017-12-02 02:44:37 +08:00
}
2018-01-25 08:33:45 +08:00
# define UPDATE_ADDITIONAL_ROWS(r) \
{ \
AdditionalPaddingRows = GFX_MAX ( AdditionalPaddingRows , r ) ; \
2017-12-02 02:44:37 +08:00
}
2018-01-25 08:33:45 +08:00
# define UPDATE_ADDITIONAL_BYTES(b) \
{ \
AdditionalPaddingBytes = GFX_MAX ( AdditionalPaddingBytes , b ) ; \
2017-12-02 02:44:37 +08:00
}
2018-01-25 08:33:45 +08:00
# define UPDATE_END_ALIGNMENT(a) \
{ \
2017-12-02 02:44:37 +08:00
__GMM_ASSERT ( ( GFX_MAX ( EndAlignment , a ) % GFX_MIN ( EndAlignment , a ) ) = = 0 ) ; /* Revisit if ever have to support complex alignments. */ \
2018-01-25 08:33:45 +08:00
EndAlignment = GFX_MAX ( EndAlignment , a ) ; \
2017-12-02 02:44:37 +08:00
}
2017-12-09 03:19:18 +08:00
if ( ! pTexInfo - > Pitch )
2017-12-02 02:44:37 +08:00
{
__GMM_ASSERT ( pTexInfo - > Type = = RESOURCE_1D ) ; // Clients can leave pitch zero for 1D, and we'll fill-in...
pTexInfo - > Pitch = Width * ( pTexInfo - > BitsPerPixel > > 3 ) ;
}
__GMM_ASSERT ( // Currently limiting our support...
2018-01-25 08:33:45 +08:00
pTexInfo - > Flags . Gpu . NoRestriction | |
pTexInfo - > Flags . Gpu . Index | |
pTexInfo - > Flags . Gpu . RenderTarget | |
pTexInfo - > Flags . Gpu . Texture | |
pTexInfo - > Flags . Gpu . Vertex ) ;
2017-12-02 02:44:37 +08:00
__GMM_ASSERT ( // Trivial, Linear Surface...
2018-01-25 08:33:45 +08:00
( ( pTexInfo - > Type = = RESOURCE_BUFFER ) | | ( pTexInfo - > Type = = RESOURCE_1D ) | | ( pTexInfo - > Type = = RESOURCE_2D ) ) & &
( pTexInfo - > MaxLod = = 0 ) & &
! GMM_IS_TILED ( pPlatform - > TileInfo [ pTexInfo - > TileMode ] ) & &
! GmmIsPlanar ( pTexInfo - > Format ) & &
( ( pTexInfo - > ArraySize < = 1 ) | | ( pTexInfo - > Type = = RESOURCE_BUFFER ) ) ) ;
2017-12-02 02:44:37 +08:00
__GMM_ASSERT ( // Valid Surface...
2018-01-25 08:33:45 +08:00
( Width > 0 ) & &
! ( ( pTexInfo - > Type = = RESOURCE_BUFFER ) & & GmmIsYUVPacked ( pTexInfo - > Format ) ) ) ;
2017-12-02 02:44:37 +08:00
// Convert to compression blocks, if applicable...
2021-12-04 00:27:13 +08:00
if ( GmmIsCompressed ( GetGmmLibContext ( ) , pTexInfo - > Format ) )
{
2017-12-02 02:44:37 +08:00
pTextureCalc - > GetCompressionBlockDimensions ( pTexInfo - > Format , & CompressWidth , & CompressHeight , & CompressDepth ) ;
2018-01-25 08:33:45 +08:00
Width = GFX_CEIL_DIV ( Width , CompressWidth ) ;
2017-12-02 02:44:37 +08:00
Height = GFX_CEIL_DIV ( Height , CompressHeight ) ;
}
__GMM_ASSERT ( // Valid Surface Follow-Up...
2018-01-25 08:33:45 +08:00
( pTexInfo - > Pitch > = ( Width * ( pTexInfo - > BitsPerPixel > > 3 ) ) ) ) ;
2017-12-02 02:44:37 +08:00
2017-12-09 03:19:18 +08:00
if ( ! pTexInfo - > Flags . Gpu . NoRestriction & & ! pTexInfo - > Flags . Info . SVM & & ! pTexInfo - > Flags . Info . Linear )
2017-12-02 02:44:37 +08:00
{
if ( pTexInfo - > Flags . Gpu . Index ) /////////////////////////////////////////////////////////
{
__GMM_ASSERT ( ! (
2018-01-25 08:33:45 +08:00
pTexInfo - > Flags . Gpu . RenderTarget | |
pTexInfo - > Flags . Gpu . Texture | |
pTexInfo - > Flags . Gpu . Vertex ) ) ; // Can explore if needed what combo's make sense--and how req's should combine.
2017-12-02 02:44:37 +08:00
2018-03-15 02:43:12 +08:00
// 3DSTATE_INDEX_BUFFER...
2017-12-02 02:44:37 +08:00
UPDATE_BASE_ALIGNMENT ( 4 ) ; // 32-bit worst-case, since GMM doesn't receive element-size from clients.
2021-12-04 00:27:13 +08:00
if ( GetGmmLibContext ( ) - > GetWaTable ( ) . WaAlignIndexBuffer )
2017-12-02 02:44:37 +08:00
{
UPDATE_END_ALIGNMENT ( 64 ) ;
}
else
{
UPDATE_END_ALIGNMENT ( 1 ) ;
}
}
if ( pTexInfo - > Flags . Gpu . Vertex ) ////////////////////////////////////////////////////////
{
__GMM_ASSERT ( ! (
2018-01-25 08:33:45 +08:00
pTexInfo - > Flags . Gpu . Index | |
pTexInfo - > Flags . Gpu . RenderTarget | |
pTexInfo - > Flags . Gpu . Texture ) ) ; // Can explore if needed what combo's make sense--and how req's should combine.
2017-12-02 02:44:37 +08:00
2018-03-15 02:43:12 +08:00
// VERTEX_BUFFER_STATE...
2017-12-02 02:44:37 +08:00
UPDATE_BASE_ALIGNMENT ( 1 ) ; // VB's have member alignment requirements--but it's up to UMD to enforce.
UPDATE_PADDING ( 1 ) ;
}
2017-12-09 03:19:18 +08:00
2017-12-02 02:44:37 +08:00
if ( pTexInfo - > Flags . Gpu . RenderTarget ) //////////////////////////////////////////////////
{
uint32_t ElementSize ;
2018-03-15 02:43:12 +08:00
// SURFACE_STATE...
2017-12-02 02:44:37 +08:00
ElementSize = ( pTexInfo - > BitsPerPixel > > 3 ) * ( GmmIsYUVPacked ( pTexInfo - > Format ) ? 2 : 1 ) ;
__GMM_ASSERT ( ( pTexInfo - > Pitch % ElementSize ) = = 0 ) ;
UPDATE_BASE_ALIGNMENT ( ElementSize ) ;
2018-03-15 02:43:12 +08:00
UPDATE_PADDING ( pTexInfo - > Pitch * 2 ) ; // "Surface Padding Requirements --> Render Target and Media Surfaces"
2017-12-02 02:44:37 +08:00
}
if ( pTexInfo - > Flags . Gpu . Texture ) // (i.e. Sampler Surfaces) ///////////////////////////
{
UPDATE_BASE_ALIGNMENT ( 1 ) ; // Sampler supports byte alignment (with performance hit if misaligned).
2021-12-04 00:27:13 +08:00
if ( GetGmmLibContext ( ) - > GetWaTable ( ) . WaNoMinimizedTrivialSurfacePadding )
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
if ( pTexInfo - > Type = = RESOURCE_BUFFER )
2017-12-02 02:44:37 +08:00
{
2021-12-04 00:27:13 +08:00
if ( GetGmmLibContext ( ) - > GetWaTable ( ) . WaNoBufferSamplerPadding )
{
2017-12-02 02:44:37 +08:00
// Client agreeing to take responsibility for flushing L3 after sampling/etc.
2017-12-09 03:19:18 +08:00
}
else
2017-12-02 02:44:37 +08:00
{
2017-12-09 03:19:18 +08:00
// GMM currently receives GENERIC_8BIT for
// RESOURCE_BUFFER creations, so we have to assume the
// worst-case sample size of 128-bit (unless we alter
2017-12-02 02:44:37 +08:00
// our interface meaning):
uint32_t ElementSize = 16 ;
2018-03-15 02:43:12 +08:00
// "Surface Padding Requirements --> Sampling Engine Surfaces"
2017-12-02 02:44:37 +08:00
UPDATE_PADDING ( ElementSize * ( ( GFX_GET_CURRENT_RENDERCORE ( pPlatform - > Platform ) = = IGFX_GEN8_CORE ) ? 512 : 256 ) ) ;
UPDATE_ADDITIONAL_BYTES ( 16 ) ;
}
2017-12-09 03:19:18 +08:00
}
2017-12-02 02:44:37 +08:00
else // RESOURCE_1D/2D...
{
2018-03-15 02:43:12 +08:00
/* Sampler needs Alignment Unit padding--
2017-12-09 03:19:18 +08:00
but sampler arch confirms that ' s overly conservative
padding - - and for trivial ( linear , single - subresource )
2 D ' s , even - row ( quad - row on BDW . A0 ) plus additional
64 B padding is sufficient . ( E . g . pitch overfetch will
2017-12-02 02:44:37 +08:00
be caught by subsequent rows or the additional 64 B . */
__GMM_ASSERT ( ( GFX_GET_CURRENT_RENDERCORE ( pPlatform - > Platform ) < = IGFX_GEN8_CORE ) ) ;
2021-12-04 00:27:13 +08:00
if ( GmmIsCompressed ( GetGmmLibContext ( ) , pTexInfo - > Format ) )
2017-12-02 02:44:37 +08:00
{
2018-03-15 02:43:12 +08:00
// "For compressed textures...padding at the bottom of the surface is to an even compressed row."
2017-12-02 02:44:37 +08:00
UPDATE_PADDING ( pTexInfo - > Pitch * 2 ) ; // (Sampler arch confirmed that even-row is sufficient on BDW despite BDW's 4x4 sampling, since this req is from L2 instead of L1.)
2017-12-09 03:19:18 +08:00
}
else
2017-12-02 02:44:37 +08:00
{
UPDATE_PADDING ( pTexInfo - > Pitch * ( ( GFX_GET_CURRENT_RENDERCORE ( pPlatform - > Platform ) = = IGFX_GEN8_CORE ) ? 4 : 2 ) ) ; // Sampler Fetch Rows: BDW ? 4 : 2
}
2018-03-15 02:43:12 +08:00
// "For packed YUV, 96 bpt, 48 bpt, and 24 bpt surface formats, additional padding is required."
2018-01-25 08:33:45 +08:00
if ( GmmIsYUVPacked ( pTexInfo - > Format ) | | ( pTexInfo - > BitsPerPixel = = 96 ) | | ( pTexInfo - > BitsPerPixel = = 48 ) | | ( pTexInfo - > BitsPerPixel = = 24 ) )
2017-12-02 02:44:37 +08:00
{
UPDATE_ADDITIONAL_BYTES ( 16 ) ;
UPDATE_ADDITIONAL_ROWS ( 1 ) ;
}
2018-03-15 02:43:12 +08:00
/* "For linear surfaces, additional padding of 64
2017-12-09 03:19:18 +08:00
bytes is required at the bottom of the surface . "
( Sampler arch confirmed the 64 bytes can overlap with
2017-12-02 02:44:37 +08:00
the other " additional 16 bytes " mentions in that section . ) */
UPDATE_ADDITIONAL_BYTES ( 64 ) ;
}
2017-12-09 03:19:18 +08:00
}
else
2017-12-02 02:44:37 +08:00
{
2018-03-15 02:43:12 +08:00
/* For SURFTYPE_BUFFER, SURFTYPE_1D, and
2017-12-09 03:19:18 +08:00
SURFTYPE_2D non - array , non - MSAA , non - mip - mapped surfaces in
linear memory , the only padding requirement is to the next
2017-12-02 02:44:37 +08:00
aligned 64 - byte boundary beyond the end of the surface . */
UPDATE_END_ALIGNMENT ( 64 ) ;
}
}
2017-12-09 03:19:18 +08:00
}
2017-12-02 02:44:37 +08:00
else // Gpu.NoRestriction...
{
2017-12-09 03:19:18 +08:00
// Clients specify NoRestriction at their own risk--e.g. it can be
// appropriate when using IA-Coherent L3 combined with L3 being in
// unified/"Rest" mode (where there won't be write-->read-only
2017-12-02 02:44:37 +08:00
// collisions on unintentionally shared cachelines).
}
2018-01-25 08:33:45 +08:00
{ //Finally calculate surf size
2017-12-02 02:44:37 +08:00
GMM_GFX_SIZE_T OriginalEnd , RequiredSize ;
2018-01-25 08:33:45 +08:00
ExistingSysMem . pVirtAddress =
( ExistingSysMem . pExistingSysMem & ( PAGE_SIZE - 1 ) ) ?
( ( uint64_t ) GFX_ALIGN ( ExistingSysMem . pExistingSysMem ,
BaseAlignment ) ) :
ExistingSysMem . pExistingSysMem ;
2017-12-02 02:44:37 +08:00
2017-12-09 03:19:18 +08:00
ExistingSysMem . pGfxAlignedVirtAddress =
2018-01-25 08:33:45 +08:00
( uint64_t ) GFX_ALIGN (
( uint64_t ) ExistingSysMem . pVirtAddress , PAGE_SIZE ) ;
2017-12-02 02:44:37 +08:00
__GMM_ASSERT ( ( ExistingSysMem . pVirtAddress % BaseAlignment ) = = 0 ) ;
RequiredSize = pTexInfo - > Pitch * Height ;
2017-12-09 03:19:18 +08:00
RequiredSize =
2018-01-25 08:33:45 +08:00
GFX_ALIGN ( RequiredSize , SizePadding ) +
( AdditionalPaddingRows * pTexInfo - > Pitch ) +
AdditionalPaddingBytes ;
2017-12-02 02:44:37 +08:00
OriginalEnd = ExistingSysMem . pVirtAddress + RequiredSize ;
RequiredSize + = GFX_ALIGN ( OriginalEnd , EndAlignment ) - OriginalEnd ;
//Ensure sufficient ExistingSysMem available.
if ( ExistingSysMem . Size < RequiredSize )
{
2017-12-09 03:19:18 +08:00
return GMM_ERROR ;
2017-12-02 02:44:37 +08:00
}
Surf . Size = RequiredSize ;
}
GMM_DPF_EXIT ;
return GMM_SUCCESS ;
}