Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
0453a81
perf(agc): record draw commands on an encoder thread
chitters2004 Nov 9, 2026
e21f21f
Merge origin/main into perf/agc-record-encoder
chitters2004 Nov 9, 2026
e3ca80f
fix(agc): order mesh argument kernel, drain on unwind, start encoder …
chitters2004 Nov 9, 2026
86ef8c1
perf(agc): record transfers and occlusion queries in the encoder stre…
chitters2004 Nov 10, 2026
ed798f1
Merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
ad553d3
fix(agc): drain the encoder before draw owners unwind and refuse fore…
chitters2004 Nov 10, 2026
b417bbf
test(agc): quiesce the encoder before clearing the shared delay in th…
chitters2004 Nov 10, 2026
c51fa9b
Merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
c1feb8d
fix(agc): let other threads look up commands while a window is open
chitters2004 Nov 10, 2026
65de8f1
test(agc): keep a raw call after a lookup in order inside an encoding…
chitters2004 Nov 10, 2026
96b3b9d
Merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
0bb09ad
fix(agc): keep segment query drains when the query hooks are absent
chitters2004 Nov 10, 2026
dbaf2fa
fix(agc): report a failed encoder replay to the producer
chitters2004 Nov 10, 2026
8e4b102
docs(agc): record raw command pointers that bypass the command encoder
chitters2004 Nov 10, 2026
b26e0c1
Merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
47bb855
feat(agc): report command encoder posts and waits in the trace summary
chitters2004 Nov 10, 2026
b057d4f
Merge remote-tracking branch 'origin/main' into perf/agc-record-encoder
chitters2004 Nov 10, 2026
c710098
chore(agc): merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
5e406e8
fix(agc): define the encoder's command lookup hook in the pipeline ca…
chitters2004 Nov 10, 2026
7831774
chore(agc): merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
eca5eb0
fix(agc): keep encoder replay failures with their command buffer
chitters2004 Nov 10, 2026
dbd6ebb
test(agc): run the recorder suite through the command encoder
chitters2004 Nov 10, 2026
b2eca5c
fix(agc): keep encoder replay failures in the batch's recording
chitters2004 Nov 10, 2026
7a03091
fix(agc): stop direct calls into a failed recording
chitters2004 Nov 10, 2026
1eef476
chore(agc): merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 10, 2026
318ea40
test(agc): drop packed transfers and queries after a failed replay
chitters2004 Nov 10, 2026
58feec9
fix(agc): drop a discarded batch's occlusion segments
chitters2004 Nov 10, 2026
93679c7
chore(agc): merge main for the worker_spin test fixes
chitters2004 Nov 10, 2026
95a3202
chore(agc): merge main for the worker_spin test fixes
chitters2004 Nov 10, 2026
9731723
chore(agc): merge main into perf/agc-encoder-no-wait
chitters2004 Nov 11, 2026
3eb653f
chore(agc): merge main for the colour write mask fix
chitters2004 Nov 11, 2026
14cde70
fix(agc): record the colour write mask through the command encoder
chitters2004 Nov 11, 2026
dee8d79
chore(agc): merge the colour write mask fix from perf/agc-record-encoder
chitters2004 Nov 11, 2026
0679fcd
perf(agc): bound the command encoder's chunks with a preallocated pool
chitters2004 Nov 11, 2026
842af65
fix(agc): make every direct write to a recorder batch name why it is …
chitters2004 Nov 11, 2026
8ba0aaf
perf(agc): park the command encoder when it runs out of chunks
chitters2004 Nov 11, 2026
6102f9a
perf(agc): attribute command encoder waits to their call sites
chitters2004 Nov 12, 2026
5d24691
perf(agc): profile command encoder wait sites behind their own switch
chitters2004 Nov 12, 2026
cb06229
fix(agc): make the command encoder's record invariants compile errors
chitters2004 Nov 12, 2026
6cab491
perf(agc): attribute pass-end encoder waits to their callers
chitters2004 Nov 12, 2026
86d7a8d
test(agc): set APS5_PROFILE_ENCODER portably in the pass-end site test
chitters2004 Nov 12, 2026
0f22016
test(agc): inject the encoder's allocation failure where Windows can …
chitters2004 Nov 12, 2026
f909e10
test(agc): drop the comment on the profile-encoder test helper
chitters2004 Nov 12, 2026
67c13b8
perf(agc): add APS5_NO_RECORD_ENCODER, a runtime switch that records …
chitters2004 Nov 12, 2026
495bc71
test(agc): add a hand-off microbench to the command encoder test
chitters2004 Nov 12, 2026
d643751
perf(agc): record a draw inline when the encoder hand-off costs more …
chitters2004 Nov 12, 2026
88d7303
test(agc): run the hand-off microbench with few usable cores and with…
chitters2004 Nov 12, 2026
85a23ea
test(agc): skip the watched clear-key hand-over on a comparing device…
chitters2004 Nov 13, 2026
27b6f32
Merge origin/main into perf/agc-record-encoder
chitters2004 Nov 13, 2026
4e2e6b1
chore: merge main into the encoder thread branch
oneandonlydean Nov 13, 2026
7a54074
test(agc): test the adaptive encoder hand-off policy without timing
chitters2004 Nov 13, 2026
0a57ba2
chore: merge the adaptive policy test commit
oneandonlydean Nov 13, 2026
5bd16c9
perf(agc): record occlusion segment queries on the command encoder
chitters2004 Nov 13, 2026
693016f
perf(agc): choose the encoder hand-off from the producer's measured cost
chitters2004 Nov 13, 2026
bcf1395
fix(agc): keep a failed recording's occlusion samples out of later reads
chitters2004 Nov 13, 2026
9e727d1
fix(agc): refuse every settle after a replay failure and keep folded …
chitters2004 Nov 13, 2026
87f7d4c
fix(agc): restore folded occlusion samples without allocating and tes…
chitters2004 Nov 13, 2026
2181971
chore(agc): merge main into the command encoder
chitters2004 Nov 14, 2026
a904c06
test(agc): audit the raw command pointers left beside the command state
chitters2004 Nov 14, 2026
a7dae6a
chore(agc): merge the synced command encoder into transfer and query …
chitters2004 Nov 14, 2026
9d1884b
Merge branch main into perf/agc-record-encoder
chitters2004 Nov 14, 2026
c22cb54
Merge the synced command encoder into transfer and query encoding
chitters2004 Nov 14, 2026
7013bce
Merge branch main into perf/agc-record-encoder
chitters2004 Nov 14, 2026
9dc5144
Merge branch main into perf/agc-encoder-no-wait
chitters2004 Nov 14, 2026
65bab98
fix(agc): free the encoder's pooled chunks when its worker cannot start
chitters2004 Nov 15, 2026
3432933
fix(agc): destroy the recorder's encoder pool when its constructor th…
chitters2004 Nov 15, 2026
7751b3d
test(agc): replace the nothrow allocation pair in the allocation fail…
chitters2004 Nov 15, 2026
653163b
Merge branch main into perf/agc-record-encoder
chitters2004 Nov 15, 2026
12164c9
fix(agc): look up the changed copy-back's push descriptor command whe…
chitters2004 Nov 15, 2026
2ae3f13
Merge branch perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 15, 2026
1a2d813
fix(agc): trace the producer's chunk pool waits as encoder waits
chitters2004 Nov 15, 2026
03ff781
fix(tools): show encoder waits in intervals without posts
chitters2004 Nov 15, 2026
818acfd
test(agc): test encoded occlusion segments and discarded batch samples
chitters2004 Nov 15, 2026
23b2b44
Merge branch main into perf/agc-record-encoder
chitters2004 Nov 15, 2026
ba4484b
Merge branch perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 15, 2026
b67f0f0
perf(agc): record inline windows on the original device table
chitters2004 Nov 16, 2026
a8d6c09
ci(sanitizers): run the command encoder tests under ASan and UBSan
chitters2004 Nov 16, 2026
4084618
Merge branch perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 16, 2026
783b920
Merge main into perf/agc-record-encoder
chitters2004 Nov 16, 2026
7917c77
Merge main into perf/agc-encoder-no-wait
chitters2004 Nov 16, 2026
6f18fe2
Merge main into perf/agc-record-encoder
chitters2004 Nov 17, 2026
fff1677
Merge main into perf/agc-encoder-no-wait
chitters2004 Nov 17, 2026
580a043
feat(agc): add a sealed command stream with inline and single-thread …
chitters2004 Nov 17, 2026
79fa193
feat(agc): record batches into sealed command streams
chitters2004 Nov 17, 2026
de38b76
test(agc): refuse submits while a replay failure is expected
chitters2004 Nov 17, 2026
da44788
docs(agc): state the durable replay latch beside the direct-batch switch
chitters2004 Nov 17, 2026
99d31e2
test(agc): link the command thunks into the pipeline cache allocation…
chitters2004 Nov 17, 2026
49797f9
fix(agc): retire a sealed batch's charge without reading its stream
chitters2004 Nov 17, 2026
73f9211
fix(agc): finish in-flight batches when a sync's submit fails
chitters2004 Nov 17, 2026
7578211
fix(agc): own the replay command pool before creating it
chitters2004 Nov 17, 2026
bce96df
fix(agc): end serial waits when the waited batch can no longer complete
chitters2004 Nov 17, 2026
784ebc5
test(agc): free the command buffer of a stream whose demotion failed
chitters2004 Nov 17, 2026
c22771b
test(agc): compare every argument of every specialized streamer after…
chitters2004 Nov 17, 2026
0ac66b6
perf(agc): choose each batch's command table once instead of testing …
chitters2004 Nov 17, 2026
212b848
test(agc): gate the typed command cost on paired medians against the …
chitters2004 Nov 17, 2026
79c126e
test(agc): measure Context::ForBatch and check every per-draw site re…
chitters2004 Nov 17, 2026
36719ef
fix(agc): latch a direct batch's failed submission like a sealed batch's
chitters2004 Nov 17, 2026
80d642c
fix(agc): finish every in-flight batch in Sync when one fence wait fails
chitters2004 Nov 17, 2026
ef9e679
feat(agc): stream every recorded command and bound streams in bytes
chitters2004 Nov 17, 2026
d94088a
fix(agc): keep sealed-batch streams within their byte cap
chitters2004 Nov 18, 2026
8e2241d
test(agc): skip memset on empty arrays in the command thunk fidelity …
chitters2004 Nov 18, 2026
055f295
fix(agc): pair each keyed entry point with its device under reuse
chitters2004 Nov 18, 2026
94af04a
test(agc): keep bit 0 clear in fake command buffers
chitters2004 Nov 18, 2026
4c5b239
refactor(agc): split Recorder::Submit into Seal and a queue step
chitters2004 Nov 18, 2026
9299ec3
fix(agc): latch a sealed batch's pre-queue failure while another batc…
chitters2004 Nov 18, 2026
db18657
Merge main into perf/agc-record-encoder
chitters2004 Nov 19, 2026
a6a36b0
Merge #17943's main sync into perf/agc-encoder-no-wait
chitters2004 Nov 19, 2026
3f52e52
fix(agc): thunk and stream vkCmdResolveImage
chitters2004 Nov 19, 2026
549e7d1
fix(agc): let batch tables defer to the context's own entry points
chitters2004 Nov 19, 2026
ca22cfb
fix(agc): carry on after a submit that queued nothing
chitters2004 Nov 19, 2026
df04631
Merge #18029's main sync into feat/agc-sealed-batch
chitters2004 Nov 19, 2026
19728b1
chore: merge main into perf/agc-record-encoder
oneandonlydean Nov 19, 2026
d161c08
Merge perf/agc-record-encoder into perf/agc-encoder-no-wait
chitters2004 Nov 19, 2026
d638f67
Merge #18029's main sync into feat/agc-sealed-batch
chitters2004 Nov 19, 2026
6852305
test(agc): finish a batch in flight after device loss
chitters2004 Nov 19, 2026
7458735
perf(agc): check a batch's table once per draw, not per command
chitters2004 Nov 19, 2026
b72771a
fix(agc): stop a sync at the first failed wait, as #20066 expects
chitters2004 Nov 19, 2026
2f519ad
docs(agc): restore the encoder switch rows a merge dropped
chitters2004 Nov 19, 2026
772c16a
test(agc): accept a batch table filtered by BatchFor at per-draw sites
chitters2004 Nov 19, 2026
07c9482
test(agc): gate the typed path on the thunk's cost only where it reso…
chitters2004 Nov 19, 2026
5f39dbe
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 20, 2026
57bd01b
fix(agc): stream the depth bias enable and dispatch base commands mai…
chitters2004 Nov 21, 2026
9bb137b
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 21, 2026
91a978c
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 22, 2026
83e48d4
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 22, 2026
bd41f31
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 23, 2026
44b170b
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 24, 2026
1c1ecb6
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 26, 2026
cfedbb0
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 26, 2026
8983b23
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 26, 2026
dab0836
fix(agc): forget a draw input mirror when the batch that uploads it i…
chitters2004 Nov 26, 2026
f9e2c8b
fix(agc): register a captured input's completion before recording its…
chitters2004 Nov 26, 2026
75078db
fix(agc): build the poison reason once per recorder, not while unwinding
chitters2004 Nov 26, 2026
6122842
test(agc): end the stalled timeline before the recorder tears down
chitters2004 Nov 26, 2026
61c260f
test(agc): signal the held submission's gate when the test exits early
chitters2004 Nov 26, 2026
0374be0
test(agc): start the refused-submit refusal once the waiter is inside…
chitters2004 Nov 26, 2026
a82cb2c
fix(agc): poison the open batch when the recorded draw path throws
chitters2004 Nov 26, 2026
5c6f509
test(agc): require the failed-replay recorder to reach the submit hook
chitters2004 Nov 26, 2026
66ba6b6
test(agc): check the dumped sample totals before subtracting the base…
chitters2004 Nov 26, 2026
1cbfb75
test(agc): require the vertex-range workload itself to replay a batch
chitters2004 Nov 26, 2026
09605b5
fix(agc): make a refused sealed batch wait for its replay before it i…
chitters2004 Nov 26, 2026
653cfba
fix(agc): drop a batch's labels when a failed wait retires it
chitters2004 Nov 26, 2026
06399b7
fix(agc): drop a discarded batch's occlusion segments from the batche…
chitters2004 Nov 26, 2026
fe52f81
fix(agc): discard the sealed batch when queueing it for submission th…
chitters2004 Nov 26, 2026
0667de7
test(agc): bound the waiter that failedSerialWait starts
chitters2004 Nov 26, 2026
f8cbba9
fix(agc): append completions behind the newest sealed batch
chitters2004 Nov 26, 2026
b97ac1e
fix(agc): end the render pass's state even when its after-pass work t…
chitters2004 Nov 26, 2026
4531f05
fix(agc): release a demoted stream's byte charge when its chunks are …
chitters2004 Nov 27, 2026
ca58f77
fix(agc): keep a draw input mirror alive from the moment its upload i…
chitters2004 Nov 27, 2026
41e5233
test(agc): keep both copy operands when a draw input mirror's discard…
chitters2004 Nov 27, 2026
98becf0
fix(agc): poison a direct or demoted batch that a draw unwound through
chitters2004 Nov 27, 2026
3e9e363
test(agc): report every recording mode's failure and check the mirror…
chitters2004 Nov 27, 2026
f52ffd3
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 27, 2026
a62bc15
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 27, 2026
6bc031b
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Nov 27, 2026
2dc7fc1
test(agc): pass the mesh argument kernel its eight rules
chitters2004 Nov 28, 2026
a177299
fix(agc): refuse a stream handle executed as a secondary command buffer
chitters2004 Nov 28, 2026
a3096ce
test(agc): replay pooled secondary command buffers from a streamed batch
chitters2004 Nov 28, 2026
3a11863
Merge main into feat/agc-sealed-batch
chitters2004 Dec 1, 2026
34ddf73
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Dec 1, 2026
8fa09f3
fix(agc): keep the reason of the lowest failed serial in FailureLatch
chitters2004 Dec 3, 2026
d0e5082
chore: merge main
oneandonlydean Dec 4, 2026
45c9ad4
fix(agc): clear write-only hazards when the open batch is sealed
oneandonlydean Dec 4, 2026
8a0cc4c
Merge branch 'main' into feat/agc-sealed-batch
chitters2004 Dec 4, 2026
0570eab
docs(agc): move debt entries into a fragment
chitters2004 Dec 5, 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
20 changes: 20 additions & 0 deletions core/libs/prx/libSceAgcDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ set(agcDriverSources
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/DeferredDestruction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/MemoryAccounting.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/PlaceholderImages.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/CommandStream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/CommandThunks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/SealedBatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/Recorder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/ParallelCompare.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/ShaderInputState.cpp
Expand Down Expand Up @@ -1239,3 +1242,20 @@ if(BUILD_TESTING)
endif()

target_sources(agc_driver_scattered_runs_tests PRIVATE tests/AllocationFailure.cpp)
add_library(agc_stream_guard_accepted OBJECT tests/StreamGuards.cpp)
target_include_directories(agc_stream_guard_accepted PRIVATE ${LIBS_INCLUDE_DIR} ${ANYPS5_VULKAN_HEADERS_INCLUDE_DIR})
foreach(agcStreamGuard IN ITEMS owning_payload owning_array pointer_argument)
string(TOUPPER "${agcStreamGuard}" agcStreamGuardDefine)
add_library(agc_stream_guard_${agcStreamGuard} OBJECT EXCLUDE_FROM_ALL tests/StreamGuards.cpp)
target_include_directories(agc_stream_guard_${agcStreamGuard} PRIVATE ${LIBS_INCLUDE_DIR} ${ANYPS5_VULKAN_HEADERS_INCLUDE_DIR})
target_compile_definitions(agc_stream_guard_${agcStreamGuard} PRIVATE APS5_GUARD_${agcStreamGuardDefine})
add_test(NAME agc_stream_guard_${agcStreamGuard} COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target agc_stream_guard_${agcStreamGuard} --config $<CONFIG>)
endforeach()
set_tests_properties(agc_stream_guard_owning_payload PROPERTIES PASS_REGULAR_EXPRESSION "payload is never destroyed, so it must be trivially destructible")
set_tests_properties(agc_stream_guard_owning_array PROPERTIES PASS_REGULAR_EXPRESSION "arrays are copied as bytes, so their elements must be trivially copyable")
set_tests_properties(agc_stream_guard_pointer_argument PROPERTIES PASS_REGULAR_EXPRESSION "pointer-to-const argument would be read")
set_tests_properties(agc_stream_guard_owning_payload agc_stream_guard_owning_array agc_stream_guard_pointer_argument PROPERTIES RESOURCE_LOCK agc_stream_guard_build TIMEOUT 300)
if(Python3_Interpreter_FOUND)
add_test(NAME agc_command_resolver_sites COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_command_resolver_sites.py)
set_tests_properties(agc_command_resolver_sites PROPERTIES TIMEOUT 20)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ class TraceFormat {
using Clock = std::chrono::steady_clock;
static constexpr std::array<std::string_view, 6> WorkerBusyScopes{"Driver.Packet", "Driver.Suspend", "Driver.EndSubmission", "Driver.Rewind", "Driver.Completion", "Driver.FinisherDrain"};
static constexpr std::string_view WorkerWaitScope = "Driver.WorkerWait";
static constexpr char EncoderPostScope[] = "Encoder.post";
static constexpr char EncoderCommandScope[] = "Encoder.command";
static constexpr char EncoderWaitScope[] = "Encoder.wait";
static constexpr std::string_view WorkerPrefix = "queue worker ";
static constexpr std::size_t TopPhases = 8;

Expand Down Expand Up @@ -695,6 +698,10 @@ class TraceFormat {
std::map<std::string, std::uint64_t> phaseCounts;
std::map<std::string, Clock::duration> waitedPhases;
std::map<std::string, std::uint64_t> ownedCounts;
std::uint64_t encoderPosts = 0;
std::uint64_t encoderCommands = 0;
std::uint64_t encoderWaits = 0;
Clock::duration encoderWait{};
std::map<std::string, std::uint64_t> graphicsCounts;
bool dropped = summary.ownedDrawUnbound != 0;
if (summary.ownedDrawUnbound != 0) ownedCounts["OwnedDraw.unbound"] = summary.ownedDrawUnbound;
Expand All @@ -718,7 +725,12 @@ class TraceFormat {
for (const auto& total : thread.totals) {
const std::string_view scope = total.scope;
if (total.stage == nullptr && std::find(WorkerBusyScopes.begin(), WorkerBusyScopes.end(), scope) != WorkerBusyScopes.end()) busy += total.length;
if (total.stage == nullptr && GraphicsTrackScope(scope)) graphicsCounts[std::string(scope)] += total.count;
if (total.stage == nullptr && scope == EncoderPostScope) encoderPosts += total.count;
else if (total.stage == nullptr && scope == EncoderCommandScope) encoderCommands += total.count;
else if (total.stage == nullptr && scope == EncoderWaitScope) {
encoderWaits += total.count;
encoderWait += total.length;
} else if (total.stage == nullptr && GraphicsTrackScope(scope)) graphicsCounts[std::string(scope)] += total.count;
else if (scope.starts_with("OwnedDraw.") && total.stage == nullptr) ownedCounts[std::string(scope)] += total.count;
else if (scope != WorkerWaitScope) {
const auto name = Name(total.scope, total.stage);
Expand Down Expand Up @@ -777,6 +789,7 @@ class TraceFormat {
output += ':' + std::to_string(value);
}
output += '}';
output += ",\"encoder\":{\"posts\":" + std::to_string(encoderPosts) + ",\"commands\":" + std::to_string(encoderCommands) + ",\"waits\":" + std::to_string(encoderWaits) + ",\"wait_ms_per_frame\":" + number(milliseconds(encoderWait) * perPresent) + '}';
output += ",\"graphics_track\":{";
bool firstGraphics = true;
for (const auto& [name, value] : graphicsCounts) {
Expand Down
9 changes: 6 additions & 3 deletions core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,12 @@ struct VulkanDevice::State {
template<typename TFunction>
TFunction DeviceFunction(Graphics::FunctionName name) const {
++Graphics::DeviceProcLookups();
auto function = reinterpret_cast<TFunction>(deviceProc(device, name.Value()));
auto function = deviceProc(device, name.Value());
if (function == nullptr) {
throw std::runtime_error(std::string("Vulkan device function missing: ") + name.Value());
}
return function;
if (Graphics::IsCommandName(name.Value())) function = Graphics::CommandThunk(name.Value(), function, device);
return reinterpret_cast<TFunction>(function);
}

void CreateWorkgroupMemoryLayout() {
Expand Down Expand Up @@ -1264,6 +1265,7 @@ struct VulkanDevice::State {
}
Graphics::ResetCheckpointSnapshots();
if (compileOnly && device != VK_NULL_HANDLE) {
Graphics::ForgetCommandDevice(device);
reinterpret_cast<PFN_vkDestroyDevice>(deviceProc(device, "vkDestroyDevice"))(device, nullptr);
device = VK_NULL_HANDLE;
}
Expand Down Expand Up @@ -1377,6 +1379,7 @@ struct VulkanDevice::State {
if (settlePool != VK_NULL_HANDLE) destroyPool(device, settlePool, nullptr);
Graphics::DestroyRecordingPools(context);
Graphics::DestroyDeferredObjects(device);
Graphics::ForgetCommandDevice(device);
destroyDevice(device, nullptr);
Graphics::MemoryAccounting::ForgetDevice(device);
}
Expand Down Expand Up @@ -2906,7 +2909,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
if (!GuestMemory::GpuMutex().HeldByThisThread()) gpuLock.lock();
state->placeholderImages = std::make_unique<Graphics::PlaceholderImages>(graphicsContext());
}
state->recorder = std::make_unique<Graphics::Recorder>(graphicsContext(), state->timelineSemaphores);
state->recorder = std::make_unique<Graphics::Recorder>(graphicsContext(), state->timelineSemaphores, state->functionsReady, family);
state->recorder->Activate();
state->context = buildContext();
state->contextReady = true;
Expand Down
119 changes: 119 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/CommandList.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_COMMANDLIST_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_COMMANDLIST_HPP

#include <vulkan/vulkan.h>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string_view>

#define APS5_COMMANDS(X) \
X(CmdBeginQuery) \
X(CmdBeginRenderPass) \
X(CmdBeginRenderingKHR) \
X(CmdBindDescriptorSets) \
X(CmdBindIndexBuffer) \
X(CmdBindPipeline) \
X(CmdBindShadersEXT) \
X(CmdBindVertexBuffers) \
X(CmdBlitImage) \
X(CmdClearAttachments) \
X(CmdClearColorImage) \
X(CmdClearDepthStencilImage) \
X(CmdCopyBuffer) \
X(CmdCopyBufferToImage) \
X(CmdCopyImage) \
X(CmdCopyImageToBuffer) \
X(CmdCopyQueryPoolResults) \
X(CmdDispatch) \
X(CmdDispatchBase) \
X(CmdDispatchIndirect) \
X(CmdDraw) \
X(CmdDrawIndexed) \
X(CmdDrawIndexedIndirect) \
X(CmdDrawIndexedIndirectCountKHR) \
X(CmdDrawIndirect) \
X(CmdDrawIndirectCountKHR) \
X(CmdDrawMeshTasksEXT) \
X(CmdDrawMeshTasksIndirectEXT) \
X(CmdEndQuery) \
X(CmdEndRenderPass) \
X(CmdEndRenderingKHR) \
X(CmdExecuteCommands) \
X(CmdFillBuffer) \
X(CmdPipelineBarrier) \
X(CmdPushConstants) \
X(CmdPushDescriptorSetKHR) \
X(CmdResetQueryPool) \
X(CmdResolveImage) \
X(CmdSetCheckpointNV) \
X(CmdSetColorWriteMaskEXT) \
X(CmdSetCullMode) \
X(CmdSetCullModeEXT) \
X(CmdSetDepthBias) \
X(CmdSetDepthBias2EXT) \
X(CmdSetDepthBiasEnableEXT) \
X(CmdSetDepthBounds) \
X(CmdSetDepthBoundsTestEnable) \
X(CmdSetDepthBoundsTestEnableEXT) \
X(CmdSetDepthCompareOp) \
X(CmdSetDepthCompareOpEXT) \
X(CmdSetDepthTestEnable) \
X(CmdSetDepthTestEnableEXT) \
X(CmdSetDepthWriteEnable) \
X(CmdSetDepthWriteEnableEXT) \
X(CmdSetFrontFace) \
X(CmdSetFrontFaceEXT) \
X(CmdSetScissor) \
X(CmdSetScissorWithCount) \
X(CmdSetScissorWithCountEXT) \
X(CmdSetStencilCompareMask) \
X(CmdSetStencilOp) \
X(CmdSetStencilOpEXT) \
X(CmdSetStencilReference) \
X(CmdSetStencilTestEnable) \
X(CmdSetStencilTestEnableEXT) \
X(CmdSetStencilWriteMask) \
X(CmdSetViewport) \
X(CmdSetViewportWithCount) \
X(CmdSetViewportWithCountEXT) \
X(CmdUpdateBuffer) \
X(CmdWriteBufferMarkerAMD) \
X(CmdWriteTimestamp)

namespace AgcDriver::Graphics {

enum class CommandId : std::uint16_t {
#define APS5_COMMAND_ID(name) name,
APS5_COMMANDS(APS5_COMMAND_ID)
#undef APS5_COMMAND_ID
Count
};

inline constexpr std::size_t CommandCount = static_cast<std::size_t>(CommandId::Count);

struct DeviceFunctions;

struct CommandFunctions {
#define APS5_COMMAND_MEMBER(name) PFN_vk##name name = nullptr;
APS5_COMMANDS(APS5_COMMAND_MEMBER)
#undef APS5_COMMAND_MEMBER
const DeviceFunctions* listed = nullptr;
};

std::span<const std::string_view> CommandNames();
bool IsCommandName(std::string_view name) noexcept;
CommandId CommandFor(std::string_view name);
void ResolveCommandFunctions(CommandFunctions& functions, VkDevice device, PFN_vkGetDeviceProcAddr resolve);
const CommandFunctions& StreamedCommands();
PFN_vkVoidFunction CommandThunk(std::string_view name, PFN_vkVoidFunction real, VkDevice device = VK_NULL_HANDLE);
void ForgetCommandDevice(VkDevice device);
std::size_t CommandDeviceEntries(CommandId id) noexcept;
std::size_t CommandDeviceStorage(CommandId id) noexcept;
bool IsCommandThunk(std::string_view name, PFN_vkVoidFunction function) noexcept;
std::size_t CommandThunkSlots(CommandId id) noexcept;
bool CommandStreams(CommandId id) noexcept;

}

#endif
Loading