@@ -1886,33 +1886,33 @@ static void TestSmallTextureAlignment(const TestContext& ctx)
18861886 UINT HeightAboveThreshold;
18871887 };
18881888
1889- static const TextureCase NON_MSAA_CASES [] =
1890- {
1891- { DXGI_FORMAT_R8_UNORM , 128 , 128 , 320 , 320 },
1892- { DXGI_FORMAT_R8G8B8A8_UNORM , 64 , 64 , 160 , 160 },
1893- { DXGI_FORMAT_BC1_UNORM , 128 , 128 , 640 , 256 },
1894- };
1895- static const TextureCase MSAA_CASES [] =
1896- {
1897- { DXGI_FORMAT_R8G8B8A8_UNORM , 256 , 256 , 1152 , 512 },
1898- { DXGI_FORMAT_R16G16B16A16_FLOAT , 256 , 128 , 576 , 512 },
1899- { DXGI_FORMAT_R32G32B32A32_FLOAT , 256 , 128 , 576 , 256 },
1900- };
1889+ static const TextureCase NON_MSAA_CASES [] =
1890+ {
1891+ { DXGI_FORMAT_R8_UNORM , 128 , 128 , 320 , 320 },
1892+ { DXGI_FORMAT_R8G8B8A8_UNORM , 64 , 64 , 160 , 160 },
1893+ { DXGI_FORMAT_BC1_UNORM , 128 , 128 , 640 , 256 },
1894+ };
1895+ static const TextureCase MSAA_CASES [] =
1896+ {
1897+ { DXGI_FORMAT_R8G8B8A8_UNORM , 256 , 256 , 1152 , 512 },
1898+ { DXGI_FORMAT_R16G16B16A16_FLOAT , 256 , 128 , 576 , 512 },
1899+ { DXGI_FORMAT_R32G32B32A32_FLOAT , 256 , 128 , 576 , 256 },
1900+ };
19011901
19021902 for (UINT msaaIndex = 0 ; msaaIndex < 2 ; ++msaaIndex)
19031903 {
19041904 const bool isMsaa = msaaIndex != 0 ;
19051905 const UINT64 largeAlignment = isMsaa ?
19061906 D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
19071907 D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT ;
1908- const UINT64 smallAlignment = isMsaa ?
1909- D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
1910- D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT ;
1911- const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES ;
1912- const size_t textureCaseCount = isMsaa ? _countof (MSAA_CASES ) : _countof (NON_MSAA_CASES );
1913- const D3D12_HEAP_FLAGS heapFlags = isMsaa ?
1914- D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :
1915- D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES ;
1908+ const UINT64 smallAlignment = isMsaa ?
1909+ D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
1910+ D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT ;
1911+ const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES ;
1912+ const size_t textureCaseCount = isMsaa ? _countof (MSAA_CASES ) : _countof (NON_MSAA_CASES );
1913+ const D3D12_HEAP_FLAGS heapFlags = isMsaa ?
1914+ D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :
1915+ D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES ;
19161916 const D3D12_RESOURCE_FLAGS resourceFlags = isMsaa ?
19171917 D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET :
19181918 D3D12_RESOURCE_FLAG_NONE ;
@@ -1932,11 +1932,11 @@ static void TestSmallTextureAlignment(const TestContext& ctx)
19321932
19331933 D3D12MA ::CALLOCATION_DESC allocDesc = D3D12MA ::CALLOCATION_DESC { pool.Get () };
19341934
1935- for (size_t textureCaseIndex = 0 ; textureCaseIndex < textureCaseCount; ++textureCaseIndex)
1936- {
1937- const TextureCase& textureCase = textureCases[textureCaseIndex];
1938- for (UINT thresholdIndex = 0 ; thresholdIndex < 2 ; ++thresholdIndex)
1939- {
1935+ for (size_t textureCaseIndex = 0 ; textureCaseIndex < textureCaseCount; ++textureCaseIndex)
1936+ {
1937+ const TextureCase& textureCase = textureCases[textureCaseIndex];
1938+ for (UINT thresholdIndex = 0 ; thresholdIndex < 2 ; ++thresholdIndex)
1939+ {
19401940 const bool belowThreshold = thresholdIndex == 0 ;
19411941 D3D12_RESOURCE_DESC resDesc = {};
19421942 resDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D ;
@@ -1962,23 +1962,23 @@ static void TestSmallTextureAlignment(const TestContext& ctx)
19621962 CHECK_BOOL (alloc0->GetHeap () == alloc1->GetHeap ());
19631963
19641964 // Note these asserts may fail if you use D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT=2.
1965- const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment;
1966- CHECK_BOOL ((alloc0->GetOffset () % expectedAlignment) == 0 );
1967- CHECK_BOOL ((alloc1->GetOffset () % expectedAlignment) == 0 );
1968- if (belowThreshold)
1969- {
1970- const UINT64 nonZeroOffset = alloc0->GetOffset () > 0 ? alloc0->GetOffset () : alloc1->GetOffset ();
1971- wprintf (L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n " ,
1972- (UINT )textureCase.Format ,
1973- isMsaa ? 1u : 0u ,
1974- resDesc.Width ,
1975- resDesc.Height ,
1976- nonZeroOffset,
1977- nonZeroOffset < largeAlignment ? L" YES" : L" NO" );
1978- }
1979-
1980- alloc1.Reset ();
1981- alloc0.Reset ();
1965+ const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment;
1966+ CHECK_BOOL ((alloc0->GetOffset () % expectedAlignment) == 0 );
1967+ CHECK_BOOL ((alloc1->GetOffset () % expectedAlignment) == 0 );
1968+ if (belowThreshold)
1969+ {
1970+ const UINT64 nonZeroOffset = alloc0->GetOffset () > 0 ? alloc0->GetOffset () : alloc1->GetOffset ();
1971+ wprintf (L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n " ,
1972+ (UINT )textureCase.Format ,
1973+ isMsaa ? 1u : 0u ,
1974+ resDesc.Width ,
1975+ resDesc.Height ,
1976+ nonZeroOffset,
1977+ nonZeroOffset < largeAlignment ? L" YES" : L" NO" );
1978+ }
1979+
1980+ alloc1.Reset ();
1981+ alloc0.Reset ();
19821982 }
19831983 }
19841984
@@ -3574,6 +3574,7 @@ static void TestTightAlignment(const TestContext& ctx)
35743574
35753575 // Use a custom pool to make sure our small buffers are not created as committed.
35763576 POOL_DESC poolDesc = {};
3577+ poolDesc.HeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS ;
35773578 poolDesc.BlockSize = MEGABYTE ;
35783579 poolDesc.MinBlockCount = poolDesc.MaxBlockCount = 1 ;
35793580
0 commit comments