PostProcessing: Improve compile error reporting

This commit is contained in:
Stenzek 2024-12-05 23:51:25 +10:00
parent c9c4307871
commit 52feb1a37d
No known key found for this signature in database
6 changed files with 34 additions and 32 deletions

View File

@ -583,16 +583,17 @@ bool PostProcessing::Chain::CheckTargets(GPUTexture::Format target_format, u32 t
m_wants_depth_buffer = false;
Error error;
for (size_t i = 0; i < m_stages.size(); i++)
{
Shader* const shader = m_stages[i].get();
progress->FormatStatusText("Compiling {}...", shader->GetName());
if (!shader->CompilePipeline(target_format, target_width, target_height, progress) ||
!shader->ResizeOutput(target_format, target_width, target_height))
if (!shader->CompilePipeline(target_format, target_width, target_height, &error, progress) ||
!shader->ResizeOutput(target_format, target_width, target_height, &error))
{
ERROR_LOG("Failed to compile one or more post-processing shaders, disabling.");
ERROR_LOG("Failed to compile post-processing shader '{}':\n{}", shader->GetName(), error.GetDescription());
Host::AddIconOSDMessage(
"PostProcessLoadFail", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format("Failed to compile post-processing shader '{}'. Disabling post-processing.", shader->GetName()));

View File

@ -44,9 +44,10 @@ public:
const ShaderOption* GetOptionByName(std::string_view name) const;
ShaderOption* GetOptionByName(std::string_view name);
virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0;
virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error) = 0;
virtual bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) = 0;
virtual bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, Error* error,
ProgressCallback* progress) = 0;
virtual GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,

View File

@ -1321,7 +1321,7 @@ GPUTexture* PostProcessing::ReShadeFXShader::GetTextureByID(TextureID id, GPUTex
return m_textures[static_cast<size_t>(id)].texture.get();
}
bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height,
bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height, Error* error,
ProgressCallback* progress)
{
m_valid = false;
@ -1342,31 +1342,29 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
const auto& [cg, cg_language] = CreateRFXCodegen(false);
Error error;
if (!CreateModule(width, height, cg.get(), cg_language, std::move(fxcode), &error))
if (!CreateModule(width, height, cg.get(), cg_language, std::move(fxcode), error))
{
ERROR_LOG("Failed to create module for '{}': {}", m_name, error.GetDescription());
Error::AddPrefix(error, "Failed to create module: ");
return false;
}
const reshadefx::effect_module& mod = cg->module();
DebugAssert(!mod.techniques.empty());
if (!CreatePasses(format, mod, &error))
if (!CreatePasses(format, mod, error))
{
ERROR_LOG("Failed to create passes for '{}': {}", m_name, error.GetDescription());
Error::AddPrefix(error, "Failed to create passes: ");
return false;
}
auto get_shader = [cg_language, &cg](const std::string& name, const std::span<Sampler> samplers,
GPUShaderStage stage) {
auto get_shader = [cg_language, &cg, error](const std::string& name, const std::span<Sampler> samplers,
GPUShaderStage stage) {
const std::string real_code = cg->finalize_code_for_entry_point(name);
const char* entry_point = (cg_language == GPUShaderLanguage::HLSL) ? name.c_str() : "main";
Error error;
std::unique_ptr<GPUShader> sshader = g_gpu_device->CreateShader(stage, cg_language, real_code, &error, entry_point);
std::unique_ptr<GPUShader> sshader = g_gpu_device->CreateShader(stage, cg_language, real_code, error, entry_point);
if (!sshader)
ERROR_LOG("Failed to compile function '{}': {}", name, error.GetDescription());
Error::AddPrefixFmt(error, "Failed to compile function '{}': ", name);
return sshader;
};
@ -1426,10 +1424,10 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
return false;
}
pass.pipeline = g_gpu_device->CreatePipeline(plconfig, &error);
pass.pipeline = g_gpu_device->CreatePipeline(plconfig, error);
if (!pass.pipeline)
{
ERROR_LOG("Failed to create pipeline for pass '{}': {}", info.name, error.GetDescription());
Error::AddPrefixFmt(error, "Failed to create pipeline for pass '{}': ", info.name);
progress->PopState();
return false;
}
@ -1444,7 +1442,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
return true;
}
bool PostProcessing::ReShadeFXShader::ResizeOutput(GPUTexture::Format format, u32 width, u32 height)
bool PostProcessing::ReShadeFXShader::ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error)
{
m_valid = false;
@ -1458,7 +1456,7 @@ bool PostProcessing::ReShadeFXShader::ResizeOutput(GPUTexture::Format format, u3
const u32 t_width = std::max(static_cast<u32>(static_cast<float>(width) * tex.rt_scale), 1u);
const u32 t_height = std::max(static_cast<u32>(static_cast<float>(height) * tex.rt_scale), 1u);
tex.texture = g_gpu_device->FetchTexture(t_width, t_height, 1, 1, 1, GPUTexture::Type::RenderTarget, tex.format,
GPUTexture::Flags::None);
GPUTexture::Flags::None, nullptr, 0, error);
if (!tex.texture)
return {};
}

