From 628cb1c779d42bd9041d313192b239c309553704 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 22 Jun 2020 21:38:26 +0300 Subject: [PATCH] rsx: Validate blend factors according to hardware testing --- rpcs3/Emu/RSX/gcm_enums.cpp | 17 ----------------- rpcs3/Emu/RSX/gcm_enums.h | 18 ++++++++++++++++++ rpcs3/Emu/RSX/rsx_methods.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/RSX/gcm_enums.cpp b/rpcs3/Emu/RSX/gcm_enums.cpp index a5f6175ffc..c8b0f7436c 100644 --- a/rpcs3/Emu/RSX/gcm_enums.cpp +++ b/rpcs3/Emu/RSX/gcm_enums.cpp @@ -711,23 +711,6 @@ rsx::blend_equation rsx::to_blend_equation(u16 in) fmt::throw_exception("Unknown blend eq 0x%x" HERE, in); } -enum -{ - CELL_GCM_SRC_COLOR = 0x0300, - CELL_GCM_ONE_MINUS_SRC_COLOR = 0x0301, - CELL_GCM_SRC_ALPHA = 0x0302, - CELL_GCM_ONE_MINUS_SRC_ALPHA = 0x0303, - CELL_GCM_DST_ALPHA = 0x0304, - CELL_GCM_ONE_MINUS_DST_ALPHA = 0x0305, - CELL_GCM_DST_COLOR = 0x0306, - CELL_GCM_ONE_MINUS_DST_COLOR = 0x0307, - CELL_GCM_SRC_ALPHA_SATURATE = 0x0308, - CELL_GCM_CONSTANT_COLOR = 0x8001, - CELL_GCM_ONE_MINUS_CONSTANT_COLOR = 0x8002, - CELL_GCM_CONSTANT_ALPHA = 0x8003, - CELL_GCM_ONE_MINUS_CONSTANT_ALPHA = 0x8004, -}; - rsx::blend_factor rsx::to_blend_factor(u16 in) { switch (in) diff --git a/rpcs3/Emu/RSX/gcm_enums.h b/rpcs3/Emu/RSX/gcm_enums.h index bafc7a5f64..9315e1c734 100644 --- a/rpcs3/Emu/RSX/gcm_enums.h +++ b/rpcs3/Emu/RSX/gcm_enums.h @@ -529,6 +529,24 @@ enum CELL_GCM_FUNC_REVERSE_ADD_SIGNED = 0x0000F007, }; +// GCM blend factor +enum +{ + CELL_GCM_SRC_COLOR = 0x0300, + CELL_GCM_ONE_MINUS_SRC_COLOR = 0x0301, + CELL_GCM_SRC_ALPHA = 0x0302, + CELL_GCM_ONE_MINUS_SRC_ALPHA = 0x0303, + CELL_GCM_DST_ALPHA = 0x0304, + CELL_GCM_ONE_MINUS_DST_ALPHA = 0x0305, + CELL_GCM_DST_COLOR = 0x0306, + CELL_GCM_ONE_MINUS_DST_COLOR = 0x0307, + CELL_GCM_SRC_ALPHA_SATURATE = 0x0308, + CELL_GCM_CONSTANT_COLOR = 0x8001, + CELL_GCM_ONE_MINUS_CONSTANT_COLOR = 0x8002, + CELL_GCM_CONSTANT_ALPHA = 0x8003, + CELL_GCM_ONE_MINUS_CONSTANT_ALPHA = 0x8004, +}; + enum { CELL_GCM_TEXTURE_UNSIGNED_REMAP_NORMAL = 0, diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 121a39ef37..108579795c 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -829,6 +829,37 @@ namespace rsx } } + void set_blend_factor(thread* rsx, u32 reg, u32 arg) + { + for (u32 i = 0; i < 32u; i += 16) + { + switch ((arg >> i) & 0xffff) + { + case CELL_GCM_ZERO: + case CELL_GCM_ONE: + case CELL_GCM_SRC_COLOR: + case CELL_GCM_ONE_MINUS_SRC_COLOR: + case CELL_GCM_SRC_ALPHA: + case CELL_GCM_ONE_MINUS_SRC_ALPHA: + case CELL_GCM_DST_ALPHA: + case CELL_GCM_ONE_MINUS_DST_ALPHA: + case CELL_GCM_DST_COLOR: + case CELL_GCM_ONE_MINUS_DST_COLOR: + case CELL_GCM_SRC_ALPHA_SATURATE: + case CELL_GCM_CONSTANT_COLOR: + case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: + case CELL_GCM_CONSTANT_ALPHA: + case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA: + break; + + default: + // Ignore invalid values as a whole + method_registers.decode(reg, method_registers.register_previous_value); + return; + } + } + } + template struct set_texture_dirty_bit { @@ -3157,6 +3188,8 @@ namespace rsx bind_range(); bind(); bind(); + bind(); + bind(); bind>(); bind_array>();