GPU/HW: Only enable fbfetch/DSB when needed

Thanks Adreno...
This commit is contained in:
Stenzek 2024-10-28 23:20:15 +10:00
parent dadc994ba8
commit d24e8fda83
No known key found for this signature in database
3 changed files with 19 additions and 8 deletions

View File

@ -731,7 +731,7 @@ std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(
texture_filtering != GPUTextureFilter::Nearest));
std::stringstream ss;
WriteHeader(ss, use_rov);
WriteHeader(ss, use_rov, shader_blending && !use_rov, use_dual_source);
DefineMacro(ss, "TRANSPARENCY", render_mode != GPU_HW::BatchRenderMode::TransparencyDisabled);
DefineMacro(ss, "TRANSPARENCY_ONLY_OPAQUE", render_mode == GPU_HW::BatchRenderMode::OnlyOpaque);
DefineMacro(ss, "TRANSPARENCY_ONLY_TRANSPARENT", render_mode == GPU_HW::BatchRenderMode::OnlyTransparent);

View File

@ -151,8 +151,14 @@ TinyString ShaderGen::GetGLSLVersionString(RenderAPI render_api, u32 version)
(glsl_es && major_version >= 3) ? " es" : "");
}
void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */) const
void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */,
bool enable_framebuffer_fetch /* = false */,
bool enable_dual_source_blend /* = false */) const
{
DebugAssert((!enable_rov && !enable_framebuffer_fetch && !enable_dual_source_blend) ||
(enable_rov && !enable_framebuffer_fetch && !enable_dual_source_blend) ||
(enable_rov && !enable_framebuffer_fetch && !enable_dual_source_blend) ||
(!enable_rov && !enable_framebuffer_fetch && enable_dual_source_blend));
if (m_shader_language == GPUShaderLanguage::GLSL || m_shader_language == GPUShaderLanguage::GLSLES)
ss << m_glsl_version_string << "\n\n";
else if (m_spirv)
@ -169,7 +175,8 @@ void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */
#ifdef ENABLE_OPENGL
// Extension enabling for OpenGL.
if (m_shader_language == GPUShaderLanguage::GLSL || m_shader_language == GPUShaderLanguage::GLSLES)
if (enable_framebuffer_fetch &&
(m_shader_language == GPUShaderLanguage::GLSL || m_shader_language == GPUShaderLanguage::GLSLES))
{
if (GLAD_GL_EXT_shader_framebuffer_fetch)
ss << "#extension GL_EXT_shader_framebuffer_fetch : require\n";
@ -180,10 +187,13 @@ void ShaderGen::WriteHeader(std::stringstream& ss, bool enable_rov /* = false */
if (m_shader_language == GPUShaderLanguage::GLSLES)
{
// Enable EXT_blend_func_extended for dual-source blend on OpenGL ES.
if (GLAD_GL_EXT_blend_func_extended)
ss << "#extension GL_EXT_blend_func_extended : require\n";
if (GLAD_GL_ARB_blend_func_extended)
ss << "#extension GL_ARB_blend_func_extended : require\n";
if (enable_dual_source_blend)
{
if (GLAD_GL_EXT_blend_func_extended)
ss << "#extension GL_EXT_blend_func_extended : require\n";
if (GLAD_GL_ARB_blend_func_extended)
ss << "#extension GL_ARB_blend_func_extended : require\n";
}
// Test for V3D driver - we have to fudge coordinates slightly.
if (std::strstr(reinterpret_cast<const char*>(glGetString(GL_VENDOR)), "Broadcom") &&

View File

@ -42,7 +42,8 @@ protected:
void DefineMacro(std::stringstream& ss, const char* name, bool enabled) const;
void DefineMacro(std::stringstream& ss, const char* name, s32 value) const;
void WriteHeader(std::stringstream& ss, bool enable_rov = false) const;
void WriteHeader(std::stringstream& ss, bool enable_rov = false, bool enable_framebuffer_fetch = false,
bool enable_dual_source_blend = false) const;
void WriteUniformBufferDeclaration(std::stringstream& ss, bool push_constant_on_vulkan) const;
void DeclareUniformBuffer(std::stringstream& ss, const std::initializer_list<const char*>& members,
bool push_constant_on_vulkan) const;