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
2 changes: 1 addition & 1 deletion runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ if(TARGET Vulkan::Headers)
target_compile_definitions(d3d12_unmapped_vsharp_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX LEONIDA_VULKAN_DEVICE)
target_compile_options(d3d12_unmapped_vsharp_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_unmapped_vsharp COMMAND d3d12_unmapped_vsharp_test)
set_tests_properties(d3d12_unmapped_vsharp PROPERTIES SKIP_RETURN_CODE 77 ENVIRONMENT "LEONIDA_CONSOLE_FIX_US=0")
set_tests_properties(d3d12_unmapped_vsharp PROPERTIES SKIP_RETURN_CODE 77)
add_executable(d3d12_indirect_zero_test test/d3d12_indirect_zero_test.cpp)
target_link_libraries(d3d12_indirect_zero_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
target_compile_definitions(d3d12_indirect_zero_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
Expand Down
2 changes: 1 addition & 1 deletion runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ ones marked *diagnostic* only add log lines or exist to compare a run with and w
| `LEONIDA_WINDOW` | unset | `WxH` resizes the title's window when the presenter attaches to it. |
| `LEONIDA_PRESENT_DUMP` | unset | *Diagnostic.* `DIR` or `DIR,N` writes every Nth presented frame (60 by default) as a PNG into `DIR` (`src/present_dump.h`). The files are pictures of the title: keep them out of commits, issues and pull requests. |
| `LEONIDA_LOCAL_SPEECH` | unset | `1` forwards the title's speech-synthesis calls to the host's installed `xgameruntime.dll` where there is one. Unset, and wherever that library is missing, the silent voice answers. No profile sets it. |
| `LEONIDA_CONSOLE_FIX_US` | `4000` | Microseconds one submission may spend fixing the changed slots of a console descriptor heap's copy. Past it, each further changed slot is written as a null descriptor and queued for `LEONIDA_CONSOLE_RETRY_US`, so a shader reads it as empty until its turn comes. `0` removes the limit. |
| `LEONIDA_CONSOLE_FIX_US` | `0` | Microseconds one submission may spend fixing the changed slots of a console descriptor heap's copy; `0` sets no limit. Past it, each further changed slot is written as a null descriptor and queued for `LEONIDA_CONSOLE_RETRY_US`, so a shader reads it as empty until its turn comes: a limit changes results, and can hang the GPU. |
| `LEONIDA_CONSOLE_RETRY_US` | `500` | Microseconds one submission may spend retrying, round robin, the console heap slots not settled yet (a T# whose texture does not exist yet, or one deferred by `LEONIDA_CONSOLE_FIX_US`). `0` retries all of them at every submission. |
| `LEONIDA_SHADOW_ALIAS_MS` | `0` | The shortest time, in milliseconds, between two copies of the title-memory pages that XMem maps at two addresses (no write guard can watch them) into the slot-133 shadows and title windows. `0` copies them at every submission; a larger value lets a GPU read of them be up to that many milliseconds behind the title's writes. |
| `LEONIDA_REFRESH_PER_FRAME` | `0` | Trades correctness for speed. `1`: the slot-133 shadows, title windows and geometry copies are brought up to date only by the first submission after each present, not by every submission; `2`: the console descriptor heaps too. A GPU read of them can then be a frame behind the title's writes (wrong pixels). `0` refreshes all of them at every submission. |
Expand Down
11 changes: 6 additions & 5 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3290,15 +3290,16 @@ struct DeviceState {

// The slots on [offset, offset + bytes) of a heap copy's mirror, just brought up to date: each that differs from
// what its arena slot was made from is written there and fixed up.
// Past LEONIDA_CONSOLE_FIX_US of fixing in one submission (4000 by default, 0: no limit), a changed slot is written
// as a null descriptor and left to retry_console_slots: after the story load the title rewrote up to 3.7 MiB of
// its heap at once and one submission spent 28 s fixing it (speed-8). A shader reads such a slot as empty until
// its turn comes.
// LEONIDA_CONSOLE_FIX_US limits the fixing in one submission (0, the default: no limit). Past it a changed slot is
// written as a null descriptor and left to retry_console_slots: after the story load the title rewrote up to
// 3.7 MiB of its heap at once and one submission spent 28 s fixing it (speed-8). A shader reads such a slot as
// empty until its turn comes, so a limit changes results: at the first world frame lib_cs_01144 read the size it
// divides by from a nulled buffer slot and its loops never ended, which lost the device.
void fix_console_slots(ConsoleHeap& heap, std::size_t offset, std::size_t bytes) {
static const std::uint64_t budget_us = [] {
char text[16] = {};
const DWORD n = GetEnvironmentVariableA("LEONIDA_CONSOLE_FIX_US", text, sizeof(text));
return n > 0 && n < sizeof(text) ? std::strtoull(text, nullptr, 10) : 4000ull;
return n > 0 && n < sizeof(text) ? std::strtoull(text, nullptr, 10) : 0ull;
}();
const std::size_t end = std::min<std::size_t>(offset + bytes, std::size_t(heap.bytes));
if (!heap.resource_heap) {
Expand Down
Loading