Skip to content

Commit 90e1bdc

Browse files
committed
Fix in AllocatorPimpl::GetResourceAllocationInfo for cases when D3D12_TEXTURE_LAYOUT_64KB_*_SWIZZLE is used
Fixes #86
1 parent 970084e commit 90e1bdc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/D3D12MemAlloc.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7815,12 +7815,17 @@ HRESULT AllocatorPimpl::GetResourceAllocationInfo(
78157815
#ifdef __ID3D12Device1_INTERFACE_DEFINED__
78167816

78177817
#if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED
7818-
if (IsTightAlignmentEnabled() &&
7818+
if (IsTightAlignmentEnabled())
7819+
{
78197820
// Don't allow USE_TIGHT_ALIGNMENT together with ALLOW_CROSS_ADAPTER as there is a D3D Debug Layer error:
78207821
// D3D12 ERROR: ID3D12Device::GetResourceAllocationInfo: D3D12_RESOURCE_DESC::Flag D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT will be ignored since D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER is set. [ STATE_CREATION ERROR #599: CREATERESOURCE_INVALIDMISCFLAGS]
7821-
(inOutResourceDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER) == 0)
7822-
{
7823-
inOutResourceDesc.Flags |= D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT;
7822+
// Also don't allow it together with D3D12_TEXTURE_LAYOUT_64KB_*_SWIZZLE, as there is this error (see issue #86):
7823+
// D3D12 ERROR: ID3D12Device::GetResourceAllocationInfo: D3D12_RESOURCE_DESC::Flag D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is not valid when the layout is either D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE or D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE (...). [ STATE_CREATION ERROR #599: CREATERESOURCE_INVALIDMISCFLAGS]
7824+
if((inOutResourceDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER) == 0
7825+
&& (inOutResourceDesc.Layout != D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE && inOutResourceDesc.Layout != D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE))
7826+
{
7827+
inOutResourceDesc.Flags |= D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT;
7828+
}
78247829
}
78257830
#endif // #if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED
78267831

0 commit comments

Comments
 (0)