Bind TubeField as generated mesh geometry
This commit is contained in:
parent
b4cfc38251
commit
b9b9dcbe46
3 changed files with 55 additions and 22 deletions
|
|
@ -1844,23 +1844,23 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
return;
|
||||
}
|
||||
|
||||
tubeFieldVertexBuffer.Transition(activeCommandList, ResourceStates.VertexAndConstantBuffer);
|
||||
tubeFieldIndexBuffer.Transition(activeCommandList, ResourceStates.IndexBuffer);
|
||||
tubeFieldDrawArgumentBuffer.Transition(activeCommandList, ResourceStates.IndirectArgument);
|
||||
var vertexView = new VertexBufferView(
|
||||
tubeFieldVertexBuffer.Resource.GPUVirtualAddress,
|
||||
(uint)(MaxTubeFieldVertices * Marshal.SizeOf<D3D12TubeFieldVertex>()),
|
||||
(uint)Marshal.SizeOf<D3D12TubeFieldVertex>());
|
||||
var indexView = new IndexBufferView(
|
||||
tubeFieldIndexBuffer.Resource.GPUVirtualAddress,
|
||||
(uint)(MaxTubeFieldIndices * Marshal.SizeOf<uint>()),
|
||||
Format.R32_UInt);
|
||||
var generatedMesh = new D3D12PipelinePrivateGeneratedMesh(
|
||||
tubeFieldVertexBuffer,
|
||||
tubeFieldIndexBuffer,
|
||||
tubeFieldDrawArgumentBuffer,
|
||||
new VertexBufferView(
|
||||
tubeFieldVertexBuffer.Resource.GPUVirtualAddress,
|
||||
(uint)(MaxTubeFieldVertices * Marshal.SizeOf<D3D12TubeFieldVertex>()),
|
||||
(uint)Marshal.SizeOf<D3D12TubeFieldVertex>()),
|
||||
new IndexBufferView(
|
||||
tubeFieldIndexBuffer.Resource.GPUVirtualAddress,
|
||||
(uint)(MaxTubeFieldIndices * Marshal.SizeOf<uint>()),
|
||||
Format.R32_UInt),
|
||||
PrimitiveTopology.TriangleList);
|
||||
activeCommandList.SetPipelineState(tubeFieldRenderPipelineState);
|
||||
activeCommandList.SetGraphicsRootSignature(tubeFieldRenderRootSignature);
|
||||
activeCommandList.SetGraphicsRootDescriptorTable(RootTubeFieldRenderFrameConstants, frameResources.FrameConstantsDescriptor.Gpu);
|
||||
activeCommandList.IASetPrimitiveTopology(PrimitiveTopology.TriangleList);
|
||||
activeCommandList.IASetVertexBuffers(0, [vertexView]);
|
||||
activeCommandList.IASetIndexBuffer(indexView);
|
||||
BindPipelinePrivateGeneratedMesh(activeCommandList, generatedMesh);
|
||||
foreach (var batch in tubeFieldDrawBatches)
|
||||
{
|
||||
batch.Source.Transition(activeCommandList, ResourceStates.PixelShaderResource | ResourceStates.NonPixelShaderResource);
|
||||
|
|
@ -1871,16 +1871,36 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
activeCommandList.SetGraphicsRootConstantBufferView(RootTubeFieldRenderConstants, batch.ConstantsGpuVirtualAddress);
|
||||
activeCommandList.SetGraphicsRootShaderResourceView(RootTubeFieldRenderSource, batch.Source.Resource.GPUVirtualAddress);
|
||||
activeCommandList.SetGraphicsRootDescriptorTable(RootTubeFieldRenderRamp, rampDescriptor.Gpu);
|
||||
activeCommandList.ExecuteIndirect(
|
||||
tubeFieldDrawCommandSignature,
|
||||
1,
|
||||
tubeFieldDrawArgumentBuffer.Resource,
|
||||
(ulong)batch.DrawArgumentOffsetBytes,
|
||||
null,
|
||||
0);
|
||||
DrawPipelinePrivateGeneratedMesh(activeCommandList, generatedMesh, batch.DrawArgumentOffsetBytes);
|
||||
}
|
||||
}
|
||||
|
||||
private void BindPipelinePrivateGeneratedMesh(
|
||||
ID3D12GraphicsCommandList activeCommandList,
|
||||
D3D12PipelinePrivateGeneratedMesh generatedMesh)
|
||||
{
|
||||
generatedMesh.Vertices.Transition(activeCommandList, ResourceStates.VertexAndConstantBuffer);
|
||||
generatedMesh.Indices.Transition(activeCommandList, ResourceStates.IndexBuffer);
|
||||
generatedMesh.DrawArguments.Transition(activeCommandList, ResourceStates.IndirectArgument);
|
||||
activeCommandList.IASetPrimitiveTopology(generatedMesh.Topology);
|
||||
activeCommandList.IASetVertexBuffers(0, [generatedMesh.VertexView]);
|
||||
activeCommandList.IASetIndexBuffer(generatedMesh.IndexView);
|
||||
}
|
||||
|
||||
private void DrawPipelinePrivateGeneratedMesh(
|
||||
ID3D12GraphicsCommandList activeCommandList,
|
||||
D3D12PipelinePrivateGeneratedMesh generatedMesh,
|
||||
int drawArgumentOffsetBytes)
|
||||
{
|
||||
activeCommandList.ExecuteIndirect(
|
||||
tubeFieldDrawCommandSignature,
|
||||
1,
|
||||
generatedMesh.DrawArguments.Resource,
|
||||
(ulong)drawArgumentOffsetBytes,
|
||||
null,
|
||||
0);
|
||||
}
|
||||
|
||||
private D3D12FieldTexture2D ResolveTubeFieldRamp(ID3D12GraphicsCommandList activeCommandList, string rampResourceKey)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(rampResourceKey) &&
|
||||
|
|
@ -4129,6 +4149,14 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
string RampResourceKey,
|
||||
int DrawArgumentOffsetBytes);
|
||||
|
||||
private readonly record struct D3D12PipelinePrivateGeneratedMesh(
|
||||
D3D12StructuredBuffer Vertices,
|
||||
D3D12StructuredBuffer Indices,
|
||||
D3D12StructuredBuffer DrawArguments,
|
||||
VertexBufferView VertexView,
|
||||
IndexBufferView IndexView,
|
||||
PrimitiveTopology Topology);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private readonly record struct D3D12TubeFieldConstants(
|
||||
Vector4 Shape,
|
||||
|
|
|
|||
|
|
@ -244,3 +244,4 @@
|
|||
{"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"}
|
||||
{"lesson":"Mesh layout authority is now split by source. Imported/user-facing mesh packages default to the engine standard `PositionNormalUvColor` vertex layout (48-byte position, normal, uv, color contract), which is the lane for FBX/OBJ-style assets. Generated meshes can declare `layout=PipelinePrivate`; those bytes belong to the selected lowering that emits and consumes them, so Fensalir does not force TubeField or future procedural surfaces through a bloated public vertex ABI. Fensalir build and Aquarium.Engine.Tests passed with 23 tests.","timestamp":"2026-05-26T21:58: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","tests/Aquarium.Engine.Tests/FieldScriptCompilerTests.cs","state/map.yaml"],"source":"user clarified imported mesh versus generated mesh layout authority","topic":"field-mesh-layout-authority"}
|
||||
{"lesson":"TubeField now uses the first explicit pipeline-private generated mesh render lane. The compute path still owns the minimal D3D12TubeFieldVertex/index/indirect argument layout, but render now binds those buffers through a named D3D12PipelinePrivateGeneratedMesh before applying TubeField material root bindings and ExecuteIndirect. This implements the chosen generated-mesh option without creating a public imported-mesh renderer or forcing splines through PositionNormalUvColor. Fensalir build, Aquarium.Engine.Tests, and headless reload passed.","timestamp":"2026-05-26T22:49:00+01:00","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","state/map.yaml"],"source":"user chose pipeline-private generated mesh draw path for spline migration","topic":"pipeline-private-generated-mesh-rendering"}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,11 @@ next_actions:
|
|||
`PositionNormalUvColor` layout, while generated meshes may declare
|
||||
`PipelinePrivate` so the selected lowering owns the minimal bytes it emits
|
||||
and consumes. Mesh rendering is now blocked on choosing the first selected
|
||||
render lowering/material path, not on a generic imported-mesh ABI.
|
||||
render lowering/material path, not on a generic imported-mesh ABI. The
|
||||
first generated-mesh render cut is TubeField itself: compute emits
|
||||
pipeline-private vertex/index/indirect buffers, render binds them through a
|
||||
named `D3D12PipelinePrivateGeneratedMesh`, and TubeField material state
|
||||
supplies the shader-specific source/ramp/constants.
|
||||
- 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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue