From 1d17b01c16786a1f08a63632a081e0e381b229c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 19 Jun 2022 11:53:16 +0200 Subject: [PATCH 1/2] Workaround for strange driver hang on Raspberry Pi 3. Strangely, this does not fix the text rendering in the UI, but might still be enough for the libretro use case in #15469. See #15469 --- Common/GPU/OpenGL/thin3d_gl.cpp | 9 +++++++++ Common/GPU/thin3d.cpp | 30 +++++++++++++++++++++++++++++- Common/GPU/thin3d.h | 4 ++-- UI/GameSettingsScreen.cpp | 20 ++++++++++++-------- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index a9ab5151d0..cd461832fc 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -582,6 +582,15 @@ OpenGLContext::OpenGLContext() { } } + bugs_.Infest(Bugs::RASPBERRY_SHADER_COMP_HANG); + + +#if PPSSPP_ARCH(ARMV7) + if (caps_.vendor == GPUVendor::VENDOR_BROADCOM) { + bugs_.Infest(Bugs::RASPBERRY_SHADER_COMP_HANG); + } +#endif + // Try to detect old Tegra chips by checking for sub 3.0 GL versions. Like Vivante and Broadcom, // those can't handle NaN values in conditionals. if (caps_.vendor == GPUVendor::VENDOR_VIVANTE || diff --git a/Common/GPU/thin3d.cpp b/Common/GPU/thin3d.cpp index 8ae1ded37d..42349b4991 100644 --- a/Common/GPU/thin3d.cpp +++ b/Common/GPU/thin3d.cpp @@ -283,6 +283,27 @@ const UniformBufferDesc vsColBufDesc { sizeof(VsColUB), { { "TintSaturation", 4, -1, UniformType::FLOAT2, 64 }, } }; +static const std::vector vsTexColNoTint = { { + GLSL_1xx, + R"( +#if __VERSION__ >= 130 +#define attribute in +#define varying out +#endif +attribute vec3 Position; +attribute vec4 Color0; +attribute vec2 TexCoord0; +varying vec4 oColor0; +varying vec2 oTexCoord0; +uniform mat4 WorldViewProj; +uniform vec2 TintSaturation; +void main() { + gl_Position = WorldViewProj * vec4(Position, 1.0); + oColor0 = Color0; + oTexCoord0 = TexCoord0; +})" +} }; + static const std::vector vsTexCol = { { GLSL_1xx, R"( @@ -437,7 +458,12 @@ ShaderModule *CreateShader(DrawContext *draw, ShaderStage stage, const std::vect } bool DrawContext::CreatePresets() { - vsPresets_[VS_TEXTURE_COLOR_2D] = CreateShader(this, ShaderStage::Vertex, vsTexCol); + if (bugs_.Has(Bugs::RASPBERRY_SHADER_COMP_HANG)) { + vsPresets_[VS_TEXTURE_COLOR_2D] = CreateShader(this, ShaderStage::Vertex, vsTexColNoTint); + } else { + vsPresets_[VS_TEXTURE_COLOR_2D] = CreateShader(this, ShaderStage::Vertex, vsTexCol); + } + vsPresets_[VS_COLOR_2D] = CreateShader(this, ShaderStage::Vertex, vsCol); fsPresets_[FS_TEXTURE_COLOR_2D] = CreateShader(this, ShaderStage::Fragment, fsTexCol); @@ -603,6 +629,8 @@ const char *Bugs::GetBugName(uint32_t bug) { case BROKEN_FLAT_IN_SHADER: return "BROKEN_FLAT_IN_SHADER"; case EQUAL_WZ_CORRUPTS_DEPTH: return "EQUAL_WZ_CORRUPTS_DEPTH"; case MALI_STENCIL_DISCARD_BUG: return "MALI_STENCIL_DISCARD_BUG"; + case RASPBERRY_SHADER_COMP_HANG: return "RASPBERRY_SHADER_COMP_HANG"; + default: return "(N/A)"; } } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 2a3ea9d09d..45de0cc10c 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -323,6 +323,7 @@ public: BROKEN_FLAT_IN_SHADER = 6, EQUAL_WZ_CORRUPTS_DEPTH = 7, MALI_STENCIL_DISCARD_BUG = 8, + RASPBERRY_SHADER_COMP_HANG = 9, MAX_BUG, }; @@ -347,8 +348,7 @@ private: template struct AutoRef { - AutoRef() { - } + AutoRef() {} explicit AutoRef(T *p) { ptr = p; if (ptr) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index dd5b94d8f8..1f65e2dc67 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -894,14 +894,18 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_CONTINUE; }); - PopupSliderChoiceFloat *tint = new PopupSliderChoiceFloat(&g_Config.fUITint, 0.0, 1.0, sy->T("Color Tint"), 0.01f, screenManager()); - tint->SetHasDropShadow(false); - tint->SetLiveUpdate(true); - systemSettings->Add(tint); - PopupSliderChoiceFloat *saturation = new PopupSliderChoiceFloat(&g_Config.fUISaturation, 0.0, 2.0, sy->T("Color Saturation"), 0.01f, screenManager()); - saturation->SetHasDropShadow(false); - saturation->SetLiveUpdate(true); - systemSettings->Add(saturation); + + if (!draw->GetBugs().Has(Draw::Bugs::RASPBERRY_SHADER_COMP_HANG)) { + // We use shaders without tint capability on hardware with this driver bug. + PopupSliderChoiceFloat *tint = new PopupSliderChoiceFloat(&g_Config.fUITint, 0.0, 1.0, sy->T("Color Tint"), 0.01f, screenManager()); + tint->SetHasDropShadow(false); + tint->SetLiveUpdate(true); + systemSettings->Add(tint); + PopupSliderChoiceFloat *saturation = new PopupSliderChoiceFloat(&g_Config.fUISaturation, 0.0, 2.0, sy->T("Color Saturation"), 0.01f, screenManager()); + saturation->SetHasDropShadow(false); + saturation->SetLiveUpdate(true); + systemSettings->Add(saturation); + } static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), sy->GetName(), screenManager())); From 122a0fa1f608f1b6553e2aa9e573acd60a840537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 19 Jun 2022 18:10:27 +0200 Subject: [PATCH 2/2] Oops, revert debugging commit --- Common/GPU/OpenGL/thin3d_gl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index cd461832fc..acc73051c7 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -582,9 +582,6 @@ OpenGLContext::OpenGLContext() { } } - bugs_.Infest(Bugs::RASPBERRY_SHADER_COMP_HANG); - - #if PPSSPP_ARCH(ARMV7) if (caps_.vendor == GPUVendor::VENDOR_BROADCOM) { bugs_.Infest(Bugs::RASPBERRY_SHADER_COMP_HANG);