[YUV AHB] Add a BGL getter for the expected BGDesc entry count. The computation was done in BindGroup when it's more of a BGL responsibility, but also the computation used the number of static samplers in the BGL to decrement, which is incorrect when in the future the ExternalTextures expand with a static sampler (it's the "validation count" of static samplers passed during BGL creation that's the correct amount to remove). Bug: 468988322 Change-Id: Id7ae4ae4011b3d2a9e00eb9bdd278acf1848069a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/298556 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Loko Kung <lokokung@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp index 62f8fc5..96939ab 100644 --- a/src/dawn/native/BindGroup.cpp +++ b/src/dawn/native/BindGroup.cpp
@@ -576,10 +576,7 @@ } // Check that we have all the required entries. - // NOTE: Static sampler layout bindings should not have bind group entries, as the sampler is - // specified in the layout itself. - const auto expectedEntryCount = - layout->GetUnexpandedBindingCount() - layout->GetStaticSamplerCount(); + const uint32_t expectedEntryCount = layout->GetBindingCountForBindGroupCreation(); DAWN_INVALID_IF( descriptor->entryCount != expectedEntryCount,
diff --git a/src/dawn/native/BindGroupLayoutInternal.cpp b/src/dawn/native/BindGroupLayoutInternal.cpp index 65c493a..4f3e34b 100644 --- a/src/dawn/native/BindGroupLayoutInternal.cpp +++ b/src/dawn/native/BindGroupLayoutInternal.cpp
@@ -957,9 +957,9 @@ return mNeedsCrossBindingValidation; } -uint32_t BindGroupLayoutInternalBase::GetUnexpandedBindingCount() const { +uint32_t BindGroupLayoutInternalBase::GetBindingCountForBindGroupCreation() const { DAWN_ASSERT(!IsError()); - return mValidationBindingCounts.totalCount; + return mValidationBindingCounts.totalCount - mValidationBindingCounts.staticSamplerCount; } size_t BindGroupLayoutInternalBase::GetBindingDataSize() const {
diff --git a/src/dawn/native/BindGroupLayoutInternal.h b/src/dawn/native/BindGroupLayoutInternal.h index 5458ce2..258cf3d 100644 --- a/src/dawn/native/BindGroupLayoutInternal.h +++ b/src/dawn/native/BindGroupLayoutInternal.h
@@ -170,7 +170,9 @@ // used to get the stored counts. const BindingCounts& GetValidationBindingCounts() const; - uint32_t GetUnexpandedBindingCount() const; + // Returns the number of bindings that's expected in the BindGroupDescriptor for BindGroups + // created from this layout. + uint32_t GetBindingCountForBindGroupCreation() const; bool NeedsCrossBindingValidation() const;