载入中...
搜索中...
未找到
ShaderAssetValidation.cpp
浏览该文件的文档.
15 return type.basetype == spirv_cross::SPIRType::Float && type.width == 32 && type.vecsize == components &&
21 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader requires device features outside the baseline contract", {}, {}, "asset.shader.gpu-layout"));
23 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader extensions are outside the baseline contract", {}, {}, "asset.shader.gpu-layout"));
25 if (!resources.storage_buffers.empty() || !resources.storage_images.empty() || !resources.subpass_inputs.empty() ||
29 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader uses unsupported resources or specialization constants", {}, {}, "asset.shader.gpu-layout"));
31 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Only one fragment albedo sampler is supported", {}, {}, "asset.shader.gpu-layout"));
35 compiler.get_decoration(sampler.id, spv::DecorationBinding) != (mesh ? 1u : 0u) || !type.array.empty() ||
38 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Albedo must use the engine's single float sampler2D slot", {}, {}, "asset.shader.gpu-layout"));
41 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader uses unsupported uniform buffers", {}, {}, "asset.shader.gpu-layout"));
48 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Mesh Frame buffer does not match the supported prefix", {}, {}, "asset.shader.gpu-layout"));
53 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Mesh Frame member offset mismatch", {}, {}, "asset.shader.gpu-layout"));
55 if (member.basetype != spirv_cross::SPIRType::Float || member.width != 32 || member.columns != 4 ||
59 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Mesh Frame matrices require column-major mat4", {}, {}, "asset.shader.gpu-layout"));
61 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Mesh Frame requires vec4 fields", {}, {}, "asset.shader.gpu-layout"));
65 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Multiple push-constant blocks are unsupported", {}, {}, "asset.shader.gpu-layout"));
69 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Push constants require one float data[32] member", {}, {}, "asset.shader.gpu-layout"));
71 if (member.basetype != spirv_cross::SPIRType::Float || member.width != 32 || member.vecsize != 1 ||
72 member.columns != 1 || member.array.size() != 1 || !member.array_size_literal[0] || member.array[0] != 32 ||
74 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Push constants require tightly packed float data[32]", {}, {}, "asset.shader.gpu-layout"));
82 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Vertex attributes do not match the engine layout", {}, {}, "asset.shader.gpu-layout"));
90 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Fragment output must be location zero vec4", {}, {}, "asset.shader.gpu-layout"));
99 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader asset upload requires SPIRV-Tools and SPIRV-Cross", {}, {}, "asset.shader.gpu-layout"));
104 validator.SetMessageConsumer([&](spv_message_level_t, const char*, const spv_position_t&, const char* text) {
108 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "SPIR-V validation failed: " + diagnostics, {}, {}, "asset.shader.gpu-layout"));
122 if (!floatType(type, type.vecsize) || fragment.get_decoration(input.id, spv::DecorationComponent) != 0)
123 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Fragment varyings must be float vectors", {}, {}, "asset.shader.gpu-layout"));
129 if (!matched) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Vertex/fragment varying mismatch", {}, {}, "asset.shader.gpu-layout"));
133 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, error.what(), {}, {}, "asset.shader.gpu-layout"));
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Definition CookedMaterial.cpp:5
Result< void > validateShaderAssetGpu(const asset::ShaderAsset &shader)
Validate complete SPIR-V semantics and the supported engine pipeline interface before upload.
Definition ShaderAssetValidation.cpp:96
@ Unsupported
@ ParseError
Owning CPU program snapshot; decoding does not prove GPU/descriptor compatibility.
Definition ShaderAsset.h:26