mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-25 18:48:51 -04:00
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:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <spirv/unified1/spirv.hpp>
|
||||
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
||||
#include "shader_recompiler/backend/spirv/mma_layout.h"
|
||||
#include "shader_recompiler/exception.h"
|
||||
#include "shader_recompiler/environment.h"
|
||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
@@ -800,6 +801,123 @@ static void check_vertex_load_controls(bool inline_128, const char* name) {
|
||||
std::printf("PASS: %s\n", name);
|
||||
}
|
||||
|
||||
// (mma_layout.h global_table_loop, RX_VK_GM_LOOP=1) a global load whose only storage buffer is a table of 16 entries, searched in
|
||||
// the loop: CI validates the module, the return inside the loop's body with it
|
||||
static void check_table_loop() {
|
||||
ObjectPool<IR::Inst> inst_pool;
|
||||
IR::Block block{inst_pool};
|
||||
IR::Program program;
|
||||
program.stage = Stage::Compute;
|
||||
program.workgroup_size = {1, 1, 1};
|
||||
program.blocks.push_back(&block);
|
||||
program.post_order_blocks.push_back(&block);
|
||||
IR::AbstractSyntaxNode node{};
|
||||
node.type = IR::AbstractSyntaxNode::Type::Block;
|
||||
node.data.block = █
|
||||
program.syntax_list.push_back(node);
|
||||
program.syntax_list.push_back({.type = IR::AbstractSyntaxNode::Type::Return});
|
||||
IR::IREmitter ir{block};
|
||||
(void)ir.LoadGlobal32(ir.Imm64(u64{0x0000000100001000}));
|
||||
ir.Epilogue();
|
||||
TestEnvironment env;
|
||||
Optimization::CollectShaderInfoPass(env, program);
|
||||
program.info.constant_buffer_descriptors.push_back({0, 1});
|
||||
program.info.storage_buffers_descriptors.push_back({0, 0x40, 16, false});
|
||||
program.info.used_constant_buffer_types |= IR::Type::U32 | IR::Type::U32x2;
|
||||
Profile profile{};
|
||||
profile.supported_spirv = 0x00010600;
|
||||
profile.support_int64 = true;
|
||||
profile.support_descriptor_aliasing = true;
|
||||
profile.min_ssbo_alignment = 16;
|
||||
Shader::Backend::SPIRV::global_table_loop = true;
|
||||
const auto module = inspect(save_module("ssbo-table-loop", EmitSPIRV(profile, program)));
|
||||
Shader::Backend::SPIRV::global_table_loop = false;
|
||||
bool loop = false;
|
||||
for (const auto& inst : module.instructions)
|
||||
if (inst.op == spv::Op::OpLoopMerge && inst.words[2] == spv::LoopControlDontUnrollMask) loop = true;
|
||||
if (!loop) fail("the storage buffer table was not searched in a DontUnroll loop");
|
||||
std::printf("PASS: storage buffer table searched in a loop\n");
|
||||
}
|
||||
|
||||
// (mma_layout.h graphics_table_loads, RX_VK_GP_TABLE) a stage's global loads through the guest page table: 0 searches the bound
|
||||
// storage buffer, 1 reads the table alone (no search left in the load helpers), 2 keeps the search and records a load the two read
|
||||
// otherwise in the miss buffer (c0+0xff0). In every stage that takes it, each OpSelectionMerge right before its branch: the check's
|
||||
// condition once came between them and RADV crashed compiling those modules. Native task and mesh stages too, whose load helpers
|
||||
// are inlined at every load: there the table's address comes in the push block, the member at GUEST_PAGES_PUSH_OFFSET. CI
|
||||
// validates every module written
|
||||
static void check_table_loads(Stage stage, int mode, const char* name) {
|
||||
ObjectPool<IR::Inst> inst_pool;
|
||||
IR::Block block{inst_pool};
|
||||
IR::Program program;
|
||||
program.stage = stage;
|
||||
program.workgroup_size = {1, 1, 1};
|
||||
program.output_vertices = stage == Stage::Mesh ? 1 : 0;
|
||||
program.mesh.max_vertices = stage == Stage::Mesh ? 1 : 0;
|
||||
program.mesh.max_primitives = stage == Stage::Mesh ? 1 : 0;
|
||||
program.mesh.payload_words = stage == Stage::Mesh || stage == Stage::Task ? 1 : 0;
|
||||
program.blocks.push_back(&block);
|
||||
program.post_order_blocks.push_back(&block);
|
||||
IR::AbstractSyntaxNode node{};
|
||||
node.type = IR::AbstractSyntaxNode::Type::Block;
|
||||
node.data.block = █
|
||||
program.syntax_list.push_back(node);
|
||||
program.syntax_list.push_back({.type = IR::AbstractSyntaxNode::Type::Return});
|
||||
IR::IREmitter ir{block};
|
||||
(void)ir.LoadGlobal32(ir.Imm64(u64{0x0000001000001000}));
|
||||
(void)ir.LoadGlobal128(ir.Imm64(u64{0x0000001000001010}));
|
||||
ir.Epilogue();
|
||||
TestEnvironment env{stage};
|
||||
Optimization::CollectShaderInfoPass(env, program);
|
||||
program.info.constant_buffer_descriptors.push_back({0, 1});
|
||||
program.info.storage_buffers_descriptors.push_back({0, 0x40, 1, false});
|
||||
if (mode == 2) program.info.storage_buffers_descriptors.push_back({0, 0xff0, 1, true}); // (translate_program.cpp's)
|
||||
program.info.used_constant_buffer_types |= IR::Type::U32 | IR::Type::U32x2;
|
||||
Profile profile{};
|
||||
profile.supported_spirv = 0x00010600;
|
||||
profile.support_int64 = true;
|
||||
profile.unified_descriptor_binding = true;
|
||||
profile.support_descriptor_aliasing = true;
|
||||
profile.min_ssbo_alignment = 16;
|
||||
RuntimeInfo runtime_info{};
|
||||
Backend::Bindings bindings{};
|
||||
Shader::Backend::SPIRV::graphics_table_loads = mode;
|
||||
const auto module = inspect(save_module(name, EmitSPIRV(profile, runtime_info, program, bindings)));
|
||||
Shader::Backend::SPIRV::graphics_table_loads = 0;
|
||||
|
||||
// (the load helpers: the functions the entry point calls, by what each holds)
|
||||
std::map<u32, std::pair<bool, bool>> holds; // (function: a buffer search (OpArrayLength), a table read (OpConvertUToPtr))
|
||||
std::vector<u32> called;
|
||||
bool record = false;
|
||||
bool pages_member = false; // (a push block member at GUEST_PAGES_PUSH_OFFSET: the table's address)
|
||||
u32 current = 0;
|
||||
for (size_t i = 0; i < module.instructions.size(); i++) {
|
||||
const auto& inst = module.instructions[i];
|
||||
if (inst.op == spv::Op::OpMemberDecorate && inst.words.size() >= 4 && inst.words[2] == spv::DecorationOffset &&
|
||||
inst.words[3] == Shader::Backend::SPIRV::GUEST_PAGES_PUSH_OFFSET)
|
||||
pages_member = true;
|
||||
if (inst.op == spv::Op::OpFunction) current = inst.words[1];
|
||||
if (inst.op == spv::Op::OpFunctionEnd) current = 0;
|
||||
if (inst.op == spv::Op::OpArrayLength && current) holds[current].first = true;
|
||||
if (inst.op == spv::Op::OpConvertUToPtr && current) holds[current].second = true;
|
||||
if (inst.op == spv::Op::OpAtomicIAdd && current) record = true;
|
||||
if (inst.op == spv::Op::OpFunctionCall) called.push_back(inst.words[2]);
|
||||
if (inst.op == spv::Op::OpSelectionMerge &&
|
||||
(i + 1 >= module.instructions.size() || (module.instructions[i + 1].op != spv::Op::OpBranchConditional &&
|
||||
module.instructions[i + 1].op != spv::Op::OpSwitch)))
|
||||
fail("an OpSelectionMerge is not right before its branch");
|
||||
}
|
||||
if (called.size() != 2) fail("the two global loads are not two helper calls");
|
||||
for (const u32 f : called) {
|
||||
const auto [search, table] = holds[f];
|
||||
if (mode == 1 && (search || !table)) fail("RX_VK_GP_TABLE=1: a load helper still searches, or does not read the table");
|
||||
if (mode != 1 && !search) fail("a load helper no longer searches the bound storage buffer");
|
||||
if (mode == 2 && !table) fail("RX_VK_GP_TABLE=2: a load helper does not read the table to compare");
|
||||
}
|
||||
if (mode == 2 && !record) fail("RX_VK_GP_TABLE=2: no load that differs is recorded");
|
||||
if (mode != 0 && !pages_member) fail("the push block has no member for the page table's address");
|
||||
std::printf("PASS: %s\n", name);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc == 3 && std::string(argv[1]) == "--cas-loops") {
|
||||
output_dir = argv[2];
|
||||
@@ -841,4 +959,10 @@ int main(int argc, char** argv) {
|
||||
check_unsupported_profile();
|
||||
check_vertex_load_controls(false, "vertex-global-load-default");
|
||||
check_vertex_load_controls(true, "vertex-global-load-inline128");
|
||||
check_table_loop();
|
||||
for (const auto& [stage, label] : {std::pair{Stage::VertexB, "vertex"}, std::pair{Stage::Fragment, "fragment"},
|
||||
std::pair{Stage::Compute, "compute"}, std::pair{Stage::Task, "task"},
|
||||
std::pair{Stage::Mesh, "mesh"}})
|
||||
for (int mode = 0; mode <= 2; mode++)
|
||||
check_table_loads(stage, mode, (std::string("table-loads-") + label + "-" + std::to_string(mode)).c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user