Got PassBuilder shader dependency working and removed critical flag from shader builder
Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
@@ -321,7 +321,7 @@ namespace AZ
|
||||
AssetBuilderSDK::JobDescriptor jobDescriptor;
|
||||
|
||||
jobDescriptor.m_priority = -5000;
|
||||
jobDescriptor.m_critical = true;
|
||||
jobDescriptor.m_critical = false;
|
||||
jobDescriptor.m_jobKey = ShaderVariantAssetBuilderJobKey;
|
||||
jobDescriptor.SetPlatformIdentifier(info.m_identifier.data());
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace AZ
|
||||
{
|
||||
const char* auxGeomWorldShaderFilePath = "Shaders/auxgeom/auxgeomworld.azshader";
|
||||
|
||||
m_shader = RPI::LoadShader(auxGeomWorldShaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(auxGeomWorldShaderFilePath);
|
||||
if (!m_shader)
|
||||
{
|
||||
AZ_Error("DynamicPrimitiveProcessor", false, "Failed to get shader");
|
||||
|
||||
@@ -1385,9 +1385,9 @@ namespace AZ
|
||||
const char* litObjectShaderFilePath = "Shaders/auxgeom/auxgeomobjectlit.azshader";
|
||||
|
||||
// constant color shader
|
||||
m_unlitShader = RPI::LoadShader(unlitObjectShaderFilePath);
|
||||
m_unlitShader = RPI::LoadCriticalShader(unlitObjectShaderFilePath);
|
||||
// direction light shader
|
||||
m_litShader = RPI::LoadShader(litObjectShaderFilePath);
|
||||
m_litShader = RPI::LoadCriticalShader(litObjectShaderFilePath);
|
||||
|
||||
if (m_unlitShader.get() == nullptr || m_litShader == nullptr)
|
||||
{
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ namespace AZ
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendDistance.azshader";
|
||||
m_shader = RPI::LoadShader(shaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ namespace AZ
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiance.azshader";
|
||||
m_shader = RPI::LoadShader(shaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ namespace AZ
|
||||
{
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
shader = RPI::LoadShader(shaderFilePath);
|
||||
shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ namespace AZ
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridClassification.azshader";
|
||||
m_shader = RPI::LoadShader(shaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ namespace AZ
|
||||
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
Data::Instance<RPI::Shader> shader = RPI::LoadShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.azshader");
|
||||
Data::Instance<RPI::Shader> shader = RPI::LoadCriticalShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.azshader");
|
||||
if (shader)
|
||||
{
|
||||
m_probeGridRenderData.m_drawListTag = shader->GetDrawListTag();
|
||||
|
||||
+3
-3
@@ -52,7 +52,7 @@ namespace AZ
|
||||
// load the ray tracing shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracing.azshader";
|
||||
m_rayTracingShader = RPI::LoadShader(shaderFilePath);
|
||||
m_rayTracingShader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_rayTracingShader == nullptr)
|
||||
{
|
||||
return;
|
||||
@@ -64,7 +64,7 @@ namespace AZ
|
||||
|
||||
// closest hit shader
|
||||
AZStd::string closestHitShaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingClosestHit.azshader";
|
||||
m_closestHitShader = RPI::LoadShader(closestHitShaderFilePath);
|
||||
m_closestHitShader = RPI::LoadCriticalShader(closestHitShaderFilePath);
|
||||
|
||||
auto closestHitShaderVariant = m_closestHitShader->GetVariant(RPI::ShaderAsset::RootShaderVariantStableId);
|
||||
RHI::PipelineStateDescriptorForRayTracing closestHitShaderDescriptor;
|
||||
@@ -72,7 +72,7 @@ namespace AZ
|
||||
|
||||
// miss shader
|
||||
AZStd::string missShaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingMiss.azshader";
|
||||
m_missShader = RPI::LoadShader(missShaderFilePath);
|
||||
m_missShader = RPI::LoadCriticalShader(missShaderFilePath);
|
||||
|
||||
auto missShaderVariant = m_missShader->GetVariant(RPI::ShaderAsset::RootShaderVariantStableId);
|
||||
RHI::PipelineStateDescriptorForRayTracing missShaderDescriptor;
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ namespace AZ
|
||||
// load shader
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRelocation.azshader";
|
||||
m_shader = RPI::LoadShader(shaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ namespace AZ
|
||||
// create the shader resource group
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.azshader";
|
||||
m_shader = RPI::LoadShader(shaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(shaderFilePath);
|
||||
if (m_shader == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -446,7 +446,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
{
|
||||
m_shader = RPI::LoadShader(ImguiShaderFilePath);
|
||||
m_shader = RPI::LoadCriticalShader(ImguiShaderFilePath);
|
||||
|
||||
m_pipelineState = aznew RPI::PipelineStateForDraw;
|
||||
m_pipelineState->Init(m_shader);
|
||||
|
||||
+1
-1
@@ -487,7 +487,7 @@ namespace AZ
|
||||
RHI::DrawListTag& drawListTag)
|
||||
{
|
||||
// load shader
|
||||
shader = RPI::LoadShader(filePath);
|
||||
shader = RPI::LoadCriticalShader(filePath);
|
||||
AZ_Error("ReflectionProbeFeatureProcessor", shader, "Failed to find asset for shader [%s]", filePath);
|
||||
|
||||
// store drawlist tag
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ namespace AZ
|
||||
|
||||
// load shaders
|
||||
AZStd::string verticalBlurShaderFilePath = "Shaders/Reflections/ReflectionScreenSpaceBlurVertical.azshader";
|
||||
Data::Instance<AZ::RPI::Shader> verticalBlurShader = RPI::LoadShader(verticalBlurShaderFilePath);
|
||||
Data::Instance<AZ::RPI::Shader> verticalBlurShader = RPI::LoadCriticalShader(verticalBlurShaderFilePath);
|
||||
if (verticalBlurShader == nullptr)
|
||||
{
|
||||
AZ_Error("PassSystem", false, "[ReflectionScreenSpaceBlurPass '%s']: Failed to load shader '%s'!", GetPathName().GetCStr(), verticalBlurShaderFilePath.c_str());
|
||||
@@ -60,7 +60,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
AZStd::string horizontalBlurShaderFilePath = "Shaders/Reflections/ReflectionScreenSpaceBlurHorizontal.azshader";
|
||||
Data::Instance<AZ::RPI::Shader> horizontalBlurShader = RPI::LoadShader(horizontalBlurShaderFilePath);
|
||||
Data::Instance<AZ::RPI::Shader> horizontalBlurShader = RPI::LoadCriticalShader(horizontalBlurShaderFilePath);
|
||||
if (horizontalBlurShader == nullptr)
|
||||
{
|
||||
AZ_Error("PassSystem", false, "[ReflectionScreenSpaceBlurPass '%s']: Failed to load shader '%s'!", GetPathName().GetCStr(), horizontalBlurShaderFilePath.c_str());
|
||||
|
||||
@@ -22,19 +22,21 @@ namespace AZ
|
||||
class Shader;
|
||||
|
||||
//! Get the asset ID for a given shader file path
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath);
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath, bool isCritical = false);
|
||||
|
||||
//! Finds a shader asset for the given shader asset ID. Optional shaderFilePath param for debugging.
|
||||
Data::Asset<ShaderAsset> FindShaderAsset(Data::AssetId shaderAssetId, const AZStd::string& shaderFilePath = "");
|
||||
|
||||
//! Finds a shader asset for the given shader file path
|
||||
Data::Asset<ShaderAsset> FindShaderAsset(const AZStd::string& shaderFilePath);
|
||||
Data::Asset<ShaderAsset> FindCriticalShaderAsset(const AZStd::string& shaderFilePath);
|
||||
|
||||
//! Loads a shader for the given shader asset ID. Optional shaderFilePath param for debugging.
|
||||
Data::Instance<Shader> LoadShader(Data::AssetId shaderAssetId, const AZStd::string& shaderFilePath = "");
|
||||
|
||||
//! Loads a shader for the given shader file path
|
||||
Data::Instance<Shader> LoadShader(const AZStd::string& shaderFilePath);
|
||||
Data::Instance<Shader> LoadCriticalShader(const AZStd::string& shaderFilePath);
|
||||
|
||||
//! Loads a streaming image asset for the given file path
|
||||
Data::Instance<RPI::StreamingImage> LoadStreamingTexture(AZStd::string_view path);
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace AZ
|
||||
|
||||
// --- Code related to dependency shader asset handling ---
|
||||
|
||||
// Helper class to pass parameters to the AddDependency and FindReferencedAssets functions below
|
||||
struct FindPassReferenceAssetParams
|
||||
{
|
||||
void* passAssetObject;
|
||||
@@ -77,50 +78,28 @@ namespace AZ
|
||||
const char* jobKey; // Job key for adding job dependency
|
||||
};
|
||||
|
||||
//! Adds all relevant dependencies for a referenced source file, considering that the path might be relative to the original file location or a full asset path.
|
||||
//! This will usually include multiple source dependencies and a single job dependency, but will include only source dependencies if the file is not found.
|
||||
//! Note the AssetBuilderSDK::JobDependency::m_platformIdentifier will not be set by this function. The calling code must set this value before passing back
|
||||
//! to the AssetBuilderSDK::CreateJobsResponse.
|
||||
void AddPossibleDependencies(
|
||||
FindPassReferenceAssetParams& params,
|
||||
AssetBuilderSDK::CreateJobsResponse& response,
|
||||
AssetBuilderSDK::JobDescriptor& job)
|
||||
// Helper function to get a file reference and create a corresponding job dependency
|
||||
void AddDependency(FindPassReferenceAssetParams& params, AssetBuilderSDK::JobDescriptor* job)
|
||||
{
|
||||
bool dependencyFileFound = false;
|
||||
AZStd::string_view& file = params.dependencySourceFile;
|
||||
AZ::Data::AssetInfo sourceInfo;
|
||||
AZStd::string watchFolder;
|
||||
bool fileFound = false;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(fileFound, &AzToolsFramework::AssetSystem::AssetSystemRequest::GetSourceInfoBySourcePath, file.data(), sourceInfo, watchFolder);
|
||||
|
||||
AZStd::vector<AZStd::string> possibleDependencies = RPI::AssetUtils::GetPossibleDepenencyPaths(params.passAssetSourceFile, params.dependencySourceFile);
|
||||
for (auto& file : possibleDependencies)
|
||||
if (fileFound)
|
||||
{
|
||||
AssetBuilderSDK::SourceFileDependency sourceFileDependency;
|
||||
sourceFileDependency.m_sourceFileDependencyPath = file;
|
||||
response.m_sourceFileDependencyList.push_back(sourceFileDependency);
|
||||
|
||||
// The first path found is the highest priority, and will have a job dependency, as this is the one
|
||||
// the builder will actually use
|
||||
if (!dependencyFileFound)
|
||||
{
|
||||
AZ::Data::AssetInfo sourceInfo;
|
||||
AZStd::string watchFolder;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(dependencyFileFound, &AzToolsFramework::AssetSystem::AssetSystemRequest::GetSourceInfoBySourcePath, file.c_str(), sourceInfo, watchFolder);
|
||||
|
||||
if (dependencyFileFound)
|
||||
{
|
||||
AssetBuilderSDK::JobDependency jobDependency;
|
||||
jobDependency.m_jobKey = params.jobKey;
|
||||
jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order;
|
||||
jobDependency.m_sourceFile.m_sourceFileDependencyPath = file;
|
||||
job.m_jobDependencyList.push_back(jobDependency);
|
||||
}
|
||||
}
|
||||
AssetBuilderSDK::JobDependency jobDependency;
|
||||
jobDependency.m_jobKey = params.jobKey;
|
||||
jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order;
|
||||
jobDependency.m_sourceFile.m_sourceFileDependencyPath = file;
|
||||
job->m_jobDependencyList.push_back(jobDependency);
|
||||
AZ_TracePrintf(PassBuilderName, "Creating job dependency on file [%s] \n", file.data());
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to find all assetId's and object references
|
||||
bool FindPassReferencedAssets(FindPassReferenceAssetParams& params,
|
||||
AZStd::unordered_set<Data::AssetId>& referencedAssetList,
|
||||
AssetBuilderSDK::CreateJobsResponse& response,
|
||||
AssetBuilderSDK::JobDescriptor& job,
|
||||
bool jobCreationPhase)
|
||||
bool FindReferencedAssets(FindPassReferenceAssetParams& params, AssetBuilderSDK::JobDescriptor* job)
|
||||
{
|
||||
SerializeContext::ErrorHandler errorLogger;
|
||||
errorLogger.Reset();
|
||||
@@ -141,10 +120,10 @@ namespace AZ
|
||||
const AZStd::string& path = assetReference->m_filePath;
|
||||
uint32_t subId = 0;
|
||||
|
||||
if (jobCreationPhase)
|
||||
if (job != nullptr) // Create Job Phase
|
||||
{
|
||||
params.dependencySourceFile = path;
|
||||
AddPossibleDependencies(params, response, job);
|
||||
AddDependency(params, job);
|
||||
}
|
||||
else // Process Job Phase
|
||||
{
|
||||
@@ -161,12 +140,6 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the asset ID is valid, add it as a dependency
|
||||
if (assetReference->m_assetId.IsValid())
|
||||
{
|
||||
referencedAssetList.insert(assetReference->m_assetId);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -196,15 +169,16 @@ namespace AZ
|
||||
|
||||
void PassBuilder::CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response) const
|
||||
{
|
||||
// --- Handle shutdown case ---
|
||||
|
||||
if (m_isShuttingDown)
|
||||
{
|
||||
response.m_result = AssetBuilderSDK::CreateJobsResultCode::ShuttingDown;
|
||||
return;
|
||||
}
|
||||
|
||||
AssetBuilderSDK::JobDescriptor job;
|
||||
// --- Get serialization context ---
|
||||
|
||||
// Get serialization context
|
||||
SerializeContext* serializeContext = nullptr;
|
||||
ComponentApplicationBus::BroadcastResult(serializeContext, &ComponentApplicationBus::Events::GetSerializeContext);
|
||||
if (!serializeContext)
|
||||
@@ -213,7 +187,8 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Load PassAsset
|
||||
// --- Load PassAsset ---
|
||||
|
||||
AZStd::string fullPath;
|
||||
AzFramework::StringFunc::Path::ConstructFull(request.m_watchFolder.c_str(), request.m_sourceFile.c_str(), fullPath, true);
|
||||
|
||||
@@ -227,7 +202,12 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Find all Asset IDs we depend on
|
||||
AssetBuilderSDK::JobDescriptor job;
|
||||
job.m_jobKey = PassBuilderJobKey;
|
||||
job.m_critical = true; // Passes are a critical part of the rendering system
|
||||
|
||||
// --- Find all dependencies ---
|
||||
|
||||
AZStd::unordered_set<Data::AssetId> dependentList;
|
||||
Uuid passAssetUuid = AzTypeInfo<PassAsset>::Uuid();
|
||||
|
||||
@@ -238,30 +218,30 @@ namespace AZ
|
||||
params.serializeContext = serializeContext;
|
||||
params.jobKey = "Shader Asset";
|
||||
|
||||
if (!FindPassReferencedAssets(params, dependentList, response, job, true))
|
||||
if (!FindReferencedAssets(params, &job))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// --- Create a job per platform ---
|
||||
|
||||
for (const AssetBuilderSDK::PlatformInfo& platformInfo : request.m_enabledPlatforms)
|
||||
{
|
||||
job.m_jobKey = PassBuilderJobKey;
|
||||
for (auto& jobDependency : job.m_jobDependencyList)
|
||||
{
|
||||
jobDependency.m_platformIdentifier = platformInfo.m_identifier.c_str();
|
||||
}
|
||||
job.SetPlatformIdentifier(platformInfo.m_identifier.c_str());
|
||||
|
||||
// Passes are a critical part of the rendering system
|
||||
job.m_critical = true;
|
||||
|
||||
response.m_createJobOutputs.push_back(job);
|
||||
}
|
||||
|
||||
response.m_result = AssetBuilderSDK::CreateJobsResultCode::Success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PassBuilder::ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const
|
||||
{
|
||||
// Handle job cancellation and shutdown cases
|
||||
// --- Handle job cancellation and shutdown cases ---
|
||||
|
||||
AssetBuilderSDK::JobCancelListener jobCancelListener(request.m_jobId);
|
||||
if (jobCancelListener.IsCancelled() || m_isShuttingDown)
|
||||
{
|
||||
@@ -269,7 +249,8 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Get serialization context
|
||||
// --- Get serialization context ---
|
||||
|
||||
SerializeContext* serializeContext = nullptr;
|
||||
ComponentApplicationBus::BroadcastResult(serializeContext, &ComponentApplicationBus::Events::GetSerializeContext);
|
||||
if (!serializeContext)
|
||||
@@ -278,7 +259,8 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Load PassAsset
|
||||
// --- Load PassAsset ---
|
||||
|
||||
PassAsset passAsset;
|
||||
AZ::Outcome<void, AZStd::string> loadResult = JsonSerializationUtils::LoadObjectFromFile(passAsset, request.m_fullPath);
|
||||
|
||||
@@ -289,8 +271,8 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Find all Asset IDs we depend on
|
||||
AZStd::unordered_set<Data::AssetId> dependentList;
|
||||
// --- Find all dependencies ---
|
||||
|
||||
Uuid passAssetUuid = AzTypeInfo<PassAsset>::Uuid();
|
||||
|
||||
FindPassReferenceAssetParams params;
|
||||
@@ -300,21 +282,20 @@ namespace AZ
|
||||
params.serializeContext = serializeContext;
|
||||
params.jobKey = "Shader Asset";
|
||||
|
||||
AssetBuilderSDK::CreateJobsResponse dummyResponse;
|
||||
AssetBuilderSDK::JobDescriptor dummyJob;
|
||||
|
||||
if (!FindPassReferencedAssets(params, dependentList, dummyResponse, dummyJob, false))
|
||||
if (!FindReferencedAssets(params, nullptr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get destination file name and path
|
||||
// --- Get destination file name and path ---
|
||||
|
||||
AZStd::string destFileName;
|
||||
AZStd::string destPath;
|
||||
AzFramework::StringFunc::Path::GetFullFileName(request.m_fullPath.c_str(), destFileName);
|
||||
AzFramework::StringFunc::Path::ConstructFull(request.m_tempDirPath.c_str(), destFileName.c_str(), destPath, true);
|
||||
|
||||
// Save the asset to binary format for production
|
||||
// --- Save the asset to binary format for production ---
|
||||
|
||||
bool result = Utils::SaveObjectToFile(destPath, DataStream::ST_BINARY, &passAsset, passAssetUuid, serializeContext);
|
||||
if (result == false)
|
||||
{
|
||||
@@ -322,14 +303,10 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
// Success. Save output product(s) to response
|
||||
AssetBuilderSDK::JobProduct jobProduct(destPath, PassAsset::RTTI_Type(), 0);
|
||||
for (auto& assetId : dependentList)
|
||||
{
|
||||
jobProduct.m_dependencies.emplace_back(AssetBuilderSDK::ProductDependency(assetId, 0));
|
||||
}
|
||||
// --- Save output product(s) to response ---
|
||||
|
||||
jobProduct.m_dependenciesHandled = true; // We've output the dependencies immediately above so it's OK to tell the AP we've handled dependencies
|
||||
AssetBuilderSDK::JobProduct jobProduct(destPath, PassAsset::RTTI_Type(), 0);
|
||||
jobProduct.m_dependenciesHandled = true;
|
||||
response.m_outputProducts.push_back(jobProduct);
|
||||
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AZ
|
||||
|
||||
// Load shader and srg
|
||||
const char* ShaderPath = "shader/decomposemsimage.azshader";
|
||||
m_decomposeShader = LoadShader(ShaderPath);
|
||||
m_decomposeShader = LoadCriticalShader(ShaderPath);
|
||||
|
||||
if (m_decomposeShader == nullptr)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <Atom/RPI.Reflect/Shader/ShaderAsset.h>
|
||||
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
@@ -20,7 +21,7 @@ namespace AZ
|
||||
namespace RPI
|
||||
{
|
||||
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath)
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath, bool isCritical)
|
||||
{
|
||||
Data::AssetId shaderAssetId;
|
||||
|
||||
@@ -34,6 +35,19 @@ namespace AZ
|
||||
|
||||
if (!shaderAssetId.IsValid())
|
||||
{
|
||||
if (isCritical)
|
||||
{
|
||||
Data::Asset<RPI::ShaderAsset> shaderAsset = RPI::AssetUtils::LoadCriticalAsset<RPI::ShaderAsset>(shaderFilePath);
|
||||
if (shaderAsset.IsReady())
|
||||
{
|
||||
return shaderAsset.GetId();
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("RPI Utils", false, "Could not load critical shader [%s]", shaderFilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Error("RPI Utils", false, "Failed to get asset id for shader [%s]", shaderFilePath.c_str());
|
||||
}
|
||||
|
||||
@@ -83,11 +97,23 @@ namespace AZ
|
||||
return FindShaderAsset(GetShaderAssetId(shaderFilePath), shaderFilePath);
|
||||
}
|
||||
|
||||
Data::Asset<ShaderAsset> FindCriticalShaderAsset(const AZStd::string& shaderFilePath)
|
||||
{
|
||||
const bool isCritical = true;
|
||||
return FindShaderAsset(GetShaderAssetId(shaderFilePath, isCritical), shaderFilePath);
|
||||
}
|
||||
|
||||
Data::Instance<Shader> LoadShader(const AZStd::string& shaderFilePath)
|
||||
{
|
||||
return LoadShader(GetShaderAssetId(shaderFilePath), shaderFilePath);
|
||||
}
|
||||
|
||||
Data::Instance<Shader> LoadCriticalShader(const AZStd::string& shaderFilePath)
|
||||
{
|
||||
const bool isCritical = true;
|
||||
return LoadShader(GetShaderAssetId(shaderFilePath, isCritical), shaderFilePath);
|
||||
}
|
||||
|
||||
AZ::Data::Instance<RPI::StreamingImage> LoadStreamingTexture(AZStd::string_view path)
|
||||
{
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
|
||||
@@ -79,7 +79,7 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc
|
||||
|
||||
// Load the shader to be used for 2d drawing
|
||||
const char* shaderFilepath = "Shaders/SimpleTextured.azshader";
|
||||
AZ::Data::Instance<AZ::RPI::Shader> shader = AZ::RPI::LoadShader(shaderFilepath);
|
||||
AZ::Data::Instance<AZ::RPI::Shader> shader = AZ::RPI::LoadCriticalShader(shaderFilepath);
|
||||
|
||||
// Set scene to be associated with the dynamic draw context
|
||||
AZ::RPI::ScenePtr scene;
|
||||
|
||||
@@ -58,7 +58,7 @@ void UiRenderer::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstra
|
||||
|
||||
// Load the UI shader
|
||||
const char* uiShaderFilepath = "Shaders/LyShineUI.azshader";
|
||||
AZ::Data::Instance<AZ::RPI::Shader> uiShader = AZ::RPI::LoadShader(uiShaderFilepath);
|
||||
AZ::Data::Instance<AZ::RPI::Shader> uiShader = AZ::RPI::LoadCriticalShader(uiShaderFilepath);
|
||||
|
||||
// Create scene to be used by the dynamic draw context
|
||||
if (m_viewportContext)
|
||||
|
||||
Reference in New Issue
Block a user