Fix bug in ShaderVariantAssetBuilder. Add cvar in MeshDrawPacket class. (#61)
Fix bug in ShaderVariantAssetBuilder. Add a console variable to force root shader variant usage.
This commit is contained in:
@@ -162,7 +162,7 @@ namespace AZ
|
||||
AZStd::string expectedHigherPrecedenceFileFullPath;
|
||||
AzFramework::StringFunc::Path::Join(gameProjectPath, RPI::ShaderVariantTreeAsset::CommonSubFolder, expectedHigherPrecedenceFileFullPath, false /* handle directory overlap? */, false /* be case insensitive? */);
|
||||
AzFramework::StringFunc::Path::Join(expectedHigherPrecedenceFileFullPath.c_str(), shaderProductFileRelativePath.c_str(), expectedHigherPrecedenceFileFullPath, false /* handle directory overlap? */, false /* be case insensitive? */);
|
||||
AzFramework::StringFunc::Path::ReplaceExtension(expectedHigherPrecedenceFileFullPath, AZ::RPI::ShaderVariantAsset::Extension);
|
||||
AzFramework::StringFunc::Path::ReplaceExtension(expectedHigherPrecedenceFileFullPath, AZ::RPI::ShaderVariantListSourceData::Extension);
|
||||
AzFramework::StringFunc::Path::Normalize(expectedHigherPrecedenceFileFullPath);
|
||||
|
||||
AZStd::string normalizedShaderVariantListFileFullPath = shaderVariantListFileFullPath;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AtomCore/std/parallel/concurrency_checker.h>
|
||||
#include <AzCore/Console/Console.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -160,8 +161,14 @@ namespace AZ
|
||||
|
||||
// called when reflection probes are modified in the editor so that meshes can re-evaluate their probes
|
||||
void UpdateMeshReflectionProbes();
|
||||
|
||||
private:
|
||||
void ForceRebuildDrawPackets(const AZ::ConsoleCommandContainer& arguments);
|
||||
AZ_CONSOLEFUNC(MeshFeatureProcessor,
|
||||
ForceRebuildDrawPackets,
|
||||
AZ::ConsoleFunctorFlags::Null,
|
||||
"(For Testing) Invalidates all mesh draw packets, causing them to rebuild on the next frame."
|
||||
);
|
||||
|
||||
MeshFeatureProcessor(const MeshFeatureProcessor&) = delete;
|
||||
|
||||
// RPI::SceneNotificationBus::Handler overrides...
|
||||
|
||||
@@ -387,6 +387,11 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::ForceRebuildDrawPackets([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
m_forceRebuildDrawPackets = true;
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::OnRenderPipelineAdded(RPI::RenderPipelinePtr pipeline)
|
||||
{
|
||||
m_forceRebuildDrawPackets = true;;
|
||||
|
||||
@@ -17,11 +17,20 @@
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RHI/DrawPacketBuilder.h>
|
||||
#include <AzCore/Console/Console.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
AZ_CVAR(bool,
|
||||
r_forceRootShaderVariantUsage,
|
||||
false,
|
||||
[](const bool&) { AZ::Interface<AZ::IConsole>::Get()->PerformCommand("MeshFeatureProcessor.ForceRebuildDrawPackets"); },
|
||||
ConsoleFunctorFlags::Null,
|
||||
"(For Testing) Forces usage of root shader variant in the mesh draw packet level, ignoring any other shader variants that may exist."
|
||||
);
|
||||
|
||||
MeshDrawPacket::MeshDrawPacket(
|
||||
ModelLod& modelLod,
|
||||
size_t modelLodMeshIndex,
|
||||
@@ -187,7 +196,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
const ShaderVariantId finalVariantId = shaderOptions.GetShaderVariantId();
|
||||
const ShaderVariant& variant = shader->GetVariant(finalVariantId);
|
||||
const ShaderVariant& variant = r_forceRootShaderVariantUsage ? shader->GetRootVariant() : shader->GetVariant(finalVariantId);
|
||||
|
||||
Data::Instance<ShaderResourceGroup> drawSrg;
|
||||
if (drawSrgAsset)
|
||||
|
||||
Reference in New Issue
Block a user