PipelineLayout: Only allow accessing defined BGLs.
Undefined BGLs are stored as nullptr in the pipeline layout, so to be defensive we assert clients of PipelineLayout can't request undefined BGLs (which forces iteration on the BGLMask). Also fix two cases where the BGLs were iterated on incorrectly. BUG=dawn:8 Change-Id: I3c084125b93d6684b4c79a56745632874079ebec Reviewed-on: https://dawn-review.googlesource.com/c/4480 Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
6be3b97ff5
commit
393d555a0e
|
@ -52,6 +52,7 @@ namespace dawn_native {
|
|||
|
||||
const BindGroupLayoutBase* PipelineLayoutBase::GetBindGroupLayout(size_t group) const {
|
||||
ASSERT(group < kMaxBindGroups);
|
||||
ASSERT(mMask[group]);
|
||||
return mBindGroupLayouts[group].Get();
|
||||
}
|
||||
|
||||
|
|
|
@ -227,11 +227,20 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
bool ShaderModuleBase::IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout) {
|
||||
for (size_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
|
||||
if (!IsCompatibleWithBindGroupLayout(group, layout->GetBindGroupLayout(group))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t group : IterateBitSet(~layout->GetBindGroupLayoutsMask())) {
|
||||
for (size_t i = 0; i < kMaxBindingsPerGroup; ++i) {
|
||||
if (mBindingInfo[group][i].used) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "dawn_native/d3d12/ShaderModuleD3D12.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
|
||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||
#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
|
||||
|
@ -45,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
compiler.set_hlsl_options(options_hlsl);
|
||||
|
||||
const ModuleBindingInfo& moduleBindingInfo = GetBindingInfo();
|
||||
for (uint32_t group = 0; group < moduleBindingInfo.size(); ++group) {
|
||||
for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
|
||||
const auto& bindingOffsets =
|
||||
ToBackend(layout->GetBindGroupLayout(group))->GetBindingOffsets();
|
||||
const auto& groupBindingInfo = moduleBindingInfo[group];
|
||||
|
|
Loading…
Reference in New Issue