View File

@ -33,8 +33,9 @@ public:
bool LoadFromFile(std::string name, std::string filename, bool only_config, Error* error);
bool LoadFromString(std::string name, std::string filename, std::string code, bool only_config, Error* error);
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) override;
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) override;
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error) override;
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, Error* error,
ProgressCallback* progress) override;
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
s32 native_height, u32 target_width, u32 target_height) override;

View File

@ -121,7 +121,7 @@ void PostProcessing::GLSLShader::FillUniformBuffer(void* buffer, s32 viewport_x,
}
}
bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height,
bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height, Error* error,
ProgressCallback* progress)
{
if (m_pipeline)
@ -130,10 +130,10 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
PostProcessingGLSLShaderGen shadergen(g_gpu_device->GetRenderAPI(), g_gpu_device->GetFeatures().dual_source_blend,
g_gpu_device->GetFeatures().framebuffer_fetch);
std::unique_ptr<GPUShader> vs = g_gpu_device->CreateShader(GPUShaderStage::Vertex, shadergen.GetLanguage(),
shadergen.GeneratePostProcessingVertexShader(*this));
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GetLanguage(),
shadergen.GeneratePostProcessingFragmentShader(*this));
std::unique_ptr<GPUShader> vs = g_gpu_device->CreateShader(
GPUShaderStage::Vertex, shadergen.GetLanguage(), shadergen.GeneratePostProcessingVertexShader(*this), error);
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
GPUShaderStage::Fragment, shadergen.GetLanguage(), shadergen.GeneratePostProcessingFragmentShader(*this), error);
if (!vs || !fs)
return false;
@ -151,7 +151,7 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
plconfig.fragment_shader = fs.get();
plconfig.geometry_shader = nullptr;
if (!(m_pipeline = g_gpu_device->CreatePipeline(plconfig)))
if (!(m_pipeline = g_gpu_device->CreatePipeline(plconfig, error)))
return false;
if (!m_sampler)
@ -160,7 +160,7 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
config.address_u = GPUSampler::AddressMode::ClampToBorder;
config.address_v = GPUSampler::AddressMode::ClampToBorder;
config.border_color = 0xFF000000u;
if (!(m_sampler = g_gpu_device->CreateSampler(config)))
if (!(m_sampler = g_gpu_device->CreateSampler(config, error)))
return false;
}
@ -201,7 +201,7 @@ GPUDevice::PresentResult PostProcessing::GLSLShader::Apply(GPUTexture* input_col
return GPUDevice::PresentResult::OK;
}
bool PostProcessing::GLSLShader::ResizeOutput(GPUTexture::Format format, u32 width, u32 height)
bool PostProcessing::GLSLShader::ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error)
{
return true;
}

View File

@ -22,8 +22,9 @@ public:
bool LoadFromFile(std::string name, const char* filename, Error* error);
bool LoadFromString(std::string name, std::string code, Error* error);
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) override;
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) override;
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error) override;
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, Error* error,
ProgressCallback* progress) override;
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
s32 native_height, u32 target_width, u32 target_height) override;