载入中...
搜索中...
未找到
ShaderImporter.cpp
浏览该文件的文档.
2#include "asset/ShaderAsset.h"
4
5namespace eve::asset_import {
7 if (json.size() > 8 * 1024 * 1024)
9 Diagnostic::error(DiagnosticCode::InvalidArgument, "Shader source exceeds budget", {}, {}, "asset.import"));
10 auto definition = Value::fromJson(json);
11 if (!definition) return Result<PreparedAssetImport>::failure(definition.status());
12 auto shader = asset::decodeShaderAsset(definition.value());
14 auto manifest = detail::baseManifest(package, "eve.shader");
15 if (!manifest) return Result<PreparedAssetImport>::failure(manifest.status());
16 auto reference = detail::assetRef(package.packageId.child("shader:default"));
18 auto canonical = definition.value().toJson();
19 if (!canonical) return Result<PreparedAssetImport>::failure(canonical.status());
21 result.manifest = std::move(manifest).takeValue();
22 const std::string path = "assets/" + reference.value().id().format() + "/asset.json";
23 std::vector<std::uint8_t> bytes(canonical.value().begin(), canonical.value().end());
24 result.manifest.assets.push_back(
25 {reference.value(), "eve.shader", SchemaVersion(1), path, detail::sha256(bytes), {"shader"}});
26 result.manifest.entrypoints.emplace("default", reference.value());
27 result.entries.push_back({path, std::move(bytes)});
28 result.sourceMappings.push_back({"shader:default", reference.value()});
29 result.findings.push_back({"shader:default", "SPIR-V", ImportDisposition::PreservedSource,
30 "CPU stage framing admitted; GPU layout validation is still required"});
31 auto report = detail::finalizeImportReport(result, package, "evengine", "1");
32 if (!report) return Result<PreparedAssetImport>::failure(report.status());
33 return Result<PreparedAssetImport>::success(std::move(result));
34}
35} // namespace eve::asset_import
AuthorityStoreHandleRef reference
Definition Authority.cpp:24
std::uint64_t bytes
std::string path
Definition PlayHost.cpp:110
Shader * shader
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 success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:192
std::string sha256(std::span< const std::uint8_t > bytes)
Sha 256.
EVENGINE_API_PLATFORM Result< void > finalizeImportReport(PreparedAssetImport &prepared, const ImportPackageIdentity &package, std::string_view sourceEngine, std::string_view sourceVersion, Value::Object options={})
Append the deterministic mandatory import report and bind it from provenance.
Result< asset::EvaManifest > baseManifest(const ImportPackageIdentity &package, std::string_view importer)
Base manifest.
Result< AssetRef > assetRef(PersistentId id)
Asset ref.
Result< PreparedAssetImport > prepareShaderImport(const ImportPackageIdentity &package, std::string_view json)
Prepare a canonical shader definition for the existing atomic .eva publisher.
Result< ShaderAsset > decodeShaderAsset(const Value &definition, const ShaderAssetLimits &limits)
Decode strict eve.shader/1 metadata with SPIR-V 1.0 through 1.6 stages.
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
std::vector< EvaAssetEntry > assets
Definition EvaManifest.h:69
std::map< std::string, AssetRef > entrypoints
Definition EvaManifest.h:71
Common stable package metadata supplied by an import transaction.
Owning, validated source archive candidate not yet published to disk/database.
std::vector< ImportFinding > findings
std::vector< asset::EvaArchiveEntry > entries
std::vector< ImportSourceMapping > sourceMappings