Remove legacy shader pass and artifact fallbacks
This commit is contained in:
@@ -11,9 +11,9 @@ namespace XCEngine {
|
||||
namespace Resources {
|
||||
|
||||
constexpr Core::uint32 kTextureArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kMaterialArtifactSchemaVersion = 4;
|
||||
constexpr Core::uint32 kMaterialArtifactSchemaVersion = 6;
|
||||
constexpr Core::uint32 kMeshArtifactSchemaVersion = 2;
|
||||
constexpr Core::uint32 kShaderArtifactSchemaVersion = 4;
|
||||
constexpr Core::uint32 kShaderArtifactSchemaVersion = 5;
|
||||
constexpr Core::uint32 kUIDocumentArtifactSchemaVersion = 2;
|
||||
|
||||
struct TextureArtifactHeader {
|
||||
@@ -46,27 +46,10 @@ struct MeshArtifactHeader {
|
||||
};
|
||||
|
||||
struct MaterialArtifactFileHeader {
|
||||
char magic[8] = { 'X', 'C', 'M', 'A', 'T', '0', '4', '\0' };
|
||||
char magic[8] = { 'X', 'C', 'M', 'A', 'T', '0', '6', '\0' };
|
||||
Core::uint32 schemaVersion = kMaterialArtifactSchemaVersion;
|
||||
};
|
||||
|
||||
struct MaterialArtifactHeaderV2 {
|
||||
Core::int32 renderQueue = static_cast<Core::int32>(MaterialRenderQueue::Geometry);
|
||||
MaterialRenderState renderState = {};
|
||||
Core::uint32 tagCount = 0;
|
||||
Core::uint32 propertyCount = 0;
|
||||
Core::uint32 textureBindingCount = 0;
|
||||
};
|
||||
|
||||
struct MaterialArtifactHeaderV3 {
|
||||
Core::int32 renderQueue = static_cast<Core::int32>(MaterialRenderQueue::Geometry);
|
||||
MaterialRenderState renderState = {};
|
||||
Core::uint32 tagCount = 0;
|
||||
Core::uint32 keywordCount = 0;
|
||||
Core::uint32 propertyCount = 0;
|
||||
Core::uint32 textureBindingCount = 0;
|
||||
};
|
||||
|
||||
struct MaterialArtifactHeader {
|
||||
Core::int32 renderQueue = static_cast<Core::int32>(MaterialRenderQueue::Geometry);
|
||||
MaterialRenderState renderState = {};
|
||||
@@ -83,7 +66,7 @@ struct MaterialPropertyArtifact {
|
||||
};
|
||||
|
||||
struct ShaderArtifactFileHeader {
|
||||
char magic[8] = { 'X', 'C', 'S', 'H', 'D', '0', '4', '\0' };
|
||||
char magic[8] = { 'X', 'C', 'S', 'H', 'D', '0', '5', '\0' };
|
||||
Core::uint32 schemaVersion = kShaderArtifactSchemaVersion;
|
||||
};
|
||||
|
||||
@@ -92,20 +75,7 @@ struct ShaderArtifactHeader {
|
||||
Core::uint32 passCount = 0;
|
||||
};
|
||||
|
||||
struct ShaderPassArtifactHeaderV1 {
|
||||
Core::uint32 tagCount = 0;
|
||||
Core::uint32 resourceCount = 0;
|
||||
Core::uint32 variantCount = 0;
|
||||
};
|
||||
|
||||
struct ShaderPassArtifactHeader {
|
||||
Core::uint32 tagCount = 0;
|
||||
Core::uint32 resourceCount = 0;
|
||||
Core::uint32 keywordDeclarationCount = 0;
|
||||
Core::uint32 variantCount = 0;
|
||||
};
|
||||
|
||||
struct ShaderPassArtifactHeaderV4 {
|
||||
struct ShaderPassArtifactHeaderV5 {
|
||||
Core::uint32 tagCount = 0;
|
||||
Core::uint32 resourceCount = 0;
|
||||
Core::uint32 keywordDeclarationCount = 0;
|
||||
@@ -124,13 +94,6 @@ struct ShaderResourceArtifact {
|
||||
Core::uint32 binding = 0;
|
||||
};
|
||||
|
||||
struct ShaderVariantArtifactHeaderV2 {
|
||||
Core::uint32 stage = 0;
|
||||
Core::uint32 language = 0;
|
||||
Core::uint32 backend = 0;
|
||||
Core::uint64 compiledBinarySize = 0;
|
||||
};
|
||||
|
||||
struct ShaderVariantArtifactHeader {
|
||||
Core::uint32 stage = 0;
|
||||
Core::uint32 language = 0;
|
||||
|
||||
@@ -13,8 +13,7 @@ inline Containers::String NormalizeBuiltinPassMetadataValue(const Containers::St
|
||||
|
||||
inline bool IsForwardPassName(const Containers::String& value) {
|
||||
const Containers::String normalized = NormalizeBuiltinPassMetadataValue(value);
|
||||
return normalized.Empty() ||
|
||||
normalized == Containers::String("forward") ||
|
||||
return normalized == Containers::String("forward") ||
|
||||
normalized == Containers::String("forwardbase") ||
|
||||
normalized == Containers::String("forwardlit") ||
|
||||
normalized == Containers::String("forwardonly");
|
||||
@@ -87,50 +86,6 @@ inline bool MatchesBuiltinPassName(
|
||||
}
|
||||
}
|
||||
|
||||
inline bool TryResolveBuiltinMaterialPassHint(
|
||||
const Containers::String& value,
|
||||
BuiltinMaterialPass& outPass) {
|
||||
const Containers::String normalized = NormalizeBuiltinPassMetadataValue(value);
|
||||
if (normalized.Empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsForwardPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::ForwardLit;
|
||||
return true;
|
||||
}
|
||||
if (IsUnlitPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::Unlit;
|
||||
return true;
|
||||
}
|
||||
if (IsDepthOnlyPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::DepthOnly;
|
||||
return true;
|
||||
}
|
||||
if (IsShadowCasterPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::ShadowCaster;
|
||||
return true;
|
||||
}
|
||||
if (IsObjectIdPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::ObjectId;
|
||||
return true;
|
||||
}
|
||||
if (IsSkyboxPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::Skybox;
|
||||
return true;
|
||||
}
|
||||
if (IsPostProcessPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::PostProcess;
|
||||
return true;
|
||||
}
|
||||
if (IsFinalColorPassName(normalized)) {
|
||||
outPass = BuiltinMaterialPass::FinalColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool ShaderPassHasExplicitBuiltinMetadata(const Resources::ShaderPass& shaderPass) {
|
||||
if (!shaderPass.name.Empty() &&
|
||||
shaderPass.name != Containers::String("Default")) {
|
||||
@@ -183,27 +138,6 @@ inline bool ShaderPassMatchesBuiltinPass(
|
||||
return hasMetadata;
|
||||
}
|
||||
|
||||
inline bool IsRedundantLegacyMaterialShaderPassHint(
|
||||
const Resources::Shader* shader,
|
||||
const Containers::String& shaderPass) {
|
||||
if (shader == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BuiltinMaterialPass builtinPass = BuiltinMaterialPass::ForwardLit;
|
||||
if (!TryResolveBuiltinMaterialPassHint(shaderPass, builtinPass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Resources::ShaderPass& pass : shader->GetPasses()) {
|
||||
if (ShaderPassMatchesBuiltinPass(pass, builtinPass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline BuiltinPassResourceSemantic ResolveBuiltinPassResourceSemantic(
|
||||
const Resources::ShaderResourceBindingDesc& binding) {
|
||||
Containers::String semantic = NormalizeBuiltinPassMetadataValue(binding.semantic);
|
||||
|
||||
@@ -441,23 +441,21 @@ inline bool IsTransparentRenderQueue(Core::int32 renderQueue) {
|
||||
|
||||
inline bool MatchesBuiltinPass(const Resources::Material* material, BuiltinMaterialPass pass) {
|
||||
if (material == nullptr) {
|
||||
return pass == BuiltinMaterialPass::ForwardLit;
|
||||
}
|
||||
|
||||
const Resources::Shader* shader = material->GetShader();
|
||||
if (shader != nullptr) {
|
||||
for (const Resources::ShaderPass& shaderPassEntry : shader->GetPasses()) {
|
||||
if (ShaderPassMatchesBuiltinPass(shaderPassEntry, pass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shader != nullptr && ShaderHasExplicitBuiltinMetadata(*shader)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return pass == BuiltinMaterialPass::ForwardLit;
|
||||
const Resources::Shader* shader = material->GetShader();
|
||||
if (shader == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Resources::ShaderPass& shaderPassEntry : shader->GetPasses()) {
|
||||
if (ShaderPassMatchesBuiltinPass(shaderPassEntry, pass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
Reference in New Issue
Block a user