载入中...
搜索中...
未找到
ShaderResourceValidation.cpp
浏览该文件的文档.
14 return t.basetype == spirv_cross::SPIRType::Float && t.width == 32 && t.vecsize == size && t.columns == 1 &&
17Result<void> stage(std::span<const uint32_t> words, bool vertex, const ShaderResourceInputs& inputs) {
20 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "Invalid Vulkan 1.2 SPIR-V", "shader.resources"));
24 entries[0].execution_model != (vertex ? spv::ExecutionModelVertex : spv::ExecutionModelFragment))
25 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Expected one main entry point with the requested stage", "shader.resources"));
28 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Resource programs require only Shader/Matrix capabilities", "shader.resources"));
29 if (!compiler.get_declared_extensions().empty() || !compiler.get_specialization_constants().empty())
30 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Extensions and specialization constants are unsupported", "shader.resources"));
34 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Resource programs require combined sampled images and uniform buffers", "shader.resources"));
35 if (r.storage_buffers.size() > 1) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Only the readonly instance matrix buffer is supported", "shader.resources"));
43 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Instance storage must be vertex-only set 1 binding 33", "shader.resources"));
47 m.basetype != spirv_cross::SPIRType::Float || m.width != 32 || m.vecsize != 4 || m.columns != 4 ||
48 m.array.size() != 1 || m.array[0] != 0 || compiler.type_struct_member_array_stride(t, 0) != 64 ||
51 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Instance storage must contain readonly column-major mat4 records", "shader.resources"));
59 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Expected a non-shadow, non-MS float combined image", "shader.resources"));
66 if (found == inputs.images.end()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader image binding has no supplied resource", "shader.resources"));
69 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Image binding is outside the resource program ABI", "shader.resources"));
73 if (t.image.dim != expectedDimension || bool(t.image.arrayed) != (expected == ShaderImageDimension::Array2D))
74 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Shader image view dimension does not match the supplied resource", "shader.resources"));
80 if (!compiler.get_type(buffer.type_id).array.empty()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Buffer descriptor arrays unsupported", "shader.resources"));
83 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Uniform buffer is larger than its supplied bytes", "shader.resources"));
85 if (t.member_types.empty() || t.member_types.size() > 6) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Expected the supported Frame prefix", "shader.resources"));
89 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Frame member offset mismatch", "shader.resources"));
94 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Frame matrices must be column-major mat4", "shader.resources"));
96 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Frame trailing members must be vec4", "shader.resources"));
99 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Uniform binding is outside the resource program ABI", "shader.resources"));
101 if (r.push_constant_buffers.size() > 1) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Multiple push constant blocks unsupported", "shader.resources"));
105 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Push constants must contain float data[32]", "shader.resources"));
107 if (m.basetype != spirv_cross::SPIRType::Float || m.width != 32 || m.vecsize != 1 || m.columns != 1 ||
110 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Push constants must be 128 tightly packed float bytes", "shader.resources"));
116 if (location > 5 || sizes[location] == 0 || !floats(compiler.get_type(input.type_id), sizes[location]))
117 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Resource vertex inputs require position/normal/UV or optional vec4 tangent at location 5", "shader.resources"));
122 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "Fragment output must be one vec4 at location 0", "shader.resources"));
128Result<void> validateResourceShaderStages(std::span<const uint32_t> vertex, std::span<const uint32_t> fragment,
138 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, error.what(), "shader.resources"));
144 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "SPIR-V validation provider is unavailable", "shader.resources"));
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 PbrGpuUniform.cpp:5
Result< void > validateResourceShaderStages(std::span< const uint32_t > vertex, std::span< const uint32_t > fragment, const ShaderResourceInputs &inputs)
Validate resource shader stages.
Definition ShaderResourceValidation.cpp:128
ShaderImageDimension
Sampled image view dimension; arrays retain all authored layers.
Definition ShaderResources.h:33
@ Unsupported
@ Unsupported
@ ParseError
Inputs for descriptor set 1 of a resource mesh program.
Definition ShaderResources.h:67