Skip to content

Commit ce5786d

Browse files
author
L Sikkes
committed
NVIDIA: Pathtracer + DLSS
1 parent 4732933 commit ce5786d

184 files changed

Lines changed: 18915 additions & 726 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
/drivers/sdl/ @godotengine/input
3232

3333
## Rendering
34+
/drivers/aftermath/ @godotengine/rendering
3435
/drivers/d3d12/ @godotengine/rendering
3536
/drivers/dummy/ @godotengine/rendering
3637
/drivers/egl/ @godotengine/rendering
3738
/drivers/gles3/ @godotengine/rendering
3839
/drivers/metal/ @godotengine/rendering
3940
/drivers/spirv-reflect/ @godotengine/rendering
41+
/drivers/streamline/ @godotengine/rendering
4042
/drivers/vulkan/ @godotengine/rendering
4143

4244
## OS

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ cmake-build-debug
136136
*.cppcheck
137137
cppcheck-cppcheck-build-dir/
138138

139+
# Cursor
140+
.cursor/
141+
139142
# Eclipse CDT
140143
.cproject
141144
.settings/
@@ -277,6 +280,7 @@ thirdparty/swappy-frame-pacing/x86/abi.json
277280
thirdparty/swappy-frame-pacing/x86_64/abi.json
278281

279282
thirdparty/perfetto/
283+
thirdparty/aftermath/
280284

281285
# Visual Studio 2015/2017 cache/options directory
282286
.vs/

