Triforce v0.8.0

Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-25 10:21:32 -06:00
parent 861702476a
commit 4fa4f9188b
881 changed files with 179428 additions and 15581 deletions

View File

@@ -15,6 +15,7 @@
#include <vector>
#include "common/common_types.h"
#include "shader_recompiler/frontend/ampere/geometry_exit.h"
#include "shader_recompiler/frontend/ampere/program_address_map.h"
#include "shader_recompiler/frontend/ampere/register_pressure.h"
namespace Shader::Ampere {
@@ -104,13 +105,23 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
const u32 target = relocation.output_target != ~0U ? relocation.output_target :
result.source_instruction_offsets[static_cast<size_t>(relocation.target)];
const s64 relative = s64{address_of(target)} - address_of(relocation.output_index) - 8;
if (relative < -0x800000 || relative > 0x7fffff) return fail(index, "lowered branch distance");
result.instructions[relocation.output_index] |= (static_cast<u64>(relative) & 0xffffff) << 20;
u64& word = result.instructions[relocation.output_index];
if (relative < -0x800000 || relative > 0x7fffff) {
// ((Triforce) past the reach of BRA and CAL (a 24-bit offset, 8 MiB either way: about 786,000 lowered
// instructions): their absolute forms, JMP and JCAL, which hold the target's address in 32 bits (20-51;
// the frontend reads them so, IsAbsoluteJump). The predicate and the flow test stay as they are
const u64 op = word >> 52;
if (op != 0xe24 && op != 0xe26) return fail(index, "lowered branch distance");
word = (word & ~(u64{0xfff} << 52)) | (u64{op == 0xe24 ? 0xe21U : 0xe22U} << 52) |
(u64{address_of(target)} << 20);
continue;
}
word |= (static_cast<u64>(relative) & 0xffffff) << 20;
}
result.source_size = (index + 1) * sizeof(Instruction);
return result;
};
if (code.empty() || code.size() > 65536) return fail(0, "invalid native program size");
if (code.empty() || code.size() > MaximumNativeInstructions) return fail(0, "invalid native program size");
std::optional<GeometryExitEnvelope> geometry_exit;
if (code.front().Bits(0, 12) == 0x34e) {
if (!geometry_stage) return fail(0, "native program counter load outside geometry stage");
@@ -3823,11 +3834,14 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
const s64 relative = static_cast<s64>(raw << 14) >> 14;
if (s64{index} * 16 + 16 + relative != 0)
return fail(index, "native computed branch relative base");
const s64 offset = -s64{address_of(static_cast<u32>(result.instructions.size()))} - 8;
if (offset < -0x800000) return fail(index, "native computed branch range");
// ((Triforce) BRX goes to the table's value plus its own address plus its offset, which reaches back only 8 MiB
// (24 bits). Past that, JMX: the value plus the offset alone, -8 (the frontend's AnalyzeBRX adds the 8 back)
const s64 back = -s64{address_of(static_cast<u32>(result.instructions.size()))} - 8;
const bool absolute = back < -0x800000;
const s64 offset = absolute ? -8 : back;
const u32 source = opcode == 0x958 ? uniform_register(insn.Bits(24, 8)) : insn.Bits(24, 8);
if (source == ~0U) return fail(index, "native uniform computed branch source");
emit(0xe25000000000000fULL | predicate | (u64{source} << 8) |
emit((absolute ? 0xe20000000000000fULL : 0xe25000000000000fULL) | predicate | (u64{source} << 8) |
((static_cast<u64>(offset) & 0xffffff) << 20));
computed_branch = true;
break;
@@ -3928,7 +3942,17 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
if (target < 0 || target % 16) return fail(index, "native branch destination alignment");
relocations.push_back({static_cast<u32>(result.instructions.size()), target / 16});
emit(0xe24000000000000fULL | branch_predicate);
if (computed_branch && target == s64{index} * 16 && branch_predicate == (u64{7} << 16))
// ((Triforce) a loop that leaves only by predicated EXITs: the program ends at the closing self-branch after the
// loop's unconditional jump back, which nothing falls into (one of OoT's compute programs, its EXITs all @P0)
const auto unconditional_jump = [&](const Instruction& before) {
const u32 op = before.Bits(0, 12);
return before.Bits(12, 4) == 7 && ((op == 0x947 && before.Bits(87, 4) == 7) || op == 0x94d);
};
// (and only when no branch so far goes past it: code a branch reaches behind it is the program's still)
const bool after_jump = index > 0 && call_targets.empty() && unconditional_jump(code[index - 1]) &&
std::none_of(relocations.begin(), relocations.end(),
[&](const auto& r) { return r.target > s64{index}; });
if ((computed_branch || after_jump) && target == s64{index} * 16 && branch_predicate == (u64{7} << 16))
return finish(index); // the closing self-branch
break;
}
@@ -3963,7 +3987,9 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
const bool write = opcode == 0x927;
const u32 region = insn.Bits(76, 2);
const bool output = insn.Bits(79, 1) != 0;
if ((insn.words[2] & ~0xf800U) != 0 || (region != 0 && region != 3) || write != output ||
// ((Triforce) a read may be of the output region (.O): the program reading back what it wrote (one of OoT's
// task programs reads its payload so); a write is always to it
if ((insn.words[2] & ~0xf800U) != 0 || (region != 0 && region != 3) || (write && !output) ||
(!write && region != 3) || (!write && dest == 255))
return fail(index, "native stage buffer access mode");
emit(0xefc0000000000000ULL | predicate | (write ? u64{insn.Bits(32, 8)} : dest) |

View File

@@ -16,6 +16,7 @@
#include <string_view>
#include <vector>
#include "common/common_types.h"
#include "shader_recompiler/frontend/ampere/program_address_map.h" // ((Triforce) Shader::Ampere::MaximumNativeInstructions)
namespace Shader::AmpereRegmap {
@@ -166,13 +167,26 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
if (relocation.target > index) return fail(index, "native branch or call leaves captured program");
const u32 target = result.source_instruction_offsets[static_cast<size_t>(relocation.target)];
const s64 relative = s64{address_of(target)} - address_of(relocation.output_index) - 8;
if (relative < -0x800000 || relative > 0x7fffff) return fail(index, "lowered branch distance");
result.instructions[relocation.output_index] |= (static_cast<u64>(relative) & 0xffffff) << 20;
u64& word = result.instructions[relocation.output_index];
if (relative < -0x800000 || relative > 0x7fffff) {
// ((Triforce) past the reach of BRA and CAL (a 24-bit offset, 8 MiB either way: about 786,000 lowered
// instructions): their absolute forms, JMP and JCAL, which hold the target's address in 32 bits (20-51;
// the frontend reads them so, IsAbsoluteJump). The predicate and the flow test stay as they are
const u64 op = word >> 52;
if (op != 0xe24 && op != 0xe26) return fail(index, "lowered branch distance");
word = (word & ~(u64{0xfff} << 52)) | (u64{op == 0xe24 ? 0xe21U : 0xe22U} << 52) |
(u64{address_of(target)} << 20);
continue;
}
word |= (static_cast<u64>(relative) & 0xffffff) << 20;
}
result.source_size = (index + 1) * sizeof(Instruction);
return result;
};
if (code.empty() || code.size() > 65536) return fail(0, "invalid native program size");
if (code.empty() || code.size() > Shader::Ampere::MaximumNativeInstructions) return fail(0, "invalid native program size");
// ((Triforce) A shared memory store (STS) not yet followed by a barrier: an LDS after it may read what another lane of
// the warp stored (see LDS below)
bool shared_store_pending = false;
for (u32 index = 0; index < code.size(); ++index) {
auto insn = code[index];
result.source_instruction_offsets.push_back(static_cast<u32>(result.instructions.size()));
@@ -230,7 +244,11 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
opcode == 0x927 || opcode == 0xb9b || opcode == 0x59f || opcode == 0x983 ||
opcode == 0x98e || opcode == 0xb6c || opcode == 0x9a8 || (renameable & (1U << f));
if (reg >= 255 || reg + 3 < reserved_base) continue; // (a quad below may reach up)
if (register_field && reg >= reserved_base) any_high = true;
// A vector load can write reserved registers even when its first destination is below them.
const bool load_dest = f == 0 && (opcode == 0x381 || opcode == 0x981);
const u32 load_size = insn.Bits(73, 3);
const u32 width = load_dest && load_size == 6 ? 4U : load_dest && load_size == 5 ? 2U : 1U;
if (register_field && reg + width > reserved_base) any_high = true;
}
for (u32 f = 0; f < 4 && any_high; ++f) {
const u32 bit = bits[f], reg = insn.Bits(bit, 8);
@@ -1589,6 +1607,7 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
case 0xb1d: // BAR.SYNC 0 (bit 80: .DEFER_BLOCKING), full workgroup.
if (insn.words[1] || (insn.words[2] & ~0x10000U) || native_predicate != 7)
return fail(index, "native workgroup barrier mode");
shared_store_pending = false;
emit(0xf0a8000000000000ULL | predicate | (u64{1} << 43) |
(u64{1} << 44) | (u64{1} << 39) | (u64{7} << 39));
break;
@@ -1611,6 +1630,22 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
address = 250;
}
const u32 data = opcode == 0x388 ? insn.Bits(32, 8) : static_cast<u32>(dest);
// ((Triforce) A warp stores to shared memory (STS) and reads it back (LDS) with no barrier between: the Switch runs
// a warp's shared memory accesses in order, Vulkan orders another lane's store and this lane's load only through a
// barrier, and the driver's compiler may move them past each other (OoT's 4/3 gameplay network on NVIDIA's
// cooperative matrix path: 16x2 bright bars). As for LDSM, and as lower_to_maxwell.h has it: a subgroup barrier
// before the first LDS after an STS, only where the LDS is not predicated (every lane of the warp reaches it).
// RX_VK_SHARED_NO_LDS_BARRIER=1: none, as before
static const bool lds_barrier = [] {
const char* const e = std::getenv("RX_VK_SHARED_NO_LDS_BARRIER");
return !(e && *e && *e != '0');
}();
if (opcode == 0x388) {
shared_store_pending = true;
} else if (shared_store_pending && lds_barrier && native_predicate == 7) {
emit(0xef98000000000000ULL | predicate | (u64{1} << 20)); // (MEMBAR, bit 20: barrier_operations.cpp)
shared_store_pending = false;
}
emit((opcode == 0x388 ? 0xef58000000000000ULL : 0xef48000000000000ULL) |
predicate | data | (u64{address} << 8) | (u64{insn.Bits(40, 24)} << 20) |
(u64{width} << 48));
@@ -1723,9 +1758,12 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
return fail(index, "native matrix load mode");
u32 address = insn.Bits(24, 8);
const u64 offset = insn.Bits(40, 24);
// ((Triforce) An address the results overwrite is copied first, to R254: the paths below use R246-R253, and R253
// (the copy's old place) is where each matrix's row address is shuffled to, so matrices 1-3 of an .x2/.x4 shuffled
// matrix 0's address and read the wrong rows (as lower_to_maxwell.h has it: gpu/vk/tests/ldsm_address_test.cpp)
if (address != 255 && address >= dest && address < dest + count) {
emit(0x5c10000000000000ULL | predicate | 253 | (u64{address} << 8) | (u64{255} << 20));
address = 253;
emit(0x5c10000000000000ULL | predicate | 254 | (u64{address} << 8) | (u64{255} << 20));
address = 254;
}
// (hookshot) A warp stores its tiles (STS) and reads them back with LDSM, often with no BAR between: the Switch runs a
// warp's shared memory accesses in order, Vulkan orders another lane's store and this lane's load only through a
@@ -3275,11 +3313,14 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
const s64 relative = static_cast<s64>(raw << 14) >> 14;
if (s64{index} * 16 + 16 + relative != 0)
return fail(index, "native computed branch relative base");
const s64 offset = -s64{address_of(static_cast<u32>(result.instructions.size()))} - 8;
if (offset < -0x800000) return fail(index, "native computed branch range");
// ((Triforce) BRX goes to the table's value plus its own address plus its offset, which reaches back only 8 MiB
// (24 bits). Past that, JMX: the value plus the offset alone, -8 (the frontend's AnalyzeBRX adds the 8 back)
const s64 back = -s64{address_of(static_cast<u32>(result.instructions.size()))} - 8;
const bool absolute = back < -0x800000;
const s64 offset = absolute ? -8 : back;
const u32 source = opcode == 0x958 ? uniform_register(insn.Bits(24, 8)) : insn.Bits(24, 8);
if (source == ~0U) return fail(index, "native uniform computed branch source");
emit(0xe25000000000000fULL | predicate | (u64{source} << 8) |
emit((absolute ? 0xe20000000000000fULL : 0xe25000000000000fULL) | predicate | (u64{source} << 8) |
((static_cast<u64>(offset) & 0xffffff) << 20));
computed_branch = true;
break;
@@ -3406,7 +3447,17 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
if (target < 0 || target % 16) return fail(index, "native branch destination alignment");
relocations.push_back({static_cast<u32>(result.instructions.size()), target / 16});
emit(0xe24000000000000fULL | branch_predicate);
if (computed_branch && target == s64{index} * 16 && branch_predicate == (u64{7} << 16))
// ((Triforce) a loop that leaves only by predicated EXITs: the program ends at the closing self-branch after the
// loop's unconditional jump back, which nothing falls into (one of OoT's compute programs, its EXITs all @P0)
const auto unconditional_jump = [&](const Instruction& before) {
const u32 op = before.Bits(0, 12);
return before.Bits(12, 4) == 7 && ((op == 0x947 && before.Bits(87, 4) == 7) || op == 0x94d);
};
// (and only when no branch so far goes past it: code a branch reaches behind it is the program's still)
const bool after_jump = index > 0 && call_targets.empty() && unconditional_jump(code[index - 1]) &&
std::none_of(relocations.begin(), relocations.end(),
[&](const auto& r) { return r.target > s64{index}; });
if ((computed_branch || after_jump) && target == s64{index} * 16 && branch_predicate == (u64{7} << 16))
return finish(index); // the closing self-branch
break;
}
@@ -3419,7 +3470,9 @@ inline LoweredProgram LowerToMaxwellWith(std::span<const Instruction> code, u32
const bool write = opcode == 0x927;
const u32 region = insn.Bits(76, 2);
const bool output = insn.Bits(79, 1) != 0;
if ((insn.words[2] & ~0xf800U) != 0 || (region != 0 && region != 3) || write != output ||
// ((Triforce) a read may be of the output region (.O): the program reading back what it wrote (one of OoT's
// task programs reads its payload so); a write is always to it
if ((insn.words[2] & ~0xf800U) != 0 || (region != 0 && region != 3) || (write && !output) ||
(!write && region != 3) || (!write && dest == 255))
return fail(index, "native stage buffer access mode");
emit(0xefc0000000000000ULL | predicate | (write ? u64{insn.Bits(32, 8)} : dest) |

View File

@@ -8,6 +8,12 @@
namespace Shader::Ampere {
constexpr u64 NativeAddressMapMagic = 0x50414d4e4544454eULL;
// (Triforce) The most native instructions a program may have, for the capture, the lowering and this map: as many as fit
// in the largest code area the renderer reads (a control section whose area ends past 16 MiB is refused: stage_head,
// gpu/vk/vk_shader.cpp), 16 bytes each. The GPU has no instruction count of its own: Maxwell and Ampere address a program
// by a 32-bit offset in its program region, and an Ampere BRA's offset has 50 bits. (65,536, 1 MiB, refused compute
// program 79116b290d46542f, 0x104680 bytes of code, on every platform)
constexpr u32 MaximumNativeInstructions = (16u << 20) / 16;
inline bool HasNativeAddressMap(std::span<const u64> code) {
return code.size() >= 2 && code.back() == NativeAddressMapMagic;
}
@@ -20,7 +26,7 @@ inline void AppendNativeAddressMap(std::vector<u64>& code, std::span<const u32>
inline std::optional<u32> NativeProgramAddress(std::span<const u64> code, u32 address) {
if (!HasNativeAddressMap(code) || address % 16) return {};
const u64 count = code[code.size() - 2];
if (!count || count > 65536 || count + 2 > code.size() || address / 16 >= count) return {};
if (!count || count > MaximumNativeInstructions || count + 2 > code.size() || address / 16 >= count) return {};
const size_t start = code.size() - static_cast<size_t>(count) - 2;
const u64 target = code[start + address / 16];
if (target < 0x50 || target >= start * 8 || target % 8 || target % 32 == 0) return {};

View File

@@ -3,12 +3,14 @@
#pragma once
#include "shader_recompiler/frontend/ampere/lower_to_maxwell.h"
#include "shader_recompiler/frontend/ampere/program_address_map.h"
namespace Shader::Ampere {
class ProgramCaptureState {
public:
enum class Result { Continue, Complete, InvalidTarget };
static constexpr u32 MaximumInstructions = 65536;
// ((Triforce) a target past the largest program, program_address_map.h; it was 65,536 instructions, 1 MiB)
static constexpr u32 MaximumInstructions = MaximumNativeInstructions;
Result Observe(const Instruction& instruction, u32 index) {
const u32 opcode = instruction.Bits(0, 12);

View File

@@ -337,6 +337,10 @@ U32 IREmitter::IsbeRead(const U32& address) {
return Inst<U32>(Opcode::IsbeRead, address);
}
U32 IREmitter::IsbeReadOutput(const U32& address) {
return Inst<U32>(Opcode::IsbeReadOutput, address);
}
void IREmitter::IsbeWriteAttribute(const U32& address, const U32& value) {
Inst(Opcode::IsbeWriteAttribute, address, value);
}

View File

@@ -89,6 +89,7 @@ public:
void SetPatch(Patch patch, const F32& value);
[[nodiscard]] U32 IsbeRead(const U32& address);
[[nodiscard]] U32 IsbeReadOutput(const U32& address); // (hookshot) the output region read back
void IsbeWriteAttribute(const U32& address, const U32& value);
void IsbeWriteMapU8(const U32& address, const U32& value);
void IsbeWriteMapU32(const U32& address, const U32& value);

View File

@@ -10,7 +10,7 @@ namespace Shader::IR {
namespace Detail {
OpcodeMeta META_TABLE[542] = {
OpcodeMeta META_TABLE[NUM_OPCODES] = {
#define OPCODE(name_token, type_token, ...) \
{ \
.name{#name_token}, \
@@ -21,7 +21,7 @@ OpcodeMeta META_TABLE[542] = {
#undef OPCODE
};
u8 NUM_ARGS[542] = {
u8 NUM_ARGS[NUM_OPCODES] = {
#define OPCODE(name_token, type_token, ...) u8(CalculateNumArgsOf(Opcode::name_token)),
#include "opcodes.inc"
#undef OPCODE

View File

@@ -20,6 +20,7 @@ enum class Opcode {
#define OPCODE(name, ...) name,
#include "opcodes.inc"
#undef OPCODE
Count,
};
namespace Detail {
@@ -57,12 +58,13 @@ static constexpr Type F64x2{Type::F64x2};
static constexpr Type F64x3{Type::F64x3};
static constexpr Type F64x4{Type::F64x4};
extern OpcodeMeta META_TABLE[542];
inline constexpr size_t NUM_OPCODES = static_cast<size_t>(Opcode::Count);
extern OpcodeMeta META_TABLE[NUM_OPCODES];
constexpr size_t CalculateNumArgsOf(Opcode op) noexcept {
const auto& arg_types = META_TABLE[size_t(op)].arg_types;
return size_t(std::distance(arg_types.begin(), std::ranges::find(arg_types, Type::Void)));
}
extern u8 NUM_ARGS[542];
extern u8 NUM_ARGS[NUM_OPCODES];
} // namespace Detail
/// Get return type of an opcode

View File

@@ -50,6 +50,7 @@ OPCODE(SetAttributeIndexed, Void, U32,
OPCODE(GetPatch, F32, Patch, )
OPCODE(SetPatch, Void, Patch, F32, )
OPCODE(IsbeRead, U32, U32, )
OPCODE(IsbeReadOutput, U32, U32, )
OPCODE(IsbeWriteAttribute, Void, U32, U32, )
OPCODE(IsbeWriteMapU8, Void, U32, U32, )
OPCODE(IsbeWriteMapU32, Void, U32, U32, )
@@ -100,6 +101,7 @@ OPCODE(WriteGlobal64, Void, Opaq
OPCODE(WriteGlobal128, Void, Opaque, U32x4, )
// Storage buffer operations
OPCODE(StorageBufferLength, U32, U32, )
OPCODE(LoadStorageU8, U32, U32, U32, )
OPCODE(LoadStorageS8, U32, U32, U32, )
OPCODE(LoadStorageU16, U32, U32, U32, )

View File

@@ -127,7 +127,7 @@ void TranslatorVisitor::ISBERD(u64 insn) {
// nx2 pseudo instruction for the ISBERD/ISBEWR of Switch 2 task and mesh programs (see
// frontend/ampere/lower_to_maxwell.h). Addresses are linear bytes in the stage buffer: reads come
// from the input attribute region, writes go to the output attribute or map region.
// from the input attribute region (or with .O the output one, read back), writes go to the output attribute or map region.
void TranslatorVisitor::ISBE_nx2(u64 insn) {
union {
u64 raw;
@@ -136,6 +136,7 @@ void TranslatorVisitor::ISBE_nx2(u64 insn) {
BitField<20, 24, u64> offset;
BitField<44, 1, u64> is_32;
BitField<45, 1, u64> attribute;
BitField<47, 1, u64> output;
BitField<48, 1, u64> write;
} const isbe{insn};
@@ -145,7 +146,8 @@ void TranslatorVisitor::ISBE_nx2(u64 insn) {
}
const IR::U32 address{ir.IAdd(X(isbe.address_reg), ir.Imm32(static_cast<u32>(isbe.offset)))};
if (isbe.write == 0) {
X(isbe.reg, ir.IsbeRead(address));
// (hookshot) .O: the program reads back its own output region (a task's payload, a mesh's attributes)
X(isbe.reg, isbe.output != 0 ? ir.IsbeReadOutput(address) : ir.IsbeRead(address));
return;
}
const IR::U32 value{X(isbe.reg)};

View File

@@ -4,6 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <atomic>
#include <algorithm>
#include <array>
#include <bitset>
@@ -29,6 +30,7 @@ extern thread_local u32 g_nvn2_compute_ssbo_base;
extern thread_local u32 g_nvn2_compute_ssbo_count;
extern thread_local u32 g_nvn2_compute_layout_end;
extern thread_local bool g_nvn2_miss_log_this;
extern std::atomic<u32> g_table_check_unchecked;
}
namespace Shader::Maxwell {
@@ -196,8 +198,17 @@ void AddNVNStorageBuffers(IR::Program& program) {
static const bool miss_log{std::getenv("RX_VK_MISS_LOG") != nullptr && std::atoi(std::getenv("RX_VK_MISS_LOG")) != 0};
// (compute only: the driver crashed compiling a mesh program with it; and only the program vk_shader.cpp names when
// RX_VK_MISS_LOG_PROG is set: Optimization::g_nvn2_miss_log_this)
if (miss_log && (program.stage == Stage::Compute || program.stage == Stage::Mesh || program.stage == Stage::Task) &&
Optimization::g_nvn2_miss_log_this && descs.size() < Info::MAX_SSBOS) {
// (Triforce, RX_VK_GP_TABLE=2: the vertex, fragment, compute, task and mesh stages' loads checked against the page table record
// there too. The mesh fallback's task and mesh stages get the buffer as with the miss log, and leave it unused)
static const bool table_check{std::getenv("RX_VK_GP_TABLE") != nullptr && std::atoi(std::getenv("RX_VK_GP_TABLE")) == 2};
const bool graphics{program.stage == Stage::VertexB || program.stage == Stage::Fragment || program.stage == Stage::Compute ||
program.stage == Stage::Task || program.stage == Stage::Mesh};
if (table_check && graphics && program.info.uses_global_memory && descs.size() >= Info::MAX_SSBOS)
Optimization::g_table_check_unchecked.fetch_add(1, std::memory_order_relaxed); // (no room for the check's buffer)
if (((miss_log && (program.stage == Stage::Compute || program.stage == Stage::Mesh || program.stage == Stage::Task) &&
Optimization::g_nvn2_miss_log_this) ||
(table_check && graphics && program.info.uses_global_memory)) &&
descs.size() < Info::MAX_SSBOS) {
descs.push_back({
.cbuf_index = driver_cbuf,
.cbuf_offset = 0xff0U,