[dawn][native] Update kMaxExternalImmediateConstantsPerPipeline
Now that all core backends use a fixed size of 64 bytes for immediates,
set kMaxExternalImmediateConstantsPerPipeline in terms of that.
Fixes: 458693086
Bug: 366291600
Bug: 458081201
Change-Id: I3360e0c52851dc3a969ab4355a2f05c889037c58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/272074
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/dawn/common/Constants.h b/src/dawn/common/Constants.h
index c72d3d0..7f489d9 100644
--- a/src/dawn/common/Constants.h
+++ b/src/dawn/common/Constants.h
@@ -50,17 +50,19 @@
// All Immediate constants are 32 bit
static constexpr uint32_t kImmediateConstantElementByteSize = sizeof(uint32_t);
-// Known as 'Immediate Data'. User could update them through APIs.
-static constexpr uint32_t kMaxExternalImmediateConstantsPerPipeline = 16u;
-
-// Vulkan requires min-max push constant bytes is 128 byte, which is
-// equals to 32 32bit constants. D3D12 requires 64 32bit constants limits.
-// Pick 32 here.
+// Total number of "internal" 32-bit immediates, which includes both external (user) immediates
+// and any other immediates used by Dawn internally (e.g. workgroup sizes).
+// Vulkan's min-max push constant limit is 128 bytes / 4 = 32 values,
+// while D3D12's limit is 256 bytes / 4 = 64 values, so we pick 32 here.
static constexpr uint32_t kMaxImmediateConstantsPerPipeline = 32u;
// Adapter Max limitation for user immediate constants is 64 bytes.
static constexpr uint32_t kMaxImmediateDataBytes = 64u;
+// Known as 'Immediate Data' that users can update via the API
+static constexpr uint32_t kMaxExternalImmediateConstantsPerPipeline =
+ kMaxImmediateDataBytes / kImmediateConstantElementByteSize;
+
// Default subgroup sizes.
static constexpr uint32_t kDefaultSubgroupMinSize = 4u;
static constexpr uint32_t kDefaultSubgroupMaxSize = 128u;
diff --git a/src/dawn/native/ImmediateConstantsLayout.h b/src/dawn/native/ImmediateConstantsLayout.h
index 51a5dae..88b9957 100644
--- a/src/dawn/native/ImmediateConstantsLayout.h
+++ b/src/dawn/native/ImmediateConstantsLayout.h
@@ -80,9 +80,10 @@
// Convert byte sizes and offsets into immediate constant indices and offsets
// (dividing everything by kImmediateConstantElementByteSize)
constexpr ImmediateConstantMask GetImmediateConstantBlockBits(size_t byteOffset, size_t byteSize) {
- size_t firstIndex = byteOffset / kImmediateConstantElementByteSize;
- size_t constantCount = byteSize / kImmediateConstantElementByteSize;
-
+ // This bit math can be done in uint64_t because there are <= 64 bits in the mask.
+ static_assert(ImmediateConstantMask{}.size() <= 64);
+ uint64_t firstIndex = byteOffset / kImmediateConstantElementByteSize;
+ uint64_t constantCount = byteSize / kImmediateConstantElementByteSize;
return ((1u << constantCount) - 1u) << firstIndex;
}