Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -14,7 +14,6 @@
#include <optional>
#include <thread>
#include <span>
#include <unordered_map>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -163,7 +162,7 @@ class DrawFinisher {
std::uint64_t labelAddress = 0;
std::vector<std::byte> labelBytes;
bool countedUnknown = false;
std::vector<Range> countedWrites;
bool counted = false;
};
struct PendingBlockCounts {
std::uint64_t answered = 0, verified = 0;
Expand Down Expand Up @@ -203,7 +202,8 @@ class DrawFinisher {
void countPendingWrites(Pending& held);
void uncountPendingWrites(Pending& held);
bool pendingBlocksClear(std::span<const Range> ranges) const;
std::unordered_map<std::uint64_t, std::uint32_t> pendingWriteBlocks;
static constexpr std::size_t PendingWriteSlots = 4096;
std::array<std::uint32_t, PendingWriteSlots> pendingWriteBlocks{};
std::size_t pendingUnknownJobs = 0;
std::size_t pendingWideRanges = 0;
std::vector<Job> ran;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,18 @@ DrawFinisher::PendingBlockCounts DrawFinisher::PendingBlockTotals() {

void DrawFinisher::countPendingWrites(Pending& held) {
held.countedUnknown = held.unknown;
held.countedWrites.clear();
held.counted = !held.unknown;
if (held.unknown) {
++pendingUnknownJobs;
return;
}
held.countedWrites = held.writes;
for (const auto& range : held.countedWrites) {
for (const auto& range : held.writes) {
if (range.second <= range.first) continue;
if (pendingWriteWide(range)) {
++pendingWideRanges;
continue;
}
for (auto block = range.first >> PendingWriteBlockShift; block <= (range.second - 1u) >> PendingWriteBlockShift; ++block) ++pendingWriteBlocks[block];
for (auto block = range.first >> PendingWriteBlockShift; block <= (range.second - 1u) >> PendingWriteBlockShift; ++block) ++pendingWriteBlocks[block % PendingWriteSlots];
}
}

Expand All @@ -203,18 +202,16 @@ void DrawFinisher::uncountPendingWrites(Pending& held) {
held.countedUnknown = false;
return;
}
for (const auto& range : held.countedWrites) {
if (!held.counted) return;
for (const auto& range : held.writes) {
if (range.second <= range.first) continue;
if (pendingWriteWide(range)) {
--pendingWideRanges;
continue;
}
for (auto block = range.first >> PendingWriteBlockShift; block <= (range.second - 1u) >> PendingWriteBlockShift; ++block) {
const auto found = pendingWriteBlocks.find(block);
if (found != pendingWriteBlocks.end() && --found->second == 0u) pendingWriteBlocks.erase(found);
}
for (auto block = range.first >> PendingWriteBlockShift; block <= (range.second - 1u) >> PendingWriteBlockShift; ++block) --pendingWriteBlocks[block % PendingWriteSlots];
}
held.countedWrites.clear();
held.counted = false;
}

bool DrawFinisher::pendingBlocksClear(std::span<const Range> ranges) const {
Expand All @@ -223,7 +220,7 @@ bool DrawFinisher::pendingBlocksClear(std::span<const Range> ranges) const {
if (range.second <= range.first) continue;
if (pendingWriteWide(range)) return false;
for (auto block = range.first >> PendingWriteBlockShift; block <= (range.second - 1u) >> PendingWriteBlockShift; ++block) {
if (pendingWriteBlocks.contains(block)) return false;
if (pendingWriteBlocks[block % PendingWriteSlots] != 0u) return false;
}
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The code reads environment names through `getenv`, `IsEnvironmentSet`, `kibSetti
| `APS5_IMAGE_SLABS` | presence | `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp` | | suballocates small optimal-tiled sampled and storage images from shared blocks; off by default since #22216 (DEVICE_LOST in PPSA06866 on NVIDIA) |
| `APS5_KEEP_SPECIALIZED_MIB` | integer | `core/shader/recompiler/Recompiler.cpp` | 0 | MiB of the most recently specialized SPIR-V modules held in memory, so a variant materialized again soon after its last result was released is not specialized again; unset or `0` holds none and releases a module's words with its last result; a value that is not a whole number throws, and a value too large to shift into bytes is capped |
| `APS5_LOAD_EXEC_STANDARD_ERROR` | string | `core/libs/tests/GuestSystemServiceLoadExecStandardError.cpp` | | marker that the standard-error load-exec test sets in its child process to choose a mode, `list` or `none`; not a product setting |
| `APS5_NO_PENDING_WRITE_BLOCKS` | presence | `core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp` | | runtime switch: the draw finisher answers every pending-overlap query by walking its pending jobs, as before. Unset, it keeps under its lock a count per 1 MiB block of the write ranges of its pending jobs, a count of pending jobs with unknown writes and a count of ranges wider than 256 blocks, kept at every enqueue and completion, and answers no overlap without the walk when no job has unknown writes, no range is wide and no block of the queried ranges is counted |
| `APS5_NO_PENDING_WRITE_BLOCKS` | presence | `core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp` | | runtime switch: the draw finisher answers every pending-overlap query by walking its pending jobs, as before. Unset, it keeps under its lock a count per 1 MiB block of the write ranges of its pending jobs (in a fixed table of 4096 counts, which blocks 4 GiB apart share), a count of pending jobs with unknown writes and a count of ranges wider than 256 blocks, kept at every enqueue and completion, and answers no overlap without the walk when no job has unknown writes, no range is wide and no block of the queried ranges is counted |
| `APS5_NO_STAGE_POOL_REUSE` | presence | `core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp` | | runtime switch: a device-local staging shadow (written or atomic elements of a host import) is refused before the buffer pool is asked whenever the device-local heap is within an eighth of its reported budget, instead of first reusing the released device-local buffer memory the pool retains; a shadow that needs a new allocation there is refused either way; APS5_AB can toggle it |
| `APS5_NO_WIDE_TABLE_COPY_HLE` | presence | `core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp` | | runs the descriptor-table copy kernel of 11 instruction words that loads and stores 16 bytes per thread as a shader; without it a dispatch of that kernel (2 user SGPRs pointing at two buffer descriptors, 64x1x1, group id x only, launched in whole groups) whose descriptors both have stride 16, no swizzle, the descriptor word 0x0004bfac and a nonzero base, with the source holding the records, runs as one buffer copy of min(groups x 64, destination records) x 16 bytes; `APS5_AB` can switch it |
| `APS5_SKIP_TIMING_TESTS` | string | `core/libs/prx/libSceAgcDriver/tests/Pm4.cpp`, `core/libs/tests/PreciseWait.cpp` | | treats the timing tests' runner as preempted, so they skip without probing the clock, and drops the latency bound of `agc_driver_pm4_order_signal`; an empty value or one starting with 0 leaves the probe on |
Expand Down
Loading