Fixed TestTightAlignment for D3D12_RESOURCE_HEAP_TIER_1
diff --git a/src/Tests.cpp b/src/Tests.cpp index b38840f..b24a2ee 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp
@@ -1886,18 +1886,18 @@ UINT HeightAboveThreshold; }; - static const TextureCase NON_MSAA_CASES[] = - { - { DXGI_FORMAT_R8_UNORM, 128, 128, 320, 320 }, - { DXGI_FORMAT_R8G8B8A8_UNORM, 64, 64, 160, 160 }, - { DXGI_FORMAT_BC1_UNORM, 128, 128, 640, 256 }, - }; - static const TextureCase MSAA_CASES[] = - { - { DXGI_FORMAT_R8G8B8A8_UNORM, 256, 256, 1152, 512 }, - { DXGI_FORMAT_R16G16B16A16_FLOAT, 256, 128, 576, 512 }, - { DXGI_FORMAT_R32G32B32A32_FLOAT, 256, 128, 576, 256 }, - }; + static const TextureCase NON_MSAA_CASES[] = + { + { DXGI_FORMAT_R8_UNORM, 128, 128, 320, 320 }, + { DXGI_FORMAT_R8G8B8A8_UNORM, 64, 64, 160, 160 }, + { DXGI_FORMAT_BC1_UNORM, 128, 128, 640, 256 }, + }; + static const TextureCase MSAA_CASES[] = + { + { DXGI_FORMAT_R8G8B8A8_UNORM, 256, 256, 1152, 512 }, + { DXGI_FORMAT_R16G16B16A16_FLOAT, 256, 128, 576, 512 }, + { DXGI_FORMAT_R32G32B32A32_FLOAT, 256, 128, 576, 256 }, + }; for (UINT msaaIndex = 0; msaaIndex < 2; ++msaaIndex) { @@ -1905,14 +1905,14 @@ const UINT64 largeAlignment = isMsaa ? D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - const UINT64 smallAlignment = isMsaa ? - D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT : - D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; - const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES; - const size_t textureCaseCount = isMsaa ? _countof(MSAA_CASES) : _countof(NON_MSAA_CASES); - const D3D12_HEAP_FLAGS heapFlags = isMsaa ? - D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES : - D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; + const UINT64 smallAlignment = isMsaa ? + D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT : + D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; + const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES; + const size_t textureCaseCount = isMsaa ? _countof(MSAA_CASES) : _countof(NON_MSAA_CASES); + const D3D12_HEAP_FLAGS heapFlags = isMsaa ? + D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES : + D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; const D3D12_RESOURCE_FLAGS resourceFlags = isMsaa ? D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET : D3D12_RESOURCE_FLAG_NONE; @@ -1932,11 +1932,11 @@ D3D12MA::CALLOCATION_DESC allocDesc = D3D12MA::CALLOCATION_DESC{ pool.Get() }; - for (size_t textureCaseIndex = 0; textureCaseIndex < textureCaseCount; ++textureCaseIndex) - { - const TextureCase& textureCase = textureCases[textureCaseIndex]; - for (UINT thresholdIndex = 0; thresholdIndex < 2; ++thresholdIndex) - { + for (size_t textureCaseIndex = 0; textureCaseIndex < textureCaseCount; ++textureCaseIndex) + { + const TextureCase& textureCase = textureCases[textureCaseIndex]; + for (UINT thresholdIndex = 0; thresholdIndex < 2; ++thresholdIndex) + { const bool belowThreshold = thresholdIndex == 0; D3D12_RESOURCE_DESC resDesc = {}; resDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; @@ -1962,23 +1962,23 @@ CHECK_BOOL(alloc0->GetHeap() == alloc1->GetHeap()); // Note these asserts may fail if you use D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT=2. - const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment; - CHECK_BOOL((alloc0->GetOffset() % expectedAlignment) == 0); - CHECK_BOOL((alloc1->GetOffset() % expectedAlignment) == 0); - if (belowThreshold) - { - const UINT64 nonZeroOffset = alloc0->GetOffset() > 0 ? alloc0->GetOffset() : alloc1->GetOffset(); - wprintf(L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n", - (UINT)textureCase.Format, - isMsaa ? 1u : 0u, - resDesc.Width, - resDesc.Height, - nonZeroOffset, - nonZeroOffset < largeAlignment ? L"YES" : L"NO"); - } - - alloc1.Reset(); - alloc0.Reset(); + const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment; + CHECK_BOOL((alloc0->GetOffset() % expectedAlignment) == 0); + CHECK_BOOL((alloc1->GetOffset() % expectedAlignment) == 0); + if (belowThreshold) + { + const UINT64 nonZeroOffset = alloc0->GetOffset() > 0 ? alloc0->GetOffset() : alloc1->GetOffset(); + wprintf(L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n", + (UINT)textureCase.Format, + isMsaa ? 1u : 0u, + resDesc.Width, + resDesc.Height, + nonZeroOffset, + nonZeroOffset < largeAlignment ? L"YES" : L"NO"); + } + + alloc1.Reset(); + alloc0.Reset(); } } @@ -3574,6 +3574,7 @@ // Use a custom pool to make sure our small buffers are not created as committed. POOL_DESC poolDesc = {}; + poolDesc.HeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; poolDesc.BlockSize = MEGABYTE; poolDesc.MinBlockCount = poolDesc.MaxBlockCount = 1;