Move live sensor fusion boundary into Aquarium
This commit is contained in:
parent
2b30d67b43
commit
4f1afdab2c
6 changed files with 248 additions and 27 deletions
|
|
@ -34,12 +34,13 @@ diegetic scene content.
|
|||
|
||||
`Aquarium.LocalCast` is the first concrete live client for this contract. It
|
||||
reads `localcast.visual.render_frame` from LocalCastBridge's typed CultCache
|
||||
MessagePack document. The older CPU path can still map point claims into
|
||||
`TemporalGaussianObservation` rows for accumulator smoothing, but the live
|
||||
LocalCast path now prefers `AquariumGpuFusionField`: compact fusion seeds enter
|
||||
the D3D12 backend, `D3D12LocalCastFusion.hlsl` dispatches over them, and the
|
||||
compute shader writes the temporal Gaussian buffer consumed by the SDF Gaussian
|
||||
draw. It does not downsample the document in client space.
|
||||
MessagePack document. That point/seed route is now explicitly a fallback and
|
||||
debug harness: it proves the million-slot temporal Gaussian draw and keeps OBS
|
||||
fed while the live capture path moves into Aquarium. The production ownership
|
||||
line is `AquariumGpuSensorFrame`: camera and Leap inputs arrive as calibrated
|
||||
sensor records plus shared GPU texture handles, the D3D12 backend owns their
|
||||
metadata buffers, and fusion kernels lower those GPU-resident inputs into the
|
||||
temporal Gaussian buffer consumed by the SDF Gaussian draw.
|
||||
|
||||
LocalCast GPU fusion also has its own live-history accumulator. New frames
|
||||
update stable-key tracks, stale tracks expire after a bounded horizon, and the
|
||||
|
|
@ -57,8 +58,9 @@ instead of a scrapbook with a power cord.
|
|||
backend output and do not invent identity.
|
||||
- The compact support kernel has a finite bound. Renderer cost must scale from
|
||||
declared bounds, not from infinite translucent fog.
|
||||
- Client code may construct observations or a field, but Aquarium owns packet
|
||||
layout, root binding, shader evaluation, and temporal-control metadata.
|
||||
- Client code may construct observations or a field for diagnostics, but
|
||||
Aquarium owns live sensor texture import, packet layout, root binding, shader
|
||||
evaluation, fusion, and temporal-control metadata.
|
||||
- JSON is not a renderer boundary. CultCache/CultNet producers should lower into
|
||||
typed contract rows before Aquarium sees the data.
|
||||
|
||||
|
|
@ -67,18 +69,21 @@ instead of a scrapbook with a power cord.
|
|||
This cut deliberately claims million-slot ingestion, not a finished million-splat
|
||||
renderer architecture. The live D3D12 path can draw up to 1,048,576 temporal
|
||||
Gaussians through instanced proxy quads, only uploads the active seed/packet
|
||||
span, and now owns the GPU lowering step from LocalCast fusion seeds to Gaussian
|
||||
packets. The next scaling cut belongs to the Aquarium renderer: packed camera
|
||||
planes, selected-cut residency, tiled/bin dispatch, GPU accumulation, and
|
||||
clustered visibility. Do not push that scheduler into LocalCastBridge.
|
||||
span, and now owns the GPU lowering step. Python/LocalCastBridge may still
|
||||
produce calibration artifacts and reference captures, but it must not own
|
||||
per-frame dense stereo, feature tracking, or reconstruction compute. The next
|
||||
scaling cut belongs to the Aquarium renderer: shared texture import, packed
|
||||
camera planes, Leap packed-map channel extraction, selected-cut residency,
|
||||
tiled/bin dispatch, GPU accumulation, and clustered visibility.
|
||||
|
||||
## GPU Fusion Spine
|
||||
|
||||
The active GPU boundary is deliberately narrow:
|
||||
|
||||
```text
|
||||
LocalCast typed visual frame
|
||||
-> AquariumGpuFusionSeed[]
|
||||
LocalCast calibration/device metadata
|
||||
-> AquariumGpuSensorFrame { calibrated cameras + shared GPU textures }
|
||||
-> D3D12 sensor metadata buffers + imported texture SRVs
|
||||
-> D3D12 LocalCast fusion compute shader
|
||||
-> RWStructuredBuffer<TemporalGaussian>
|
||||
-> instanced SDF Gaussian draw
|
||||
|
|
@ -87,18 +92,23 @@ LocalCast typed visual frame
|
|||
|
||||
Ownership:
|
||||
|
||||
- `AquariumGpuFusionField` is the renderer contract for GPU-owned fusion input.
|
||||
- `AquariumGpuSensorFrame` is the live renderer contract for GPU-owned fusion
|
||||
input.
|
||||
- `AquariumGpuFusionField` remains a temporary fallback/debug contract for
|
||||
already-derived point claims.
|
||||
- `LocalCastGpuFusionMapper` converts typed LocalCast point claims into compact
|
||||
seeds without client downsampling.
|
||||
- `LocalCastGpuFusionAccumulator` owns the bounded live history buffer for
|
||||
seeds only for that fallback path.
|
||||
- `LocalCastGpuFusionAccumulator` owns the bounded history buffer for fallback
|
||||
stable seeds before GPU lowering.
|
||||
- `D3D12LocalCastFusion.hlsl` owns the first compute lowering pass.
|
||||
- `D3D12Renderer` owns UAV-capable temporal Gaussian storage, dispatch, and the
|
||||
transition back to shader-resource state for the draw.
|
||||
- `D3D12Renderer` owns GPU sensor camera metadata storage, UAV-capable temporal
|
||||
Gaussian storage, dispatch, and the transition back to shader-resource state
|
||||
for the draw.
|
||||
|
||||
Next cut: replace point-claim seeds with packed camera planes and Leap packed
|
||||
maps so the compute shader performs stereo/flow/feature extraction directly on
|
||||
GPU-resident sensor data.
|
||||
Current Aquarium cut: the contract and D3D12 camera metadata buffer exist, and
|
||||
the fusion root now accepts that buffer beside fallback seeds. Next cut: import
|
||||
the external texture handles as SRVs, bind packed camera planes and Leap packed
|
||||
maps, then move stereo/flow/feature extraction directly into GPU kernels.
|
||||
|
||||
The first shader pass also uses camera-facing proxy planes to evaluate each
|
||||
kernel. True ray-integrated volume compositing, Gaussian depth sorting, and
|
||||
|
|
|
|||
|
|
@ -277,6 +277,64 @@ public readonly record struct AquariumGpuFusionSeed(
|
|||
float ShapePower,
|
||||
int FieldId);
|
||||
|
||||
public enum AquariumGpuSensorKind
|
||||
{
|
||||
Unknown,
|
||||
RgbCamera,
|
||||
HighRateTracker,
|
||||
LeapPackedMap,
|
||||
}
|
||||
|
||||
public enum AquariumGpuSensorPixelFormat
|
||||
{
|
||||
Unknown,
|
||||
Bgra8Unorm,
|
||||
Rgba8Unorm,
|
||||
R8Unorm,
|
||||
R16Unorm,
|
||||
R16Float,
|
||||
Rg8Unorm,
|
||||
LeapPackedMap,
|
||||
}
|
||||
|
||||
public readonly record struct AquariumExternalGpuTexture(
|
||||
TextureHandle Handle,
|
||||
IntPtr SharedHandle,
|
||||
int Width,
|
||||
int Height,
|
||||
AquariumGpuSensorPixelFormat PixelFormat,
|
||||
long TimestampNs,
|
||||
int PlaneIndex = 0);
|
||||
|
||||
public readonly record struct AquariumGpuSensorCamera(
|
||||
string SensorId,
|
||||
AquariumGpuSensorKind Kind,
|
||||
Matrix4x4 WorldFromSensor,
|
||||
Matrix4x4 SensorFromWorld,
|
||||
Vector4 Intrinsics,
|
||||
Vector4 Distortion01,
|
||||
Vector4 Distortion23,
|
||||
int Width,
|
||||
int Height,
|
||||
int FirstTextureIndex,
|
||||
int TextureCount,
|
||||
long TimestampNs);
|
||||
|
||||
public sealed class AquariumGpuSensorFrame
|
||||
{
|
||||
public static AquariumGpuSensorFrame Empty { get; } = new();
|
||||
|
||||
public IReadOnlyList<AquariumGpuSensorCamera> Cameras { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<AquariumExternalGpuTexture> ExternalTextures { get; init; } = [];
|
||||
|
||||
public float AccumulationWindowSeconds { get; init; }
|
||||
|
||||
public float PresentationDelaySeconds { get; init; }
|
||||
|
||||
public bool HasInput => Cameras.Count > 0 || ExternalTextures.Count > 0;
|
||||
}
|
||||
|
||||
public sealed class AquariumGpuFusionField
|
||||
{
|
||||
public static AquariumGpuFusionField Empty { get; } = new();
|
||||
|
|
@ -315,5 +373,7 @@ public sealed class AquariumSceneState
|
|||
|
||||
public AquariumTemporalGaussianField TemporalGaussianField { get; init; } = AquariumTemporalGaussianField.Empty;
|
||||
|
||||
public AquariumGpuSensorFrame GpuSensorFrame { get; init; } = AquariumGpuSensorFrame.Empty;
|
||||
|
||||
public AquariumGpuFusionField GpuFusionField { get; init; } = AquariumGpuFusionField.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private const Format SceneDepthFormat = Format.D32_Float;
|
||||
private const int MaxSdfLightCount = 64;
|
||||
private const int MaxSdfObjectCount = 64;
|
||||
private const int MaxGpuSensorCameraCount = 32;
|
||||
private const int MaxTemporalGaussianCount = 1_048_576;
|
||||
private const float SurfaceTransparentMinZ = -1.85f;
|
||||
private const float SurfaceTransparentMaxZ = 0.45f;
|
||||
|
|
@ -54,7 +55,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private const int RootTemporalGaussians = 13;
|
||||
private const int RootFusionFrameConstants = 0;
|
||||
private const int RootFusionSeeds = 1;
|
||||
private const int RootFusionOutput = 2;
|
||||
private const int RootFusionSensorCameras = 2;
|
||||
private const int RootFusionOutput = 3;
|
||||
private static readonly DebugUi.DebugUiOption[] RenderDebugOptions =
|
||||
[
|
||||
new(0, "Final"),
|
||||
|
|
@ -131,15 +133,18 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private readonly D3D12RenderTarget[] bloomScratchTargets = new D3D12RenderTarget[BloomLevelCount];
|
||||
private readonly D3D12StructuredBuffer sdfLightBuffer;
|
||||
private readonly D3D12StructuredBuffer sdfObjectBuffer;
|
||||
private readonly D3D12StructuredBuffer gpuSensorCameraBuffer;
|
||||
private readonly D3D12StructuredBuffer gpuFusionSeedBuffer;
|
||||
private readonly D3D12StructuredBuffer temporalGaussianBuffer;
|
||||
private readonly D3D12CubeTexture studioPmremTexture;
|
||||
private readonly D3D12CubeTexture studioIrradianceTexture;
|
||||
private readonly AquariumSdfLight[] sdfLights = new AquariumSdfLight[MaxSdfLightCount];
|
||||
private readonly AquariumSdfObject[] sdfObjects = new AquariumSdfObject[MaxSdfObjectCount];
|
||||
private readonly D3D12GpuSensorCameraPacket[] gpuSensorCameras = new D3D12GpuSensorCameraPacket[MaxGpuSensorCameraCount];
|
||||
private readonly D3D12GpuFusionSeedPacket[] gpuFusionSeeds = new D3D12GpuFusionSeedPacket[MaxTemporalGaussianCount];
|
||||
private readonly D3D12TemporalGaussianPacket[] temporalGaussians = new D3D12TemporalGaussianPacket[MaxTemporalGaussianCount];
|
||||
private int temporalGaussianCount;
|
||||
private int gpuSensorCameraCount;
|
||||
private bool temporalGaussiansGpuGenerated;
|
||||
private Viewport viewport;
|
||||
private RawRect scissorRect;
|
||||
|
|
@ -238,10 +243,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
CreateGraphRenderTargets();
|
||||
sdfLightBuffer = new D3D12StructuredBuffer(device, MaxSdfLightCount, Marshal.SizeOf<AquariumSdfLight>(), "Aquarium D3D12 Sdf Light Buffer");
|
||||
sdfObjectBuffer = new D3D12StructuredBuffer(device, MaxSdfObjectCount, Marshal.SizeOf<AquariumSdfObject>(), "Aquarium D3D12 Sdf Object Buffer");
|
||||
gpuSensorCameraBuffer = new D3D12StructuredBuffer(device, MaxGpuSensorCameraCount, Marshal.SizeOf<D3D12GpuSensorCameraPacket>(), "Aquarium D3D12 GPU Sensor Camera Buffer");
|
||||
gpuFusionSeedBuffer = new D3D12StructuredBuffer(device, MaxTemporalGaussianCount, Marshal.SizeOf<D3D12GpuFusionSeedPacket>(), "Aquarium D3D12 LocalCast GPU Fusion Seed Buffer");
|
||||
temporalGaussianBuffer = new D3D12StructuredBuffer(device, MaxTemporalGaussianCount, Marshal.SizeOf<D3D12TemporalGaussianPacket>(), "Aquarium D3D12 Temporal Gaussian Buffer", allowUnorderedAccess: true);
|
||||
resourceRegistry.Add("sdf-light-buffer", sdfLightBuffer);
|
||||
resourceRegistry.Add("sdf-object-buffer", sdfObjectBuffer);
|
||||
resourceRegistry.Add("gpu-sensor-camera-buffer", gpuSensorCameraBuffer);
|
||||
resourceRegistry.Add("gpu-fusion-seed-buffer", gpuFusionSeedBuffer);
|
||||
resourceRegistry.Add("temporal-gaussian-buffer", temporalGaussianBuffer);
|
||||
commandList = device.CreateCommandList<ID3D12GraphicsCommandList>(0, CommandListType.Direct, frames[frameIndex].CommandAllocator, null);
|
||||
|
|
@ -496,10 +503,15 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
}
|
||||
|
||||
CopySceneState(frame.Scene);
|
||||
var activeAccumulationWindow = frame.Scene.GpuFusionField.Seeds.Count > 0
|
||||
var activeGpuSensorInput = frame.Scene.GpuSensorFrame.HasInput;
|
||||
var activeAccumulationWindow = activeGpuSensorInput
|
||||
? frame.Scene.GpuSensorFrame.AccumulationWindowSeconds
|
||||
: frame.Scene.GpuFusionField.Seeds.Count > 0
|
||||
? frame.Scene.GpuFusionField.AccumulationWindowSeconds
|
||||
: frame.Scene.TemporalGaussianField.AccumulationWindowSeconds;
|
||||
var activePresentationDelay = frame.Scene.GpuFusionField.Seeds.Count > 0
|
||||
var activePresentationDelay = activeGpuSensorInput
|
||||
? frame.Scene.GpuSensorFrame.PresentationDelaySeconds
|
||||
: frame.Scene.GpuFusionField.Seeds.Count > 0
|
||||
? frame.Scene.GpuFusionField.PresentationDelaySeconds
|
||||
: frame.Scene.TemporalGaussianField.PresentationDelaySeconds;
|
||||
var frameConstants = frameResources.UploadRing.WriteConstant(new FrameConstants(
|
||||
|
|
@ -527,7 +539,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
new Vector4(frame.CursorWorld.X, frame.CursorWorld.Y, previousCursorWorld.X, previousCursorWorld.Y),
|
||||
new Vector4(
|
||||
temporalGaussianCount,
|
||||
MaxTemporalGaussianCount,
|
||||
gpuSensorCameraCount,
|
||||
activeAccumulationWindow,
|
||||
activePresentationDelay)));
|
||||
frameResources.FrameConstantsDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
|
|
@ -544,6 +556,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sdfLightBuffer.CreateShaderResourceView(device, frameResources.SdfLightDescriptor);
|
||||
frameResources.SdfObjectDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
sdfObjectBuffer.CreateShaderResourceView(device, frameResources.SdfObjectDescriptor);
|
||||
frameResources.GpuSensorCameraDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
gpuSensorCameraBuffer.CreateShaderResourceView(device, frameResources.GpuSensorCameraDescriptor);
|
||||
frameResources.GpuFusionSeedDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
gpuFusionSeedBuffer.CreateShaderResourceView(device, frameResources.GpuFusionSeedDescriptor);
|
||||
frameResources.TemporalGaussianDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
|
|
@ -764,6 +778,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
studioPmremTexture.Dispose();
|
||||
temporalGaussianBuffer.Dispose();
|
||||
gpuFusionSeedBuffer.Dispose();
|
||||
gpuSensorCameraBuffer.Dispose();
|
||||
sdfObjectBuffer.Dispose();
|
||||
sdfLightBuffer.Dispose();
|
||||
DisposeBloomRenderTargets();
|
||||
|
|
@ -1416,6 +1431,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
{
|
||||
sdfLightBuffer.Upload(activeCommandList, frameResources.UploadRing, sdfLights);
|
||||
sdfObjectBuffer.Upload(activeCommandList, frameResources.UploadRing, sdfObjects);
|
||||
gpuSensorCameraBuffer.UploadPartial(activeCommandList, frameResources.UploadRing, gpuSensorCameras.AsSpan(0, gpuSensorCameraCount));
|
||||
if (temporalGaussiansGpuGenerated)
|
||||
{
|
||||
gpuFusionSeedBuffer.UploadPartial(activeCommandList, frameResources.UploadRing, gpuFusionSeeds.AsSpan(0, temporalGaussianCount));
|
||||
|
|
@ -1448,6 +1464,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
activeCommandList.SetPipelineState(localCastFusionPipelineState!);
|
||||
activeCommandList.SetComputeRootDescriptorTable(RootFusionFrameConstants, frameResources.FrameConstantsDescriptor.Gpu);
|
||||
activeCommandList.SetComputeRootDescriptorTable(RootFusionSeeds, frameResources.GpuFusionSeedDescriptor.Gpu);
|
||||
activeCommandList.SetComputeRootDescriptorTable(RootFusionSensorCameras, frameResources.GpuSensorCameraDescriptor.Gpu);
|
||||
activeCommandList.SetComputeRootDescriptorTable(RootFusionOutput, frameResources.TemporalGaussianUnorderedAccessDescriptor.Gpu);
|
||||
activeCommandList.Dispatch((uint)((temporalGaussianCount + 127) / 128), 1, 1);
|
||||
temporalGaussianBuffer.Transition(activeCommandList, ResourceStates.PixelShaderResource | ResourceStates.NonPixelShaderResource);
|
||||
|
|
@ -1492,6 +1509,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
Array.Clear(sdfObjects);
|
||||
Array.Clear(sdfLights);
|
||||
temporalGaussianCount = 0;
|
||||
gpuSensorCameraCount = 0;
|
||||
temporalGaussiansGpuGenerated = false;
|
||||
heightFieldBrushConstants = D3D12HeightFieldBrushConstants.FromBrushes(scene.HeightFieldBrushes);
|
||||
|
||||
|
|
@ -1507,6 +1525,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sdfLights[index] = scene.SdfLights[index];
|
||||
}
|
||||
|
||||
gpuSensorCameraCount = Math.Min(scene.GpuSensorFrame.Cameras.Count, MaxGpuSensorCameraCount);
|
||||
for (var index = 0; index < gpuSensorCameraCount; index++)
|
||||
{
|
||||
gpuSensorCameras[index] = ToGpuSensorCameraPacket(scene.GpuSensorFrame.Cameras[index]);
|
||||
}
|
||||
|
||||
if (scene.GpuFusionField.Seeds.Count > 0)
|
||||
{
|
||||
var seedCount = Math.Min(scene.GpuFusionField.Seeds.Count, MaxTemporalGaussianCount);
|
||||
|
|
@ -1527,6 +1551,34 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
}
|
||||
}
|
||||
|
||||
private static D3D12GpuSensorCameraPacket ToGpuSensorCameraPacket(AquariumGpuSensorCamera camera)
|
||||
{
|
||||
static Vector4 Row0(Matrix4x4 matrix) => new(matrix.M11, matrix.M12, matrix.M13, matrix.M14);
|
||||
static Vector4 Row1(Matrix4x4 matrix) => new(matrix.M21, matrix.M22, matrix.M23, matrix.M24);
|
||||
static Vector4 Row2(Matrix4x4 matrix) => new(matrix.M31, matrix.M32, matrix.M33, matrix.M34);
|
||||
|
||||
return new D3D12GpuSensorCameraPacket(
|
||||
camera.Intrinsics,
|
||||
camera.Distortion01,
|
||||
camera.Distortion23,
|
||||
new Vector4(
|
||||
Math.Max(0, camera.Width),
|
||||
Math.Max(0, camera.Height),
|
||||
(int)camera.Kind,
|
||||
camera.TextureCount),
|
||||
new Vector4(
|
||||
Math.Max(0, camera.FirstTextureIndex),
|
||||
camera.TextureCount,
|
||||
camera.TimestampNs * 0.000000001f,
|
||||
0.0f),
|
||||
Row0(camera.WorldFromSensor),
|
||||
Row1(camera.WorldFromSensor),
|
||||
Row2(camera.WorldFromSensor),
|
||||
Row0(camera.SensorFromWorld),
|
||||
Row1(camera.SensorFromWorld),
|
||||
Row2(camera.SensorFromWorld));
|
||||
}
|
||||
|
||||
private static D3D12GpuFusionSeedPacket ToGpuFusionSeedPacket(AquariumGpuFusionSeed seed)
|
||||
{
|
||||
return new D3D12GpuFusionSeedPacket(
|
||||
|
|
@ -2022,6 +2074,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
26,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var sensorCameraRange = new DescriptorRange(
|
||||
DescriptorRangeType.ShaderResourceView,
|
||||
1,
|
||||
27,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var outputRange = new DescriptorRange(
|
||||
DescriptorRangeType.UnorderedAccessView,
|
||||
1,
|
||||
|
|
@ -2032,6 +2090,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
{
|
||||
new RootParameter(new RootDescriptorTable([frameRange]), ShaderVisibility.All),
|
||||
new RootParameter(new RootDescriptorTable([seedRange]), ShaderVisibility.All),
|
||||
new RootParameter(new RootDescriptorTable([sensorCameraRange]), ShaderVisibility.All),
|
||||
new RootParameter(new RootDescriptorTable([outputRange]), ShaderVisibility.All),
|
||||
};
|
||||
var description = new RootSignatureDescription(
|
||||
|
|
@ -2351,6 +2410,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
|
||||
public D3D12DescriptorSlot SdfObjectDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot GpuSensorCameraDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot GpuFusionSeedDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot TemporalGaussianDescriptor { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aquarium.Engine.Render.Features;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly record struct D3D12GpuSensorCameraPacket(
|
||||
Vector4 Intrinsics,
|
||||
Vector4 Distortion01,
|
||||
Vector4 Distortion23,
|
||||
Vector4 ExtentsKind,
|
||||
Vector4 TextureRangeTime,
|
||||
Vector4 WorldFromSensor0,
|
||||
Vector4 WorldFromSensor1,
|
||||
Vector4 WorldFromSensor2,
|
||||
Vector4 SensorFromWorld0,
|
||||
Vector4 SensorFromWorld1,
|
||||
Vector4 SensorFromWorld2);
|
||||
|
|
@ -46,7 +46,23 @@ struct TemporalGaussian
|
|||
float4 shapePad;
|
||||
};
|
||||
|
||||
struct GpuSensorCamera
|
||||
{
|
||||
float4 intrinsics;
|
||||
float4 distortion01;
|
||||
float4 distortion23;
|
||||
float4 extentsKind;
|
||||
float4 textureRangeTime;
|
||||
float4 worldFromSensor0;
|
||||
float4 worldFromSensor1;
|
||||
float4 worldFromSensor2;
|
||||
float4 sensorFromWorld0;
|
||||
float4 sensorFromWorld1;
|
||||
float4 sensorFromWorld2;
|
||||
};
|
||||
|
||||
StructuredBuffer<GpuFusionSeed> fusionSeeds : register(t26);
|
||||
StructuredBuffer<GpuSensorCamera> sensorCameras : register(t27);
|
||||
RWStructuredBuffer<TemporalGaussian> temporalGaussiansOut : register(u0);
|
||||
|
||||
[numthreads(128, 1, 1)]
|
||||
|
|
@ -60,6 +76,7 @@ void D3D12LocalCastFusionCS(uint3 dispatchThreadId : SV_DispatchThreadID)
|
|||
}
|
||||
|
||||
GpuFusionSeed seed = fusionSeeds[index];
|
||||
uint cameraCount = (uint)temporalGaussianInfo.y;
|
||||
TemporalGaussian gaussian;
|
||||
gaussian.centerHistoryWeight = seed.centerHistoryWeight;
|
||||
gaussian.previousCenterFieldId = seed.previousCenterFieldId;
|
||||
|
|
@ -68,5 +85,10 @@ void D3D12LocalCastFusionCS(uint3 dispatchThreadId : SV_DispatchThreadID)
|
|||
gaussian.orientation = float4(0.0, 0.0, 0.0, 1.0);
|
||||
gaussian.colorOpacity = seed.colorOpacity;
|
||||
gaussian.shapePad = seed.shapePad;
|
||||
if (cameraCount > 0)
|
||||
{
|
||||
GpuSensorCamera camera = sensorCameras[index % cameraCount];
|
||||
gaussian.shapePad.w = camera.textureRangeTime.z;
|
||||
}
|
||||
temporalGaussiansOut[index] = gaussian;
|
||||
}
|
||||
|
|
|
|||
50
tests/Aquarium.Engine.Tests/GpuSensorFrameContractTests.cs
Normal file
50
tests/Aquarium.Engine.Tests/GpuSensorFrameContractTests.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Render;
|
||||
|
||||
namespace Aquarium.Engine.Tests;
|
||||
|
||||
public sealed class GpuSensorFrameContractTests
|
||||
{
|
||||
[Fact]
|
||||
public void SceneStateCarriesSharedGpuSensorFrameAsRendererInput()
|
||||
{
|
||||
var frame = new AquariumGpuSensorFrame
|
||||
{
|
||||
AccumulationWindowSeconds = 18.0f,
|
||||
PresentationDelaySeconds = 0.35f,
|
||||
Cameras =
|
||||
[
|
||||
new AquariumGpuSensorCamera(
|
||||
"kiyo-pro-left",
|
||||
AquariumGpuSensorKind.RgbCamera,
|
||||
Matrix4x4.Identity,
|
||||
Matrix4x4.Identity,
|
||||
new Vector4(840.0f, 840.0f, 960.0f, 540.0f),
|
||||
Vector4.Zero,
|
||||
Vector4.Zero,
|
||||
1920,
|
||||
1080,
|
||||
0,
|
||||
1,
|
||||
10_000_000_000)
|
||||
],
|
||||
ExternalTextures =
|
||||
[
|
||||
new AquariumExternalGpuTexture(
|
||||
new TextureHandle("kiyo-pro-left-bgra"),
|
||||
new IntPtr(1234),
|
||||
1920,
|
||||
1080,
|
||||
AquariumGpuSensorPixelFormat.Bgra8Unorm,
|
||||
10_000_000_000)
|
||||
],
|
||||
};
|
||||
|
||||
var scene = new AquariumSceneState { GpuSensorFrame = frame };
|
||||
|
||||
Assert.True(scene.GpuSensorFrame.HasInput);
|
||||
Assert.Equal("kiyo-pro-left", scene.GpuSensorFrame.Cameras[0].SensorId);
|
||||
Assert.Equal(AquariumGpuSensorPixelFormat.Bgra8Unorm, scene.GpuSensorFrame.ExternalTextures[0].PixelFormat);
|
||||
Assert.Equal(18.0f, scene.GpuSensorFrame.AccumulationWindowSeconds, 6);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue