Add bounded CPU reference for temporal resolve

This commit is contained in:
Emil
2026-09-24 02:57:25 +03:00
parent 1e247e60e9
commit 3a4a262750
4 changed files with 350 additions and 1 deletions
@@ -0,0 +1,45 @@
#pragma once
#include <array>
#include <cstdint>
#include <vector>
namespace faset::render {
// CPU-only 1:1 oracle for the temporal resolve shader. Color is already
// display-referred; motion is current-minus-previous normalized scene UV.
// The renderer does not call this per-pixel path in production.
struct TemporalReferencePixel {
std::array<float, 4> color{0, 0, 0, 1};
float depth{1};
std::array<float, 2> motion{};
float previous_depth{1};
bool motion_valid{};
float reactive{};
};
struct TemporalReferenceFrame {
std::uint32_t width{}, height{};
std::vector<TemporalReferencePixel> pixels;
};
struct TemporalReferenceHistory {
std::uint32_t width{}, height{};
std::vector<std::array<float, 4>> color;
std::vector<float> depth;
};
struct TemporalReferenceResult {
TemporalReferenceHistory history;
std::vector<std::uint8_t> accepted;
std::uint32_t accepted_count{};
};
// A null previous history is the first-frame/cut fallback. Extents must agree
// when history is supplied; reset it instead of reprojecting stale dimensions.
// Input is bounded to four million pixels so synthetic tests cannot consume
// unbounded memory. Invalid motion rejects history for that pixel.
TemporalReferenceResult temporal_reference_resolve(
const TemporalReferenceFrame& current,
const TemporalReferenceHistory* previous = nullptr);
} // namespace faset::render