Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cd61b53
feat(agc): draw PS4 LS-HS-VS tessellation through the off-chip ring l…
B-Howell Nov 17, 2026
74ddfc4
fix(agc): bump the pipeline journal format for the tessellation on-ch…
B-Howell Nov 17, 2026
74f6325
feat(shader): lower PS4 on-chip tessellation LDS through the off-chip…
B-Howell Nov 17, 2026
33f8d6a
test(agc): expect request serialization version 63 in shader memory t…
B-Howell Nov 17, 2026
0a430c5
Merge #22251 head 33f8d6a5a87 into claude/gcn-on-chip-tessellation
B-Howell Nov 17, 2026
88d2f03
test(agc): expect request serialization version 64 in shader memory t…
B-Howell Nov 17, 2026
3a4e170
feat(agc): draw PS4 ES-GS-VS geometry shaders through a Vulkan geomet…
B-Howell Nov 17, 2026
88c71af
Merge #22328 head 88d2f038970 into claude/gcn-es-gs-copy-vs
B-Howell Nov 17, 2026
e5db2fa
Merge remote-tracking branch 'origin/main' into claude/gcn-es-gs-copy-vs
B-Howell Nov 17, 2026
8b64e1c
fix(shader): fold scalar adds, shifts and bit masks in GCN copy progr…
B-Howell Nov 17, 2026
de3aca1
fix(shader): refuse GCN copy programs with control flow and keep stra…
B-Howell Nov 17, 2026
099c38c
docs(debt): shorten the GCN geometry shader entry
B-Howell Nov 17, 2026
8e00caf
fix(shader): follow GCN copy program stream branches on a known SCC
B-Howell Nov 17, 2026
c89e3c5
test(agc): cover a taken copy program branch and an SCC overwritten b…
B-Howell Nov 17, 2026
a5e2d3e
Merge remote-tracking branch 'origin/main' into claude/gcn-ls-hs-vs-t…
B-Howell Nov 17, 2026
a589520
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 17, 2026
61c3102
Merge #22328 head a589520069d into claude/gcn-es-gs-copy-vs
B-Howell Nov 17, 2026
258b593
fix(agc): update the Linux pipeline journal layout guards for the geo…
B-Howell Nov 17, 2026
2126519
Merge origin/main into claude/gcn-ls-hs-vs-tessellation
B-Howell Nov 20, 2026
c9a457f
Merge the updated #22251 branch (with current main) into claude/gcn-o…
B-Howell Nov 20, 2026
d2b78a1
Merge the updated #22328 branch (with current main) into claude/gcn-e…
B-Howell Nov 20, 2026
b212904
test(agc): give the GCN program decode fixture a formatted color target
B-Howell Nov 20, 2026
119ae93
Merge the #22251 fixture fix into claude/gcn-on-chip-tessellation
B-Howell Nov 20, 2026
e19de24
Merge the #22251 fixture fix into claude/gcn-es-gs-copy-vs
B-Howell Nov 20, 2026
358fbde
test(agc): give the GCN geometry program decode fixture a formatted c…
B-Howell Nov 20, 2026
963751c
Merge remote-tracking branch 'origin/main' into claude/gcn-ls-hs-vs-t…
B-Howell Nov 21, 2026
bb91cb8
Merge the updated #22251 branch (with current main) into claude/gcn-o…
B-Howell Nov 21, 2026
0ffacd1
Merge the updated #22328 branch (with current main) into claude/gcn-e…
B-Howell Nov 21, 2026
38769b3
Merge remote-tracking branch 'origin/main' into claude/gcn-ls-hs-vs-t…
B-Howell Nov 22, 2026
86ed118
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 22, 2026
8eba1cb
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 22, 2026
25063d7
feat(agc): render PS4 color views of several slices through the verte…
claude Nov 23, 2026
f7e55e6
fix(agc): decode restarted ES-GS-VS clip layout from the copy program
B-Howell Nov 27, 2026
fc94747
Merge remote-tracking branch 'origin/main' into claude/gcn-es-gs-copy-vs
B-Howell Nov 27, 2026
73f688b
refactor(agc): share the GS position-export program choice across dra…
B-Howell Nov 27, 2026
ab34471
Merge remote-tracking branch 'origin/main' into claude/gcn-ls-hs-vs-t…
B-Howell Nov 27, 2026
74f2c00
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 27, 2026
c2ea4d4
fix(agc): close GCN geometry review gaps in decode, keys and lowering
B-Howell Nov 27, 2026
9519fe4
Merge remote-tracking branch 'origin/main' into claude/gcn-es-gs-copy-vs
B-Howell Nov 27, 2026
c614dad
fix(shader): bound computed on-chip tessellation LDS reads
B-Howell Nov 27, 2026
a150328
test(shader): replay version 64 tessellated requests with emulated ba…
B-Howell Nov 27, 2026
e62a8c2
Merge remote-tracking branch 'origin/main' into claude/gcn-ls-hs-vs-t…
B-Howell Nov 27, 2026
78a86c6
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 27, 2026
8d40b8d
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
715ebdf
test(shader): replay version 65 tessellated requests with emulated ba…
B-Howell Nov 27, 2026
8ba6cb8
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
6bbf38c
fix(agc): collapse a zero-width viewport only for GCN geometry triang…
B-Howell Nov 27, 2026
42e81a0
fix(shader): refuse a merged hull program that keeps its outputs on chip
B-Howell Nov 27, 2026
6a3e3bf
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 27, 2026
b98de9e
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
8c5d518
fix(agc): map indirect-draw user data registers through hidden user w…
B-Howell Nov 27, 2026
ddbed32
fix(shader): refuse an on-chip pass-through hull that reads LDS after…
B-Howell Nov 27, 2026
d901b8c
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 27, 2026
a370895
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
e80c70c
docs(debt): record the on-chip tessellation refusals and the copy-les…
B-Howell Nov 27, 2026
665df49
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
66a4b64
fix(agc): decode vertex stages with each program's hidden user words
B-Howell Nov 27, 2026
72886d0
Merge branch 'claude/gcn-ls-hs-vs-tessellation' into claude/gcn-on-ch…
B-Howell Nov 27, 2026
654a958
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
58c5304
docs(debt): shorten the on-chip tessellation entry and note the copy-…
B-Howell Nov 27, 2026
75aef74
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 27, 2026
8dd935b
fix(agc): capture the pinned tessellation constants with the draw's m…
B-Howell Nov 27, 2026
bbafa86
fix(geometry): refuse copy-program memory accesses other than GSVS reads
B-Howell Nov 27, 2026
d4c1ba3
Merge branch 'main' into claude/gcn-es-gs-copy-vs
B-Howell Nov 28, 2026
2ffa22b
test(geometry): catch duplicated quads and twisted strips in the GCN …
B-Howell Nov 28, 2026
dbb26e7
Merge branch 'claude/gcn-on-chip-tessellation' into claude/gcn-es-gs-…
B-Howell Nov 28, 2026
1e74360
fix(geometry): bound address evaluation and refuse unproven GSVS copy…
B-Howell Nov 28, 2026
84c6ee2
fix(geometry): compute GSVS ring sizes in 64 bits and refuse ones tha…
B-Howell Nov 28, 2026
0e4742f
Merge remote-tracking branch 'refs/remotes/pr/22439' into fix/agc-ps4…
leskal Dec 1, 2026
cf306ea
Merge remote-tracking branch 'refs/remotes/pr/26040' into fix/agc-ps4…
leskal Dec 1, 2026
f224ad5
fix(agc): accept the PS4 copy VS render target index as a geometry gl…
claude Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct DrawDecode {
ShaderRecompiler::ShaderPixelStageInfo pixel;
std::vector<DrawProgram> programs;
std::vector<ShaderRecompiler::ProgramRole> roles;
std::optional<std::uint32_t> copyStreamConfig;
};

