D3D12: Allocate resource heap with 64KB alignment when possible

This patch allocates D3D12 resource heap with 64KB alignment when
the system supports 64KB alignment for multisampled textures.

Bug: dawn:849
Change-Id: Ie0301f457a28a39e0b5f2ac38bd7ed46b9115823
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/144560
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp b/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
index dd71270..9c498f6 100644
--- a/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
@@ -38,11 +38,9 @@
     heapDesc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
     heapDesc.Properties.CreationNodeMask = 0;
     heapDesc.Properties.VisibleNodeMask = 0;
-    // It is preferred to use a size that is a multiple of the alignment.
-    // However, MSAA heaps are always aligned to 4MB instead of 64KB. This means
-    // if the heap size is too small, the VMM would fragment.
-    // TODO(crbug.com/dawn/849): Consider having MSAA vs non-MSAA heaps.
-    heapDesc.Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
+    heapDesc.Alignment = mDevice->IsToggleEnabled(Toggle::D3D12Use64KBAlignedMSAATexture)
+                             ? D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT
+                             : D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
     heapDesc.Flags = mHeapFlags;
 
     // CreateHeap will implicitly make the created heap resident. We must ensure enough free