upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
authormohamedsaad.lahlou <169635474+lahlousaad4@users.noreply.github.com>2026-11-22 03:07:36 +0100
committermohamedsaad.lahlou <169635474+lahlousaad4@users.noreply.github.com>2026-11-22 03:07:36 +0100
commit4e1de429fdaaef0a5a5b84548e9b29e4b4c67d45 (patch)
tree428dc6b5cef8d04caff5c8528e240bcc16763462 /runtime/src/main.cpp
parentc432cdce127ed2d22a99aa6ef57d91db4a10b5bb (diff)
Runtime: add opt-in D3D12 call tracing
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index 8e2ac0b03..20c870377 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -9,7 +9,7 @@
9// gta6rt --init <image> [--game-dir DIR] 9// gta6rt --init <image> [--game-dir DIR]
10// The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. 10// The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run.
11// 11//
12// gta6rt --run <exe> [--game-dir DIR] [-- game arguments...] 12// gta6rt --run <exe> [--game-dir DIR] [--trace-d3d12] [-- game arguments...]
13// The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and 13// The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and
14// command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run 14// command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run
15// (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. 15// (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code.
@@ -21,6 +21,7 @@
21#include <vector> 21#include <vector>
22 22
23#include "pe_loader.h" 23#include "pe_loader.h"
24#include "../shims/d3d12_trace.h"
24#include "../shims/process_shim.h" 25#include "../shims/process_shim.h"
25#include "../shims/shims.h" 26#include "../shims/shims.h"
26 27
@@ -38,8 +39,8 @@ const char* binding_name(rt::Binding b) {
38int usage() { 39int usage() {
39 std::fprintf(stderr, 40 std::fprintf(stderr,
40 "usage: gta6rt --dry-run <image> [--game-dir DIR]\n" 41 "usage: gta6rt --dry-run <image> [--game-dir DIR]\n"
41 " gta6rt --init <image> [--game-dir DIR]\n" 42 " gta6rt --init <image> [--game-dir DIR] [--trace-d3d12]\n"
42 " gta6rt --run <exe> [--game-dir DIR] [-- game arguments...]\n"); 43 " gta6rt --run <exe> [--game-dir DIR] [--trace-d3d12] [-- game arguments...]\n");
43 return 2; 44 return 2;
44} 45}
45 46
@@ -47,7 +48,7 @@ int usage() {
47 48
48int wmain(int argc, wchar_t** argv) { 49int wmain(int argc, wchar_t** argv) {
49 std::filesystem::path image, game_dir; 50 std::filesystem::path image, game_dir;
50 bool dry_run = false, init = false, run = false; 51 bool dry_run = false, init = false, run = false, trace_d3d12 = false;
51 std::vector<std::string> game_args; 52 std::vector<std::string> game_args;
52 for (int i = 1; i < argc; ++i) { 53 for (int i = 1; i < argc; ++i) {
53 std::wstring a = argv[i]; 54 std::wstring a = argv[i];
@@ -58,6 +59,7 @@ int wmain(int argc, wchar_t** argv) {
58 if (a == L"--dry-run") dry_run = true; 59 if (a == L"--dry-run") dry_run = true;
59 else if (a == L"--init") init = true; 60 else if (a == L"--init") init = true;
60 else if (a == L"--run") run = true; 61 else if (a == L"--run") run = true;
62 else if (a == L"--trace-d3d12") trace_d3d12 = true;
61 else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; 63 else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i];
62 else if (image.empty()) image = a; 64 else if (image.empty()) image = a;
63 else return usage(); 65 else return usage();
@@ -65,6 +67,7 @@ int wmain(int argc, wchar_t** argv) {
65 if (image.empty()) return usage(); 67 if (image.empty()) return usage();
66 if (!dry_run && !init && !run) return usage(); 68 if (!dry_run && !init && !run) return usage();
67 if (game_dir.empty()) game_dir = image.parent_path(); 69 if (game_dir.empty()) game_dir = image.parent_path();
70 rt::d3d12_trace::set_enabled(trace_d3d12);
68 71
69 try { 72 try {
70 rt::Loader loader(game_dir); 73 rt::Loader loader(game_dir);