@@ -733,6 +733,12 @@ static void TestSmallBuffers(const TestContext& ctx)
733733{
734734 wprintf (L" Test small buffers\n " );
735735
736+ const bool isTightAlignmentEnabled = ctx.allocator ->IsTightAlignmentSupported () &&
737+ (ctx.allocatorFlags & D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT) == 0 ;
738+ const bool expectSmallBuffersCommitted = !isTightAlignmentEnabled &&
739+ (ctx.allocatorFlags & D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED) == 0 ;
740+
741+
736742 D3D12MA::CPOOL_DESC poolDesc = D3D12MA::CPOOL_DESC{
737743 D3D12_HEAP_TYPE_DEFAULT,
738744 D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS };
@@ -778,9 +784,9 @@ static void TestSmallBuffers(const TestContext& ctx)
778784 CHECK_HR (ctx.allocator ->CreateResource (&allocDesc, &resDesc, D3D12_RESOURCE_STATE_COMMON,
779785 nullptr , &resWithAlloc.allocation , IID_PPV_ARGS (&resWithAlloc.resource )));
780786 CHECK_BOOL (resWithAlloc.allocation && resWithAlloc.allocation ->GetResource ());
781- // Expected to be committed unless tight alignment is supported.
787+ // Expected to be committed?
782788 const bool isCommitted = resWithAlloc.allocation ->GetHeap () == NULL ;
783- CHECK_BOOL (isCommitted != (ctx. allocator -> IsTightAlignmentSupported () != FALSE ) );
789+ CHECK_BOOL (isCommitted == expectSmallBuffersCommitted );
784790 }
785791
786792 // Test 3: NEVER_ALLOCATE.
@@ -3057,13 +3063,10 @@ static void TestTightAlignment(const TestContext& ctx)
30573063
30583064 wprintf (L" Test resource tight alignment\n " );
30593065
3060- if (!ctx.allocator ->IsTightAlignmentSupported ())
3061- {
3062- wprintf (L" Skipped due to tight alignment not supported.\n " );
3063- return ;
3064- }
3066+ const bool isTightAlignmentEnabled = ctx.allocator ->IsTightAlignmentSupported () &&
3067+ (ctx.allocatorFlags & ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT) == 0 ;
30653068
3066- // Use a custom heap to make sure our small buffers are not created as committed.
3069+ // Use a custom pool to make sure our small buffers are not created as committed.
30673070 POOL_DESC poolDesc = {};
30683071 poolDesc.BlockSize = MEGABYTE;
30693072 poolDesc.MinBlockCount = poolDesc.MaxBlockCount = 1 ;
@@ -3096,12 +3099,24 @@ static void TestTightAlignment(const TestContext& ctx)
30963099 CHECK_BOOL (allocs[i] && allocs[i]->GetResource ());
30973100 }
30983101
3102+ const UINT64 secondAllocOffset = allocs[1 ]->GetOffset ();
3103+
30993104 // Print the offset of the 2nd buffer.
31003105 wprintf (L" In D3D12_HEAP_TYPE_%s, with MinAllocationAlignment=%llu, a %llu B buffer was aligned to %llu B.\n " ,
31013106 HEAP_TYPE_NAMES[(size_t )heapType],
31023107 poolDesc.MinAllocationAlignment ,
31033108 resDesc.Width ,
3104- allocs[1 ]->GetOffset ());
3109+ secondAllocOffset);
3110+
3111+ UINT64 expectedMinAlignment = 1 ;
3112+ if (isTightAlignmentEnabled)
3113+ {
3114+ if (minAlignmentTestIndex == 0 )
3115+ expectedMinAlignment = D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT;
3116+ }
3117+ else
3118+ expectedMinAlignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
3119+ CHECK_BOOL (secondAllocOffset % expectedMinAlignment == 0 );
31053120 }
31063121 }
31073122}
0 commit comments