rendering: formalize shader keyword metadata contract
This commit is contained in:
@@ -451,6 +451,7 @@ bool WriteMaterialArtifactFile(
|
||||
header.renderQueue = material.GetRenderQueue();
|
||||
header.renderState = material.GetRenderState();
|
||||
header.tagCount = material.GetTagCount();
|
||||
header.keywordCount = material.GetKeywordCount();
|
||||
|
||||
const std::vector<MaterialProperty> properties = GatherMaterialProperties(material);
|
||||
std::vector<MaterialProperty> nonTextureProperties;
|
||||
@@ -472,6 +473,10 @@ bool WriteMaterialArtifactFile(
|
||||
WriteString(output, material.GetTagValue(tagIndex));
|
||||
}
|
||||
|
||||
for (Core::uint32 keywordIndex = 0; keywordIndex < material.GetKeywordCount(); ++keywordIndex) {
|
||||
WriteString(output, material.GetKeyword(keywordIndex));
|
||||
}
|
||||
|
||||
for (const MaterialProperty& property : nonTextureProperties) {
|
||||
WriteString(output, property.name);
|
||||
|
||||
@@ -528,6 +533,7 @@ bool WriteShaderArtifactFile(const fs::path& artifactPath, const Shader& shader)
|
||||
ShaderPassArtifactHeader passHeader;
|
||||
passHeader.tagCount = static_cast<Core::uint32>(pass.tags.Size());
|
||||
passHeader.resourceCount = static_cast<Core::uint32>(pass.resources.Size());
|
||||
passHeader.keywordDeclarationCount = static_cast<Core::uint32>(pass.keywordDeclarations.Size());
|
||||
passHeader.variantCount = static_cast<Core::uint32>(pass.variants.Size());
|
||||
output.write(reinterpret_cast<const char*>(&passHeader), sizeof(passHeader));
|
||||
|
||||
@@ -547,6 +553,17 @@ bool WriteShaderArtifactFile(const fs::path& artifactPath, const Shader& shader)
|
||||
output.write(reinterpret_cast<const char*>(&resourceArtifact), sizeof(resourceArtifact));
|
||||
}
|
||||
|
||||
for (const ShaderKeywordDeclaration& declaration : pass.keywordDeclarations) {
|
||||
ShaderKeywordDeclarationArtifactHeader declarationHeader;
|
||||
declarationHeader.declarationType = static_cast<Core::uint32>(declaration.type);
|
||||
declarationHeader.optionCount = static_cast<Core::uint32>(declaration.options.Size());
|
||||
output.write(reinterpret_cast<const char*>(&declarationHeader), sizeof(declarationHeader));
|
||||
|
||||
for (const Containers::String& option : declaration.options) {
|
||||
WriteString(output, option);
|
||||
}
|
||||
}
|
||||
|
||||
for (const ShaderStageVariant& variant : pass.variants) {
|
||||
ShaderVariantArtifactHeader variantHeader;
|
||||
variantHeader.stage = static_cast<Core::uint32>(variant.stage);
|
||||
|
||||
Reference in New Issue
Block a user