SConstruct

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", Tru
199199
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False))
200200
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver on supported platforms (Apple arm64 only)", False))
201201
opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loader dynamically", True))
202+
opts.Add(BoolVariable("use_streamline", "Enable Streamline support", True))
203+
opts.Add(BoolVariable("use_aftermath", "Enable NVIDIA Nsight Aftermath GPU crash dump support", False))
202204
opts.Add(BoolVariable("accesskit", "Enable the AccessKit driver for screen reader support", True))
203205
opts.Add(BoolVariable("angle", "Enable the ANGLE rendering driver for OpenGL ES 3.0 on supported platforms", True))
204206
opts.Add(BoolVariable("sdl", "Enable the SDL3 input driver", True))
@@ -288,6 +290,13 @@ opts.Add(
288290
)
289291
opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False))
290292
opts.Add(BoolVariable("strict_checks", "Enforce stricter checks (debug option)", False))
293+
opts.Add(
294+
BoolVariable(
295+
"error_backtrace",
296+
"Dump native C++ stack traces to stderr on each printed engine error (slow); use debug_symbols for file:line where supported",
297+
False,
298+
)
299+
)
291300
opts.Add(
292301
BoolVariable(
293302
"limit_transitive_includes", "Attempt to limit the amount of transitive includes in system headers", True
@@ -596,6 +605,34 @@ if not env["deprecated"]:
596605
if env["precision"] == "double":
597606
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
598607

608+
if env["use_streamline"]:
609+
if env["platform"] == "windows":
610+
env.AppendUnique(CPPDEFINES=["STREAMLINE_ENABLED"])
611+
else:
612+
env["use_streamline"] = False
613+
614+
if env["use_aftermath"]:
615+
if env["platform"] == "windows":
616+
from misc.utility.thirdparty_fetch import fetch_zip
617+
618+
if not fetch_zip(
619+
name="NVIDIA Nsight Aftermath SDK",
620+
url=(
621+
"https://developer.nvidia.com/downloads/assets/tools/secure/"
622+
"nsight-aftermath-sdk/2025_5_0/windows_x64/"
623+
"NVIDIA_Nsight_Aftermath_SDK_2025.5.0.25317-windows_x64.zip"
624+
),
625+
dest_dir="thirdparty/aftermath/include",
626+
zip_subdir="include",
627+
):
628+
env["use_aftermath"] = False
629+
else:
630+
# Aftermath is Windows-only.
631+
env["use_aftermath"] = False
632+
633+
if env["use_aftermath"]:
634+
env.AppendUnique(CPPDEFINES=["AFTERMATH_ENABLED"])
635+
599636
# Library Support
600637
if env["library_type"] != "executable":
601638
if "library" not in env.get("supported", []):
@@ -682,6 +719,9 @@ if env["production"]:
682719
if env["strict_checks"]:
683720
env.Append(CPPDEFINES=["STRICT_CHECKS"])
684721

722+
if env["error_backtrace"]:
723+
env.Append(CPPDEFINES=["ERROR_BACKTRACE_ENABLED"])
724+
685725
# Run SCU file generation script if in a SCU build.
686726
if env["scu_build"]:
687727
env.Append(CPPDEFINES=["SCU_BUILD_ENABLED"])

core/config/engine.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,18 @@ bool Engine::is_validation_layers_enabled() const {
282282
return use_validation_layers;
283283
}
284284

285+
bool Engine::is_raytracing_validation_enabled() const {
286+
return use_raytracing_validation;
287+
}
288+
285289
bool Engine::is_generate_spirv_debug_info_enabled() const {
286290
return generate_spirv_debug_info;
287291
}
288292

293+
bool Engine::is_gpu_markers_enabled() const {
294+
return use_gpu_markers;
295+
}
296+
289297
bool Engine::is_extra_gpu_memory_tracking_enabled() const {
290298
return extra_gpu_memory_tracking;
291299
}

core/config/engine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class Engine {
7676
double _physics_interpolation_fraction = 0.0f;
7777
bool abort_on_gpu_errors = false;
7878
bool use_validation_layers = false;
79+
bool use_raytracing_validation = false;
7980
bool generate_spirv_debug_info = false;
81+
bool use_gpu_markers = false;
8082
bool extra_gpu_memory_tracking = false;
8183
#if defined(DEBUG_ENABLED) || defined(DEV_ENABLED)
8284
bool accurate_breadcrumbs = false;
@@ -210,7 +212,9 @@ class Engine {
210212

211213
bool is_abort_on_gpu_errors_enabled() const;
212214
bool is_validation_layers_enabled() const;
215+
bool is_raytracing_validation_enabled() const;
213216
bool is_generate_spirv_debug_info_enabled() const;
217+
bool is_gpu_markers_enabled() const;
214218
bool is_extra_gpu_memory_tracking_enabled() const;
215219
#if defined(DEBUG_ENABLED) || defined(DEV_ENABLED)
216220
bool is_accurate_breadcrumbs_enabled() const;

core/error/error_backtrace.cpp

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/**************************************************************************/
2+
/* error_backtrace.cpp */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
30+
31+
#include "core/error/error_backtrace.h"
32+
33+
#include "core/string/ustring.h"
34+
35+
#include <cstring>
36+
37+
#if defined(ERROR_BACKTRACE_ENABLED)
38+
39+
#include <cstdio>
40+
41+
#ifdef WINDOWS_ENABLED
42+
43+
#include "core/os/mutex.h"
44+
45+
#include <windows.h>
46+
47+
// Some versions of imagehlp.dll lack the proper packing directives themselves
48+
// so we need to do it.
49+
#pragma pack(push, before_imagehlp, 8)
50+
#include <imagehlp.h>
51+
#pragma pack(pop, before_imagehlp)
52+
53+
static Mutex sym_init_mutex;
54+
static bool sym_initialized = false;
55+
56+
static void _ensure_sym_initialized() {
57+
MutexLock lock(sym_init_mutex);
58+
if (sym_initialized) {
59+
return;
60+
}
61+
HANDLE process = GetCurrentProcess();
62+
if (SymInitialize(process, nullptr, TRUE)) {
63+
SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
64+
sym_initialized = true;
65+
}
66+
}
67+
68+
static String _native_backtrace_string_windows() {
69+
_ensure_sym_initialized();
70+
71+
void *stack[62];
72+
const USHORT frame_count = CaptureStackBackTrace(0, 62, stack, nullptr);
73+
74+
String out = " Native C++ backtrace (" + String::num_int64((int64_t)frame_count) + " frames):\n";
75+
76+
HANDLE process = GetCurrentProcess();
77+
for (USHORT i = 0; i < frame_count; i++) {
78+
const DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
79+
if (!sym_initialized) {
80+
out += " [" + String::num_int64((int64_t)i) + "] 0x" + String::num_uint64((uint64_t)(uintptr_t)stack[i], 16, true) + "\n";
81+
continue;
82+
}
83+
84+
DWORD64 displacement = 0;
85+
char symbol_buffer[sizeof(IMAGEHLP_SYMBOL64) + 1024];
86+
IMAGEHLP_SYMBOL64 *symbol = reinterpret_cast<IMAGEHLP_SYMBOL64 *>(symbol_buffer);
87+
memset(symbol, 0, sizeof(IMAGEHLP_SYMBOL64));
88+
symbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
89+
symbol->MaxNameLength = 1024;
90+
91+
if (SymGetSymFromAddr64(process, address, &displacement, symbol) && symbol->Name[0] != '\0') {
92+
char und_name[1024];
93+
if (UnDecorateSymbolName(symbol->Name, und_name, sizeof(und_name), UNDNAME_COMPLETE) == 0) {
94+
snprintf(und_name, sizeof(und_name), "%s", symbol->Name);
95+
}
96+
DWORD offset_line = 0;
97+
IMAGEHLP_LINE64 line = {};
98+
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
99+
if (SymGetLineFromAddr64(process, address, &offset_line, &line) && line.FileName) {
100+
out += " [" + String::num_int64((int64_t)i) + "] " + String::utf8(und_name) + " (" + String::utf8(line.FileName) + ":" + String::num_uint64((uint64_t)line.LineNumber) + ")\n";
101+
} else {
102+
out += " [" + String::num_int64((int64_t)i) + "] " + String::utf8(und_name) + "\n";
103+
}
104+
} else {
105+
out += " [" + String::num_int64((int64_t)i) + "] 0x" + String::num_uint64((uint64_t)(uintptr_t)stack[i], 16, true) + "\n";
106+
}
107+
}
108+
109+
out += " -- end native C++ backtrace --\n";
110+
return out;
111+
}
112+
113+
#elif defined(__has_include)
114+
115+
#if __has_include(<execinfo.h>)
116+
117+
#include <cxxabi.h>
118+
#include <dlfcn.h>
119+
#include <execinfo.h>
120+
121+
#include <cstdlib>
122+
123+
static String _native_backtrace_string_unix() {
124+
void *frames[64];
125+
const int n = backtrace(frames, 64);
126+
if (n <= 0) {
127+
return String(" Native C++ backtrace: (unavailable)\n");
128+
}
129+
130+
char **symbols = backtrace_symbols(frames, n);
131+
String out = " Native C++ backtrace (" + String::num_int64((int64_t)n) + " frames):\n";
132+
133+
for (int i = 0; i < n; i++) {
134+
char fname[1024] = "???";
135+
if (symbols && symbols[i]) {
136+
snprintf(fname, sizeof(fname), "%s", symbols[i]);
137+
}
138+
139+
Dl_info info;
140+
if (dladdr(frames[i], &info) && info.dli_sname && info.dli_sname[0] == '_') {
141+
int status = 0;
142+
char *demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
143+
if (status == 0 && demangled) {
144+
snprintf(fname, sizeof(fname), "%s", demangled);
145+
}
146+
if (demangled) {
147+
free(demangled);
148+
}
149+
}
150+
151+
out += " [" + String::num_int64((int64_t)i) + "] " + String::utf8(fname) + "\n";
152+
}
153+
154+
if (symbols) {
155+
free(symbols);
156+
}
157+
158+
out += " -- end native C++ backtrace --\n";
159+
return out;
160+
}
161+
162+
#else
163+
164+
static String _native_backtrace_string_stub() {
165+
return String(" Native C++ backtrace: (execinfo.h not available on this platform)\n");
166+
}
167+
168+
#endif
169+
170+
#else
171+
172+
static String _native_backtrace_string_stub() {
173+
return String(" Native C++ backtrace: (__has_include not supported; rebuild with a C++17 compiler)\n");
174+
}
175+
176+
#endif
177+
178+
String backtrace_dump() {
179+
#ifdef WINDOWS_ENABLED
180+
return _native_backtrace_string_windows();
181+
#elif defined(__has_include) && __has_include(<execinfo.h>)
182+
return _native_backtrace_string_unix();
183+
#else
184+
return _native_backtrace_string_stub();
185+
#endif
186+
}
187+
188+
#else
189+
190+
String backtrace_dump() {
191+
return String();
192+
}
193+
194+
#endif

core/error/error_backtrace.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**************************************************************************/
2+
/* error_backtrace.h */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
30+
31+
#pragma once
32+
33+
#include "core/string/ustring.h"
34+
35+
// Capture current native C++ stack as text. Empty string if disabled or unavailable.
36+
String backtrace_dump();

0 commit comments

Comments
 (0)