void ReadUserWords(const QueueState& queue, DrawProgram& program, bool staticAbi);
Expand All @@ -50,6 +51,9 @@ void DecodeGraphicsPrograms(DrawDecode& decoded, const QueueState& queue, const
ShaderRecompiler::ShaderVertexStageInfo DecodeOrderedVertexStageInfo(std::span<const std::byte> header, std::uint64_t headerAddress, std::span<const std::uint32_t> userData, std::vector<Graphics::DecodeRead>& reads, std::uint32_t hiddenUserWords);

void AppendProgramMemory(std::vector<ShaderRecompiler::MemoryRegion>& memory, const std::vector<DrawProgram>& programs);
const DrawProgram& PositionExportProgram(const std::vector<DrawProgram>& programs, const std::vector<ShaderRecompiler::ProgramRole>& roles, std::size_t index);
std::vector<ShaderRecompiler::GeometryCopyExport> GeometryCopyExports(const DrawDecode& decoded, const std::vector<DrawProgram>& programs);
std::uint64_t GeometryConfigurationKey(const std::optional<ShaderRecompiler::GeometryConfiguration>& geometry);
std::vector<std::pair<std::size_t, std::size_t>> UserDataWords(const std::vector<DrawProgram>& programs, const std::vector<ShaderRecompiler::ProgramRole>& roles, std::uint32_t location);

struct PreparedGraphicsStage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ struct PreparedShaders : PreparedShaderState {
bool pending = false;
std::vector<std::size_t> convertedSamples;
std::vector<std::size_t> layerRowSamples;
std::vector<std::pair<std::size_t, std::uint32_t>> tessellationConstants;
};

class SharedCode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ShaderMemory {
// included, the initial regions excluded: one stage's own reads on the draw path's shared
// ShaderMemory (Regions() stays the union). The spans point into the pages, as Regions()'s do.
[[nodiscard]] std::vector<ShaderRecompiler::MemoryRegion> TakeRecentRegions();
[[nodiscard]] bool ReadWords(std::uint64_t address, std::span<std::uint32_t> values) { return readWords(this, address, values.data(), values.size()); }
// The driver's source handle memo outcomes, for the [capture] line (APS5_PROFILE_DRAW).
static void CountHandleMemo(bool hit);
struct SupplyCounts {
Expand Down
42 changes: 27 additions & 15 deletions core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ DrawFinisher::Pending heldWrites(const DrawTail& tail) {
}
const auto& roles = tail.decode->roles;
for (std::size_t i = 0; i < tail.matched.size(); ++i) {
if (i < roles.size() && roles[i] == ShaderRecompiler::ProgramRole::GeometryBack) continue;
if (i < roles.size() && ShaderRecompiler::LinkedOnlyRole(roles[i])) continue;
const auto& variant = tail.matched[i];
if (variant == nullptr || variant->compiled == nullptr) {
const bool candidates = !tail.drawHit && i < tail.dataCandidates.size() && !tail.dataCandidates[i].empty();
Expand Down Expand Up @@ -664,10 +664,11 @@ DrawVerdict Driver::draw(QueueState& queue, std::span<const std::uint32_t> packe
decodeReads.resize(programs.size());
const auto decodeVertexInfo = [&](std::size_t i) {
const auto& program = programs[i];
if (program.binary.stage == Stage::Fragment || roles[i] == Role::GeometryBack) return;
vertexInfos[i] = DecodeOrderedVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, decodeReads[i], 8u - program.firstUserSgpr);
if (program.binary.stage == Stage::Fragment || ShaderRecompiler::LinkedOnlyRole(roles[i])) return;
vertexInfos[i] = DecodeOrderedVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, decodeReads[i], program.hiddenUserWords);
if (vertexInfos[i]) {
vertexInfos[i]->paClVsOutCntl = PositionExportLayout(program.snapshot.get(), program.codeOffset, program.binary.code, readRegister(queue.context, 0x207), program.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
const auto& exporter = PositionExportProgram(programs, roles, i);
vertexInfos[i]->paClVsOutCntl = PositionExportLayout(exporter.snapshot.get(), exporter.codeOffset, exporter.binary.code, readRegister(queue.context, 0x207), exporter.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
vertexInfos[i]->depthRemapMode = graphics.depthRemap.mode;
Graphics::ApplyPointSize(graphics, *vertexInfos[i]);
}
Expand Down Expand Up @@ -708,7 +709,8 @@ DrawVerdict Driver::draw(QueueState& queue, std::span<const std::uint32_t> packe
stageData.resize(programs.size());
auto& drawHit = tail.drawHit;
auto& verifyHit = tail.verifyHit;
tail.stageEntries = useDrawEntries && !(graphics.stages.tessellation && !drawParameters.indirect && drawParameters.instanceCount > 1u);
const bool onChipTessellation = graphics.stages.tessellation && graphics.stages.tessellation->onChip;
tail.stageEntries = useDrawEntries && !onChipTessellation && !(graphics.stages.tessellation && !drawParameters.indirect && drawParameters.instanceCount > 1u);
const bool stageEntries = tail.stageEntries;
try {
lookupDraw(submission, localDevice, graphics, pixel, programs, roles, vertexInfos, stageEntries, registerKey, profile, drawKey, entry, matched, matchedRegions, drawHit, verifyHit, phaseTiming, phaseMs, dataEntry, dataCandidates, stageData);
Expand Down Expand Up @@ -944,19 +946,20 @@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
const auto locate = [&](std::uint32_t location) -> std::optional<std::pair<std::size_t, std::size_t>> {
if (location == 0x280u) return std::nullopt;
for (std::size_t i = 0; i < programs.size(); ++i) {
if (roles[i] == Role::Fragment || roles[i] == Role::GeometryBack || location < programs[i].userDataBase) continue;
const auto word = location - programs[i].userDataBase + (8u - programs[i].firstUserSgpr);
if (roles[i] == Role::Fragment || ShaderRecompiler::LinkedOnlyRole(roles[i]) || location < programs[i].userDataBase) continue;
const auto word = location - programs[i].userDataBase + programs[i].hiddenUserWords;
if (word < programs[i].userData.size()) return std::make_pair(i, static_cast<std::size_t>(word));
}
return std::nullopt;
};
const auto decodeVertexInfo = [&](std::size_t i) {
const auto& program = programs[i];
if (program.binary.stage == Stage::Fragment || roles[i] == Role::GeometryBack) return;
if (program.binary.stage == Stage::Fragment || ShaderRecompiler::LinkedOnlyRole(roles[i])) return;
decodeReads[i].clear();
vertexInfos[i] = Graphics::DecodeVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, &decodeReads[i], false, 8u - program.firstUserSgpr);
vertexInfos[i] = Graphics::DecodeVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, &decodeReads[i], false, program.hiddenUserWords);
if (vertexInfos[i]) {
vertexInfos[i]->paClVsOutCntl = PositionExportLayout(program.snapshot.get(), program.codeOffset, program.binary.code, tail.reg207, program.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
const auto& exporter = PositionExportProgram(programs, roles, i);
vertexInfos[i]->paClVsOutCntl = PositionExportLayout(exporter.snapshot.get(), exporter.codeOffset, exporter.binary.code, tail.reg207, exporter.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
vertexInfos[i]->depthRemapMode = graphics.depthRemap.mode;
Graphics::ApplyPointSize(graphics, *vertexInfos[i]);
}
Expand Down Expand Up @@ -1029,7 +1032,7 @@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
const bool fixedSlots = localDevice->GraphicsPipelineLibraries();
const bool hasFragment = std::ranges::any_of(programs, [](const DrawProgram& program) { return program.binary.stage == ShaderRecompiler::ShaderStage::Fragment; });
for (std::size_t i = 0; i < programs.size(); ++i) {
if (roles[i] == Role::GeometryBack) continue;
if (ShaderRecompiler::LinkedOnlyRole(roles[i])) continue;
const auto& program = programs[i];
pushCursorBytes = Graphics::StagePushOffset(pushCursorBytes, program.binary.stage, fixedSlots);
require(pushCursorBytes <= Graphics::PushBlockBytes(fixedSlots), "stage push constant offset exceeds the pipeline push constant block");
Expand Down Expand Up @@ -1477,7 +1480,7 @@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
}

std::vector<std::shared_ptr<DispatchVariant>> recipeStages;
if (registerKey && !drawParameters.indirect && !patchedStages && !graphics.stages.tessellationGeometry && Graphics::DrawRecipes()) {
if (registerKey && !drawParameters.indirect && !patchedStages && !graphics.stages.tessellationGeometry && !(graphics.stages.tessellation && graphics.stages.tessellation->onChip) && Graphics::DrawRecipes()) {
recipeStages.reserve(programs.size());
for (std::size_t i = 0; i < programs.size(); ++i) recipeStages.push_back(drawHit ? (matched[i] != nullptr && matched[i]->donor != nullptr ? matched[i]->donor : matched[i]) : fresh[i]);
if (std::all_of(recipeStages.begin(), recipeStages.end(), [](const std::shared_ptr<DispatchVariant>& variant) { return variant == nullptr; })) recipeStages.clear();
Expand Down Expand Up @@ -1580,6 +1583,14 @@ void Driver::restartFinishedDraw(DrawTail& tail) {
if (fresh.header.empty()) NoteRawGraphicsDraw(fresh);
program.snapshot = std::move(snapshot);
}
if (tail.decode->state.stages.legacyGeometry) {
auto exports = GeometryCopyExports(*tail.decode, tail.writablePrograms);
if (exports != tail.decode->state.stages.legacyGeometry->exports) {
auto refreshed = std::make_shared<DrawDecode>(*tail.decode);
refreshed->state.stages.legacyGeometry->exports = std::move(exports);
tail.decode = std::move(refreshed);
}
}
}
if (tail.drawHit && !tail.userPatches.empty()) {
if (verifyDrawRecipe()) {
Expand Down Expand Up @@ -1619,10 +1630,11 @@ void Driver::restartFinishedDraw(DrawTail& tail) {
tail.decodeReads[i].clear();
tail.vertexInfos[i].reset();
const auto& program = programs[i];
if (program.binary.stage == Stage::Fragment || roles[i] == Role::GeometryBack) continue;
tail.vertexInfos[i] = DecodeOrderedVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, tail.decodeReads[i], 8u - program.firstUserSgpr);
if (program.binary.stage == Stage::Fragment || ShaderRecompiler::LinkedOnlyRole(roles[i])) continue;
tail.vertexInfos[i] = DecodeOrderedVertexStageInfo(program.binary.header, program.binary.headerAddress, program.userData, tail.decodeReads[i], program.hiddenUserWords);
if (!tail.vertexInfos[i]) continue;
tail.vertexInfos[i]->paClVsOutCntl = PositionExportLayout(program.snapshot.get(), program.codeOffset, program.binary.code, tail.reg207, program.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
const auto& exporter = PositionExportProgram(programs, roles, i);
tail.vertexInfos[i]->paClVsOutCntl = PositionExportLayout(exporter.snapshot.get(), exporter.codeOffset, exporter.binary.code, tail.reg207, exporter.tailContinuation.get()) | graphics.layerExports | graphics.viewportExports;
tail.vertexInfos[i]->depthRemapMode = graphics.depthRemap.mode;
Graphics::ApplyPointSize(graphics, *tail.vertexInfos[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libSceAgcDriver/Execution/include/Pm4.hpp"
#include "Optimization/ResourceProgram.hpp"
#include "Optimization/TessellationLowering.hpp"
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <map>
#include <mutex>
#include <optional>
#include <span>
#include <sstream>
#include <stdexcept>
Expand All @@ -22,6 +25,35 @@ namespace AgcDriver::DriverDetail {

namespace {

std::array<std::uint32_t, ShaderRecompiler::TessellationConstantWords> ReadTessellationConstants(ShaderMemory& shaderMemory, std::span<const std::uint32_t> userData, std::uint32_t word) {
require(word + 4u <= userData.size(), "the tessellation constant buffer's V# lies past the stage's user data");
const auto base = static_cast<std::uint64_t>(userData[word]) | (static_cast<std::uint64_t>(userData[word + 1u] & 0xffffu) << 32u);
const auto stride = (userData[word + 1u] >> 16u) & 0x3fffu;
const auto size = stride == 0u ? static_cast<std::uint64_t>(userData[word + 2u]) : static_cast<std::uint64_t>(stride) * userData[word + 2u];
std::array<std::uint32_t, ShaderRecompiler::TessellationConstantWords> constants{};
const auto count = static_cast<std::size_t>(std::min<std::uint64_t>(constants.size(), size / 4u));
if (count == 0u) return constants;
require(base % 4u == 0u, "the tessellation constant buffer starts at an address that is not a whole dword");
require(shaderMemory.ReadWords(base, std::span(constants).first(count)), "the tessellation constant buffer could not be read");
return constants;
}

std::optional<std::uint32_t> TessellationConstantWord(const ShaderSnapshot& snapshot, std::size_t codeOffset) {
std::lock_guard lock(snapshot.prepared->mutex);
for (const auto& [offset, word] : snapshot.prepared->tessellationConstants) {
if (offset == codeOffset) return word;
}
return std::nullopt;
}

void RecordTessellationConstantWord(const ShaderSnapshot& snapshot, std::size_t codeOffset, std::uint32_t word) {
std::lock_guard lock(snapshot.prepared->mutex);
for (const auto& [offset, known] : snapshot.prepared->tessellationConstants) {
if (offset == codeOffset) return;
}
snapshot.prepared->tessellationConstants.emplace_back(codeOffset, word);
}

void TraceMaterializationFailure(std::uint64_t token, const Submission& submission, std::size_t packetOffset, std::size_t stage, const char* phase, const std::exception_ptr& failure) {
if (token == 0) return;
const char* type = "unknown";
Expand Down Expand Up @@ -179,12 +211,25 @@ std::shared_ptr<const ShaderRecompiler::RecompileResult> Driver::materializeDraw
{waveSize, program.firstUserSgpr, program.userData, std::nullopt, program.binary.stage == Stage::Fragment ? std::optional(pixel) : std::nullopt, vertexInfos[i], memory, RegisteredFloatMode(*program.snapshot)},
localDevice->Target(),
{0, 0, pushOffset, pushBytes},
ShaderRecompiler::GraphicsCompileContext{program.firstUserSgpr, linked, Graphics::StageMeshConfiguration(graphics.stages, program.binary.stage), graphics.stages.tessellation, {drawParameters.indexAddress, drawParameters.indexCount, drawParameters.indexSize, drawParameters.instanceCount}, program.binary.stage == Stage::Mesh ? meshBarycentrics : std::nullopt, emulateBarycentrics && program.binary.stage == Stage::Fragment}
ShaderRecompiler::GraphicsCompileContext{program.firstUserSgpr, linked, Graphics::StageMeshConfiguration(graphics.stages, program.binary.stage), graphics.stages.tessellation, {drawParameters.indexAddress, drawParameters.indexCount, drawParameters.indexSize, drawParameters.instanceCount}, program.binary.stage == Stage::Mesh ? meshBarycentrics : std::nullopt, emulateBarycentrics && program.binary.stage == Stage::Fragment, std::nullopt, Graphics::StageGeometryConfiguration(graphics.stages, program.binary.stage)}
};
if (request.graphics->tessellation && request.graphics->tessellation->onChip && (program.binary.stage == Stage::TessellationControl || program.binary.stage == Stage::TessellationEvaluation)) {
if (const auto word = TessellationConstantWord(*program.snapshot, program.codeOffset)) request.graphics->tessellationConstants = ReadTessellationConstants(shaderMemory, program.userData, *word);
}
const auto pinTessellationConstants = [&](const ShaderRecompiler::TessellationConstantsRequired& required) {
if (request.graphics->tessellationConstants) throw required;
RecordTessellationConstantWord(*program.snapshot, program.codeOffset, required.UserDataWord());
request.graphics->tessellationConstants = ReadTessellationConstants(shaderMemory, program.userData, required.UserDataWord());
};
const auto waitedBefore = traceCapSync() || profile ? Graphics::Recorder::ThreadWaitedMs() : 0.0;
auto invocation = [&] {
try {
return InvocationFor(*program.snapshot, program.codeOffset, request, AsyncDrawCompile());
try {
return InvocationFor(*program.snapshot, program.codeOffset, request, AsyncDrawCompile());
} catch (const ShaderRecompiler::TessellationConstantsRequired& required) {
pinTessellationConstants(required);
return InvocationFor(*program.snapshot, program.codeOffset, request, AsyncDrawCompile());
}
} catch (const DrawCompilePending&) {
throw;
} catch (...) {
Expand Down Expand Up @@ -215,7 +260,15 @@ std::shared_ptr<const ShaderRecompiler::RecompileResult> Driver::materializeDraw
const auto capture = [&] {
const SampledReadScope sampling(evidenceReads);
try {
return CaptureInvocation(shaderMemory, *program.snapshot, program.codeOffset, request, invocation);
try {
return CaptureInvocation(shaderMemory, *program.snapshot, program.codeOffset, request, invocation);
} catch (const ShaderRecompiler::TessellationConstantsRequired& required) {
pinTessellationConstants(required);
invocation = InvocationFor(*program.snapshot, program.codeOffset, request, AsyncDrawCompile());
return CaptureInvocation(shaderMemory, *program.snapshot, program.codeOffset, request, invocation);
}
} catch (const DrawCompilePending&) {
throw;
} catch (const std::exception& error) {
throw named(error, shaderMemory.Regions());
}
Expand Down
Loading
Loading