generate the proper per-view descriptor-set layout in the shader
the per-view descriptor-set layout depends on both the material and the variant.
This commit is contained in:
@@ -32,7 +32,6 @@ backend::DescriptorSetLayout const& getDepthVariantLayout() noexcept;
|
||||
backend::DescriptorSetLayout const& getSsrVariantLayout() noexcept;
|
||||
backend::DescriptorSetLayout const& getPerRenderableLayout() noexcept;
|
||||
|
||||
backend::DescriptorSetLayout const& getPerViewLayout() noexcept; // @deprecated
|
||||
backend::DescriptorSetLayout getPerViewDescriptorSetLayout(
|
||||
MaterialDomain domain,
|
||||
UserVariantFilterMask variantFilter,
|
||||
|
||||
@@ -102,10 +102,6 @@ DescriptorSetLayout const& getSsrVariantLayout() noexcept {
|
||||
return ssrVariantDescriptorSetLayout;
|
||||
}
|
||||
|
||||
DescriptorSetLayout const& getPerViewLayout() noexcept {
|
||||
return perViewDescriptorSetLayout;
|
||||
}
|
||||
|
||||
DescriptorSetLayout const& getPerRenderableLayout() noexcept {
|
||||
return perRenderableDescriptorSetLayout;
|
||||
}
|
||||
@@ -160,6 +156,10 @@ DescriptorSetLayout getPerViewDescriptorSetLayout(
|
||||
bool isLit,
|
||||
ReflectionMode reflectionMode,
|
||||
RefractionMode refractionMode) noexcept {
|
||||
|
||||
bool const ssr = reflectionMode == ReflectionMode::SCREEN_SPACE ||
|
||||
refractionMode == RefractionMode::SCREEN_SPACE;
|
||||
|
||||
switch (domain) {
|
||||
case MaterialDomain::SURFACE: {
|
||||
//
|
||||
@@ -171,14 +171,13 @@ DescriptorSetLayout getPerViewDescriptorSetLayout(
|
||||
layout.bindings.erase(
|
||||
std::remove_if(layout.bindings.begin(), layout.bindings.end(),
|
||||
[](auto const& entry) {
|
||||
return entry.binding == PerViewBindingPoints::IBL_DFG_LUT ||
|
||||
entry.binding == PerViewBindingPoints::IBL_SPECULAR;
|
||||
return entry.binding == PerViewBindingPoints::IBL_DFG_LUT ||
|
||||
entry.binding == PerViewBindingPoints::IBL_SPECULAR;
|
||||
}),
|
||||
layout.bindings.end());
|
||||
}
|
||||
// remove descriptors not needed for SSRs
|
||||
if (reflectionMode != ReflectionMode::SCREEN_SPACE &&
|
||||
refractionMode != RefractionMode::SCREEN_SPACE) {
|
||||
if (!ssr) {
|
||||
layout.bindings.erase(
|
||||
std::remove_if(layout.bindings.begin(), layout.bindings.end(),
|
||||
[](auto const& entry) {
|
||||
|
||||
@@ -604,12 +604,30 @@ std::string ShaderGenerator::createFragmentProgram(ShaderModel shaderModel,
|
||||
CodeGenerator::generateSeparator(fs);
|
||||
|
||||
if (featureLevel >= FeatureLevel::FEATURE_LEVEL_1) {
|
||||
assert_invariant(mMaterialDomain == MaterialDomain::SURFACE);
|
||||
|
||||
// We need to filter out all the descriptors not included in the "resolved" layout below
|
||||
backend::DescriptorSetLayout const perViewDescriptorSetLayout =
|
||||
descriptor_sets::getPerViewDescriptorSetLayout(
|
||||
mMaterialDomain, variantFilter,
|
||||
material.isLit, material.reflectionMode, material.refractionMode);
|
||||
auto getPerViewDescriptorSetLayoutWithVariant = [](
|
||||
filament::Variant variant,
|
||||
UserVariantFilterMask variantFilter,
|
||||
bool isLit,
|
||||
ReflectionMode reflectionMode,
|
||||
RefractionMode refractionMode) -> backend::DescriptorSetLayout {
|
||||
|
||||
if (filament::Variant::isValidDepthVariant(variant)) {
|
||||
return descriptor_sets::getDepthVariantLayout();
|
||||
}
|
||||
if (filament::Variant::isSSRVariant(variant)) {
|
||||
return descriptor_sets::getSsrVariantLayout();
|
||||
}
|
||||
// We need to filter out all the descriptors not included in the "resolved" layout below
|
||||
return descriptor_sets::getPerViewDescriptorSetLayout(
|
||||
MaterialDomain::SURFACE, variantFilter,
|
||||
isLit, reflectionMode, refractionMode);
|
||||
};
|
||||
|
||||
auto const perViewDescriptorSetLayout = getPerViewDescriptorSetLayoutWithVariant(
|
||||
variant, variantFilter,
|
||||
material.isLit, material.reflectionMode, material.refractionMode);
|
||||
|
||||
// this is the list of samplers we need to filter
|
||||
auto list = SibGenerator::getPerViewSib(variant).getSamplerInfoList();
|
||||
|
||||
Reference in New Issue
Block a user