Fix: webgpu error regarding mismatched pipeline (#9056)

This commit is contained in:
Ben Doherty
2025-08-11 17:30:07 -04:00
committed by Benjamin Doherty
parent 05bd56d0e8
commit 94b8ee481f
3 changed files with 17 additions and 3 deletions

View File

@@ -1067,7 +1067,8 @@ void RenderPass::Executor::execute(FEngine const& engine, DriverApi& driver,
// Each material has a per-material descriptor-set layout which encodes the
// material's parameters (ubo and samplers)
pipeline.pipelineLayout.setLayout[+DescriptorSetBindingPoints::PER_MATERIAL] =
ma->getDescriptorSetLayout().getHandle();
ma->getDescriptorSetLayout(info.materialVariant).getHandle();
if (UTILS_UNLIKELY(ma->getMaterialDomain() == MaterialDomain::POST_PROCESS)) {
// It is possible to get a post-process material here (even though it's

View File

@@ -465,6 +465,9 @@ void FEngine::init() {
}
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*this));
}
// We must commit the default material instance here. It may not be used in a scene, but its
// descriptor set may still be used for shared variants.
mDefaultMaterial->getDefaultInstance()->commit(driverApi);
if (UTILS_UNLIKELY(getSupportedFeatureLevel() >= FeatureLevel::FEATURE_LEVEL_1)) {
mDefaultColorGrading = downcast(ColorGrading::Builder().build(*this));

View File

@@ -96,8 +96,18 @@ public:
DescriptorSetLayout const& getPerViewDescriptorSetLayout(
Variant const variant, bool const useVsmDescriptorSetLayout) const noexcept;
DescriptorSetLayout const& getDescriptorSetLayout() const noexcept {
return mDescriptorSetLayout;
// Returns the layout that should be used when this material is bound to the pipeline for the
// given variant. Shared variants use the Engine's default material's variants, so we should
// also use the default material's layout.
DescriptorSetLayout const& getDescriptorSetLayout(Variant variant = {}) const noexcept {
if (!isSharedVariant(variant)) {
return mDescriptorSetLayout;
}
FMaterial const* const pDefaultMaterial = mEngine.getDefaultMaterial();
if (UTILS_UNLIKELY(!pDefaultMaterial)) {
return mDescriptorSetLayout;
}
return pDefaultMaterial->getDescriptorSetLayout();
}
void compile(CompilerPriorityQueue priority,