diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 89fad2ef05..f7c554ea45 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -108,71 +108,65 @@ bool D3D12GSRender::LoadProgram() }; prop.Blend = CD3D12_BLEND_DESC; - if (m_set_blend) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE]) { prop.Blend.RenderTarget[0].BlendEnable = true; - if (m_set_blend_mrt1) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) prop.Blend.RenderTarget[1].BlendEnable = true; - if (m_set_blend_mrt2) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) prop.Blend.RenderTarget[2].BlendEnable = true; - if (m_set_blend_mrt3) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) prop.Blend.RenderTarget[3].BlendEnable = true; - } - if (m_set_blend_equation) - { - prop.Blend.RenderTarget[0].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[0].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[0].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[0].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); - if (m_set_blend_mrt1) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) { - prop.Blend.RenderTarget[1].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[1].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[1].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[1].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); } - if (m_set_blend_mrt2) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) { - prop.Blend.RenderTarget[2].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[2].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[2].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[2].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); } - if (m_set_blend_mrt3) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) { - prop.Blend.RenderTarget[3].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[3].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); - } - } - - if (m_set_blend_sfactor && m_set_blend_dfactor) - { - prop.Blend.RenderTarget[0].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[0].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[0].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[0].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); - - if (m_set_blend_mrt1) - { - prop.Blend.RenderTarget[1].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[1].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[1].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[1].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); + prop.Blend.RenderTarget[3].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[3].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); } - if (m_set_blend_mrt2) + prop.Blend.RenderTarget[0].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[0].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[0].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[0].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); + + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) { - prop.Blend.RenderTarget[2].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[2].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[2].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[2].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); + prop.Blend.RenderTarget[1].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[1].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[1].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[1].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); } - if (m_set_blend_mrt3) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) { - prop.Blend.RenderTarget[3].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[3].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[3].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[3].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); + prop.Blend.RenderTarget[2].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[2].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[2].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[2].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); + } + + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) + { + prop.Blend.RenderTarget[3].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[3].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[3].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[3].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); } } @@ -182,7 +176,7 @@ bool D3D12GSRender::LoadProgram() prop.Blend.RenderTarget[0].LogicOp = getLogicOp(rsx::method_registers[NV4097_SET_LOGIC_OP]); } - if (m_set_blend_color) +// if (m_set_blend_color) { // glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a); // checkForGlError("glBlendColor"); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 1382881fb1..32b061d51d 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1664,7 +1664,7 @@ void GLGSRender::end() // Enable(m_set_depth_test, GL_DEPTH_TEST); Enable(m_set_alpha_test, GL_ALPHA_TEST); - Enable(m_set_blend || m_set_blend_mrt1 || m_set_blend_mrt2 || m_set_blend_mrt3, GL_BLEND); +// Enable(m_set_blend || m_set_blend_mrt1 || m_set_blend_mrt2 || m_set_blend_mrt3, GL_BLEND); Enable(m_set_scissor_horizontal && m_set_scissor_vertical, GL_SCISSOR_TEST); // Enable(m_set_logic_op, GL_LOGIC_OP); Enable(m_set_cull_face, GL_CULL_FACE); @@ -1847,21 +1847,21 @@ void GLGSRender::end() checkForGlError("glPolygonStipple"); } - if (m_set_blend_equation) +// if (m_set_blend_equation) { - glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha); +// glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha); checkForGlError("glBlendEquationSeparate"); } - if (m_set_blend_sfactor && m_set_blend_dfactor) +// if (m_set_blend_sfactor && m_set_blend_dfactor) { - glBlendFuncSeparate(m_blend_sfactor_rgb, m_blend_dfactor_rgb, m_blend_sfactor_alpha, m_blend_dfactor_alpha); +// glBlendFuncSeparate(m_blend_sfactor_rgb, m_blend_dfactor_rgb, m_blend_sfactor_alpha, m_blend_dfactor_alpha); checkForGlError("glBlendFuncSeparate"); } - if (m_set_blend_color) +// if (m_set_blend_color) { - glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a); +// glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a); checkForGlError("glBlendColor"); } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index c5351ae3bb..f705617ca4 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -629,83 +629,33 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const // Blending case NV4097_SET_BLEND_ENABLE: - { - m_set_blend = ARGS(0) ? true : false; notifyBlendStateChange(); break; - } case NV4097_SET_BLEND_ENABLE_MRT: - { - m_set_blend_mrt1 = ARGS(0) & 0x02 ? true : false; - m_set_blend_mrt2 = ARGS(0) & 0x04 ? true : false; - m_set_blend_mrt3 = ARGS(0) & 0x08 ? true : false; notifyBlendStateChange(); break; - } case NV4097_SET_BLEND_FUNC_SFACTOR: - { - m_set_blend_sfactor = true; - m_blend_sfactor_rgb = ARGS(0) & 0xffff; - m_blend_sfactor_alpha = ARGS(0) >> 16; - - if (count == 2) - { - m_set_blend_dfactor = true; - m_blend_dfactor_rgb = ARGS(1) & 0xffff; - m_blend_dfactor_alpha = ARGS(1) >> 16; - } notifyBlendStateChange(); break; - } case NV4097_SET_BLEND_FUNC_DFACTOR: - { - m_set_blend_dfactor = true; - m_blend_dfactor_rgb = ARGS(0) & 0xffff; - m_blend_dfactor_alpha = ARGS(0) >> 16; notifyBlendStateChange(); break; - } case NV4097_SET_BLEND_COLOR: - { - m_set_blend_color = true; - m_blend_color_r = ARGS(0) & 0xff; - m_blend_color_g = (ARGS(0) >> 8) & 0xff; - m_blend_color_b = (ARGS(0) >> 16) & 0xff; - m_blend_color_a = (ARGS(0) >> 24) & 0xff; notifyBlendStateChange(); break; - } case NV4097_SET_BLEND_COLOR2: - { - if (u32 value = ARGS(0)) - { - LOG_WARNING(RSX, "TODO : NV4097_SET_BLEND_COLOR2: 0x%x", value); - } break; - } case NV4097_SET_BLEND_EQUATION: - { - m_set_blend_equation = true; - m_blend_equation_rgb = ARGS(0) & 0xffff; - m_blend_equation_alpha = ARGS(0) >> 16; notifyBlendStateChange(); break; - } - case NV4097_SET_REDUCE_DST_COLOR: - { - if (u32 value = ARGS(0)) - { - LOG_WARNING(RSX, "TODO: NV4097_SET_REDUCE_DST_COLOR: 0x%x", value); - } break; - } // Depth bound testing case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE: diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 176d9aa2cd..e4c10cd278 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -242,26 +242,6 @@ public: // Clearing u32 m_clear_surface_mask; - // Blending - bool m_set_blend; - bool m_set_blend_dfactor; - u16 m_blend_dfactor_rgb; - u16 m_blend_dfactor_alpha; - bool m_set_blend_sfactor; - u16 m_blend_sfactor_rgb; - u16 m_blend_sfactor_alpha; - bool m_set_blend_equation; - u16 m_blend_equation_rgb; - u16 m_blend_equation_alpha; - bool m_set_blend_color; - u8 m_blend_color_r; - u8 m_blend_color_g; - u8 m_blend_color_b; - u8 m_blend_color_a; - bool m_set_blend_mrt1; - bool m_set_blend_mrt2; - bool m_set_blend_mrt3; - // Stencil Test bool m_set_two_side_light_enable; @@ -420,10 +400,8 @@ protected: user_handler.set(0); m_set_alpha_test = false; m_set_depth_bounds_test = false; - m_set_blend = false; - m_set_blend_mrt1 = false; - m_set_blend_mrt2 = false; - m_set_blend_mrt3 = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] = 0; + rsx::method_registers[NV4097_SET_BLEND_ENABLE] = false; m_set_cull_face = false; m_set_dither = false; m_set_scissor_horizontal = false; @@ -461,12 +439,9 @@ protected: m_depth_bounds_max = 1.0; m_clip_min = 0.0; m_clip_max = 1.0; - m_blend_equation_rgb = 0x8006; // GL_FUNC_ADD - m_blend_equation_alpha = 0x8006; // GL_FUNC_ADD - m_blend_sfactor_rgb = 1; // GL_ONE - m_blend_dfactor_rgb = 0; // GL_ZERO - m_blend_sfactor_alpha = 1; // GL_ONE - m_blend_dfactor_alpha = 0; // GL_ZERO + rsx::method_registers[NV4097_SET_BLEND_EQUATION] = (0x8006) | (0x8006 << 16); // GL_FUNC_ADD + rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] = 1 | (1 << 16); + rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] = 0; m_point_x = 0; m_point_y = 0; m_point_size = 1.0; @@ -512,14 +487,8 @@ protected: m_set_scissor_vertical = false; m_set_front_polygon_mode = false; m_set_back_polygon_mode = false; - m_set_blend = false; - m_set_blend_mrt1 = false; - m_set_blend_mrt2 = false; - m_set_blend_mrt3 = false; - m_set_blend_sfactor = false; - m_set_blend_dfactor = false; - m_set_blend_equation = false; - m_set_blend_color = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] = 0; + rsx::method_registers[NV4097_SET_BLEND_ENABLE] = false; m_set_two_side_light_enable = false; m_set_point_sprite_control = false; m_set_point_size = false; diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 3d69f9aa4e..22108aac6a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -471,8 +471,8 @@ void SetupRsxRenderingStates(vm::ptr& cntxt) rsx::method_registers[NV4097_SET_COLOR_MASK] = -1; rsx::method_registers[NV4097_SET_DEPTH_MASK] = 0; r.m_set_alpha_test = false; - r.m_set_blend = false; - r.m_set_blend_mrt1 = r.m_set_blend_mrt2 = r.m_set_blend_mrt3 = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE] = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] = false; // r.m_set_logic_op = false; r.m_set_cull_face = false; r.m_set_depth_bounds_test = false; diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index be978d3c31..18b4dc5105 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -494,7 +494,7 @@ void RSXDebugger::GetFlags() m_list_flags->InsertItem(i, name); m_list_flags->SetItem(i, 1, value ? "Enabled" : "Disabled"); i++; LIST_FLAGS_ADD("Alpha test", render.m_set_alpha_test); - LIST_FLAGS_ADD("Blend", render.m_set_blend); + LIST_FLAGS_ADD("Blend", rsx::method_registers[NV4097_SET_BLEND_ENABLE]); LIST_FLAGS_ADD("Scissor", render.m_set_scissor_horizontal && render.m_set_scissor_vertical); LIST_FLAGS_ADD("Cull face", render.m_set_cull_face); LIST_FLAGS_ADD("Depth bounds test", render.m_set_depth_bounds_test); @@ -595,11 +595,11 @@ void RSXDebugger::GetSettings() LIST_SETTINGS_ADD("Alpha func", !(render.m_set_alpha_func) ? "(none)" : wxString::Format("0x%x (%s)", render.m_alpha_func, ParseGCMEnum(render.m_alpha_func, CELL_GCM_ENUM))); - LIST_SETTINGS_ADD("Blend color", !(render.m_set_blend_color) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d", - render.m_blend_color_r, - render.m_blend_color_g, - render.m_blend_color_b, - render.m_blend_color_a)); + LIST_SETTINGS_ADD("Blend color", !(rsx::method_registers[NV4097_SET_BLEND_COLOR]) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d", + rsx::method_registers[NV4097_SET_BLEND_COLOR] & 0xFF, + (rsx::method_registers[NV4097_SET_BLEND_COLOR] >> 8) & 0xFF, + (rsx::method_registers[NV4097_SET_BLEND_COLOR] >> 16) & 0xFF, + (rsx::method_registers[NV4097_SET_BLEND_COLOR] >> 24) & 0xFF)); LIST_SETTINGS_ADD("Clipping", wxString::Format("Min:%f, Max:%f", render.m_clip_min, render.m_clip_max)); LIST_SETTINGS_ADD("Color mask", !(rsx::method_registers[NV4097_SET_COLOR_MASK]) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d", (rsx::method_registers[NV4097_SET_COLOR_MASK] >> 16) & 0xff, @@ -652,7 +652,7 @@ void RSXDebugger::SetFlags(wxListEvent& event) switch(event.m_itemIndex) { case 0: render.m_set_alpha_test ^= true; break; - case 1: render.m_set_blend ^= true; break; + case 1: rsx::method_registers[NV4097_SET_BLEND_ENABLE] ^= true; break; case 2: render.m_set_cull_face ^= true; break; case 3: render.m_set_depth_bounds_test ^= true; break; // case 4: render.m_set_depth_test ^= true; break;