载入中...
搜索中...
未找到
AssetCooker.cpp
浏览该文件的文档.
24 data::HashFunction::getHashFunction("sha256")->hash("sha256", reinterpret_cast<const char*>(bytes.data()),
33 for (unsigned shift = 0; shift != 64; shift += 8) bytes.push_back(static_cast<std::uint8_t>(size >> shift));
72bool predicateText(const Value::Object& predicate, std::string_view name, std::string_view actual) {
91 (redistribution->asString() != "runtime-embedded" && redistribution->asString() != "project-only"))
104Result<std::vector<std::uint8_t>> binaryDefinition(std::span<const std::uint8_t> json, std::uint64_t maximumBytes,
106 auto parsed = Value::fromJson(std::string_view(reinterpret_cast<const char*>(json.data()), json.size()));
111 DiagnosticCode::ParseError, "runtime definition root must be an object", {}, {}, "asset.cook"));
140 profile.variant = {"android", "arm64", "vulkan", {"astc", "etc2", "rgba8"}, "spirv-1.6", "high", {}};
147 DiagnosticCode::Unsupported, "unknown asset Cook target", std::string(target), {}, "asset.cook"));
151Result<AssetCookReceipt> cookEvaToEvpack(const EvaArchive& source, const AssetCookProfile& profile,
165 auto dependencyValidation = validateEvaDependencies(dependencyManifest, profile.availableDependencies);
166 if (!dependencyValidation) return Result<AssetCookReceipt>::failure(dependencyValidation.status());
174 if (dependency.kind == EvaDependencyKind::RuntimeOptional || dependency.kind == EvaDependencyKind::Build ||
195 if (dependency.from.id() == asset.asset.id() && platformDependencyApplies(dependency, profile.variant))
207 Diagnostic::error(DiagnosticCode::Unsupported, "eve.shader/1 requires Vulkan SPIR-V 1.6 target",
210 std::string_view(reinterpret_cast<const char*>(definition->bytes.data()), definition->bytes.size()));
216 std::any_of(canonical.entries.begin(), canonical.entries.end(), [&](const EvaArchiveEntry& entry) {
224 if (std::find(profile.variant.textureFamilies.begin(), profile.variant.textureFamilies.end(), "rgba8") ==
230 std::string_view(reinterpret_cast<const char*>(definition->bytes.data()), definition->bytes.size()));
245 auto image = cookCanonicalImageRgba8(definition->bytes, sourceBlob->bytes, evpackLimits.maximumChunkBytes);
248 binaryDefinition(image.value().definition, evpackLimits.maximumChunkBytes, assetDependencyPolicies);
250 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Definition,
252 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Bulk, 1,
258 if (std::find(profile.variant.textureFamilies.begin(), profile.variant.textureFamilies.end(), "rgba8") ==
265 std::string_view(reinterpret_cast<const char*>(definition->bytes.data()), definition->bytes.size()));
271 Diagnostic::error(DiagnosticCode::ParseError, "eve.volume-texture/1 source blob path is missing",
281 cookCanonicalVolumeTextureRgba8(definition->bytes, sourceBlob->bytes, evpackLimits.maximumChunkBytes);
284 binaryDefinition(volume.value().definition, evpackLimits.maximumChunkBytes, assetDependencyPolicies);
286 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Definition,
288 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Bulk, 1,
297 binaryDefinition(pcg.value().definition, evpackLimits.maximumChunkBytes, assetDependencyPolicies);
299 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Definition,
301 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Bulk, 1,
309 build.chunks.push_back({asset.asset.id(), asset.type, asset.schemaVersion, 0, EvpackChunkKind::Definition, 0,
367 DiagnosticCode::InvalidArgument, "external dependency fact is invalid", {}, {}, "asset.dependency"));
372 Diagnostic::error(DiagnosticCode::TypeMismatch, "dependency resolver reports conflicting types",
378 Diagnostic::error(DiagnosticCode::NotFound, "entrypoint does not resolve to a local asset", name, {},
387 return Result<EvaDependencyValidation>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,
394 if (!edges.emplace(dependency.from.id(), dependency.to.id(), dependency.kind, dependency.path).second)
396 DiagnosticCode::Conflict, "duplicate dependency edge", dependency.path, {}, "asset.dependency"));
406 const std::string resolvedType = target->second.first + "/" + std::to_string(target->second.second.value());
412 if (dependency.kind == EvaDependencyKind::RuntimeRequired && local.contains(dependency.to.id()))
418 std::function<Result<void>(const PersistentId&)> visit = [&](const PersistentId& node) -> Result<void> {
456 std::tuple<PersistentId, PersistentId, EvaDependencyKind, std::string, std::string, std::string, std::string>;
480 {id, EvaAssetChangeKind::Removed, asset->type, asset->schemaVersion, asset->contentHash, {}, {}, {}});
481 } else if (asset->type != found->second->type || asset->schemaVersion != found->second->schemaVersion ||
491 {id, EvaAssetChangeKind::Added, {}, {}, {}, asset->type, asset->schemaVersion, asset->contentHash});
Deterministic canonical .eva to capability-targeted .evpack Cook.
Typed dependency closure validation for `.eva`.
Deterministic semantic comparison of two `.eva` manifests.
Transactional migrations for canonical definitions stored in .eva.
Safe source-image conversion to runtime EVIMG payloads.
Canonical PCG graph compilation to runtime execution plans.
Bounded R8 volume conversion to runtime EVVOL.
Bounded deterministic compression used by the .evpack wire format.
JSON-free versioned runtime metadata codec.
const PersistentId & id() const noexcept
Return the stable asset identity.
Definition ResourceRef.h:65
static Result< AssetRef > parse(std::string_view text)
Parse an asset://<canonical UUID> reference.
Definition ResourceRef.cpp:20
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:207
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
static HashFunction * getHashFunction(std::string function)
Get a HashFunction instance for the given function.
Definition HashFunction.cpp:573
virtual void hash(std::string function, const char *input, uint64_t length, Value &output) const =0
Hash the input, producing an set of bytes as output.
Definition AssetCooker.cpp:19
Result< Evpack > parseEvpack(std::span< const std::uint8_t > bytes, const EvpackLimits &limits, const EvpackTrust &trust)
Parse, bound-check and hash-verify a complete untrusted .evpack.
Definition Evpack.cpp:542
Result< CookedCanonicalVolumeTexture > cookCanonicalVolumeTextureRgba8(std::span< const uint8_t > definition, std::span< const uint8_t > sourceR8, uint64_t maximumDecodedBytes)
Definition CanonicalMeshEncode.cpp:246
Result< std::vector< std::uint8_t > > buildEvaArchive(const EvaManifest &manifest, std::vector< EvaArchiveEntry > entries, const EvaArchiveLimits &limits)
Build a deterministic ZIP64 .eva, selecting raw Deflate only when smaller than Store.
Definition EvaArchive.cpp:408
std::string evpackCodecBuildIdentity(EvpackCodec codec)
Stable codec implementation identity included in deterministic Cook keys.
Definition EvpackCompression.cpp:64
Result< std::vector< std::uint8_t > > buildEvpack(EvpackBuild build, const EvpackLimits &limits)
Build deterministic little-endian .evpack bytes from validated Cook output.
Definition Evpack.cpp:248
Result< CookedCanonicalImage > cookCanonicalImageRgba8(std::span< const std::uint8_t > definition, std::span< const std::uint8_t > encodedSource, std::uint64_t maximumDecodedBytes)
Decode image/2 base images or image/3 explicit linear RGBA8 mip chains into bounded EVIMG.
Definition CanonicalImageCook.cpp:163
Result< EvaArchive > parseEvaArchive(std::span< const std::uint8_t > bytes, const EvaArchiveLimits &limits)
Parse and fully verify an untrusted .eva ZIP64 image.
Definition EvaArchive.cpp:505
Result< EvaPackageDiff > diffEvaManifests(const EvaManifest &before, const EvaManifest &after)
Compare two admitted manifests without using paths, timestamps or archive order.
Definition AssetCooker.cpp:471
CookPublication
Publication policy controls license admission without making legal inferences.
Definition AssetCooker.h:17
@ LocalInspection
Result< AssetCookReceipt > cookEvaToEvpack(const EvaArchive &source, const AssetCookProfile &profile, const EvaArchiveLimits &evaLimits, const EvpackLimits &evpackLimits)
Cook an admitted source archive into one target-specific runtime pack.
Definition AssetCooker.cpp:151
Result< EvaArchive > migrateEvaArchive(EvaArchive source, const EvaArchiveLimits &limits)
Migrate every definition in an owning archive to its current schema.
Definition AssetMigration.cpp:538
@ Platform
@ RuntimeOptional
@ RuntimeRequired
Result< CookedCanonicalPcgGraph > cookCanonicalPcgGraph(std::span< const std::uint8_t > definition, std::uint32_t maximumRules, std::uint64_t maximumPlanBytes)
Compile eve.pcg-graph/1 terrain scatter rules to a bounded PointGraph plan.
Definition CanonicalMeshEncode.cpp:121
Result< AssetCookProfile > assetCookProfileForTarget(std::string_view target)
Resolve a stable CLI/tool target name to its exact capability profile.
Definition AssetCooker.cpp:130
Result< std::vector< std::uint8_t > > encodeRuntimeDefinition(const Value &value, const RuntimeDefinitionLimits &limits)
Encode an owning metadata tree as deterministic EVDEF\0\1 bytes.
Definition RuntimeDefinition.cpp:236
Result< std::string > serializeEvaManifest(const EvaManifest &manifest)
Serialize a validated manifest as deterministic compact JSON.
Definition EvaManifest.cpp:321
Result< ShaderAsset > decodeShaderAsset(const Value &definition, const ShaderAssetLimits &limits)
Decode strict eve.shader/1 metadata with SPIR-V 1.0 through 1.6 stages.
Definition ShaderAsset.cpp:56
Result< EvaDependencyValidation > validateEvaDependencies(const EvaManifest &manifest, std::span< const AvailableAssetDependency > available)
Validate local/external references, expected types and required-edge acyclicity.
Definition AssetCooker.cpp:355
@ Definition
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ NotFound
@ PreconditionViolation
@ Unsupported
@ ParseError
@ Conflict
StrongUuid< detail::PersistentIdTag > PersistentId
Stable instance identity for persistence, networking and process boundaries.
Definition Identity.h:253
Explicit deterministic target profile for one runtime variant.
Definition AssetCooker.h:23
std::vector< AvailableAssetDependency > availableDependencies
Definition AssetCooker.h:28
One owning regular-file entry inside an .eva archive.
Definition EvaArchive.h:31
Admission budgets applied before allocating decoded archive entries.
Definition EvaArchive.h:21
Fully admitted source archive with its typed manifest and payloads.
Definition EvaArchive.h:37
One directed dependency between stable asset identities.
Definition EvaManifest.h:44
Value::Object fallback
Required observable behavior when a runtime-optional target is unavailable.
Definition EvaManifest.h:52
std::vector< EvaDependency > dependencies
Definition EvaManifest.h:70
Deterministically ordered semantic package difference.
Definition AssetDiff.h:27
Resource limits checked before package allocations and hash work.
Definition Evpack.h:126
Capability-addressed runtime representation; list order is fallback order.
Definition Evpack.h:81
std::vector< std::string > textureFamilies
Definition Evpack.h:85
Structural and allocation limits for untrusted EVDEF metadata.
Definition RuntimeDefinition.h:17
std::uint64_t maximumBytes
Definition RuntimeDefinition.h:18