Plan generic field resource claims
This commit is contained in:
parent
12cd13c9ff
commit
43ef462925
4 changed files with 129 additions and 16 deletions
|
|
@ -55,6 +55,9 @@ public static class AquariumFieldScriptCompiler
|
|||
domains.Add(domain);
|
||||
}
|
||||
|
||||
break;
|
||||
case "claim":
|
||||
AddResourceClaim(args, resourceAliases, domainKeys, domains, claims, candidates, lineIndex);
|
||||
break;
|
||||
case "tubeclaim":
|
||||
AddTubeClaim(args, resourceAliases, domainKeys, domains, claims, candidates, lineIndex);
|
||||
|
|
@ -300,6 +303,62 @@ public static class AquariumFieldScriptCompiler
|
|||
Vec3(args, "period", Vector3.Zero, lineIndex),
|
||||
StringValue(args, "owner", "AquariumFieldScriptCompiler"));
|
||||
|
||||
private static void AddResourceClaim(
|
||||
IReadOnlyDictionary<string, string> args,
|
||||
IReadOnlyDictionary<string, AquariumFieldResourceDeclaration> resourceAliases,
|
||||
ISet<string> domainKeys,
|
||||
ICollection<AquariumFieldDomain> domains,
|
||||
ICollection<AquariumFieldClaim> claims,
|
||||
ICollection<AquariumFieldCandidate> candidates,
|
||||
int lineIndex)
|
||||
{
|
||||
var id = Required(args, "id", lineIndex);
|
||||
var resourceId = Required(args, "resource", lineIndex);
|
||||
if (!resourceAliases.TryGetValue(resourceId, out var resource))
|
||||
{
|
||||
throw new FormatException($"Field claim `{id}` references unbound resource `{resourceId}` at line {lineIndex + 1}.");
|
||||
}
|
||||
|
||||
var encoding = Enum.Parse<AquariumFieldEncoding>(Required(args, "encoding", lineIndex), ignoreCase: true);
|
||||
var layer = Enum.Parse<AquariumFieldLayer>(StringValue(args, "layer", nameof(AquariumFieldLayer.Form)), ignoreCase: true);
|
||||
var domainKey = StringValue(args, "domain", $"dsl:domain:{id}");
|
||||
EnsureDefaultDomain(domainKey, domainKeys, domains);
|
||||
|
||||
var confidence = Math.Clamp(Float(args, "confidence", 1.0f, lineIndex), 0.0f, 1.0f);
|
||||
var supportRadius = MathF.Max(0.0001f, Float(args, "radius", 0.01f, lineIndex));
|
||||
var claim = new AquariumFieldClaim(
|
||||
ClaimKey: $"dsl:claim:{id}",
|
||||
DomainKey: domainKey,
|
||||
ProducerKey: StringValue(args, "producer", resource.ResourceKey),
|
||||
Layer: layer,
|
||||
Encoding: encoding,
|
||||
Support: new AquariumFieldSupport(
|
||||
Vec3(args, "center", Vector3.Zero, lineIndex),
|
||||
Vec3(args, "support", new Vector3(supportRadius), lineIndex),
|
||||
Matrix4x4.Identity,
|
||||
supportRadius,
|
||||
ProjectedError: Float(args, "projectedError", 0.0f, lineIndex),
|
||||
Curvature: Float(args, "curvature", 0.0f, lineIndex),
|
||||
TemporalUncertainty: Float(args, "temporal", 0.0f, lineIndex)),
|
||||
Proposal: new AquariumFieldProposalPolicy(
|
||||
Enum.Parse<AquariumFieldProposalKind>(StringValue(args, "proposal", nameof(AquariumFieldProposalKind.DeterministicStructural)), ignoreCase: true),
|
||||
SourcePdf: Float(args, "sourcePdf", 1.0f, lineIndex),
|
||||
TargetContribution: confidence,
|
||||
RepresentedCandidateCount: Int(args, "represented", Math.Max(1, resource.DepthOrCount), lineIndex),
|
||||
Seed: UInt(args, "seed", StableSeed(id), lineIndex)),
|
||||
PayloadHandle: resource.ResourceKey,
|
||||
ObservedTimeNs: resource.ValidUntilNs,
|
||||
Confidence: confidence);
|
||||
claims.Add(claim);
|
||||
candidates.Add(new AquariumFieldCandidate(
|
||||
CandidateKey: $"dsl:claim:{id}:candidate",
|
||||
ClaimKey: claim.ClaimKey,
|
||||
Layer: claim.Layer,
|
||||
Encoding: claim.Encoding,
|
||||
Proposal: claim.Proposal,
|
||||
Guide: AquariumFieldGuide.Valid(confidence, Float(args, "age", 0.0f, lineIndex))));
|
||||
}
|
||||
|
||||
private static void AddTubeClaim(
|
||||
IReadOnlyDictionary<string, string> args,
|
||||
IReadOnlyDictionary<string, AquariumFieldResourceDeclaration> resourceAliases,
|
||||
|
|
@ -317,19 +376,7 @@ public static class AquariumFieldScriptCompiler
|
|||
}
|
||||
|
||||
var domainKey = StringValue(args, "domain", $"dsl:domain:{id}");
|
||||
if (domainKeys.Add(domainKey))
|
||||
{
|
||||
domains.Add(new AquariumFieldDomain(
|
||||
domainKey,
|
||||
"",
|
||||
AquariumFieldDomainKind.RollingBuffer,
|
||||
Matrix4x4.Identity,
|
||||
Matrix4x4.Identity,
|
||||
Vector3.Zero,
|
||||
Vector3.One,
|
||||
Vector3.Zero,
|
||||
"AquariumFieldScriptCompiler"));
|
||||
}
|
||||
EnsureDefaultDomain(domainKey, domainKeys, domains);
|
||||
|
||||
var confidence = Math.Clamp(Float(args, "confidence", 1.0f, lineIndex), 0.0f, 1.0f);
|
||||
var supportRadius = MathF.Max(0.0001f, Float(args, "radius", 0.01f, lineIndex));
|
||||
|
|
@ -366,6 +413,28 @@ public static class AquariumFieldScriptCompiler
|
|||
Guide: AquariumFieldGuide.Valid(confidence, Float(args, "age", 0.0f, lineIndex))));
|
||||
}
|
||||
|
||||
private static void EnsureDefaultDomain(
|
||||
string domainKey,
|
||||
ISet<string> domainKeys,
|
||||
ICollection<AquariumFieldDomain> domains)
|
||||
{
|
||||
if (!domainKeys.Add(domainKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
domains.Add(new AquariumFieldDomain(
|
||||
domainKey,
|
||||
"",
|
||||
AquariumFieldDomainKind.RollingBuffer,
|
||||
Matrix4x4.Identity,
|
||||
Matrix4x4.Identity,
|
||||
Vector3.Zero,
|
||||
Vector3.One,
|
||||
Vector3.Zero,
|
||||
"AquariumFieldScriptCompiler"));
|
||||
}
|
||||
|
||||
private static void AddTubeSpline(
|
||||
IReadOnlyDictionary<string, string> args,
|
||||
IReadOnlyDictionary<string, AquariumFieldResourceDeclaration> resourceAliases,
|
||||
|
|
|
|||
|
|
@ -242,3 +242,4 @@
|
|||
{"lesson":"SurfacePage is now a resolvable field resource kind rather than just a planner enum. AquariumFieldResourceDeclaration has a SurfacePage factory, the field evidence DSL accepts `surfacepage id=... key=... width=... height=... format=...`, and D3D12FieldResourceRegistry allocates empty GPU-resident shader-readable page textures or lazily loads local source-backed pages through the same texture upload path. This does not finish terrain/heightfield lowering; it creates the resource authority that future Height/Sdf2D/Material packets can bind. Fensalir build/tests/headless reload and Mimir build/field smokes passed.","timestamp":"2026-05-26T21:05:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","src/Aquarium.Engine.Contracts/Render/AquariumFieldScriptCompiler.cs","src/Aquarium.Engine/Render/D3D12FieldTexture2D.cs","src/Aquarium.Engine/Render/D3D12FieldResourceRegistry.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","tests/Aquarium.Engine.Tests/FieldScriptCompilerTests.cs","state/map.yaml"],"source":"continued field resource resolver migration","topic":"field-surface-page-resource-resolver"}
|
||||
{"lesson":"VolumeTexture is now a resolvable field resource kind. AquariumFieldResourceDeclaration has a VolumeTexture factory, the field evidence DSL accepts `volumetexture id=... key=... width=... height=... depth=... format=...`, and D3D12FieldResourceRegistry allocates empty GPU-resident shader-readable Texture3D resources with format/dimension/version tracking. This creates resource authority for future density/extinction/SDF3D lowerings without pretending those render paths exist yet. Fensalir build/tests/headless reload and Mimir build/field smokes passed.","timestamp":"2026-05-26T21:11:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","src/Aquarium.Engine.Contracts/Render/AquariumFieldScriptCompiler.cs","src/Aquarium.Engine/Render/D3D12FieldTexture3D.cs","src/Aquarium.Engine/Render/D3D12FieldTextureFormat.cs","src/Aquarium.Engine/Render/D3D12FieldResourceRegistry.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","tests/Aquarium.Engine.Tests/FieldScriptCompilerTests.cs","state/map.yaml"],"source":"continued field resource resolver migration","topic":"field-volume-texture-resource-resolver"}
|
||||
{"lesson":"Mesh is now a resolvable field resource package rather than loose scalar handles. AquariumFieldMeshResource owns Mesh.Vertices, Mesh.Indices, topology, index format, bounds, submesh count, and version; the field evidence DSL accepts `mesh id=... key=... vertices=... vertexStride=... indices=... indexFormat=... topology=...`; and D3D12FieldResourceRegistry allocates/reuses GPU-resident vertex and index buffers under the mesh resource key. This creates resource authority for future mesh draw/compute lowerings without pretending a material or vertex-layout render path exists yet. Fensalir build/tests/headless reload passed.","timestamp":"2026-05-26T21:24:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","src/Aquarium.Engine.Contracts/Render/AquariumFieldScriptCompiler.cs","src/Aquarium.Engine/Render/D3D12FieldMesh.cs","src/Aquarium.Engine/Render/D3D12FieldResourceRegistry.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","tests/Aquarium.Engine.Tests/FieldScriptCompilerTests.cs","state/map.yaml"],"source":"user clarified Mesh package API boundary","topic":"field-mesh-resource-resolver"}
|
||||
{"lesson":"The field evidence DSL can now plan generic resource-backed claims, not only Tube claims. `claim id=... resource=... encoding=... layer=...` creates a selected claim/candidate over the declared resource, so Mesh packages, SurfacePage height/SDF/material pages, and VolumeTexture density/extinction resources can reach AquariumFieldLoweringPlanner and produce backend packets. This closes the planner/resource contract cut. Actual Mesh rendering remains blocked on a vertex attribute/material layout contract; the mesh package owns buffer shape, not byte semantics. Fensalir build and Aquarium.Engine.Tests passed.","timestamp":"2026-05-26T21:42:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldScriptCompiler.cs","tests/Aquarium.Engine.Tests/FieldScriptCompilerTests.cs","state/map.yaml"],"source":"continued field packet/resource migration after mesh resolver","topic":"generic-field-resource-claims"}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,13 @@ next_actions:
|
|||
first-class packages with `Mesh.Vertices` and `Mesh.Indices` buffer members,
|
||||
topology, index format, bounds, submesh count, and version. The DSL can
|
||||
declare a GPU-resident mesh package, and the D3D12 registry allocates and
|
||||
reuses matching vertex/index GPU buffers under the mesh resource key.
|
||||
Remaining cuts are render lowerings that consume meshes, surface pages, and
|
||||
volumes as selected geometry/height/SDF/material/density domains.
|
||||
reuses matching vertex/index GPU buffers under the mesh resource key. The
|
||||
evidence DSL also has a generic resource-backed `claim` command, so Mesh,
|
||||
Height/SurfacePage, and Density/VolumeTexture resources can be planned into
|
||||
backend packets without pretending a render path exists. Remaining cuts are
|
||||
render lowerings that consume those packets. Mesh rendering is blocked on a
|
||||
vertex attribute/material contract; stride/count/index format is resource
|
||||
shape, not enough authority to decide position/normal/uv/color semantics.
|
||||
- Move any remaining client-only Epiphany state found here back to `E:\Projects\Aquarium-Engine`.
|
||||
- Keep Mimir app/adapters out of this repo; Fensalir may expose generic sensor-fusion contracts only.
|
||||
- Package contracts/host deliberately before replacing sibling source references in client repos.
|
||||
|
|
|
|||
|
|
@ -192,4 +192,43 @@ public sealed class FieldScriptCompilerTests
|
|||
Assert.Equal(AquariumFieldMeshTopology.TriangleList, resource.Mesh.Topology);
|
||||
Assert.Equal(AquariumFieldMeshIndexFormat.UInt32, resource.Mesh.IndexFormat);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CompileEvidencePlansGenericResourceClaims()
|
||||
{
|
||||
var frame = AquariumFieldScriptCompiler.CompileEvidence(
|
||||
"""
|
||||
mesh id=quad key=aquarium:resource:mesh:quad vertices=4 vertexStride=32 indices=6 indexFormat=UInt32 topology=TriangleList min=-1,-1,0 max=1,1,0 submeshes=1 version=9
|
||||
surfacepage id=height key=aquarium:resource:surface-page:height width=64 height=64 format=R16Float
|
||||
volumetexture id=fog key=aquarium:resource:volume-texture:fog width=16 height=16 depth=16 format=R16Float
|
||||
claim id=quad resource=quad encoding=Mesh layer=Form radius=1
|
||||
claim id=height resource=height encoding=Height layer=Form radius=1
|
||||
claim id=fog resource=fog encoding=Density layer=Appearance radius=1
|
||||
""",
|
||||
new Dictionary<string, AquariumFieldResourceDeclaration>(StringComparer.Ordinal));
|
||||
|
||||
var plan = AquariumFieldLoweringPlanner.Plan(frame);
|
||||
|
||||
Assert.Empty(plan.DeferredRequests);
|
||||
Assert.Collection(
|
||||
plan.Packets,
|
||||
packet =>
|
||||
{
|
||||
Assert.Equal(AquariumFieldEncoding.Mesh, packet.Encoding);
|
||||
Assert.Equal(AquariumFieldBackendKind.Mesh, packet.Backend);
|
||||
Assert.Equal("aquarium:resource:mesh:quad", packet.PayloadHandle);
|
||||
},
|
||||
packet =>
|
||||
{
|
||||
Assert.Equal(AquariumFieldEncoding.Height, packet.Encoding);
|
||||
Assert.Equal(AquariumFieldBackendKind.SurfacePage, packet.Backend);
|
||||
Assert.Equal("aquarium:resource:surface-page:height", packet.PayloadHandle);
|
||||
},
|
||||
packet =>
|
||||
{
|
||||
Assert.Equal(AquariumFieldEncoding.Density, packet.Encoding);
|
||||
Assert.Equal(AquariumFieldBackendKind.VolumeSplat, packet.Backend);
|
||||
Assert.Equal("aquarium:resource:volume-texture:fog", packet.PayloadHandle);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue