diff --git a/rpcs3/Emu/RSX/GL/GLDraw.cpp b/rpcs3/Emu/RSX/GL/GLDraw.cpp index 0da7ddc068..1226976bf4 100644 --- a/rpcs3/Emu/RSX/GL/GLDraw.cpp +++ b/rpcs3/Emu/RSX/GL/GLDraw.cpp @@ -144,10 +144,16 @@ void GLGSRender::update_draw_state() bool color_mask_r = rsx::method_registers.color_mask_r(index); bool color_mask_a = rsx::method_registers.color_mask_a(index); - if (rsx::method_registers.surface_color() == rsx::surface_color_format::g8b8) + switch (rsx::method_registers.surface_color()) { - //Map GB components onto RG + case rsx::surface_color_format::b8: + rsx::get_b8_colormask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); + break; + case rsx::surface_color_format::g8b8: rsx::get_g8b8_r8g8_colormask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); + break; + default: + break; } gl_state.color_maski(index, color_mask_r, color_mask_g, color_mask_b, color_mask_a); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 4ac300af65..691ed21721 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -613,10 +613,16 @@ void GLGSRender::clear_surface(u32 arg) colormask = 0; break; } + case rsx::surface_color_format::b8: + { + rsx::get_b8_clear_color(clear_r, clear_g, clear_b, clear_a); + colormask = rsx::get_b8_clearmask(colormask); + break; + } case rsx::surface_color_format::g8b8: { rsx::get_g8b8_clear_color(clear_r, clear_g, clear_b, clear_a); - colormask = rsx::get_g8b8_r8g8_colormask(colormask); + colormask = rsx::get_g8b8_r8g8_clearmask(colormask); break; } case rsx::surface_color_format::a8b8g8r8: @@ -624,7 +630,7 @@ void GLGSRender::clear_surface(u32 arg) case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: { rsx::get_abgr8_clear_color(clear_r, clear_g, clear_b, clear_a); - colormask = rsx::get_abgr8_colormask(colormask); + colormask = rsx::get_abgr8_clearmask(colormask); break; } default: diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index f9c18e0d7b..24d9eada0f 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1308,10 +1308,17 @@ void VKGSRender::clear_surface(u32 mask) colormask = 0; break; } + case rsx::surface_color_format::b8: + { + rsx::get_b8_clear_color(clear_r, clear_g, clear_b, clear_a); + colormask = rsx::get_b8_clearmask(colormask); + use_fast_clear = (colormask == RSX_GCM_CLEAR_RED_BIT); + break; + } case rsx::surface_color_format::g8b8: { rsx::get_g8b8_clear_color(clear_r, clear_g, clear_b, clear_a); - colormask = rsx::get_g8b8_r8g8_colormask(colormask); + colormask = rsx::get_g8b8_r8g8_clearmask(colormask); use_fast_clear = (colormask == (RSX_GCM_CLEAR_RED_BIT | RSX_GCM_CLEAR_GREEN_BIT)); break; } @@ -1320,7 +1327,7 @@ void VKGSRender::clear_surface(u32 mask) case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: { rsx::get_abgr8_clear_color(clear_r, clear_g, clear_b, clear_a); - colormask = rsx::get_abgr8_colormask(colormask); + colormask = rsx::get_abgr8_clearmask(colormask); [[fallthrough]]; } default: @@ -1646,8 +1653,17 @@ bool VKGSRender::load_program() bool color_mask_r = rsx::method_registers.color_mask_r(index); bool color_mask_a = rsx::method_registers.color_mask_a(index); - if (rsx::method_registers.surface_color() == rsx::surface_color_format::g8b8) + switch (rsx::method_registers.surface_color()) + { + case rsx::surface_color_format::b8: + rsx::get_b8_colormask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); + break; + case rsx::surface_color_format::g8b8: rsx::get_g8b8_r8g8_colormask(color_mask_r, color_mask_g, color_mask_b, color_mask_a); + break; + default: + break; + } properties.state.set_color_mask(index, color_mask_r, color_mask_g, color_mask_b, color_mask_a); } diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 36cdb8476c..34d68df413 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -726,11 +726,11 @@ namespace rsx } // Convert color write mask for G8B8 to R8G8 - static inline u32 get_g8b8_r8g8_colormask(u32 mask) + static inline u32 get_g8b8_r8g8_clearmask(u32 mask) { u32 result = 0; - if (mask & 0x20) result |= 0x20; - if (mask & 0x40) result |= 0x10; + if (mask & RSX_GCM_CLEAR_GREEN_BIT) result |= RSX_GCM_CLEAR_GREEN_BIT; + if (mask & RSX_GCM_CLEAR_BLUE_BIT) result |= RSX_GCM_CLEAR_RED_BIT; return result; } @@ -747,13 +747,13 @@ namespace rsx red = blue; } - static inline u32 get_abgr8_colormask(u32 mask) + static inline u32 get_abgr8_clearmask(u32 mask) { u32 result = 0; - if (mask & 0x10) result |= 0x40; - if (mask & 0x20) result |= 0x20; - if (mask & 0x40) result |= 0x10; - if (mask & 0x80) result |= 0x80; + if (mask & RSX_GCM_CLEAR_RED_BIT) result |= RSX_GCM_CLEAR_BLUE_BIT; + if (mask & RSX_GCM_CLEAR_GREEN_BIT) result |= RSX_GCM_CLEAR_GREEN_BIT; + if (mask & RSX_GCM_CLEAR_BLUE_BIT) result |= RSX_GCM_CLEAR_RED_BIT; + if (mask & RSX_GCM_CLEAR_ALPHA_BIT) result |= RSX_GCM_CLEAR_ALPHA_BIT; return result; } @@ -767,6 +767,26 @@ namespace rsx std::swap(red, blue); } + static inline u32 get_b8_clearmask(u32 mask) + { + u32 result = 0; + if (mask & RSX_GCM_CLEAR_BLUE_BIT) result |= RSX_GCM_CLEAR_RED_BIT; + return result; + } + + static inline void get_b8_colormask(bool& red, bool& green, bool& blue, bool& alpha) + { + red = blue; + green = false; + blue = false; + alpha = false; + } + + static inline void get_b8_clear_color(u8& red, u8& /*green*/, u8& blue, u8& /*alpha*/) + { + std::swap(red, blue); + } + static inline color4f decode_border_color(u32 colorref) { color4f result;