mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] postprocess: centralize frame format utilities
This commit is contained in:
@@ -41,39 +41,6 @@ bool CFrameProcessorUtil::FrameMetadataChanged(
|
||||
previous.maxFrameAverageLightLevel != current.maxFrameAverageLightLevel));
|
||||
}
|
||||
|
||||
FrameType CFrameProcessorUtil::GetFrameType(DXGI_FORMAT format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM : return FRAME_TYPE_BGRA;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM : return FRAME_TYPE_RGBA;
|
||||
case DXGI_FORMAT_R10G10B10A2_UNORM : return FRAME_TYPE_RGBA10;
|
||||
case DXGI_FORMAT_R16G16B16A16_FLOAT: return FRAME_TYPE_RGBA16F;
|
||||
default : return FRAME_TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
bool CFrameProcessorUtil::ResourceDescMatches(
|
||||
const D3D12_RESOURCE_DESC& left, const D3D12_RESOURCE_DESC& right,
|
||||
bool compareAlignment)
|
||||
{
|
||||
// GetDesc may report a resolved alignment when resource creation requested
|
||||
// automatic alignment, so callers comparing creation descriptors can omit
|
||||
// this allocation metadata.
|
||||
return
|
||||
left.Dimension == right.Dimension &&
|
||||
(!compareAlignment || left.Alignment == right.Alignment) &&
|
||||
left.Width == right.Width &&
|
||||
left.Height == right.Height &&
|
||||
left.DepthOrArraySize == right.DepthOrArraySize &&
|
||||
left.MipLevels == right.MipLevels &&
|
||||
left.Format == right.Format &&
|
||||
left.SampleDesc.Count == right.SampleDesc.Count &&
|
||||
left.SampleDesc.Quality == right.SampleDesc.Quality &&
|
||||
left.Layout == right.Layout &&
|
||||
left.Flags == right.Flags;
|
||||
}
|
||||
|
||||
static bool IsFullDamage(const RECT * dirtyRects, unsigned nbDirtyRects,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
|
||||
@@ -29,9 +29,6 @@ class CFrameProcessorUtil
|
||||
public:
|
||||
static bool FrameMetadataChanged(const D12FrameFormat& previous,
|
||||
const D12FrameFormat& current);
|
||||
static FrameType GetFrameType(DXGI_FORMAT format);
|
||||
static bool ResourceDescMatches(const D3D12_RESOURCE_DESC& left,
|
||||
const D3D12_RESOURCE_DESC& right, bool compareAlignment = true);
|
||||
static void ClipDirtyRects(RECT dirtyRects[], unsigned * nbDirtyRects,
|
||||
unsigned width, unsigned height);
|
||||
static bool BuildCopyDamage(const CPostProcessor& postProcessor,
|
||||
|
||||
@@ -290,8 +290,7 @@ bool CHardwareFrameProcessor::EnsureCandidateResource(
|
||||
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
|
||||
if (candidate.resource &&
|
||||
CFrameProcessorUtil::ResourceDescMatches(
|
||||
candidate.resource->GetDesc(), desc, false))
|
||||
D12::Same(candidate.resource->GetDesc(), desc, D12::DescCmp::CREATE))
|
||||
return true;
|
||||
|
||||
candidate.resource.Reset();
|
||||
|
||||
@@ -263,8 +263,7 @@ bool CSoftwareFrameProcessor::EnsureProductResource(
|
||||
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
|
||||
if (product.resource &&
|
||||
CFrameProcessorUtil::ResourceDescMatches(
|
||||
product.resource->GetDesc(), desc, false))
|
||||
D12::Same(product.resource->GetDesc(), desc, D12::DescCmp::CREATE))
|
||||
return true;
|
||||
|
||||
product.resource.Reset();
|
||||
|
||||
@@ -572,7 +572,7 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
||||
srcFormat.desc = srcDesc;
|
||||
srcFormat.width = (unsigned)srcDesc.Width;
|
||||
srcFormat.height = srcDesc.Height;
|
||||
srcFormat.format = CFrameProcessorUtil::GetFrameType(srcDesc.Format);
|
||||
srcFormat.format = D12::Type(srcDesc.Format);
|
||||
srcFormat.sdrWhiteLevel = sdrWhiteLevel;
|
||||
srcFormat.colorTransform = m_control.GetColorTransform();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user