Skip to content

Commit

Permalink
fix binding prune logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hana-alice committed Sep 8, 2023
1 parent d14c32f commit e6daacd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion native/cocos/renderer/gfx-wgpu/WGPUDescriptorSetLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ ccstd::hash_t hash(const ccstd::vector<WGPUBindGroupLayoutEntry> &entries) {
return hash;
}

bool checkInUse(uint8_t binding, const ccstd::set<uint8_t> &bindingInUse, bool samplerBinding) {
bool res = bindingInUse.find(binding) != bindingInUse.end();
if (!res && samplerBinding) {
res |= bindingInUse.find(binding - CC_WGPU_MAX_ATTACHMENTS) != bindingInUse.end();
}
return res;
}

} // namespace

using namespace emscripten;
Expand Down Expand Up @@ -202,7 +210,7 @@ void CCWGPUDescriptorSetLayout::prepare(ccstd::set<uint8_t> &bindingInUse, bool
ccstd::vector<WGPUBindGroupLayoutEntry> bindGroupLayoutEntries{};
bindGroupLayoutEntries.reserve(_gpuLayoutEntryObj->bindGroupLayoutEntries.size());
for (const auto &[bd, layoutEntry] : _gpuLayoutEntryObj->bindGroupLayoutEntries) {
if (bindingInUse.find(static_cast<uint8_t>(bd)) != bindingInUse.end()) {
if(checkInUse(static_cast<uint8_t>(bd), bindingInUse, layoutEntry.sampler.type != WGPUSamplerBindingType_Undefined)) {
bindGroupLayoutEntries.emplace_back(layoutEntry);
}
}
Expand Down

0 comments on commit e6daacd

Please sign in to comment.