[dawn][d3d12] Improve limitation on storage buffers on QC
The storage buffer binding size was limited to 2^27 but further
clarifications showed that since we only use [RW]ByteAddressBuffer, the
binding size can be 2^29 (still lower than D3D12's requirement of 2^31).
Bug: 364384943
Bug: 42242119
Change-Id: Ib5ae58d7e49b4093f6399497cbe528f05661a350
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212895
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
index 9146a69..27e88cf 100644
--- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
+++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
@@ -354,19 +354,9 @@
// Max number of "constants" where each constant is a 16-byte float4
limits->v1.maxUniformBufferBindingSize = D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * 16;
- if (gpu_info::IsQualcomm_ACPI(GetVendorId())) {
- // limit of number of texels in a buffer == (1 << 27)
- // D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP
- // This limit doesn't apply to a raw buffer, but only applies to
- // typed, or structured buffer. so this could be a QC driver bug.
- limits->v1.maxStorageBufferBindingSize = uint64_t(1)
- << D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP;
- } else {
- limits->v1.maxStorageBufferBindingSize = kAssumedMaxBufferSize;
- }
-
// D3D12 has no documented limit on the buffer size.
limits->v1.maxBufferSize = kAssumedMaxBufferSize;
+ limits->v1.maxStorageBufferBindingSize = kAssumedMaxBufferSize;
// 1 for SV_Position and 1 for (SV_IsFrontFace OR SV_SampleIndex).
// See the discussions in https://github.com/gpuweb/gpuweb/issues/1962 for more details.
@@ -385,6 +375,14 @@
// https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics#:~:text=UINT%20WaveLaneCountMax
limits->experimentalSubgroupLimits.maxSubgroupSize = 128u;
+ if (gpu_info::IsQualcomm_ACPI(GetVendorId())) {
+ // Due to a driver and hardware limitation, Raw Buffers can only address 2^27 WORDS instead
+ // of the guaranteeed 2^31 bytes. Probably because it uses some form of texel buffer of
+ // 32bit values to implement [RW]ByteAddressBuffer.
+ limits->v1.maxStorageBufferBindingSize = sizeof(uint32_t)
+ << D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP;
+ }
+
return {};
}