From d9067d85af1caf78da78f77e7ae20125212530ef Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 24 May 2026 01:05:07 +0200 Subject: [tools] add separate maxwell disassembler, ir dumper, and spirv translator (#3453) why not? Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3453 Reviewed-by: MaranBr Reviewed-by: CamilleLaVey --- tools/maxwell-ir/main.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tools/maxwell-ir/main.cpp (limited to 'tools/maxwell-ir/main.cpp') diff --git a/tools/maxwell-ir/main.cpp b/tools/maxwell-ir/main.cpp new file mode 100644 index 0000000000..66aeaeac40 --- /dev/null +++ b/tools/maxwell-ir/main.cpp @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#include +#include + +#include "shader_recompiler/frontend/ir/basic_block.h" +#include "shader_recompiler/frontend/maxwell/control_flow.h" +#include "shader_recompiler/frontend/maxwell/translate_program.h" +#include "shader_recompiler/host_translate_info.h" +#include "shader_recompiler/object_pool.h" +#include "../maxwell-disas/file_environment.h" + +int IrShaderRecompilerImpl(int argc, char *argv[]) { + size_t cfg_offset = 0; + + Shader::ObjectPool inst_pool; + Shader::ObjectPool block_pool; + Shader::ObjectPool cfg_blocks; + FileEnvironment env; + + FILE *fp = fopen(argv[1], "rb"); + if (fp != NULL) { + struct stat st; + fstat(fileno(fp), &st); + auto const words = (st.st_size / sizeof(u64)); + env.code.resize(words + 1); + fread(env.code.data(), sizeof(u64), words, fp); + fclose(fp); + } + + env.read_highest = env.read_lowest + env.code.size() * sizeof(u64); + + Shader::Maxwell::Flow::CFG cfg(env, cfg_blocks, cfg_offset); + + Shader::HostTranslateInfo host_info; + host_info.support_float64 = true; + host_info.support_float16 = true; + host_info.support_int64 = true; + host_info.needs_demote_reorder = true; + host_info.support_snorm_render_buffer = true; + host_info.support_viewport_index_layer = true; + host_info.support_geometry_shader_passthrough = true; + host_info.support_conditional_barrier = true; + host_info.min_ssbo_alignment = 0; + auto program = Shader::Maxwell::TranslateProgram(inst_pool, block_pool, env, cfg, host_info); + auto const dumped_ir = Shader::IR::DumpProgram(program); + std::printf("%s\n", dumped_ir.c_str()); + return EXIT_SUCCESS; +} + +int main(int argc, char *argv[]) { + if (argc < 2) { + printf("usage: %s [input file]\n", argv[0]); + return EXIT_FAILURE; + } + return IrShaderRecompilerImpl(argc, argv); +} -- cgit v1.2.3