载入中...
搜索中...
未找到
ShaderAssetLoader.cpp
浏览该文件的文档.
3#include "asset/ShaderAsset.h"
4
5namespace eve::asset {
7 const EvpackCapabilities& capabilities) {
8 if (capabilities.graphics != "vulkan")
10 Diagnostic::error(DiagnosticCode::Unsupported, "eve.shader/1 requires Vulkan", {}, {}, "asset.shader"));
11 auto payload = reader.read(asset, "eve.shader/1", capabilities, 8 * 1024 * 1024);
12 if (!payload) return Result<ShaderAsset>::failure(payload.status());
13 if (payload.value().chunks.size() != 1 || payload.value().chunks.front().kind != EvpackChunkKind::Definition)
15 "eve.shader/1 requires one self-contained definition", {},
16 {}, "asset.shader"));
18 limits.maximumBytes = 8 * 1024 * 1024;
19 limits.maximumValues = 600000;
20 auto definition = decodeRuntimeDefinition(payload.value().chunks.front().bytes, limits);
21 if (!definition) return Result<ShaderAsset>::failure(definition.status());
22 return decodeShaderAsset(definition.value());
23}
24} // namespace eve::asset
Value::Object payload
Typed capability-aware runtime access to admitted packs.
JSON-free versioned runtime metadata codec.
const AssetImportLimits & limits
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Immutable reader retaining an admitted pack by shared ownership.
Result< RuntimeAssetPayload > read(const AssetRef &asset, std::string_view expectedType, const EvpackCapabilities &capabilities, std::uint64_t maximumDecodedBytes) const
Resolve, type-check, variant-select and decode a canonical runtime asset.
Result< Value > decodeRuntimeDefinition(std::span< const std::uint8_t > bytes, const RuntimeDefinitionLimits &limits)
Decode a bounded EVDEF\0\1 metadata tree without a JSON parser.
EVENGINE_API_FOUNDATION Result< ShaderAsset > loadShaderAsset(const EvpackResourceReader &reader, const AssetRef &asset, const EvpackCapabilities &capabilities)
Read and decode one capability-selected eve.shader/1 from an admitted runtime package.
Result< ShaderAsset > decodeShaderAsset(const Value &definition, const ShaderAssetLimits &limits)
Decode strict eve.shader/1 metadata with SPIR-V 1.0 through 1.6 stages.
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
Structural and allocation limits for untrusted EVDEF metadata.