diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 6e0310a16..c111ee332 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -237,18 +237,19 @@ void main() return ss.str(); } -std::string GPU_HW::GenerateFragmentShader(bool textured, bool blending, bool transparent, - TextureColorMode texture_color_mode) +std::string GPU_HW::GenerateFragmentShader(bool transparent, bool textured, TextureColorMode texture_color_mode, + bool blending) { std::stringstream ss; GenerateShaderHeader(ss); + DefineMacro(ss, "TRANSPARENT", transparent); DefineMacro(ss, "TEXTURED", textured); - DefineMacro(ss, "BLENDING", blending); DefineMacro(ss, "PALETTE", textured && (texture_color_mode == GPU::TextureColorMode::Palette4Bit || texture_color_mode == GPU::TextureColorMode::Palette8Bit)); DefineMacro(ss, "PALETTE_4_BIT", textured && texture_color_mode == GPU::TextureColorMode::Palette4Bit); DefineMacro(ss, "PALETTE_8_BIT", textured && texture_color_mode == GPU::TextureColorMode::Palette8Bit); + DefineMacro(ss, "BLENDING", blending); ss << R"( in vec3 v_col0; diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index b8b0215cf..43aed708a 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -84,8 +84,8 @@ protected: } std::string GenerateVertexShader(bool textured); - std::string GenerateFragmentShader(bool textured, bool blending, bool transparent, - TextureColorMode texture_color_mode); + std::string GenerateFragmentShader(bool transparent, bool textured, TextureColorMode texture_color_mode, + bool blending); std::string GenerateScreenQuadVertexShader(); std::string GenerateFillFragmentShader(); diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 2795346d0..8ab322c73 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -289,9 +289,9 @@ bool GPU_HW_OpenGL::CompilePrograms() for (u32 format = 0; format < 3; format++) { // TODO: eliminate duplicate shaders here - if (!CompileProgram(m_render_programs[textured][blending][transparent][format], - ConvertToBoolUnchecked(textured), ConvertToBoolUnchecked(blending), - ConvertToBoolUnchecked(transparent), static_cast(format))) + if (!CompileProgram(m_render_programs[transparent][textured][format][blending], + ConvertToBoolUnchecked(transparent), ConvertToBoolUnchecked(textured), + static_cast(format), ConvertToBoolUnchecked(blending))) { return false; } @@ -303,11 +303,11 @@ bool GPU_HW_OpenGL::CompilePrograms() return true; } -bool GPU_HW_OpenGL::CompileProgram(GL::Program& prog, bool textured, bool blending, bool transparent, - TextureColorMode texture_color_mode) +bool GPU_HW_OpenGL::CompileProgram(GL::Program& prog, bool transparent, bool textured, + TextureColorMode texture_color_mode, bool blending) { const std::string vs = GenerateVertexShader(textured); - const std::string fs = GenerateFragmentShader(textured, blending, transparent, texture_color_mode); + const std::string fs = GenerateFragmentShader(transparent, textured, texture_color_mode, blending); if (!prog.Compile(vs.c_str(), fs.c_str())) return false; @@ -342,8 +342,8 @@ bool GPU_HW_OpenGL::CompileProgram(GL::Program& prog, bool textured, bool blendi void GPU_HW_OpenGL::SetDrawState() { const GL::Program& prog = - m_render_programs[BoolToUInt32(m_batch.texture_enable)][BoolToUInt32(m_batch.texture_blending_enable)] - [BoolToUInt32(m_batch.transparency_enable)][static_cast(m_batch.texture_color_mode)]; + m_render_programs[BoolToUInt32(m_batch.transparency_enable)][BoolToUInt32(m_batch.texture_enable)] + [static_cast(m_batch.texture_color_mode)][BoolToUInt32(m_batch.texture_blending_enable)]; prog.Bind(); prog.Uniform2i(0, m_drawing_offset.x, m_drawing_offset.y); diff --git a/src/core/gpu_hw_opengl.h b/src/core/gpu_hw_opengl.h index 4d44c96df..37c5ef2f3 100644 --- a/src/core/gpu_hw_opengl.h +++ b/src/core/gpu_hw_opengl.h @@ -51,8 +51,8 @@ private: void CreateVertexBuffer(); bool CompilePrograms(); - bool CompileProgram(GL::Program& prog, bool textured, bool blending, bool transparent, TextureColorMode texture_color_mode); - + bool CompileProgram(GL::Program& prog, bool transparent, bool textured, TextureColorMode texture_color_mode, + bool blending); void SetDrawState(); // downsample texture - used for readbacks at >1xIR. @@ -74,7 +74,7 @@ private: bool m_last_transparency_enable = false; TransparencyMode m_last_transparency_mode = TransparencyMode::BackgroundMinusForeground; - std::array, 2>, 2>, 2> m_render_programs; + std::array, 3>, 2>, 2> m_render_programs; std::array m_texture_page_programs; GLStats m_stats = {};