Add reservoir guide history targets
This commit is contained in:
parent
fc54694fe5
commit
febb41ed49
11 changed files with 122 additions and 11 deletions
|
|
@ -463,6 +463,20 @@ Add a dedicated reservoir guide history target rather than packing previous
|
|||
reservoir validity into existing control channels. Preserve current-control.w
|
||||
as the current confidence lane.
|
||||
|
||||
Guide schema:
|
||||
|
||||
```text
|
||||
x: reservoir confidence
|
||||
y: reservoir sample age
|
||||
z: domain validity
|
||||
w: invalidation code
|
||||
```
|
||||
|
||||
Current state: SDF and temporal Gaussian passes write a scene reservoir guide
|
||||
MRT. Resolve reads current and previous guide textures, folds confidence and
|
||||
domain validity into history validation, and writes a ping-ponged history
|
||||
reservoir guide target. `history-control.w` remains pixel history age.
|
||||
|
||||
### Phase C: Fractal Probe Pipeline
|
||||
|
||||
Turn IFS node probes into typed reservoir candidates with renderer-facing camera
|
||||
|
|
|
|||
|
|
@ -141,6 +141,25 @@ Not built yet:
|
|||
sample age, domain validity, and invalidation reason;
|
||||
- SSD/RAM residency queues driven by reservoir contribution estimates.
|
||||
|
||||
## TAA Guide Layout
|
||||
|
||||
Reservoir/TAA guide data has a dedicated current scene target and ping-ponged
|
||||
history target. It is deliberately separate from `history-control.w`, which
|
||||
continues to own pixel history age.
|
||||
|
||||
```text
|
||||
x: reservoir confidence
|
||||
y: reservoir sample age
|
||||
z: domain validity
|
||||
w: invalidation code
|
||||
```
|
||||
|
||||
The first live producers are SDF surfaces and temporal Gaussian splats. Resolve
|
||||
reads the current and previous guide textures, folds confidence and domain
|
||||
validity into history validation, then writes the next history guide. Future
|
||||
ReSTIR/GRIS passes should extend the producer side of this schema rather than
|
||||
packing more reservoir folklore into scene-control channels.
|
||||
|
||||
## Implementation Roadmap
|
||||
|
||||
1. Keep the CPU reservoir core pure and exhaustive under unit tests.
|
||||
|
|
|
|||
|
|
@ -345,8 +345,9 @@ Tasks:
|
|||
domains.
|
||||
- [ ] Feed reservoir confidence, selected target, candidate count, sample age,
|
||||
and invalidation reason into TAA guide/history buffers. Current
|
||||
scene-control.w now carries current reservoir confidence into resolve; full
|
||||
previous-frame reservoir guide storage remains open.
|
||||
reservoir confidence, sample age, domain validity, and invalidation code now
|
||||
have explicit scene/history reservoir guide targets; selected target and
|
||||
candidate count still need producer-side packing once GPU reservoirs exist.
|
||||
- [ ] Add confidence decay and stale uncertainty growth.
|
||||
- [ ] Add fake contribution probe.
|
||||
- [ ] Add convergence telemetry.
|
||||
|
|
@ -367,7 +368,7 @@ Tests:
|
|||
- [x] temporal reuse rejects mismatched domain ancestry;
|
||||
- [x] spatial reuse rejects invalid local-frame shifts;
|
||||
- [x] TAA history confidence is modulated by current reservoir confidence;
|
||||
- TAA history confidence drops when previous-frame reservoir validity changes;
|
||||
- [x] TAA history confidence drops when previous-frame reservoir/domain validity changes;
|
||||
- update cost respects budget.
|
||||
|
||||
Exit gate:
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private const int RootStudioIrradiance = 11;
|
||||
private const int RootSdfObjects = 12;
|
||||
private const int RootTemporalGaussians = 13;
|
||||
private const int RootCurrentReservoirGuide = 14;
|
||||
private const int RootHistoryReservoirGuide = 15;
|
||||
private const int RootFusionFrameConstants = 0;
|
||||
private const int RootFusionSeeds = 1;
|
||||
private const int RootFusionSensorCameras = 2;
|
||||
|
|
@ -131,12 +133,14 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
private D3D12RenderTarget sceneRenderTarget;
|
||||
private D3D12RenderTarget sceneMetadataRenderTarget;
|
||||
private D3D12RenderTarget sceneControlRenderTarget;
|
||||
private D3D12RenderTarget sceneReservoirGuideRenderTarget;
|
||||
private readonly Dictionary<string, D3D12RenderTarget> graphRenderTargets = new(StringComparer.Ordinal);
|
||||
private D3D12TrackedResource sceneDepthTarget;
|
||||
private D3D12DescriptorSlot sceneDepthStencilView;
|
||||
private readonly D3D12RenderTarget[] historyRenderTargets = new D3D12RenderTarget[2];
|
||||
private readonly D3D12RenderTarget[] historyMetadataRenderTargets = new D3D12RenderTarget[2];
|
||||
private readonly D3D12RenderTarget[] historyControlRenderTargets = new D3D12RenderTarget[2];
|
||||
private readonly D3D12RenderTarget[] historyReservoirGuideRenderTargets = new D3D12RenderTarget[2];
|
||||
private readonly D3D12RenderTarget[] bloomRenderTargets = new D3D12RenderTarget[BloomLevelCount];
|
||||
private readonly D3D12RenderTarget[] bloomScratchTargets = new D3D12RenderTarget[BloomLevelCount];
|
||||
private readonly D3D12StructuredBuffer sdfLightBuffer;
|
||||
|
|
@ -253,6 +257,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget = CreateSceneRenderTarget();
|
||||
sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target");
|
||||
sceneControlRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-control-target", "Aquarium D3D12 Scene Control Target");
|
||||
sceneReservoirGuideRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-reservoir-guide-target", "Aquarium D3D12 Scene Reservoir Guide Target");
|
||||
sceneDepthStencilView = depthStencilViewArena.Allocate();
|
||||
sceneDepthTarget = CreateSceneDepthTarget(sceneDepthStencilView);
|
||||
CreateHistoryRenderTargets();
|
||||
|
|
@ -610,6 +615,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneMetadataRenderTarget.CreateShaderResourceView(device, frameResources.SceneMetadataDescriptor);
|
||||
frameResources.SceneControlDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
sceneControlRenderTarget.CreateShaderResourceView(device, frameResources.SceneControlDescriptor);
|
||||
frameResources.SceneReservoirGuideDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
sceneReservoirGuideRenderTarget.CreateShaderResourceView(device, frameResources.SceneReservoirGuideDescriptor);
|
||||
var historyReadIndex = temporalFrameIndex & 1;
|
||||
frameResources.HistoryDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
historyRenderTargets[historyReadIndex].CreateShaderResourceView(device, frameResources.HistoryDescriptor);
|
||||
|
|
@ -617,6 +624,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
historyMetadataRenderTargets[historyReadIndex].CreateShaderResourceView(device, frameResources.HistoryMetadataDescriptor);
|
||||
frameResources.HistoryControlDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
historyControlRenderTargets[historyReadIndex].CreateShaderResourceView(device, frameResources.HistoryControlDescriptor);
|
||||
frameResources.HistoryReservoirGuideDescriptor = frameResources.TransientShaderDescriptors.Allocate();
|
||||
historyReservoirGuideRenderTargets[historyReadIndex].CreateShaderResourceView(device, frameResources.HistoryReservoirGuideDescriptor);
|
||||
for (var level = 0; level < BloomLevelCount; level++)
|
||||
{
|
||||
frameResources.BloomDescriptors[level] = frameResources.TransientShaderDescriptors.Allocate();
|
||||
|
|
@ -829,6 +838,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget.Dispose();
|
||||
sceneMetadataRenderTarget.Dispose();
|
||||
sceneControlRenderTarget.Dispose();
|
||||
sceneReservoirGuideRenderTarget.Dispose();
|
||||
sceneDepthTarget.Dispose();
|
||||
heightFieldRenderTarget.Dispose();
|
||||
for (var index = 0; index < frames.Length; index++)
|
||||
|
|
@ -1011,6 +1021,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
resourceRegistry.RemoveRenderTarget("scene-hdr-target");
|
||||
resourceRegistry.RemoveRenderTarget("scene-metadata-target");
|
||||
resourceRegistry.RemoveRenderTarget("scene-control-target");
|
||||
resourceRegistry.RemoveRenderTarget("scene-reservoir-guide-target");
|
||||
resourceRegistry.RemoveResource("scene-depth-target");
|
||||
resourceRegistry.RemoveRenderTarget("height-field-target");
|
||||
DisposeBloomRenderTargets();
|
||||
|
|
@ -1019,6 +1030,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget.Dispose();
|
||||
sceneMetadataRenderTarget.Dispose();
|
||||
sceneControlRenderTarget.Dispose();
|
||||
sceneReservoirGuideRenderTarget.Dispose();
|
||||
sceneDepthTarget.Dispose();
|
||||
heightFieldRenderTarget.Dispose();
|
||||
for (var index = 0; index < frames.Length; index++)
|
||||
|
|
@ -1044,6 +1056,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget = CreateSceneRenderTarget();
|
||||
sceneMetadataRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-metadata-target", "Aquarium D3D12 Scene Metadata Target");
|
||||
sceneControlRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-control-target", "Aquarium D3D12 Scene Control Target");
|
||||
sceneReservoirGuideRenderTarget = CreateSceneAuxiliaryRenderTarget("scene-reservoir-guide-target", "Aquarium D3D12 Scene Reservoir Guide Target");
|
||||
sceneDepthStencilView = depthStencilViewArena.Allocate();
|
||||
sceneDepthTarget = CreateSceneDepthTarget(sceneDepthStencilView);
|
||||
CreateHistoryRenderTargets();
|
||||
|
|
@ -1135,6 +1148,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
historyRenderTargets[index] = CreateSceneAuxiliaryRenderTarget($"history-{index}", $"Aquarium D3D12 History {index}");
|
||||
historyMetadataRenderTargets[index] = CreateSceneAuxiliaryRenderTarget($"history-metadata-{index}", $"Aquarium D3D12 History Metadata {index}");
|
||||
historyControlRenderTargets[index] = CreateSceneAuxiliaryRenderTarget($"history-control-{index}", $"Aquarium D3D12 History Control {index}");
|
||||
historyReservoirGuideRenderTargets[index] = CreateSceneAuxiliaryRenderTarget($"history-reservoir-guide-{index}", $"Aquarium D3D12 History Reservoir Guide {index}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1145,6 +1159,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
resourceRegistry.RemoveRenderTarget($"history-{index}");
|
||||
resourceRegistry.RemoveRenderTarget($"history-metadata-{index}");
|
||||
resourceRegistry.RemoveRenderTarget($"history-control-{index}");
|
||||
resourceRegistry.RemoveRenderTarget($"history-reservoir-guide-{index}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1155,6 +1170,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
historyRenderTargets[index]?.Dispose();
|
||||
historyMetadataRenderTargets[index]?.Dispose();
|
||||
historyControlRenderTargets[index]?.Dispose();
|
||||
historyReservoirGuideRenderTargets[index]?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1296,10 +1312,12 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
sceneMetadataRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
sceneControlRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
sceneReservoirGuideRenderTarget.Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
sceneDepthTarget.Transition(context.CommandList, ResourceStates.DepthWrite);
|
||||
context.CommandList.ClearRenderTargetView(sceneRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(sceneMetadataRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(sceneControlRenderTarget.RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(sceneReservoirGuideRenderTarget.RenderTargetView.Cpu, new Color4(1.0f, 0.0f, 1.0f, 0.0f));
|
||||
context.CommandList.ClearDepthStencilView(sceneDepthStencilView.Cpu, ClearFlags.Depth, 1.0f, 0);
|
||||
context.CommandList.SetDescriptorHeaps(frameResources.TransientShaderDescriptors.Heap);
|
||||
context.CommandList.SetPipelineState(scenePipelineState!);
|
||||
|
|
@ -1319,6 +1337,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget.RenderTargetView.Cpu,
|
||||
sceneMetadataRenderTarget.RenderTargetView.Cpu,
|
||||
sceneControlRenderTarget.RenderTargetView.Cpu,
|
||||
sceneReservoirGuideRenderTarget.RenderTargetView.Cpu,
|
||||
],
|
||||
sceneDepthStencilView.Cpu);
|
||||
context.CommandList.IASetPrimitiveTopology(PrimitiveTopology.TriangleList);
|
||||
|
|
@ -1422,15 +1441,19 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
sceneRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
sceneMetadataRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
sceneControlRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
sceneReservoirGuideRenderTarget.Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
historyRenderTargets[historyReadIndex].Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
historyMetadataRenderTargets[historyReadIndex].Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
historyControlRenderTargets[historyReadIndex].Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
historyReservoirGuideRenderTargets[historyReadIndex].Transition(context.CommandList, ResourceStates.PixelShaderResource);
|
||||
historyRenderTargets[historyWriteIndex].Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
historyMetadataRenderTargets[historyWriteIndex].Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
historyControlRenderTargets[historyWriteIndex].Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
historyReservoirGuideRenderTargets[historyWriteIndex].Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
context.CommandList.ClearRenderTargetView(historyRenderTargets[historyWriteIndex].RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(historyMetadataRenderTargets[historyWriteIndex].RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(historyControlRenderTargets[historyWriteIndex].RenderTargetView.Cpu, new Color4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
context.CommandList.ClearRenderTargetView(historyReservoirGuideRenderTargets[historyWriteIndex].RenderTargetView.Cpu, new Color4(1.0f, 0.0f, 1.0f, 0.0f));
|
||||
|
||||
context.BackBuffer.Transition(context.CommandList, ResourceStates.RenderTarget);
|
||||
context.CommandList.SetDescriptorHeaps(frameResources.TransientShaderDescriptors.Heap);
|
||||
|
|
@ -1446,6 +1469,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
context.CommandList.SetGraphicsRootDescriptorTable(RootHistoryControl, frameResources.HistoryControlDescriptor.Gpu);
|
||||
context.CommandList.SetGraphicsRootDescriptorTable(RootSdfObjects, frameResources.SdfObjectDescriptor.Gpu);
|
||||
context.CommandList.SetGraphicsRootDescriptorTable(RootTemporalGaussians, frameResources.TemporalGaussianDescriptor.Gpu);
|
||||
context.CommandList.SetGraphicsRootDescriptorTable(RootCurrentReservoirGuide, frameResources.SceneReservoirGuideDescriptor.Gpu);
|
||||
context.CommandList.SetGraphicsRootDescriptorTable(RootHistoryReservoirGuide, frameResources.HistoryReservoirGuideDescriptor.Gpu);
|
||||
|
||||
context.CommandList.RSSetViewports(viewport);
|
||||
context.CommandList.RSSetScissorRects(scissorRect);
|
||||
|
|
@ -1455,6 +1480,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
historyRenderTargets[historyWriteIndex].RenderTargetView.Cpu,
|
||||
historyMetadataRenderTargets[historyWriteIndex].RenderTargetView.Cpu,
|
||||
historyControlRenderTargets[historyWriteIndex].RenderTargetView.Cpu,
|
||||
historyReservoirGuideRenderTargets[historyWriteIndex].RenderTargetView.Cpu,
|
||||
],
|
||||
null);
|
||||
context.CommandList.IASetPrimitiveTopology(PrimitiveTopology.TriangleList);
|
||||
|
|
@ -2170,6 +2196,18 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
8,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var currentReservoirGuideRange = new DescriptorRange(
|
||||
DescriptorRangeType.ShaderResourceView,
|
||||
1,
|
||||
26,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var historyReservoirGuideRange = new DescriptorRange(
|
||||
DescriptorRangeType.ShaderResourceView,
|
||||
1,
|
||||
27,
|
||||
0,
|
||||
D3D12.DescriptorRangeOffsetAppend);
|
||||
var studioPmremRange = new DescriptorRange(
|
||||
DescriptorRangeType.ShaderResourceView,
|
||||
1,
|
||||
|
|
@ -2210,6 +2248,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
new RootParameter(new RootDescriptorTable([studioIrradianceRange]), ShaderVisibility.Pixel),
|
||||
new RootParameter(new RootDescriptorTable([sdfObjectRange]), ShaderVisibility.All),
|
||||
new RootParameter(new RootDescriptorTable([temporalGaussianRange]), ShaderVisibility.All),
|
||||
new RootParameter(new RootDescriptorTable([currentReservoirGuideRange]), ShaderVisibility.Pixel),
|
||||
new RootParameter(new RootDescriptorTable([historyReservoirGuideRange]), ShaderVisibility.Pixel),
|
||||
};
|
||||
var staticSamplers = new[]
|
||||
{
|
||||
|
|
@ -2313,17 +2353,17 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
|
||||
private ID3D12PipelineState CreateScenePipelineState(string path)
|
||||
{
|
||||
return CreateFullscreenPipelineState(path, "FullscreenTriangleVS", "D3D12ScenePS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
return CreateFullscreenPipelineState(path, "FullscreenTriangleVS", "D3D12ScenePS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
}
|
||||
|
||||
private ID3D12PipelineState CreateSdfObjectProxyPipelineState(string path)
|
||||
{
|
||||
return CreateFullscreenPipelineState(path, "D3D12SdfObjectProxyVS", "D3D12SdfProxyPS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
return CreateFullscreenPipelineState(path, "D3D12SdfObjectProxyVS", "D3D12SdfProxyPS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
}
|
||||
|
||||
private ID3D12PipelineState CreateTemporalGaussianPipelineState(string path)
|
||||
{
|
||||
return CreateFullscreenPipelineState(path, "D3D12TemporalGaussianVS", "D3D12TemporalGaussianPS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
return CreateFullscreenPipelineState(path, "D3D12TemporalGaussianVS", "D3D12TemporalGaussianPS", [SceneHdrFormat, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat], enableDepth: true);
|
||||
}
|
||||
|
||||
private ID3D12PipelineState CreateLocalCastFusionPipelineState(string path)
|
||||
|
|
@ -2363,7 +2403,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
path,
|
||||
"FullscreenTriangleVS",
|
||||
"D3D12ResolvePS",
|
||||
[Format.B8G8R8A8_UNorm, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat]);
|
||||
[Format.B8G8R8A8_UNorm, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat, SceneHdrFormat]);
|
||||
}
|
||||
|
||||
private ID3D12PipelineState CreateHeightFieldBasePipelineState(string path)
|
||||
|
|
@ -2633,12 +2673,16 @@ public sealed class D3D12Renderer : IAquariumRenderer
|
|||
|
||||
public D3D12DescriptorSlot SceneControlDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot SceneReservoirGuideDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot HistoryDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot HistoryMetadataDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot HistoryControlDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot HistoryReservoirGuideDescriptor { get; set; }
|
||||
|
||||
public D3D12DescriptorSlot[] BloomDescriptors { get; } = new D3D12DescriptorSlot[BloomLevelCount];
|
||||
|
||||
public D3D12DescriptorSlot[] BloomScratchDescriptors { get; } = new D3D12DescriptorSlot[BloomLevelCount];
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ Texture2D<float4> historyControlTexture : register(t8);
|
|||
Texture2D<float4> bloomTexture0 : register(t9);
|
||||
Texture2D<float4> bloomTexture1 : register(t10);
|
||||
Texture2D<float4> bloomTexture2 : register(t11);
|
||||
Texture2D<float4> currentReservoirGuideTexture : register(t26);
|
||||
Texture2D<float4> historyReservoirGuideTexture : register(t27);
|
||||
SamplerState sourceSampler : register(s0);
|
||||
|
||||
struct SdfObject
|
||||
|
|
@ -57,6 +59,7 @@ struct ResolveOut
|
|||
float4 historyColor : SV_Target1;
|
||||
float4 historyMetadata : SV_Target2;
|
||||
float4 historyControl : SV_Target3;
|
||||
float4 historyReservoirGuide : SV_Target4;
|
||||
};
|
||||
|
||||
static const float FIELD_ID_HEIGHT_FIELD = 4.0;
|
||||
|
|
@ -189,6 +192,16 @@ float4 loadHistoryControl(float2 uv)
|
|||
return historyControlTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 loadCurrentReservoirGuide(float2 uv)
|
||||
{
|
||||
return currentReservoirGuideTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
float4 loadHistoryReservoirGuide(float2 uv)
|
||||
{
|
||||
return historyReservoirGuideTexture.Load(int3(pixelFromUv(uv), 0));
|
||||
}
|
||||
|
||||
void currentNeighborhood(float2 uv, out float3 neighborhoodMin, out float3 neighborhoodMax)
|
||||
{
|
||||
float2 texel = 1.0 / resolution;
|
||||
|
|
@ -325,15 +338,20 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
float3 currentColor = current.rgb;
|
||||
float4 currentMetadata = loadCurrentMetadata(input.uv);
|
||||
float4 currentControl = loadCurrentControl(input.uv);
|
||||
float4 currentReservoirGuide = loadCurrentReservoirGuide(input.uv);
|
||||
float currentFieldId = currentMetadata.x;
|
||||
float3 currentNormal = currentMetadata.yzw;
|
||||
float currentCoverage = saturate(currentControl.x);
|
||||
float currentStepRatio = saturate(currentControl.y);
|
||||
float currentTemporalDetail = saturate(currentControl.z);
|
||||
float currentReservoirConfidence = currentControl.w > 0.0 ? saturate(currentControl.w) : 1.0;
|
||||
float currentReservoirConfidence = currentReservoirGuide.x > 0.0 ? saturate(currentReservoirGuide.x) : (currentControl.w > 0.0 ? saturate(currentControl.w) : 1.0);
|
||||
float currentReservoirSampleAge = max(currentReservoirGuide.y, 0.0);
|
||||
float currentReservoirDomainValidity = currentReservoirGuide.z > 0.0 ? saturate(currentReservoirGuide.z) : 1.0;
|
||||
|
||||
float historyWeight = 0.0;
|
||||
float historyAge = 0.0;
|
||||
float reservoirSampleAge = currentReservoirSampleAge;
|
||||
float reservoirInvalidationCode = 0.0;
|
||||
float3 historyColor = currentColor;
|
||||
if (frameIndex > 0.5 && currentTravel <= farDistance && currentFieldId > 0.5)
|
||||
{
|
||||
|
|
@ -346,6 +364,7 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
{
|
||||
float4 previousMetadata = loadHistoryMetadata(previousUv);
|
||||
float4 previousControl = loadHistoryControl(previousUv);
|
||||
float4 previousReservoirGuide = loadHistoryReservoirGuide(previousUv);
|
||||
float4 previous = historyTexture.SampleLevel(sourceSampler, previousUv, 0.0);
|
||||
float previousFieldId = previousMetadata.x;
|
||||
float previousTravel = previous.a;
|
||||
|
|
@ -353,6 +372,9 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
float previousCoverage = saturate(previousControl.x);
|
||||
float previousTemporalDetail = saturate(previousControl.z);
|
||||
float previousHistoryAge = max(previousControl.w, 0.0);
|
||||
float previousReservoirConfidence = previousReservoirGuide.x > 0.0 ? saturate(previousReservoirGuide.x) : 1.0;
|
||||
float previousReservoirSampleAge = max(previousReservoirGuide.y, 0.0);
|
||||
float previousReservoirDomainValidity = previousReservoirGuide.z > 0.0 ? saturate(previousReservoirGuide.z) : 1.0;
|
||||
float expectedPreviousTravel = distance(previousCameraPosition, previousWorldPosition);
|
||||
float travelDelta = abs(previousTravel - expectedPreviousTravel);
|
||||
float travelTolerance = max(0.045, expectedPreviousTravel * 0.018);
|
||||
|
|
@ -378,13 +400,16 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
float coverageContinuityWeight = 1.0 - smoothstep(0.10, 0.50, abs(previousCoverage - currentCoverage));
|
||||
float temporalDetailWeight = 1.0 - smoothstep(0.08, 0.45, abs(previousTemporalDetail - currentTemporalDetail));
|
||||
temporalDetailWeight = max(temporalDetailWeight, 1.0 - smoothstep(0.02, 0.12, max(previousTemporalDetail, currentTemporalDetail)));
|
||||
float reservoirConfidenceWeight = lerp(0.45, 1.0, currentReservoirConfidence);
|
||||
float reservoirConfidenceWeight = lerp(0.45, 1.0, min(currentReservoirConfidence, previousReservoirConfidence));
|
||||
float reservoirDomainWeight = currentReservoirDomainValidity * previousReservoirDomainValidity;
|
||||
float historyConfidence = smoothstep(0.0, 6.0, previousHistoryAge);
|
||||
float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight * temporalDetailWeight * reservoirConfidenceWeight;
|
||||
float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight * temporalDetailWeight * reservoirConfidenceWeight * reservoirDomainWeight;
|
||||
|
||||
historyColor = clampedHistory;
|
||||
historyWeight = 0.82 * lerp(0.35, 1.0, historyConfidence) * validationWeight;
|
||||
historyAge = validationWeight > 0.01 ? min(previousHistoryAge + 1.0, MAX_HISTORY_AGE) : 0.0;
|
||||
reservoirSampleAge = validationWeight > 0.01 ? min(max(currentReservoirSampleAge, previousReservoirSampleAge + 1.0), MAX_HISTORY_AGE) : currentReservoirSampleAge;
|
||||
reservoirInvalidationCode = validationWeight > 0.01 ? 0.0 : 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -444,5 +469,6 @@ ResolveOut D3D12ResolvePS(VertexOut input)
|
|||
output.historyColor = float4(resolved, currentTravel);
|
||||
output.historyMetadata = currentMetadata;
|
||||
output.historyControl = float4(currentControl.xyz, combinedHistoryAge);
|
||||
output.historyReservoirGuide = float4(currentReservoirConfidence, reservoirSampleAge, currentReservoirDomainValidity, reservoirInvalidationCode);
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ struct SceneOut
|
|||
float4 colorTravel : SV_Target0;
|
||||
float4 metadata : SV_Target1;
|
||||
float4 control : SV_Target2;
|
||||
float4 reservoirGuide : SV_Target3;
|
||||
float depth : SV_Depth;
|
||||
};
|
||||
|
||||
|
|
@ -379,6 +380,7 @@ SceneOut D3D12ScenePS(VertexOut input)
|
|||
output.colorTravel = float4(result.color, min(result.travel, farDistance + 1.0));
|
||||
output.metadata = float4(result.fieldId, result.normal);
|
||||
output.control = float4(result.coverage, result.stepCount / 72.0, 0.0, 0.0);
|
||||
output.reservoirGuide = float4(1.0, 0.0, 1.0, 0.0);
|
||||
output.depth = saturate(result.travel / max(farDistance, 0.001));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ struct SceneOut
|
|||
float4 colorTravel : SV_Target0;
|
||||
float4 metadata : SV_Target1;
|
||||
float4 control : SV_Target2;
|
||||
float4 reservoirGuide : SV_Target3;
|
||||
float depth : SV_Depth;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ SceneOut D3D12SdfProxyPS(SdfObjectProxyVertexOut input)
|
|||
stepCount / (float)SDF_TRACE_STEPS,
|
||||
saturate(surface.temporalDetail),
|
||||
saturate(surface.reservoirConfidence));
|
||||
output.reservoirGuide = float4(saturate(surface.reservoirConfidence), 0.0, 1.0, 0.0);
|
||||
output.depth = saturate(travel / max(farDistance, 0.001));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ struct SceneOut
|
|||
float4 colorTravel : SV_Target0;
|
||||
float4 metadata : SV_Target1;
|
||||
float4 control : SV_Target2;
|
||||
float4 reservoirGuide : SV_Target3;
|
||||
float depth : SV_Depth;
|
||||
};
|
||||
|
||||
|
|
@ -176,6 +177,7 @@ SceneOut D3D12TemporalGaussianPS(TemporalGaussianVertexOut input)
|
|||
output.colorTravel = float4(gaussian.colorOpacity.rgb * opacity, min(travel, farDistance + 1.0));
|
||||
output.metadata = float4(FIELD_ID_TEMPORAL_GAUSSIAN_BASE + gaussian.previousCenterFieldId.w, normal);
|
||||
output.control = float4(opacity, saturate(gaussian.centerHistoryWeight.w), saturate(gaussian.shapePad.x / 8.0), 0.0);
|
||||
output.reservoirGuide = float4(saturate(gaussian.velocityConfidence.w), 0.0, 1.0, 0.0);
|
||||
output.depth = saturate(travel / max(farDistance, 0.001));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,3 +163,4 @@
|
|||
{"timestamp":"2026-05-19T18:24:00+01:00","topic":"fractal-probe-reservoir-samples","lesson":"Fractal SDF/detail reservoir candidates now have a typed probe sample: domain key, node key, local center, bound radius, target contribution, source PDF, material delta, and payload handle. `FractalProbeReuseValidator` rejects unknown domains, sibling-domain reuse, invalid bounds, and excessive local shift. This starts the GRIS-style domain-shift boundary; renderer inputs for camera motion, disocclusion, material compatibility, and visibility still need to be wired before reuse is complete.","files":["src/Aquarium.Engine.Fractal/Lod/FractalProbeSample.cs","tests/Aquarium.Engine.Fractal.Tests/FractalProbeSampleTests.cs","docs/temporal-spatial-evidence-reservoir.md","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"continued Perfect Machine work after connecting fractal contribution updates to reservoir candidates"}
|
||||
{"timestamp":"2026-05-19T18:46:00+01:00","topic":"taa-reservoir-guide-lane","lesson":"SDF surfaces now publish `reservoirConfidence`; the SDF proxy writes it to current scene-control.w, and D3D12Post folds that value into history validation with debug mode 12 showing reservoir confidence, temporal detail, and history weight. This is the first cache/reservoir signal woven into TAA buffers. History-control.w still owns history age, so previous-frame reservoir confidence/sample age/invalidation reason require an expanded guide layout before full ReSTIR-style TAA integration.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl"],"source":"user explicitly asked to weave the cache into TAA buffers"}
|
||||
{"timestamp":"2026-05-19T19:22:00+01:00","topic":"perfect-machine-waterfall-architecture","lesson":"The Perfect Machine architecture is now mapped before further implementation. The design authority is `docs/perfect-machine-architecture.md`: authored domains and sensor inputs lower into evidence candidates, target evaluation, ReSTIR/GRIS reservoirs, heuristic occupancy graph updates, residency/page scheduling, 2D/3D/projected SDF splat packets, and TAA guide buffers. The public article `perfect-machine-fractal-reservoir-architecture.md` defends the architecture in Void's interview-thesis voice with research footnotes.","files":["docs/perfect-machine-architecture.md","E:/Projects/gamecult-site/GameCult/Blog/perfect-machine-fractal-reservoir-architecture.md","state/map.yaml","state/memory.json"],"source":"user requested a waterfall design pass and public job-interview style architecture article before more implementation"}
|
||||
{"timestamp":"2026-05-19T20:10:00+01:00","topic":"explicit-reservoir-guide-targets","lesson":"Phase B of the Perfect Machine architecture is implemented: the renderer now owns explicit current and history reservoir guide targets instead of packing previous reservoir validity into scene-control/history-control. Guide schema is x=reservoir confidence, y=sample age, z=domain validity, w=invalidation code. SDF and temporal Gaussian passes write the current guide; D3D12Post validates against current/previous guide data and persists the next guide while history-control.w remains pixel history age.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12TemporalGaussian.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","docs/perfect-machine-architecture.md","docs/temporal-spatial-evidence-reservoir.md"],"source":"Perfect Machine marching orders after architecture note became the design authority"}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
"Zyphos passes cube-tile domain metadata through height brush packets and binds those packets into the SDF pass. The planet shader may use authored brush packets for post-hit material/detail evaluation; traced geometry must wait for selected-cut/resident packet policy so SDF distance loops do not evaluate every brush at every step.",
|
||||
"Zyphos traced planet geometry may sample only a hard-budgeted top-influence subset of authored fractal brush packets in `sdfDistance`; the current proven budget is four brushes after sorting selected packets by abs(amplitude)*max(radius). A 12-brush distance loop was tested and rejected because it pushed the live frame to about 33 ms; the four-brush loop returns the live view to about 16.4 ms while full packet richness remains available to post-hit material/detail.",
|
||||
"Temporal resolve has a cache-facing detail lane: SdfSurface.temporalDetail writes through scene-control.z into history-control.z, and D3D12Post reduces history confidence when current and previous temporal detail disagree. Use this lane for stochastic fractal/cache stability signals, not as geometry authority.",
|
||||
"Temporal resolve now has a first reservoir guide lane: SdfSurface.reservoirConfidence writes through current scene-control.w and D3D12Post multiplies history validation by that current confidence. History-control.w still owns history age, so previous-frame reservoir validity/sample age/invalidation reason need an expanded guide layout before this can be called full ReSTIR-style TAA integration.",
|
||||
"Temporal resolve now has explicit reservoir guide targets. SDF and temporal Gaussian passes write a current scene reservoir guide MRT and D3D12Post reads/writes ping-ponged history reservoir guide targets with x=confidence, y=sample age, z=domain validity, w=invalidation code. History-control.w still owns pixel history age; do not pack reservoir history back into scene-control folklore.",
|
||||
"FractalContributionCache is the live cache loop: each frame builds a resource plan from current summaries and cached states, stochastically observes only budgeted update nodes, stores mean/variance/confidence/sample age through FractalContributionEstimator, frames scheduled updates as weighted ResampledImportanceReservoir candidates, and lets backend packet compilation stay cached by selected-cut key. It is a candidate source, not the whole temporal/spatial reuse pass. Do not replace this with a static plan cache that stops learning after the first camera bucket.",
|
||||
"FractalProbeSample is the typed reservoir sample shape for fractal SDF/detail reuse: domain key, node key, local center, bound radius, target contribution, source PDF, material delta, and payload handle. Reuse must pass domain lineage and local-shift validation now, and later camera motion, disocclusion, material compatibility, and visibility validation before it is allowed into temporal/spatial reuse.",
|
||||
"Zyphos camera distance limits belong to the selected spatial domain, not one global planetary clamp. Leaf/pebble domains must be able to zoom below whole-body distances, and the parent star must be a visible SDF body when it is also the primary light source.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue