Added support for supervariants to the PrecompiledShaderBuilder
Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com>
This commit is contained in:
@@ -120,7 +120,7 @@ namespace AZ
|
||||
// Register Precompiled Shader Builder
|
||||
AssetBuilderSDK::AssetBuilderDesc precompiledShaderBuilderDescriptor;
|
||||
precompiledShaderBuilderDescriptor.m_name = "Precompiled Shader Builder";
|
||||
precompiledShaderBuilderDescriptor.m_version = 10; // ATOM-15472
|
||||
precompiledShaderBuilderDescriptor.m_version = 11; // ATOM-15740
|
||||
precompiledShaderBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", AZ::PrecompiledShaderBuilder::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
|
||||
precompiledShaderBuilderDescriptor.m_busId = azrtti_typeid<PrecompiledShaderBuilder>();
|
||||
precompiledShaderBuilderDescriptor.m_createJobFunction = AZStd::bind(&PrecompiledShaderBuilder::CreateJobs, &m_precompiledShaderBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);
|
||||
|
||||
@@ -68,20 +68,23 @@ namespace AZ
|
||||
{
|
||||
AZStd::vector<AssetBuilderSDK::JobDependency> jobDependencyList;
|
||||
|
||||
// setup dependencies on the root azshadervariant asset file names
|
||||
for (const auto& rootShaderVariantAsset : precompiledShaderAsset.m_rootShaderVariantAssets)
|
||||
// setup dependencies on the root azshadervariant asset file names, for each supervariant
|
||||
for (const auto& supervariant : precompiledShaderAsset.m_supervariants)
|
||||
{
|
||||
AZStd::string rootShaderVariantAssetPath = RPI::AssetUtils::ResolvePathReference(request.m_sourceFile.c_str(), rootShaderVariantAsset->m_rootShaderVariantAssetFileName);
|
||||
AssetBuilderSDK::SourceFileDependency sourceDependency;
|
||||
sourceDependency.m_sourceFileDependencyPath = rootShaderVariantAssetPath;
|
||||
response.m_sourceFileDependencyList.push_back(sourceDependency);
|
||||
for (const auto& rootShaderVariantAsset : supervariant->m_rootShaderVariantAssets)
|
||||
{
|
||||
AZStd::string rootShaderVariantAssetPath = RPI::AssetUtils::ResolvePathReference(request.m_sourceFile.c_str(), rootShaderVariantAsset->m_rootShaderVariantAssetFileName);
|
||||
AssetBuilderSDK::SourceFileDependency sourceDependency;
|
||||
sourceDependency.m_sourceFileDependencyPath = rootShaderVariantAssetPath;
|
||||
response.m_sourceFileDependencyList.push_back(sourceDependency);
|
||||
|
||||
AssetBuilderSDK::JobDependency jobDependency;
|
||||
jobDependency.m_jobKey = "azshadervariant";
|
||||
jobDependency.m_platformIdentifier = platformInfo.m_identifier;
|
||||
jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order;
|
||||
jobDependency.m_sourceFile = sourceDependency;
|
||||
jobDependencyList.push_back(jobDependency);
|
||||
AssetBuilderSDK::JobDependency jobDependency;
|
||||
jobDependency.m_jobKey = "azshadervariant";
|
||||
jobDependency.m_platformIdentifier = platformInfo.m_identifier;
|
||||
jobDependency.m_type = AssetBuilderSDK::JobDependencyType::Order;
|
||||
jobDependency.m_sourceFile = sourceDependency;
|
||||
jobDependencyList.push_back(jobDependency);
|
||||
}
|
||||
}
|
||||
|
||||
AssetBuilderSDK::JobDescriptor job;
|
||||
@@ -137,33 +140,37 @@ namespace AZ
|
||||
|
||||
AssetBuilderSDK::JobProduct jobProduct;
|
||||
|
||||
// load the variant product assets
|
||||
// load the variant product assets, for each supervariant
|
||||
// these are the dependency root variant asset products that were processed prior to running this job
|
||||
RPI::ShaderAssetCreator::ShaderRootVariantAssets rootVariantProductAssets;
|
||||
for (AZStd::unique_ptr<RPI::RootShaderVariantAssetSourceData>& rootShaderVariantAsset : precompiledShaderAsset.m_rootShaderVariantAssets)
|
||||
RPI::ShaderAssetCreator::ShaderSupervariants supervariants;
|
||||
for (const auto& supervariant : precompiledShaderAsset.m_supervariants)
|
||||
{
|
||||
// retrieve the variant asset
|
||||
auto assetOutcome = RPI::AssetUtils::LoadAsset<RPI::ShaderVariantAsset>(request.m_fullPath, rootShaderVariantAsset->m_rootShaderVariantAssetFileName, 0);
|
||||
if (!assetOutcome)
|
||||
RPI::ShaderAssetCreator::ShaderRootVariantAssets rootVariantProductAssets;
|
||||
for (const auto& rootShaderVariantAsset : supervariant->m_rootShaderVariantAssets)
|
||||
{
|
||||
AZ_Error(PrecompiledShaderBuilderName, false, "Failed to retrieve Variant asset for file [%s]", rootShaderVariantAsset->m_rootShaderVariantAssetFileName.c_str());
|
||||
return;
|
||||
// retrieve the variant asset
|
||||
auto assetOutcome = RPI::AssetUtils::LoadAsset<RPI::ShaderVariantAsset>(request.m_fullPath, rootShaderVariantAsset->m_rootShaderVariantAssetFileName, 0);
|
||||
if (!assetOutcome)
|
||||
{
|
||||
AZ_Error(PrecompiledShaderBuilderName, false, "Failed to retrieve Variant asset for file [%s]", rootShaderVariantAsset->m_rootShaderVariantAssetFileName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
rootVariantProductAssets.push_back(AZStd::make_pair(RHI::APIType{ rootShaderVariantAsset->m_apiName.GetCStr() }, assetOutcome.GetValue()));
|
||||
|
||||
AssetBuilderSDK::ProductDependency productDependency;
|
||||
productDependency.m_dependencyId = assetOutcome.GetValue().GetId();
|
||||
productDependency.m_flags = AZ::Data::ProductDependencyInfo::CreateFlags(AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
jobProduct.m_dependencies.push_back(productDependency);
|
||||
}
|
||||
|
||||
rootVariantProductAssets.push_back(AZStd::make_pair(RHI::APIType{ rootShaderVariantAsset->m_apiName.GetCStr() }, assetOutcome.GetValue()));
|
||||
|
||||
AssetBuilderSDK::ProductDependency productDependency;
|
||||
productDependency.m_dependencyId = assetOutcome.GetValue().GetId();
|
||||
productDependency.m_flags = AZ::Data::ProductDependencyInfo::CreateFlags(AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
jobProduct.m_dependencies.push_back(productDependency);
|
||||
supervariants.push_back({ supervariant->m_name, rootVariantProductAssets });
|
||||
}
|
||||
|
||||
// use the ShaderAssetCreator to clone the shader asset, which will update the embedded Srg and Variant asset UUIDs
|
||||
// Note that the Srg and Variant assets do not have embedded asset references and are processed with the RC Copy functionality
|
||||
RPI::ShaderAssetCreator shaderAssetCreator;
|
||||
shaderAssetCreator.Clone(Uuid::CreateRandom(),
|
||||
*shaderAsset,
|
||||
rootVariantProductAssets);
|
||||
shaderAssetCreator.Clone(Uuid::CreateRandom(), *shaderAsset, supervariants);
|
||||
|
||||
Data::Asset<RPI::ShaderAsset> outputShaderAsset;
|
||||
if (!shaderAssetCreator.End(outputShaderAsset))
|
||||
|
||||
+19
-12
@@ -7,21 +7,28 @@
|
||||
"ShaderAssetFileName": "diffuseprobegridblenddistance.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblenddistance_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+19
-12
@@ -7,21 +7,28 @@
|
||||
"ShaderAssetFileName": "diffuseprobegridblendirradiance.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridblendirradiance_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+20
-13
@@ -5,23 +5,30 @@
|
||||
"ClassData":
|
||||
{
|
||||
"ShaderAssetFileName": "diffuseprobegridborderupdatecolumn.azshader",
|
||||
"PlatformIdentifiers":
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdatecolumn_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+21
-16
@@ -2,26 +2,31 @@
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PrecompiledShaderAssetSourceData",
|
||||
"ClassData":
|
||||
{
|
||||
"ClassData": {
|
||||
"ShaderAssetFileName": "diffuseprobegridborderupdaterow.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"PlatformIdentifiers": [
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridborderupdaterow_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+19
-12
@@ -7,21 +7,28 @@
|
||||
"ShaderAssetFileName": "diffuseprobegridclassification.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridclassification_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+22
-16
@@ -2,27 +2,33 @@
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PrecompiledShaderAssetSourceData",
|
||||
"ClassData":
|
||||
"ClassData":
|
||||
{
|
||||
"ShaderAssetFileName": "diffuseprobegridraytracing.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"PlatformIdentifiers": [
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracing_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-14
@@ -2,27 +2,34 @@
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PrecompiledShaderAssetSourceData",
|
||||
"ClassData":
|
||||
"ClassData":
|
||||
{
|
||||
"ShaderAssetFileName": "diffuseprobegridraytracingclosesthit.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingclosesthit_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-13
@@ -2,26 +2,33 @@
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PrecompiledShaderAssetSourceData",
|
||||
"ClassData":
|
||||
"ClassData":
|
||||
{
|
||||
"ShaderAssetFileName": "diffuseprobegridraytracingmiss.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridraytracingmiss_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+21
-14
@@ -2,27 +2,34 @@
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PrecompiledShaderAssetSourceData",
|
||||
"ClassData":
|
||||
"ClassData":
|
||||
{
|
||||
"ShaderAssetFileName": "diffuseprobegridrelocation.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_null_0.azshadervariant"
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrelocation_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-14
@@ -7,22 +7,29 @@
|
||||
"ShaderAssetFileName": "diffuseprobegridrender.azshader",
|
||||
"PlatformIdentifiers":
|
||||
[
|
||||
"pc", "linux"
|
||||
"pc",
|
||||
"linux"
|
||||
],
|
||||
"RootShaderVariantAssets":
|
||||
"Supervariants":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_null_0.azshadervariant"
|
||||
}
|
||||
"Name": "",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-6
@@ -17,14 +17,14 @@ namespace AZ
|
||||
|
||||
namespace RPI
|
||||
{
|
||||
//! This asset contains is loaded from a Json file and contains information about
|
||||
//! This asset is loaded from a Json file and contains information about
|
||||
//! precompiled shader variants and their associated API name.
|
||||
struct RootShaderVariantAssetSourceData final
|
||||
struct PrecompiledRootShaderVariantAssetSourceData final
|
||||
: public Data::AssetData
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(RootShaderVariantAssetSourceData, "{661EF8A7-7BAC-41B6-AD5C-C7249B2390AD}");
|
||||
AZ_CLASS_ALLOCATOR(RootShaderVariantAssetSourceData, SystemAllocator, 0);
|
||||
AZ_RTTI(PrecompiledRootShaderVariantAssetSourceData, "{661EF8A7-7BAC-41B6-AD5C-C7249B2390AD}");
|
||||
AZ_CLASS_ALLOCATOR(PrecompiledRootShaderVariantAssetSourceData, SystemAllocator, 0);
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
@@ -32,7 +32,22 @@ namespace AZ
|
||||
AZStd::string m_rootShaderVariantAssetFileName;
|
||||
};
|
||||
|
||||
//! This asset contains is loaded from a Json file and contains information about
|
||||
//! This asset is loaded from a Json file and contains information about
|
||||
//! precompiled shader supervariants
|
||||
struct PrecompiledSupervariantSourceData final
|
||||
: public Data::AssetData
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(PrecompiledSupervariantSourceData, "{630BDF15-CE7C-4E2C-882E-4F7AF09C8BB6}");
|
||||
AZ_CLASS_ALLOCATOR(PrecompiledSupervariantSourceData, SystemAllocator, 0);
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
AZ::Name m_name;
|
||||
AZStd::vector<AZStd::unique_ptr<PrecompiledRootShaderVariantAssetSourceData>> m_rootShaderVariantAssets;
|
||||
};
|
||||
|
||||
//! This asset is loaded from a Json file and contains information about
|
||||
//! precompiled shader assets.
|
||||
struct PrecompiledShaderAssetSourceData final
|
||||
: public Data::AssetData
|
||||
@@ -45,7 +60,7 @@ namespace AZ
|
||||
|
||||
AZStd::string m_shaderAssetFileName;
|
||||
AZStd::vector<AZStd::string> m_platformIdentifiers;
|
||||
AZStd::vector<AZStd::unique_ptr<RootShaderVariantAssetSourceData>> m_rootShaderVariantAssets;
|
||||
AZStd::vector<AZStd::unique_ptr<PrecompiledSupervariantSourceData>> m_supervariants;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -75,11 +75,20 @@ namespace AZ
|
||||
|
||||
bool End(Data::Asset<ShaderAsset>& shaderAsset);
|
||||
|
||||
//! Clones an existing ShaderAsset nd replaces the referenced Srg and Variant assets
|
||||
using ShaderRootVariantAssets = AZStd::vector<AZStd::pair<AZ::Crc32, Data::Asset<RPI::ShaderVariantAsset>>>;
|
||||
//! Clones an existing ShaderAsset and replaces the ShaderVariant assets
|
||||
using ShaderRootVariantAssetPair = AZStd::pair<AZ::Crc32, Data::Asset<RPI::ShaderVariantAsset>>;
|
||||
using ShaderRootVariantAssets = AZStd::vector<ShaderRootVariantAssetPair>;
|
||||
|
||||
struct ShaderSupervariant
|
||||
{
|
||||
AZ::Name m_name;
|
||||
ShaderRootVariantAssets m_rootVariantAssets;
|
||||
};
|
||||
using ShaderSupervariants = AZStd::vector<ShaderSupervariant>;
|
||||
|
||||
void Clone(const Data::AssetId& assetId,
|
||||
const ShaderAsset& sourceShaderAsset,
|
||||
const ShaderRootVariantAssets& rootVariantAssets);
|
||||
const ShaderSupervariants& supervariants);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,29 +14,43 @@ namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
void RootShaderVariantAssetSourceData::Reflect(ReflectContext* context)
|
||||
void PrecompiledRootShaderVariantAssetSourceData::Reflect(ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<RootShaderVariantAssetSourceData>()
|
||||
serializeContext->Class<PrecompiledRootShaderVariantAssetSourceData>()
|
||||
->Version(0)
|
||||
->Field("APIName", &RootShaderVariantAssetSourceData::m_apiName)
|
||||
->Field("RootShaderVariantAssetFileName", &RootShaderVariantAssetSourceData::m_rootShaderVariantAssetFileName)
|
||||
->Field("APIName", &PrecompiledRootShaderVariantAssetSourceData::m_apiName)
|
||||
->Field("RootShaderVariantAssetFileName", &PrecompiledRootShaderVariantAssetSourceData::m_rootShaderVariantAssetFileName)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void PrecompiledSupervariantSourceData::Reflect(ReflectContext* context)
|
||||
{
|
||||
PrecompiledRootShaderVariantAssetSourceData::Reflect(context);
|
||||
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PrecompiledSupervariantSourceData>()
|
||||
->Version(0)
|
||||
->Field("Name", &PrecompiledSupervariantSourceData::m_name)
|
||||
->Field("RootShaderVariantAssets", &PrecompiledSupervariantSourceData::m_rootShaderVariantAssets)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void PrecompiledShaderAssetSourceData::Reflect(ReflectContext* context)
|
||||
{
|
||||
RootShaderVariantAssetSourceData::Reflect(context);
|
||||
PrecompiledSupervariantSourceData::Reflect(context);
|
||||
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PrecompiledShaderAssetSourceData>()
|
||||
->Version(1) // ATOM-15472
|
||||
->Version(2) // ATOM-15740
|
||||
->Field("ShaderAssetFileName", &PrecompiledShaderAssetSourceData::m_shaderAssetFileName)
|
||||
->Field("PlatformIdentifiers", &PrecompiledShaderAssetSourceData::m_platformIdentifiers)
|
||||
->Field("RootShaderVariantAssets", &PrecompiledShaderAssetSourceData::m_rootShaderVariantAssets)
|
||||
->Field("Supervariants", &PrecompiledShaderAssetSourceData::m_supervariants)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace AZ
|
||||
return EndCommon(shaderAsset);
|
||||
}
|
||||
|
||||
void ShaderAssetCreator::Clone(const Data::AssetId& assetId, const ShaderAsset& sourceShaderAsset, [[maybe_unused]] const ShaderRootVariantAssets& rootVariantAssets)
|
||||
void ShaderAssetCreator::Clone(const Data::AssetId& assetId, const ShaderAsset& sourceShaderAsset, [[maybe_unused]] const ShaderSupervariants& supervariants)
|
||||
{
|
||||
BeginCommon(assetId);
|
||||
|
||||
@@ -392,38 +392,60 @@ namespace AZ
|
||||
m_asset->m_shaderOptionGroupLayout = sourceShaderAsset.m_shaderOptionGroupLayout;
|
||||
m_asset->m_buildTimestamp = sourceShaderAsset.m_buildTimestamp;
|
||||
|
||||
// copy root variant assets
|
||||
// copy the perAPIShaderData
|
||||
for (auto& perAPIShaderData : sourceShaderAsset.m_perAPIShaderData)
|
||||
{
|
||||
// find the matching ShaderVariantAsset
|
||||
AZ::Data::Asset<ShaderVariantAsset> foundVariantAsset;
|
||||
for (const auto& variantAsset : rootVariantAssets)
|
||||
{
|
||||
if (variantAsset.first == perAPIShaderData.m_APIType)
|
||||
{
|
||||
foundVariantAsset = variantAsset.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundVariantAsset)
|
||||
{
|
||||
ReportWarning("Failed to find variant asset for API [%d]", perAPIShaderData.m_APIType);
|
||||
}
|
||||
|
||||
m_asset->m_perAPIShaderData.push_back(perAPIShaderData);
|
||||
if (m_asset->m_perAPIShaderData.back().m_supervariants.empty())
|
||||
if (perAPIShaderData.m_supervariants.empty())
|
||||
{
|
||||
ReportWarning("Attempting to clone a shader asset that has no supervariants for API [%d]", perAPIShaderData.m_APIType);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
if (perAPIShaderData.m_supervariants.size() != supervariants.size())
|
||||
{
|
||||
// currently we only support one supervariant when cloning
|
||||
// [GFX TODO][ATOM-15740] Support multiple supervariants in ShaderAssetCreator::Clone
|
||||
m_asset->m_perAPIShaderData.back().m_supervariants[0].m_rootShaderVariantAsset = foundVariantAsset;
|
||||
ReportError("Incorrect number of supervariants provided to ShaderAssetCreator::Clone");
|
||||
return;
|
||||
}
|
||||
|
||||
m_asset->m_perAPIShaderData.push_back(perAPIShaderData);
|
||||
|
||||
// set the supervariants for this API
|
||||
for (auto& supervariant : m_asset->m_perAPIShaderData.back().m_supervariants)
|
||||
{
|
||||
// find the matching Supervariant by name from the incoming list
|
||||
ShaderSupervariants::const_iterator itFoundSuperVariant = AZStd::find_if(
|
||||
supervariants.begin(),
|
||||
supervariants.end(),
|
||||
[&supervariant](const ShaderSupervariant& shaderSupervariant)
|
||||
{
|
||||
return supervariant.m_name == shaderSupervariant.m_name;
|
||||
});
|
||||
|
||||
if (itFoundSuperVariant == supervariants.end())
|
||||
{
|
||||
ReportError("Failed to find supervariant [%s]", supervariant.m_name.GetCStr());
|
||||
return;
|
||||
}
|
||||
|
||||
// find the matching ShaderVariantAsset for this API
|
||||
ShaderRootVariantAssets::const_iterator itFoundRootShaderVariantAsset = AZStd::find_if(
|
||||
itFoundSuperVariant->m_rootVariantAssets.begin(),
|
||||
itFoundSuperVariant->m_rootVariantAssets.end(),
|
||||
[&perAPIShaderData](const ShaderRootVariantAssetPair& rootShaderVariantAsset)
|
||||
{
|
||||
return perAPIShaderData.m_APIType == rootShaderVariantAsset.first;
|
||||
});
|
||||
|
||||
if (itFoundRootShaderVariantAsset == itFoundSuperVariant->m_rootVariantAssets.end())
|
||||
{
|
||||
ReportWarning("Failed to find root shader variant asset for API [%d] Supervariant [%s]", perAPIShaderData.m_APIType, supervariant.m_name.GetCStr());
|
||||
}
|
||||
else
|
||||
{
|
||||
supervariant.m_rootShaderVariantAsset = itFoundRootShaderVariantAsset->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
Reference in New Issue
Block a user