PostProcessing: Improve compile error reporting
This commit is contained in:
parent
c9c4307871
commit
52feb1a37d
|
@ -583,16 +583,17 @@ bool PostProcessing::Chain::CheckTargets(GPUTexture::Format target_format, u32 t
|
||||||
|
|
||||||
m_wants_depth_buffer = false;
|
m_wants_depth_buffer = false;
|
||||||
|
|
||||||
|
Error error;
|
||||||
for (size_t i = 0; i < m_stages.size(); i++)
|
for (size_t i = 0; i < m_stages.size(); i++)
|
||||||
{
|
{
|
||||||
Shader* const shader = m_stages[i].get();
|
Shader* const shader = m_stages[i].get();
|
||||||
|
|
||||||
progress->FormatStatusText("Compiling {}...", shader->GetName());
|
progress->FormatStatusText("Compiling {}...", shader->GetName());
|
||||||
|
|
||||||
if (!shader->CompilePipeline(target_format, target_width, target_height, progress) ||
|
if (!shader->CompilePipeline(target_format, target_width, target_height, &error, progress) ||
|
||||||
!shader->ResizeOutput(target_format, target_width, target_height))
|
!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(
|
Host::AddIconOSDMessage(
|
||||||
"PostProcessLoadFail", ICON_FA_EXCLAMATION_TRIANGLE,
|
"PostProcessLoadFail", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||||
fmt::format("Failed to compile post-processing shader '{}'. Disabling post-processing.", shader->GetName()));
|
fmt::format("Failed to compile post-processing shader '{}'. Disabling post-processing.", shader->GetName()));
|
||||||
|
|
|
@ -44,9 +44,10 @@ public:
|
||||||
const ShaderOption* GetOptionByName(std::string_view name) const;
|
const ShaderOption* GetOptionByName(std::string_view name) const;
|
||||||
ShaderOption* GetOptionByName(std::string_view name);
|
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,
|
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,
|
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ GPUTexture* PostProcessing::ReShadeFXShader::GetTextureByID(TextureID id, GPUTex
|
||||||
return m_textures[static_cast<size_t>(id)].texture.get();
|
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)
|
ProgressCallback* progress)
|
||||||
{
|
{
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
|
@ -1342,31 +1342,29 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||||
|
|
||||||
const auto& [cg, cg_language] = CreateRFXCodegen(false);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reshadefx::effect_module& mod = cg->module();
|
const reshadefx::effect_module& mod = cg->module();
|
||||||
DebugAssert(!mod.techniques.empty());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_shader = [cg_language, &cg](const std::string& name, const std::span<Sampler> samplers,
|
auto get_shader = [cg_language, &cg, error](const std::string& name, const std::span<Sampler> samplers,
|
||||||
GPUShaderStage stage) {
|
GPUShaderStage stage) {
|
||||||
const std::string real_code = cg->finalize_code_for_entry_point(name);
|
const std::string real_code = cg->finalize_code_for_entry_point(name);
|
||||||
const char* entry_point = (cg_language == GPUShaderLanguage::HLSL) ? name.c_str() : "main";
|
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)
|
if (!sshader)
|
||||||
ERROR_LOG("Failed to compile function '{}': {}", name, error.GetDescription());
|
Error::AddPrefixFmt(error, "Failed to compile function '{}': ", name);
|
||||||
|
|
||||||
return sshader;
|
return sshader;
|
||||||
};
|
};
|
||||||
|
@ -1426,10 +1424,10 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pass.pipeline = g_gpu_device->CreatePipeline(plconfig, &error);
|
pass.pipeline = g_gpu_device->CreatePipeline(plconfig, error);
|
||||||
if (!pass.pipeline)
|
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();
|
progress->PopState();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1442,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||||
return true;
|
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;
|
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_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);
|
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,
|
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)
|
if (!tex.texture)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,9 @@ public:
|
||||||
bool LoadFromFile(std::string name, std::string filename, bool only_config, Error* error);
|
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 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 ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error) override;
|
||||||
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) 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,
|
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
|
||||||
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||||
s32 native_height, u32 target_width, u32 target_height) override;
|
s32 native_height, u32 target_width, u32 target_height) override;
|
||||||
|
|
|
@ -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)
|
ProgressCallback* progress)
|
||||||
{
|
{
|
||||||
if (m_pipeline)
|
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,
|
PostProcessingGLSLShaderGen shadergen(g_gpu_device->GetRenderAPI(), g_gpu_device->GetFeatures().dual_source_blend,
|
||||||
g_gpu_device->GetFeatures().framebuffer_fetch);
|
g_gpu_device->GetFeatures().framebuffer_fetch);
|
||||||
|
|
||||||
std::unique_ptr<GPUShader> vs = g_gpu_device->CreateShader(GPUShaderStage::Vertex, shadergen.GetLanguage(),
|
std::unique_ptr<GPUShader> vs = g_gpu_device->CreateShader(
|
||||||
shadergen.GeneratePostProcessingVertexShader(*this));
|
GPUShaderStage::Vertex, shadergen.GetLanguage(), shadergen.GeneratePostProcessingVertexShader(*this), error);
|
||||||
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GetLanguage(),
|
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
|
||||||
shadergen.GeneratePostProcessingFragmentShader(*this));
|
GPUShaderStage::Fragment, shadergen.GetLanguage(), shadergen.GeneratePostProcessingFragmentShader(*this), error);
|
||||||
if (!vs || !fs)
|
if (!vs || !fs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
|
||||||
plconfig.fragment_shader = fs.get();
|
plconfig.fragment_shader = fs.get();
|
||||||
plconfig.geometry_shader = nullptr;
|
plconfig.geometry_shader = nullptr;
|
||||||
|
|
||||||
if (!(m_pipeline = g_gpu_device->CreatePipeline(plconfig)))
|
if (!(m_pipeline = g_gpu_device->CreatePipeline(plconfig, error)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!m_sampler)
|
if (!m_sampler)
|
||||||
|
@ -160,7 +160,7 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
|
||||||
config.address_u = GPUSampler::AddressMode::ClampToBorder;
|
config.address_u = GPUSampler::AddressMode::ClampToBorder;
|
||||||
config.address_v = GPUSampler::AddressMode::ClampToBorder;
|
config.address_v = GPUSampler::AddressMode::ClampToBorder;
|
||||||
config.border_color = 0xFF000000u;
|
config.border_color = 0xFF000000u;
|
||||||
if (!(m_sampler = g_gpu_device->CreateSampler(config)))
|
if (!(m_sampler = g_gpu_device->CreateSampler(config, error)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ GPUDevice::PresentResult PostProcessing::GLSLShader::Apply(GPUTexture* input_col
|
||||||
return GPUDevice::PresentResult::OK;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,9 @@ public:
|
||||||
bool LoadFromFile(std::string name, const char* filename, Error* error);
|
bool LoadFromFile(std::string name, const char* filename, Error* error);
|
||||||
bool LoadFromString(std::string name, std::string code, Error* error);
|
bool LoadFromString(std::string name, std::string code, Error* error);
|
||||||
|
|
||||||
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) override;
|
bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height, Error* error) override;
|
||||||
bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) 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,
|
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
|
||||||
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||||
s32 native_height, u32 target_width, u32 target_height) override;
|
s32 native_height, u32 target_width, u32 target_height) override;
|
||||||
|
|
Loading…
Reference in New Issue