d3d11: Fix DRAWINDIRECT buffer size It must be at least 12 bytes according to the validation layer. Bug: dawn:1894 Bug: dawn:1705 Change-Id: I8e4335f2cd0b616eea651a4e6e986bd7017164ed Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139740 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jie A Chen <jie.a.chen@intel.com> Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp index a534fc4..d18e9c1 100644 --- a/src/dawn/native/d3d11/BufferD3D11.cpp +++ b/src/dawn/native/d3d11/BufferD3D11.cpp
@@ -146,6 +146,11 @@ // Allocate at least 4 bytes so clamped accesses are always in bounds. uint64_t size = std::max(GetSize(), uint64_t(4u)); + // The validation layer requires: + // ByteWidth must be 12 or larger to be used with D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS. + if (GetUsage() & wgpu::BufferUsage::Indirect) { + size = std::max(size, uint64_t(12u)); + } size_t alignment = D3D11BufferSizeAlignment(GetUsage()); // Check for overflow, bufferDescriptor.ByteWidth is a UINT. if (size > std::numeric_limits<UINT>::max() - alignment) {