fix(agc): preserve dumps for non-standard shader failures

Capture the request once before rethrowing from the shared handler. Standard exceptions keep the shader address, stage, optional dump filename and full message; non-standard exceptions remain unchanged after capture.

AI-assisted: yes.
This commit is contained in:
danzaio 2026-10-12 00:46:50 -03:00
parent e71e3a4b3f
commit 56df893667
1 changed files with 9 additions and 7 deletions

View File

@ -19,6 +19,7 @@
#include <cstdlib>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
#include <list>
#include <pthread.h>
@ -30,23 +31,24 @@
namespace AgcDriver::DriverDetail {
std::shared_ptr<const ShaderRecompiler::SourceHandle> PrepareShaderWithDiagnostics(const ShaderRecompiler::RecompileRequest& request, ShaderRecompiler::ShaderPreparationContext* preparation) {
std::exception_ptr failure;
std::string dump;
try {
return ShaderRecompiler::PrepareShader(request, preparation);
} catch (const std::exception& error) {
std::string dump;
} catch (...) {
failure = std::current_exception();
try {
if (std::getenv("APS5_DUMP_SHADERS") != nullptr) dump = Driver::dumpRequest(request.shader.codeAddress, request);
} catch (...) {}
}
try {
std::rethrow_exception(failure);
} catch (const std::exception& error) {
std::ostringstream where;
where << "shader 0x" << std::hex << request.shader.codeAddress << " stage " << static_cast<unsigned>(request.shader.stage);
if (!dump.empty()) where << " (" << dump << ")";
where << ": ";
throw std::runtime_error(where.str() + error.what());
} catch (...) {
try {
if (std::getenv("APS5_DUMP_SHADERS") != nullptr) static_cast<void>(Driver::dumpRequest(request.shader.codeAddress, request));
} catch (...) {}
throw;
}
}