MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / writeGpuCrashDumpToFile

Function writeGpuCrashDumpToFile

Source/Falcor/Core/API/Aftermath.cpp:113–185  ·  view source on GitHub ↗

Helper for writing a GPU crash dump to a file.

Source from the content-addressed store, hash-verified

111
112/// Helper for writing a GPU crash dump to a file.
113static void writeGpuCrashDumpToFile(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize)
114{
115 // Create a GPU crash dump decoder object for the GPU crash dump.
116 GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {};
117 AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_CreateDecoder(GFSDK_Aftermath_Version_API, pGpuCrashDump, gpuCrashDumpSize, &decoder)
118 );
119
120 // Use the decoder object to read basic information, like application
121 // name, PID, etc. from the GPU crash dump.
122 GFSDK_Aftermath_GpuCrashDump_BaseInfo baseInfo = {};
123 AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetBaseInfo(decoder, &baseInfo));
124
125 // Use the decoder object to query the application name that was set
126 // in the GPU crash dump description.
127 uint32_t applicationNameLength = 0;
128 AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize(
129 decoder, GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName, &applicationNameLength
130 ));
131
132 std::vector<char> applicationName(applicationNameLength, '\0');
133
134 AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescription(
135 decoder, GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName, uint32_t(applicationName.size()), applicationName.data()
136 ));
137
138 // Create a unique file name for writing the crash dump data to a file.
139 // Note: due to an Nsight Aftermath bug (will be fixed in an upcoming
140 // driver release) we may see redundant crash dumps. As a workaround,
141 // attach a unique count to each generated file name.
142 static int count = 0;
143 const std::string baseFileName =
144 (getRuntimeDirectory() / fmt::format("{}-{}-{}", applicationName.data(), baseInfo.pid, ++count)).string();
145
146 // Write the crash dump data to a file using the .nv-gpudmp extension
147 // registered with Nsight Graphics.
148 const std::string crashDumpFileName = baseFileName + ".nv-gpudmp";
149 std::ofstream dumpFile(crashDumpFileName, std::ios::out | std::ios::binary);
150 if (dumpFile)
151 {
152 dumpFile.write(reinterpret_cast<const char*>(pGpuCrashDump), gpuCrashDumpSize);
153 dumpFile.close();
154 }
155
156 // Decode the crash dump to a JSON string.
157 // Step 1: Generate the JSON and get the size.
158 uint32_t jsonSize = 0;
159 AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GenerateJSON(
160 decoder,
161 GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO,
162 GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE,
163 shaderDebugInfoLookupCallback,
164 shaderLookupCallback,
165 shaderSourceDebugInfoLookupCallback,
166 nullptr,
167 &jsonSize
168 ));
169 // Step 2: Allocate a buffer and fetch the generated JSON.
170 std::vector<char> json(jsonSize);

Callers 1

gpuCrashDumpCallbackFunction · 0.85

Calls 5

sizeMethod · 0.45
dataMethod · 0.45
stringMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected