Skip to content

Commit 41b6ee4

Browse files
Spruill-1Copilot
andcommitted
GraphEvaluator: fix dispatch heuristic + 0-as-passthrough for OutputW/H
Two related bugs surfaced when wiring the new ShaderLab Scale effect through the bridge: 1) "Fixed-size viewer" detection treated *any* effect declaring OutputWidth/OutputHeight as a single-group scatter shader and dispatched (1,1,1). That was correct for CIE Histogram-style shaders that use [numthreads(32,32,1)] and iterate the whole source image inside one group, but wrong for per-pixel-tile shaders like the new Scale that use [numthreads(8,8,1)] and need (W/8, H/8, 1). With (1,1,1) only 64 threads ran -- painting an 8x8 corner of the output and leaving everything else as the cleared zeros from the UAV clear (= black). Replace the parameter-name discriminator with a thread-group-size one: groups >= 256 threads are treated as single-group scatter shaders; smaller groups tile per-pixel. The legacy DiagramSize / OutputSize parameter check stays as a belt-and- suspenders fallback for any future descriptor that intentionally uses a small group with single-group dispatch (none today). 2) OutputWidth = 0 / OutputHeight = 0 (= "pass through at source dims") was being floored at 64 by max(*f, 64.0f). Pass-through needs to fall through to the upstream-bounds path so the output texture matches the source. Drop the floor in the explicitW / explicitH read; treat 0 as "not set" and let later passes (DiagramSize fallback, then source bounds fallback) decide. The shaders own per-pixel guard (`if (dtid.x >= outW) return`) handles the actual size. Verified: ShaderLab Scale at 0.5x on a 4K HDR video source now produces correct 1920x1080 Lanczos-3 output (sample center pixel matches source content, full frame visible). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1176d79 commit 41b6ee4

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

Rendering/GraphEvaluator.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,16 +1150,16 @@ namespace ShaderLab::Rendering
11501150
if (key == L"OutputWidth")
11511151
{
11521152
if (auto* f = std::get_if<float>(&val))
1153-
explicitW = static_cast<UINT32>((std::max)(*f, 64.0f));
1153+
explicitW = (*f >= 1.0f) ? static_cast<UINT32>(*f) : 0;
11541154
else if (auto* u = std::get_if<uint32_t>(&val))
1155-
explicitW = (std::max)(*u, 64u);
1155+
explicitW = *u;
11561156
}
11571157
else if (key == L"OutputHeight")
11581158
{
11591159
if (auto* f = std::get_if<float>(&val))
1160-
explicitH = static_cast<UINT32>((std::max)(*f, 64.0f));
1160+
explicitH = (*f >= 1.0f) ? static_cast<UINT32>(*f) : 0;
11611161
else if (auto* u = std::get_if<uint32_t>(&val))
1162-
explicitH = (std::max)(*u, 64u);
1162+
explicitH = *u;
11631163
}
11641164
}
11651165
if (explicitW > 0 && explicitH > 0)
@@ -1336,13 +1336,22 @@ namespace ShaderLab::Rendering
13361336
if (hasImageOutput && imageOutW > 0 && imageOutH > 0 &&
13371337
def.threadGroupX > 0 && def.threadGroupY > 0)
13381338
{
1339-
bool isFixedSizeViewer = false;
1339+
// Discriminator: single-group scatter shaders use a large
1340+
// thread group (commonly 32x32 = 1024) and dispatch (1,1,1);
1341+
// per-pixel-tile shaders use a small group (commonly 8x8 = 64)
1342+
// and dispatch (W/tx, H/ty, 1). Threshold at 256 cleanly
1343+
// separates the two conventions in the current catalog.
1344+
//
1345+
// The DiagramSize / OutputSize parameter names ALSO mark fixed-
1346+
// output viewers (CIE Histogram, etc.) that pre-date the
1347+
// generic threshold; keep that check for descriptors that use
1348+
// an 8x8 group but still want single-group dispatch (none
1349+
// exist today, but the check is cheap and safe).
1350+
const bool largeGroup = (def.threadGroupX * def.threadGroupY) >= 256;
1351+
bool isFixedSizeViewer = largeGroup;
13401352
for (const auto& p : def.parameters)
13411353
{
1342-
if (p.name == L"DiagramSize" ||
1343-
p.name == L"OutputSize" ||
1344-
p.name == L"OutputWidth" ||
1345-
p.name == L"OutputHeight")
1354+
if (p.name == L"DiagramSize" || p.name == L"OutputSize")
13461355
{
13471356
isFixedSizeViewer = true;
13481357
break;

0 commit comments

Comments
 (0)