feat: RenderGraph 帧历史资源(ReadHistory)+ TemporalDiff 验证 pass
- PassBuilder::ReadHistory:读上一帧槽位 ((slot-1+F) mod F) 的物理镜像, TAA/运动模糊等时域效果的前置能力,RG 最后一个已知边界补齐 - 历史读不建拓扑边(跨帧依赖由同队列提交序保证)、不入本帧状态链、 不改生命周期;剔除照常参与(生产者存活判定) - 历史 barrier:首帧走 first(old=Undefined),之后走 steady 且 src=ALL_COMMANDS|MEMORY_WRITE 显式闭合跨帧可用性+可见性; 有历史读的资源,常规 entry steady 的 src 同样升级(历史读打破了 同槽位 fence 全等保前提) - TemporalDiff 调试 pass:|上一帧−当前帧|×增益,静止=黑/运动边缘发光 即链路正确;Tonemap binding2 经 push 开关切调试视图 - 编译零错误、validation 零警告、8 秒冒烟通过(9 pass 全活跃)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#version 450
|
||||
|
||||
// TemporalDiff:帧历史链路调试视图。
|
||||
// 输出 |上一帧 HDR − 当前帧 HDR| × 增益:
|
||||
// - 静止画面应接近纯黑(两帧内容一致)
|
||||
// - 运动的实体边缘发光(时域差异可见)
|
||||
// - 全屏噪声 / 错位残影 = 帧历史 barrier 或槽位镜像绑定错误
|
||||
// 这是 RenderGraph 帧历史资源(ReadHistory)的验证消费端。
|
||||
|
||||
layout(location = 0) in vec2 fragUV;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D prevImage; // 帧历史(上一帧槽位镜像)
|
||||
layout(set = 0, binding = 1) uniform sampler2D currImage; // 当前帧
|
||||
|
||||
// 全屏 pass 通用 push(16B,程序级统一声明,VUID-08878)
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float exposure; // 与其它全屏 pass 布局一致(本 pass 不用)
|
||||
float gain; // 差异增益
|
||||
float param1;
|
||||
float param2;
|
||||
} pc;
|
||||
|
||||
void main() {
|
||||
vec3 prev = texture(prevImage, fragUV).rgb;
|
||||
vec3 curr = texture(currImage, fragUV).rgb;
|
||||
outColor = vec4(abs(prev - curr) * pc.gain, 1.0);
|
||||
}
|
||||
@@ -10,13 +10,14 @@ layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D hdrImage;
|
||||
layout(set = 0, binding = 1) uniform sampler2D bloomImage;
|
||||
layout(set = 0, binding = 2) uniform sampler2D temporalDiffImage; // 帧历史差异(调试视图)
|
||||
|
||||
// 全屏 pass 通用 push(16B,程序级统一声明,VUID-08878)
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float exposure; // 曝光系数
|
||||
float aces; // >0.5 启用 ACES 曲线,否则纯 gamma
|
||||
float bloomStrength; // bloom 叠加强度(0 = 关闭)
|
||||
float _pad0;
|
||||
float debugView; // >0.5 显示帧历史差异视图(TemporalDiff)
|
||||
} pc;
|
||||
|
||||
vec3 acesFilm(vec3 x) {
|
||||
@@ -24,6 +25,13 @@ vec3 acesFilm(vec3 x) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
// 调试视图:帧历史差异(静止=黑,运动边缘发光)
|
||||
if (pc.debugView > 0.5) {
|
||||
vec3 d = clamp(texture(temporalDiffImage, fragUV).rgb, 0.0, 1.0);
|
||||
outColor = vec4(pow(d, vec3(1.0 / 2.2)), 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// bloom 在 HDR 域叠加(半分辨率模糊图线性采样上采样)
|
||||
vec4 hdrTex = texture(hdrImage, fragUV);
|
||||
vec3 hdr = hdrTex.rgb + texture(bloomImage, fragUV).rgb * pc.bloomStrength;
|
||||
|
||||
Reference in New Issue
Block a user