feat: replace scatter-based accumulation with gather-based shaders
This commit is contained in:
1 parent
e951b05d6f
commit
c447f08a6d
5 files changed
+280
-251
No files matched your search
@@ -39,11 +39,11 @@ set(SHADER_SOURCES
|
||||
shaders/align_lk.comp
|
||||
shaders/raw_structure_tensor.comp
|
||||
shaders/robustness_raw.comp
|
||||
shaders/green_scatter_raw.comp
|
||||
shaders/green_gather_raw.comp
|
||||
shaders/reference_preprocess_raw.comp
|
||||
shaders/reference_prior_raw.comp
|
||||
shaders/normalize_green_hr.comp
|
||||
shaders/color_scatter_raw.comp
|
||||
shaders/color_gather_raw.comp
|
||||
shaders/normalize_color_hr.comp
|
||||
shaders/yuv_to_rgba.comp
|
||||
)
|
||||
|
||||
+74
-54
@@ -161,64 +161,88 @@ float sampleLocalTileWeight(ivec2 planePos) {
|
||||
return clamp(localTileMask.weights[ty * tilesX + tx], 0.0, 1.0);
|
||||
}
|
||||
|
||||
void processPlane(ivec2 samplePlane, uint planeIndex) {
|
||||
void processPlaneGather(ivec2 outPos, uint planeIndex) {
|
||||
ivec2 sampleOffset = getBayerOffset(int(pc.cfaPattern), int(planeIndex));
|
||||
if (samplePlane.x < 0 || samplePlane.y < 0 ||
|
||||
samplePlane.x >= int(pc.planeWidth) || samplePlane.y >= int(pc.planeHeight)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ivec2 samplePos = sampleOffset + samplePlane * 2;
|
||||
if (samplePos.x < 0 || samplePos.y < 0 ||
|
||||
samplePos.x >= int(pc.sensorWidth) || samplePos.y >= int(pc.sensorHeight)) {
|
||||
return;
|
||||
}
|
||||
// 1. Map outPos to the reference plane coordinate:
|
||||
vec2 refPlanePos = outputToSourcePlaneCenter(vec2(outPos), sampleOffset);
|
||||
|
||||
int lscIdx = -1;
|
||||
if (!sampleMatchesPlane(samplePos, planeIndex, lscIdx)) return;
|
||||
|
||||
vec2 samplePlanePos = vec2(samplePlane);
|
||||
vec2 flow = (pc.isFirstFrame == 0u) ? sampleFlow(samplePlanePos) : vec2(0.0);
|
||||
vec2 refPlanePos = samplePlanePos - flow;
|
||||
vec2 outCenter = sourceToOutputPlaneCenter(refPlanePos, sampleOffset);
|
||||
ivec2 base = ivec2(floor(outCenter));
|
||||
|
||||
float raw = texelFetch(inputRawSampler, samplePos, 0).r;
|
||||
int bayerIndex = getBayerIndex(int(pc.cfaPattern), samplePos);
|
||||
float val = max(0.0, raw * 65535.0 - pc.blackLevel[bayerIndex]);
|
||||
vec2 lscUV = (vec2(samplePos) + 0.5) / vec2(pc.sensorWidth, pc.sensorHeight);
|
||||
vec4 lscGains = texture(uLensShadingMap, lscUV);
|
||||
float lscGain = (lscIdx == 0) ? lscGains.r : lscGains.a;
|
||||
val = (val * lscGain) / 65535.0;
|
||||
float highlightSuppression = 1.0 - 0.55 * smoothstep(0.78, 0.98, val);
|
||||
|
||||
int rX = clamp(samplePos.x / 2, 0, int(pc.planeWidth) - 1);
|
||||
int rY = clamp(samplePos.y / 2, 0, int(pc.planeHeight) - 1);
|
||||
float pInlier = 1.0;
|
||||
float flowVar = 0.03;
|
||||
// 2. Sample the flow at refPlanePos:
|
||||
vec2 flow = vec2(0.0);
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
uint confidenceIdx = rY * int(pc.planeWidth) + rX;
|
||||
pInlier = outRobustness.data[confidenceIdx] * highlightSuppression;
|
||||
flowVar = flowVarianceBuffer.data[confidenceIdx];
|
||||
pInlier *= sampleLocalTileWeight(ivec2(rX, rY));
|
||||
flow = sampleFlow(refPlanePos);
|
||||
}
|
||||
|
||||
vec2 planeRef = clamp(refPlanePos, vec2(0.0), vec2(float(pc.planeWidth - 1u), float(pc.planeHeight - 1u)));
|
||||
ivec2 planeIdx = ivec2(round(planeRef));
|
||||
vec4 kParams = kernelParams.data[planeIdx.y * int(pc.planeWidth) + planeIdx.x];
|
||||
vec3 OmegaInv = getKernelMatrix(kParams);
|
||||
// 3. Target plane position:
|
||||
vec2 targetPlanePos = refPlanePos + flow;
|
||||
|
||||
for (int oy = -1; oy <= 2; ++oy) {
|
||||
for (int ox = -1; ox <= 2; ++ox) {
|
||||
ivec2 outPos = base + ivec2(ox, oy);
|
||||
if (outPos.x < int(pc.tileX) || outPos.y < int(pc.tileY) ||
|
||||
outPos.x >= int(pc.tileX + pc.tileW) || outPos.y >= int(pc.tileY + pc.tileH) ||
|
||||
outPos.x < 0 || outPos.y < 0) continue;
|
||||
// 4. Neighborhood search in the target plane:
|
||||
ivec2 targetPlaneCenter = ivec2(round(targetPlanePos));
|
||||
|
||||
for (int oy = -2; oy <= 2; ++oy) {
|
||||
for (int ox = -2; ox <= 2; ++ox) {
|
||||
ivec2 targetPlaneNeighbor = targetPlaneCenter + ivec2(ox, oy);
|
||||
|
||||
// Boundary checks for the target plane coordinate
|
||||
if (targetPlaneNeighbor.x < 0 || targetPlaneNeighbor.y < 0 ||
|
||||
targetPlaneNeighbor.x >= int(pc.planeWidth) || targetPlaneNeighbor.y >= int(pc.planeHeight)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Target sensor position:
|
||||
ivec2 samplePos = sampleOffset + targetPlaneNeighbor * 2;
|
||||
if (samplePos.x < 0 || samplePos.y < 0 ||
|
||||
samplePos.x >= int(pc.sensorWidth) || samplePos.y >= int(pc.sensorHeight)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Verify if this sensor pixel matches the requested plane channel
|
||||
int lscIdx = -1;
|
||||
if (!sampleMatchesPlane(samplePos, planeIndex, lscIdx)) continue;
|
||||
|
||||
// Fetch target raw value and compute normalized value
|
||||
float raw = texelFetch(inputRawSampler, samplePos, 0).r;
|
||||
int bayerIndex = getBayerIndex(int(pc.cfaPattern), samplePos);
|
||||
float val = max(0.0, raw * 65535.0 - pc.blackLevel[bayerIndex]);
|
||||
|
||||
// Lens Shading correction
|
||||
vec2 lscUV = (vec2(samplePos) + 0.5) / vec2(pc.sensorWidth, pc.sensorHeight);
|
||||
vec4 lscGains = texture(uLensShadingMap, lscUV);
|
||||
float lscGain = (lscIdx == 0) ? lscGains.r : lscGains.a;
|
||||
val = (val * lscGain) / 65535.0;
|
||||
float highlightSuppression = 1.0 - 0.55 * smoothstep(0.78, 0.98, val);
|
||||
|
||||
// Robustness and flow variance lookups at targetPlaneNeighbor
|
||||
int rX = clamp(targetPlaneNeighbor.x, 0, int(pc.planeWidth) - 1);
|
||||
int rY = clamp(targetPlaneNeighbor.y, 0, int(pc.planeHeight) - 1);
|
||||
float pInlier = 1.0;
|
||||
float flowVar = 0.03;
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
uint confidenceIdx = uint(rY) * pc.planeWidth + uint(rX);
|
||||
pInlier = outRobustness.data[confidenceIdx] * highlightSuppression;
|
||||
flowVar = flowVarianceBuffer.data[confidenceIdx];
|
||||
pInlier *= sampleLocalTileWeight(ivec2(rX, rY));
|
||||
}
|
||||
|
||||
// Target pixel's aligned reference position:
|
||||
vec2 refPos = vec2(targetPlaneNeighbor) - flow;
|
||||
|
||||
// Kernel matrix (OmegaInv) lookup at refPos:
|
||||
vec2 kernelPlanePos = clamp(refPos, vec2(0.0), vec2(float(pc.planeWidth - 1u), float(pc.planeHeight - 1u)));
|
||||
ivec2 planeIdx = ivec2(round(kernelPlanePos));
|
||||
vec4 kParams = kernelParams.data[planeIdx.y * int(pc.planeWidth) + planeIdx.x];
|
||||
vec3 OmegaInv = getKernelMatrix(kParams);
|
||||
|
||||
// Output center of target pixel on HR plane:
|
||||
vec2 outCenter = sourceToOutputPlaneCenter(refPos, sampleOffset);
|
||||
|
||||
// Distance in HR plane space:
|
||||
vec2 d_hr = vec2(outPos) - outCenter;
|
||||
float reconWeight = cubicWeight(d_hr.x) * cubicWeight(d_hr.y);
|
||||
if (reconWeight <= 0.0) continue;
|
||||
vec2 d = outputToSourcePlaneCenter(vec2(outPos), sampleOffset) - refPlanePos;
|
||||
|
||||
// Mahalanobis distance calculation:
|
||||
vec2 d = outputToSourcePlaneCenter(vec2(outPos), sampleOffset) - refPos;
|
||||
float mahalanobis = OmegaInv.x * d.x * d.x + 2.0 * OmegaInv.y * d.x * d.y + OmegaInv.z * d.y * d.y;
|
||||
float effectiveSigma2 = 1.0 + 4.0 * flowVar;
|
||||
float geometricLikelihood =
|
||||
@@ -248,11 +272,7 @@ void main() {
|
||||
uint localY = gl_GlobalInvocationID.y;
|
||||
if (localX >= pc.tileW || localY >= pc.tileH) return;
|
||||
|
||||
ivec2 sourceStart = ivec2(int(pc.tileX), int(pc.tileY));
|
||||
if (pc.scale > 1.001) {
|
||||
sourceStart = ivec2(floor(vec2(float(pc.tileX), float(pc.tileY)) / pc.scale)) - ivec2(2);
|
||||
}
|
||||
ivec2 samplePlane = sourceStart + ivec2(int(localX), int(localY));
|
||||
processPlane(samplePlane, 0u);
|
||||
processPlane(samplePlane, 3u);
|
||||
ivec2 outPos = ivec2(int(pc.tileX + localX), int(pc.tileY + localY));
|
||||
processPlaneGather(outPos, 0u);
|
||||
processPlaneGather(outPos, 3u);
|
||||
}
|
||||
+81
-73
@@ -172,36 +172,97 @@ float sampleLocalTileWeight(ivec2 planePos) {
|
||||
return clamp(localTileMask.weights[ty * tilesX + tx], 0.0, 1.0);
|
||||
}
|
||||
|
||||
void splatSample(int phaseIndex, ivec2 planeOffset, vec2 outCenter,
|
||||
vec2 refPos, float val, float pInlier, float flowVar) {
|
||||
vec2 kernelPlanePos = clamp(refPos, vec2(0.0), vec2(float(pc.planeWidth - 1u), float(pc.planeHeight - 1u)));
|
||||
ivec2 planeIdx = ivec2(round(kernelPlanePos));
|
||||
vec4 kParams = kernelParams.data[planeIdx.y * int(pc.planeWidth) + planeIdx.x];
|
||||
vec3 OmegaInv = getKernelMatrix(kParams);
|
||||
void processGreenPlaneGather(ivec2 outPos, int planeIndex) {
|
||||
int familyIndex = planeIndex - 1; // 1 -> 0 (Gr), 2 -> 1 (Gb)
|
||||
ivec2 sampleOffset = getBayerOffset(int(pc.cfaPattern), planeIndex);
|
||||
|
||||
ivec2 base = ivec2(floor(outCenter));
|
||||
for (int oy = -1; oy <= 2; ++oy) {
|
||||
for (int ox = -1; ox <= 2; ++ox) {
|
||||
ivec2 outPos = base + ivec2(ox, oy);
|
||||
if (outPos.x < int(pc.tileX) || outPos.y < int(pc.tileY) ||
|
||||
outPos.x >= int(pc.tileX + pc.tileW) ||
|
||||
outPos.y >= int(pc.tileY + pc.tileH) ||
|
||||
outPos.x < 0 || outPos.y < 0) {
|
||||
// 1. Map outPos to the reference plane coordinate:
|
||||
vec2 refPlanePos = outputToSourcePlaneCenter(vec2(outPos), sampleOffset);
|
||||
|
||||
// 2. Sample the flow at refPlanePos:
|
||||
vec2 flow = vec2(0.0);
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
flow = sampleFlow(refPlanePos);
|
||||
}
|
||||
|
||||
// 3. Target plane position:
|
||||
vec2 targetPlanePos = refPlanePos + flow;
|
||||
|
||||
// 4. Neighborhood search in the target plane:
|
||||
ivec2 targetPlaneCenter = ivec2(round(targetPlanePos));
|
||||
|
||||
for (int oy = -2; oy <= 2; ++oy) {
|
||||
for (int ox = -2; ox <= 2; ++ox) {
|
||||
ivec2 targetPlaneNeighbor = targetPlaneCenter + ivec2(ox, oy);
|
||||
|
||||
// Boundary checks for the target plane coordinate
|
||||
if (targetPlaneNeighbor.x < 0 || targetPlaneNeighbor.y < 0 ||
|
||||
targetPlaneNeighbor.x >= int(pc.planeWidth) || targetPlaneNeighbor.y >= int(pc.planeHeight)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Target sensor position:
|
||||
ivec2 samplePos = sampleOffset + targetPlaneNeighbor * 2;
|
||||
if (samplePos.x < 0 || samplePos.y < 0 ||
|
||||
samplePos.x >= int(pc.sensorWidth) || samplePos.y >= int(pc.sensorHeight)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Verify if this sensor pixel matches the requested plane channel
|
||||
int lscIdx = -1;
|
||||
int family = getGreenFamily(int(pc.cfaPattern), samplePos, lscIdx);
|
||||
if (family < 0 || family + 1 != planeIndex) continue;
|
||||
|
||||
// Fetch target raw value and compute normalized value
|
||||
float raw = texelFetch(inputRawSampler, samplePos, 0).r;
|
||||
int bayerIndex = getBayerIndex(int(pc.cfaPattern), samplePos);
|
||||
float val = max(0.0, raw * 65535.0 - pc.blackLevel[bayerIndex]);
|
||||
|
||||
// Lens Shading correction
|
||||
vec2 lscUV = (vec2(samplePos) + 0.5) / vec2(pc.sensorWidth, pc.sensorHeight);
|
||||
vec4 lscGains = texture(uLensShadingMap, lscUV);
|
||||
float lscGain = (lscIdx == 1) ? lscGains.g : lscGains.b;
|
||||
val = (val * lscGain) / 65535.0;
|
||||
float highlightSuppression = 1.0 - 0.70 * smoothstep(0.78, 0.98, val);
|
||||
|
||||
// Robustness and flow variance lookups at targetPlaneNeighbor
|
||||
int rX = clamp(targetPlaneNeighbor.x, 0, int(pc.planeWidth) - 1);
|
||||
int rY = clamp(targetPlaneNeighbor.y, 0, int(pc.planeHeight) - 1);
|
||||
float pInlier = 1.0;
|
||||
float flowVar = 0.03;
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
uint confidenceIdx = uint(rY) * pc.planeWidth + uint(rX);
|
||||
pInlier = outRobustness.data[confidenceIdx];
|
||||
flowVar = flowVarianceBuffer.data[confidenceIdx];
|
||||
pInlier *= sampleLocalTileWeight(ivec2(rX, rY));
|
||||
}
|
||||
|
||||
// Target pixel's aligned reference position:
|
||||
vec2 refPos = vec2(targetPlaneNeighbor) - flow;
|
||||
|
||||
// Kernel matrix (OmegaInv) lookup at refPos:
|
||||
vec2 kernelPlanePos = clamp(refPos, vec2(0.0), vec2(float(pc.planeWidth - 1u), float(pc.planeHeight - 1u)));
|
||||
ivec2 planeIdx = ivec2(round(kernelPlanePos));
|
||||
vec4 kParams = kernelParams.data[planeIdx.y * int(pc.planeWidth) + planeIdx.x];
|
||||
vec3 OmegaInv = getKernelMatrix(kParams);
|
||||
|
||||
// Output center of target pixel on HR plane:
|
||||
vec2 outCenter = sourceToOutputPlaneCenter(refPos, sampleOffset);
|
||||
|
||||
// Distance in HR plane space:
|
||||
vec2 d_hr = vec2(outPos) - outCenter;
|
||||
float reconWeight = cubicWeight(d_hr.x) * cubicWeight(d_hr.y);
|
||||
if (reconWeight <= 0.0) continue;
|
||||
|
||||
vec2 d = outputToSourcePlaneCenter(vec2(outPos), planeOffset) - refPos;
|
||||
// Mahalanobis distance calculation:
|
||||
vec2 d = outputToSourcePlaneCenter(vec2(outPos), sampleOffset) - refPos;
|
||||
float mahalanobis = OmegaInv.x * d.x * d.x +
|
||||
(OmegaInv.y * d.x * d.y) * 2.0 +
|
||||
OmegaInv.z * d.y * d.y;
|
||||
float effectiveSigma2 = 1.0 + 4.0 * flowVar;
|
||||
float geometricLikelihood =
|
||||
exp(-0.5 * max(mahalanobis, 0.0) / effectiveSigma2);
|
||||
float inlierPosterior = clamp(pInlier * pc.frameWeight, 0.0, 1.0);
|
||||
float inlierPosterior = clamp(pInlier * pc.frameWeight * highlightSuppression, 0.0, 1.0);
|
||||
float w = inlierDecisionGate(inlierPosterior) *
|
||||
geometricLikelihood * reconWeight *
|
||||
sensorPrecisionWeight(val);
|
||||
@@ -213,7 +274,7 @@ void splatSample(int phaseIndex, ivec2 planeOffset, vec2 outCenter,
|
||||
uint localY = uint(outPos.y - int(pc.tileY));
|
||||
uint idx = localY * pc.bufferStride + localX;
|
||||
|
||||
if (phaseIndex == 0) {
|
||||
if (familyIndex == 0) {
|
||||
atomicAdd(greenPhase0.data[idx].x, sumFixed);
|
||||
atomicAdd(greenPhase0.data[idx].y, weightFixed);
|
||||
} else {
|
||||
@@ -224,65 +285,12 @@ void splatSample(int phaseIndex, ivec2 planeOffset, vec2 outCenter,
|
||||
}
|
||||
}
|
||||
|
||||
void processGreenPlane(ivec2 samplePlane, int planeIndex) {
|
||||
ivec2 sampleOffset = getBayerOffset(int(pc.cfaPattern), planeIndex);
|
||||
if (samplePlane.x < 0 || samplePlane.y < 0 ||
|
||||
samplePlane.x >= int(pc.planeWidth) || samplePlane.y >= int(pc.planeHeight)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ivec2 samplePos = sampleOffset + samplePlane * 2;
|
||||
if (samplePos.x < 0 || samplePos.y < 0 ||
|
||||
samplePos.x >= int(pc.sensorWidth) || samplePos.y >= int(pc.sensorHeight)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int lscIdx = -1;
|
||||
int family = getGreenFamily(int(pc.cfaPattern), samplePos, lscIdx);
|
||||
if (family < 0 || family + 1 != planeIndex) return;
|
||||
|
||||
vec2 planePos = vec2(samplePlane);
|
||||
vec2 flow = vec2(0.0);
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
flow = sampleFlow(planePos);
|
||||
}
|
||||
vec2 refPos = planePos - flow;
|
||||
vec2 outCenter = sourceToOutputPlaneCenter(refPos, sampleOffset);
|
||||
|
||||
float raw = texelFetch(inputRawSampler, samplePos, 0).r;
|
||||
int bayerIndex = getBayerIndex(int(pc.cfaPattern), samplePos);
|
||||
float val = max(0.0, raw * 65535.0 - pc.blackLevel[bayerIndex]);
|
||||
|
||||
vec2 lscUV = (vec2(samplePos) + 0.5) / vec2(pc.sensorWidth, pc.sensorHeight);
|
||||
vec4 lscGains = texture(uLensShadingMap, lscUV);
|
||||
float lscGain = (lscIdx == 1) ? lscGains.g : lscGains.b;
|
||||
val = (val * lscGain) / 65535.0;
|
||||
float highlightSuppression = 1.0 - 0.70 * smoothstep(0.78, 0.98, val);
|
||||
|
||||
int rX = clamp(samplePos.x / 2, 0, int(pc.planeWidth) - 1);
|
||||
int rY = clamp(samplePos.y / 2, 0, int(pc.planeHeight) - 1);
|
||||
float pInlier = 1.0;
|
||||
float flowVar = 0.03;
|
||||
if (pc.isFirstFrame == 0u) {
|
||||
uint confidenceIdx = rY * int(pc.planeWidth) + rX;
|
||||
pInlier = outRobustness.data[confidenceIdx];
|
||||
flowVar = flowVarianceBuffer.data[confidenceIdx];
|
||||
pInlier *= sampleLocalTileWeight(ivec2(rX, rY));
|
||||
}
|
||||
splatSample(family, sampleOffset, outCenter, refPos, val,
|
||||
pInlier * highlightSuppression, flowVar);
|
||||
}
|
||||
|
||||
void main() {
|
||||
uint localX = gl_GlobalInvocationID.x;
|
||||
uint localY = gl_GlobalInvocationID.y;
|
||||
if (localX >= pc.tileW || localY >= pc.tileH) return;
|
||||
|
||||
ivec2 sourceStart = ivec2(int(pc.tileX), int(pc.tileY));
|
||||
if (pc.scale > 1.001) {
|
||||
sourceStart = ivec2(floor(vec2(float(pc.tileX), float(pc.tileY)) / pc.scale)) - ivec2(2);
|
||||
}
|
||||
ivec2 samplePlane = sourceStart + ivec2(int(localX), int(localY));
|
||||
processGreenPlane(samplePlane, 1);
|
||||
processGreenPlane(samplePlane, 2);
|
||||
ivec2 outPos = ivec2(int(pc.tileX + localX), int(pc.tileY + localY));
|
||||
processGreenPlaneGather(outPos, 1);
|
||||
processGreenPlaneGather(outPos, 2);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "vulkan_raw_stacker.h"
|
||||
#include "align_lk.comp.h"
|
||||
#include "common.h"
|
||||
#include "color_scatter_raw.comp.h"
|
||||
#include "green_scatter_raw.comp.h"
|
||||
#include "color_gather_raw.comp.h"
|
||||
#include "green_gather_raw.comp.h"
|
||||
#include "normalize_color_hr.comp.h"
|
||||
#include "normalize_green_hr.comp.h"
|
||||
#include "reference_preprocess_raw.comp.h"
|
||||
@@ -110,7 +110,7 @@ struct RawSuperResPerfStats {
|
||||
double tileAlignmentLkStage2Ms = 0.0;
|
||||
double tileAlignmentRegularize2Ms = 0.0;
|
||||
double tileRobustness2Ms = 0.0;
|
||||
double scatterMs = 0.0;
|
||||
double gatherMs = 0.0;
|
||||
double normalizeMs = 0.0;
|
||||
|
||||
double outputReadbackMs = 0.0;
|
||||
@@ -162,12 +162,12 @@ struct RawSuperResPerfStats {
|
||||
if (tilesProcessed > 0) {
|
||||
LOGI(
|
||||
"RawSuperResPerf tile-detail: clearOut=%.3f clearTile=%.3f "
|
||||
"maskUpload=%.3f refinedUpload=%.3f scatter=%.3f normalize=%.3f "
|
||||
"avgTile=%.3f avgScatterFrame=%.3f avgNonRefFramePrep=%.3f",
|
||||
"maskUpload=%.3f refinedUpload=%.3f gather=%.3f normalize=%.3f "
|
||||
"avgTile=%.3f avgGatherFrame=%.3f avgNonRefFramePrep=%.3f",
|
||||
outputClearMs, tileClearMs, localMaskUploadMs,
|
||||
tileRefinedStateUploadMs, scatterMs,
|
||||
tileRefinedStateUploadMs, gatherMs,
|
||||
normalizeMs, averageMillis(tileProcessingMs, tilesProcessed),
|
||||
averageMillis(scatterMs, tileScatterFrameInstances),
|
||||
averageMillis(gatherMs, tileScatterFrameInstances),
|
||||
averageMillis(tileRefinedStateUploadMs, tileAlignedFrameInstances));
|
||||
}
|
||||
}
|
||||
@@ -421,18 +421,18 @@ void VulkanRawStacker::initVulkanResources() {
|
||||
gInfo.usage =
|
||||
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
gInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
VK_CHECK(vkCreateBuffer(device, &gInfo, nullptr, &rbScatterAccumBuffers[c]));
|
||||
VK_CHECK(vkCreateBuffer(device, &gInfo, nullptr, &rbGatherAccumBuffers[c]));
|
||||
|
||||
VkMemoryRequirements gReqs;
|
||||
vkGetBufferMemoryRequirements(device, rbScatterAccumBuffers[c], &gReqs);
|
||||
vkGetBufferMemoryRequirements(device, rbGatherAccumBuffers[c], &gReqs);
|
||||
VkMemoryAllocateInfo gAlloc{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};
|
||||
gAlloc.allocationSize = gReqs.size;
|
||||
gAlloc.memoryTypeIndex = vm.findMemoryType(
|
||||
gReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK(
|
||||
vkAllocateMemory(device, &gAlloc, nullptr, &rbScatterAccumMemories[c]));
|
||||
vkBindBufferMemory(device, rbScatterAccumBuffers[c],
|
||||
rbScatterAccumMemories[c], 0);
|
||||
vkAllocateMemory(device, &gAlloc, nullptr, &rbGatherAccumMemories[c]));
|
||||
vkBindBufferMemory(device, rbGatherAccumBuffers[c],
|
||||
rbGatherAccumMemories[c], 0);
|
||||
}
|
||||
|
||||
VkDeviceSize priorBufferSize =
|
||||
@@ -498,13 +498,13 @@ void VulkanRawStacker::initVulkanResources() {
|
||||
&barrier, 0, nullptr);
|
||||
}
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
vkCmdFillBuffer(cb, rbScatterAccumBuffers[c], 0, greenAccumSize, 0);
|
||||
vkCmdFillBuffer(cb, rbGatherAccumBuffers[c], 0, greenAccumSize, 0);
|
||||
VkBufferMemoryBarrier barrier{};
|
||||
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
barrier.dstAccessMask =
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||
barrier.buffer = rbScatterAccumBuffers[c];
|
||||
barrier.buffer = rbGatherAccumBuffers[c];
|
||||
barrier.size = greenAccumSize;
|
||||
vkCmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 1,
|
||||
@@ -772,7 +772,7 @@ void VulkanRawStacker::createPipelines() {
|
||||
robustness_raw_comp_spv,
|
||||
robustness_raw_comp_spv_size);
|
||||
|
||||
// --- 4. Green HR Scatter Pipeline ---
|
||||
// --- 4. Green HR Gather Pipeline ---
|
||||
VkDescriptorSetLayoutBinding gsBindings[9] = {};
|
||||
gsBindings[0] = {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT, nullptr}; // Input RAW
|
||||
@@ -798,22 +798,22 @@ void VulkanRawStacker::createPipelines() {
|
||||
gsLayoutInfo.bindingCount = 9;
|
||||
gsLayoutInfo.pBindings = gsBindings;
|
||||
vkCreateDescriptorSetLayout(device, &gsLayoutInfo, nullptr,
|
||||
&greenScatterSetLayout);
|
||||
&greenGatherSetLayout);
|
||||
|
||||
VkPipelineLayoutCreateInfo gsPLInfo{
|
||||
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
|
||||
gsPLInfo.setLayoutCount = 1;
|
||||
gsPLInfo.pSetLayouts = &greenScatterSetLayout;
|
||||
gsPLInfo.pSetLayouts = &greenGatherSetLayout;
|
||||
gsPLInfo.pushConstantRangeCount = 1;
|
||||
gsPLInfo.pPushConstantRanges = &pushConstantRange;
|
||||
vkCreatePipelineLayout(device, &gsPLInfo, nullptr,
|
||||
&greenScatterPipelineLayout);
|
||||
&greenGatherPipelineLayout);
|
||||
|
||||
greenScatterPipeline = createComputePipeline(
|
||||
device, greenScatterPipelineLayout, green_scatter_raw_comp_spv,
|
||||
green_scatter_raw_comp_spv_size);
|
||||
greenGatherPipeline = createComputePipeline(
|
||||
device, greenGatherPipelineLayout, green_gather_raw_comp_spv,
|
||||
green_gather_raw_comp_spv_size);
|
||||
|
||||
// --- 5. Color Scatter Pipeline (R/B) ---
|
||||
// --- 5. Color Gather Pipeline (R/B) ---
|
||||
VkDescriptorSetLayoutBinding csBindings[9] = {};
|
||||
csBindings[0] = {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT, nullptr};
|
||||
@@ -839,20 +839,20 @@ void VulkanRawStacker::createPipelines() {
|
||||
csLayoutInfo.bindingCount = 9;
|
||||
csLayoutInfo.pBindings = csBindings;
|
||||
vkCreateDescriptorSetLayout(device, &csLayoutInfo, nullptr,
|
||||
&colorScatterSetLayout);
|
||||
&colorGatherSetLayout);
|
||||
|
||||
VkPipelineLayoutCreateInfo csPLInfo{
|
||||
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
|
||||
csPLInfo.setLayoutCount = 1;
|
||||
csPLInfo.pSetLayouts = &colorScatterSetLayout;
|
||||
csPLInfo.pSetLayouts = &colorGatherSetLayout;
|
||||
csPLInfo.pushConstantRangeCount = 1;
|
||||
csPLInfo.pPushConstantRanges = &pushConstantRange;
|
||||
vkCreatePipelineLayout(device, &csPLInfo, nullptr,
|
||||
&colorScatterPipelineLayout);
|
||||
&colorGatherPipelineLayout);
|
||||
|
||||
colorScatterPipeline = createComputePipeline(
|
||||
device, colorScatterPipelineLayout, color_scatter_raw_comp_spv,
|
||||
color_scatter_raw_comp_spv_size);
|
||||
colorGatherPipeline = createComputePipeline(
|
||||
device, colorGatherPipelineLayout, color_gather_raw_comp_spv,
|
||||
color_gather_raw_comp_spv_size);
|
||||
|
||||
// --- 6. Reference Normalize Pipeline ---
|
||||
VkDescriptorSetLayoutBinding rnBindings[3] = {};
|
||||
@@ -2711,11 +2711,11 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &robustnessSets[0]));
|
||||
VkDescriptorSet robustSet = robustnessSets[0];
|
||||
|
||||
allocInfo.pSetLayouts = &greenScatterSetLayout;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &greenScatterSet));
|
||||
allocInfo.pSetLayouts = &greenGatherSetLayout;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &greenGatherSet));
|
||||
|
||||
allocInfo.pSetLayouts = &colorScatterSetLayout;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &colorScatterSets[0]));
|
||||
allocInfo.pSetLayouts = &colorGatherSetLayout;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &colorGatherSets[0]));
|
||||
|
||||
allocInfo.pSetLayouts = &referenceNormalizeSetLayout;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &referenceNormalizeSet));
|
||||
@@ -2745,36 +2745,36 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
3);
|
||||
updateBufferDescriptorSet(device, robustSet, flowVarianceBuffer,
|
||||
VK_WHOLE_SIZE, 4);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, alignmentBuffer,
|
||||
updateBufferDescriptorSet(device, greenGatherSet, alignmentBuffer,
|
||||
VK_WHOLE_SIZE, 1);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, kernelBuffer,
|
||||
updateBufferDescriptorSet(device, greenGatherSet, kernelBuffer,
|
||||
VK_WHOLE_SIZE, 2);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, robustnessBuffer,
|
||||
updateBufferDescriptorSet(device, greenGatherSet, robustnessBuffer,
|
||||
VK_WHOLE_SIZE, 3);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, flowVarianceBuffer,
|
||||
updateBufferDescriptorSet(device, greenGatherSet, flowVarianceBuffer,
|
||||
VK_WHOLE_SIZE, 4);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, greenPhaseAccumBuffers[0],
|
||||
updateBufferDescriptorSet(device, greenGatherSet, greenPhaseAccumBuffers[0],
|
||||
VK_WHOLE_SIZE, 5);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, greenPhaseAccumBuffers[1],
|
||||
updateBufferDescriptorSet(device, greenGatherSet, greenPhaseAccumBuffers[1],
|
||||
VK_WHOLE_SIZE, 6);
|
||||
updateImageDescriptorSet(device, greenScatterSet, lscView, lscSampler, 7);
|
||||
updateBufferDescriptorSet(device, greenScatterSet, localTileMaskBuffer,
|
||||
updateImageDescriptorSet(device, greenGatherSet, lscView, lscSampler, 7);
|
||||
updateBufferDescriptorSet(device, greenGatherSet, localTileMaskBuffer,
|
||||
VK_WHOLE_SIZE, 8);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0], alignmentBuffer,
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0], alignmentBuffer,
|
||||
VK_WHOLE_SIZE, 1);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0], kernelBuffer,
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0], kernelBuffer,
|
||||
VK_WHOLE_SIZE, 2);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0], robustnessBuffer,
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0], robustnessBuffer,
|
||||
VK_WHOLE_SIZE, 3);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0],
|
||||
rbScatterAccumBuffers[0], VK_WHOLE_SIZE, 4);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0],
|
||||
rbScatterAccumBuffers[1], VK_WHOLE_SIZE, 5);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0], flowVarianceBuffer,
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0],
|
||||
rbGatherAccumBuffers[0], VK_WHOLE_SIZE, 4);
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0],
|
||||
rbGatherAccumBuffers[1], VK_WHOLE_SIZE, 5);
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0], flowVarianceBuffer,
|
||||
VK_WHOLE_SIZE, 6);
|
||||
updateImageDescriptorSet(device, colorScatterSets[0], lscView, lscSampler,
|
||||
updateImageDescriptorSet(device, colorGatherSets[0], lscView, lscSampler,
|
||||
7);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0], localTileMaskBuffer,
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0], localTileMaskBuffer,
|
||||
VK_WHOLE_SIZE, 8);
|
||||
updateBufferDescriptorSet(device, referenceNormalizeSet,
|
||||
normalizedReferenceBuffer, VK_WHOLE_SIZE, 1);
|
||||
@@ -3364,7 +3364,7 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
greenAccumBufferSize, 0);
|
||||
}
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
vkCmdFillBuffer(cb, rbScatterAccumBuffers[c], 0,
|
||||
vkCmdFillBuffer(cb, rbGatherAccumBuffers[c], 0,
|
||||
greenAccumBufferSize, 0);
|
||||
}
|
||||
VkMemoryBarrier memBarrier{VK_STRUCTURE_TYPE_MEMORY_BARRIER};
|
||||
@@ -3409,9 +3409,9 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
pc.frameWeight = isRef ? 1.0f : frameFusionWeights[i];
|
||||
|
||||
const auto localMaskUploadStart = PerfClock::now();
|
||||
updateBufferDescriptorSet(device, greenScatterSet,
|
||||
updateBufferDescriptorSet(device, greenGatherSet,
|
||||
frameMaskBuffers[i].buffer, VK_WHOLE_SIZE, 8);
|
||||
updateBufferDescriptorSet(device, colorScatterSets[0],
|
||||
updateBufferDescriptorSet(device, colorGatherSets[0],
|
||||
frameMaskBuffers[i].buffer, VK_WHOLE_SIZE, 8);
|
||||
perf.localMaskUploadMs += elapsedMillis(localMaskUploadStart);
|
||||
if (!kFastPath && !isRef &&
|
||||
@@ -3652,66 +3652,66 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
|
||||
// Accumulate this frame's contribution for this tile's 3 channels
|
||||
{
|
||||
const auto scatterStart = PerfClock::now();
|
||||
const auto gatherStart = PerfClock::now();
|
||||
VkCommandBuffer cb = vm.beginSingleTimeCommands();
|
||||
VkBufferMemoryBarrier preScatterBarriers[4]{};
|
||||
uint32_t preScatterBarrierCount = 0;
|
||||
VkBufferMemoryBarrier preGatherBarriers[4]{};
|
||||
uint32_t preGatherBarrierCount = 0;
|
||||
|
||||
preScatterBarriers[preScatterBarrierCount].sType =
|
||||
preGatherBarriers[preGatherBarrierCount].sType =
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
preScatterBarriers[preScatterBarrierCount].srcAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].srcAccessMask =
|
||||
VK_ACCESS_HOST_WRITE_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].dstAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].dstAccessMask =
|
||||
VK_ACCESS_SHADER_READ_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].buffer =
|
||||
preGatherBarriers[preGatherBarrierCount].buffer =
|
||||
frameMaskBuffers[i].buffer;
|
||||
preScatterBarriers[preScatterBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preScatterBarrierCount;
|
||||
preGatherBarriers[preGatherBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preGatherBarrierCount;
|
||||
|
||||
if (kFastPath ? !isRef : refinedCache != nullptr) {
|
||||
preScatterBarriers[preScatterBarrierCount].sType =
|
||||
preGatherBarriers[preGatherBarrierCount].sType =
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
preScatterBarriers[preScatterBarrierCount].srcAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].srcAccessMask =
|
||||
VK_ACCESS_HOST_WRITE_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].dstAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].dstAccessMask =
|
||||
VK_ACCESS_SHADER_READ_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].buffer = alignmentBuffer;
|
||||
preScatterBarriers[preScatterBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preScatterBarrierCount;
|
||||
preGatherBarriers[preGatherBarrierCount].buffer = alignmentBuffer;
|
||||
preGatherBarriers[preGatherBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preGatherBarrierCount;
|
||||
|
||||
preScatterBarriers[preScatterBarrierCount].sType =
|
||||
preGatherBarriers[preGatherBarrierCount].sType =
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
preScatterBarriers[preScatterBarrierCount].srcAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].srcAccessMask =
|
||||
VK_ACCESS_HOST_WRITE_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].dstAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].dstAccessMask =
|
||||
VK_ACCESS_SHADER_READ_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].buffer = robustnessBuffer;
|
||||
preScatterBarriers[preScatterBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preScatterBarrierCount;
|
||||
preGatherBarriers[preGatherBarrierCount].buffer = robustnessBuffer;
|
||||
preGatherBarriers[preGatherBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preGatherBarrierCount;
|
||||
|
||||
preScatterBarriers[preScatterBarrierCount].sType =
|
||||
preGatherBarriers[preGatherBarrierCount].sType =
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
preScatterBarriers[preScatterBarrierCount].srcAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].srcAccessMask =
|
||||
VK_ACCESS_HOST_WRITE_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].dstAccessMask =
|
||||
preGatherBarriers[preGatherBarrierCount].dstAccessMask =
|
||||
VK_ACCESS_SHADER_READ_BIT;
|
||||
preScatterBarriers[preScatterBarrierCount].buffer =
|
||||
preGatherBarriers[preGatherBarrierCount].buffer =
|
||||
flowVarianceBuffer;
|
||||
preScatterBarriers[preScatterBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preScatterBarrierCount;
|
||||
preGatherBarriers[preGatherBarrierCount].size = VK_WHOLE_SIZE;
|
||||
++preGatherBarrierCount;
|
||||
}
|
||||
vkCmdPipelineBarrier(cb, VK_PIPELINE_STAGE_HOST_BIT,
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0,
|
||||
nullptr, preScatterBarrierCount,
|
||||
preScatterBarriers, 0, nullptr);
|
||||
nullptr, preGatherBarrierCount,
|
||||
preGatherBarriers, 0, nullptr);
|
||||
|
||||
updateImageDescriptorSet(device, greenScatterSet,
|
||||
updateImageDescriptorSet(device, greenGatherSet,
|
||||
uploadedFrames[i].view, sampler, 0);
|
||||
vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
greenScatterPipeline);
|
||||
greenGatherPipeline);
|
||||
vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
greenScatterPipelineLayout, 0, 1,
|
||||
&greenScatterSet, 0, nullptr);
|
||||
greenGatherPipelineLayout, 0, 1,
|
||||
&greenGatherSet, 0, nullptr);
|
||||
|
||||
PlaneTileRange greenRange0 = computePlaneTileRange(
|
||||
frame.cfaPattern, 1, tileOriginX, tileOriginY, currentTileW,
|
||||
@@ -3742,7 +3742,7 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
pc.tileW = greenEndX - greenStartX;
|
||||
pc.tileH = greenEndY - greenStartY;
|
||||
|
||||
vkCmdPushConstants(cb, greenScatterPipelineLayout,
|
||||
vkCmdPushConstants(cb, greenGatherPipelineLayout,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(pc),
|
||||
&pc);
|
||||
vkCmdDispatch(cb, (pc.tileW + 15) / 16, (pc.tileH + 15) / 16, 1);
|
||||
@@ -3762,12 +3762,12 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
nullptr, 2, greenBarriers, 0, nullptr);
|
||||
|
||||
vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
colorScatterPipeline);
|
||||
updateImageDescriptorSet(device, colorScatterSets[0],
|
||||
colorGatherPipeline);
|
||||
updateImageDescriptorSet(device, colorGatherSets[0],
|
||||
uploadedFrames[i].view, sampler, 0);
|
||||
vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
colorScatterPipelineLayout, 0, 1,
|
||||
&colorScatterSets[0], 0, nullptr);
|
||||
colorGatherPipelineLayout, 0, 1,
|
||||
&colorGatherSets[0], 0, nullptr);
|
||||
|
||||
PlaneTileRange redRange = computePlaneTileRange(
|
||||
frame.cfaPattern, 0, tileOriginX, tileOriginY, currentTileW,
|
||||
@@ -3795,7 +3795,7 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
pc.tileY = colorStartY;
|
||||
pc.tileW = colorEndX - colorStartX;
|
||||
pc.tileH = colorEndY - colorStartY;
|
||||
vkCmdPushConstants(cb, colorScatterPipelineLayout,
|
||||
vkCmdPushConstants(cb, colorGatherPipelineLayout,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(pc),
|
||||
&pc);
|
||||
vkCmdDispatch(cb, (pc.tileW + 15) / 16, (pc.tileH + 15) / 16, 1);
|
||||
@@ -3806,7 +3806,7 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
colorBarriers[c].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||
colorBarriers[c].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
|
||||
colorBarriers[c].dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
colorBarriers[c].buffer = rbScatterAccumBuffers[c];
|
||||
colorBarriers[c].buffer = rbGatherAccumBuffers[c];
|
||||
colorBarriers[c].size = VK_WHOLE_SIZE;
|
||||
}
|
||||
vkCmdPipelineBarrier(cb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
@@ -3814,7 +3814,8 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
nullptr, 2, colorBarriers, 0, nullptr);
|
||||
|
||||
vm.endSingleTimeCommands(cb);
|
||||
perf.scatterMs += elapsedMillis(scatterStart);
|
||||
perf.gatherMs += elapsedMillis(gatherStart);
|
||||
++perf.tileScatterFrameInstances; // Keep stats count unchanged for simplicity
|
||||
}
|
||||
} // end for each frame
|
||||
|
||||
@@ -3951,7 +3952,7 @@ bool VulkanRawStacker::processStack(uint16_t *outBuffer, size_t bufferSize) {
|
||||
updateBufferDescriptorSet(device, colorNormalizeSets[colorIdx],
|
||||
fusedBayerBuffer, VK_WHOLE_SIZE, 0);
|
||||
updateBufferDescriptorSet(device, colorNormalizeSets[colorIdx],
|
||||
rbScatterAccumBuffers[colorIdx],
|
||||
rbGatherAccumBuffers[colorIdx],
|
||||
VK_WHOLE_SIZE, 1);
|
||||
updateBufferDescriptorSet(device, colorNormalizeSets[colorIdx],
|
||||
priorBayerBuffer, VK_WHOLE_SIZE, 2);
|
||||
@@ -4151,19 +4152,19 @@ void VulkanRawStacker::releaseVulkanResources() {
|
||||
if (robustnessPipeline)
|
||||
vkDestroyPipeline(device, robustnessPipeline, nullptr);
|
||||
|
||||
if (greenScatterSetLayout)
|
||||
vkDestroyDescriptorSetLayout(device, greenScatterSetLayout, nullptr);
|
||||
if (greenScatterPipelineLayout)
|
||||
vkDestroyPipelineLayout(device, greenScatterPipelineLayout, nullptr);
|
||||
if (greenScatterPipeline)
|
||||
vkDestroyPipeline(device, greenScatterPipeline, nullptr);
|
||||
if (greenGatherSetLayout)
|
||||
vkDestroyDescriptorSetLayout(device, greenGatherSetLayout, nullptr);
|
||||
if (greenGatherPipelineLayout)
|
||||
vkDestroyPipelineLayout(device, greenGatherPipelineLayout, nullptr);
|
||||
if (greenGatherPipeline)
|
||||
vkDestroyPipeline(device, greenGatherPipeline, nullptr);
|
||||
|
||||
if (colorScatterSetLayout)
|
||||
vkDestroyDescriptorSetLayout(device, colorScatterSetLayout, nullptr);
|
||||
if (colorScatterPipelineLayout)
|
||||
vkDestroyPipelineLayout(device, colorScatterPipelineLayout, nullptr);
|
||||
if (colorScatterPipeline)
|
||||
vkDestroyPipeline(device, colorScatterPipeline, nullptr);
|
||||
if (colorGatherSetLayout)
|
||||
vkDestroyDescriptorSetLayout(device, colorGatherSetLayout, nullptr);
|
||||
if (colorGatherPipelineLayout)
|
||||
vkDestroyPipelineLayout(device, colorGatherPipelineLayout, nullptr);
|
||||
if (colorGatherPipeline)
|
||||
vkDestroyPipeline(device, colorGatherPipeline, nullptr);
|
||||
|
||||
if (referenceNormalizeSetLayout)
|
||||
vkDestroyDescriptorSetLayout(device, referenceNormalizeSetLayout, nullptr);
|
||||
@@ -4228,10 +4229,10 @@ void VulkanRawStacker::releaseVulkanResources() {
|
||||
vkFreeMemory(device, greenPhaseAccumMemories[phase], nullptr);
|
||||
}
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
if (rbScatterAccumBuffers[c])
|
||||
vkDestroyBuffer(device, rbScatterAccumBuffers[c], nullptr);
|
||||
if (rbScatterAccumMemories[c])
|
||||
vkFreeMemory(device, rbScatterAccumMemories[c], nullptr);
|
||||
if (rbGatherAccumBuffers[c])
|
||||
vkDestroyBuffer(device, rbGatherAccumBuffers[c], nullptr);
|
||||
if (rbGatherAccumMemories[c])
|
||||
vkFreeMemory(device, rbGatherAccumMemories[c], nullptr);
|
||||
}
|
||||
if (priorBayerBuffer)
|
||||
vkDestroyBuffer(device, priorBayerBuffer, nullptr);
|
||||
|
||||
@@ -58,16 +58,16 @@ private:
|
||||
VkDescriptorSetLayout robustnessSetLayout = VK_NULL_HANDLE;
|
||||
std::vector<VkDescriptorSet> robustnessSets; // Per-frame sets
|
||||
|
||||
// Green HR scatter/splat path
|
||||
VkPipelineLayout greenScatterPipelineLayout = VK_NULL_HANDLE;
|
||||
VkPipeline greenScatterPipeline = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout greenScatterSetLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSet greenScatterSet = VK_NULL_HANDLE;
|
||||
// Green HR gather/splat path
|
||||
VkPipelineLayout greenGatherPipelineLayout = VK_NULL_HANDLE;
|
||||
VkPipeline greenGatherPipeline = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout greenGatherSetLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSet greenGatherSet = VK_NULL_HANDLE;
|
||||
|
||||
VkPipelineLayout colorScatterPipelineLayout = VK_NULL_HANDLE;
|
||||
VkPipeline colorScatterPipeline = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout colorScatterSetLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSet colorScatterSets[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkPipelineLayout colorGatherPipelineLayout = VK_NULL_HANDLE;
|
||||
VkPipeline colorGatherPipeline = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout colorGatherSetLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSet colorGatherSets[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
|
||||
VkDescriptorSetLayout referenceNormalizeSetLayout = VK_NULL_HANDLE;
|
||||
VkPipelineLayout referenceNormalizePipelineLayout = VK_NULL_HANDLE;
|
||||
@@ -107,8 +107,8 @@ private:
|
||||
|
||||
VkBuffer greenPhaseAccumBuffers[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkDeviceMemory greenPhaseAccumMemories[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkBuffer rbScatterAccumBuffers[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkDeviceMemory rbScatterAccumMemories[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkBuffer rbGatherAccumBuffers[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
VkDeviceMemory rbGatherAccumMemories[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
|
||||
|
||||
VkBuffer priorBayerBuffer = VK_NULL_HANDLE;
|
||||
VkDeviceMemory priorBayerMemory = VK_NULL_HANDLE;
|
||||
|
||||
Reference in new issue
Block a user