diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index 6a783aef7c..2e37cfae94 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -382,6 +382,17 @@ BOOL get_front_face_ccw(u32 ffv) throw EXCEPTION("Invalid front face value (0x%x)", ffv); } +D3D12_CULL_MODE get_cull_face(u32 cfv) +{ + switch (cfv) + { + case CELL_GCM_FRONT: return D3D12_CULL_MODE_FRONT; + case CELL_GCM_BACK: return D3D12_CULL_MODE_BACK; + default: return D3D12_CULL_MODE_NONE; + } + throw EXCEPTION("Invalid cull face value (0x%x)", cfv); +} + DXGI_FORMAT get_index_type(rsx::index_array_type index_type) { switch (index_type) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index c507c46510..677986e5a6 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h @@ -93,6 +93,11 @@ DXGI_FORMAT get_depth_samplable_surface_format(rsx::surface_depth_format format) */ BOOL get_front_face_ccw(u32 set_front_face_value); +/** +* Convert cull face value to a D3D12_CULL_MODE telling wheter cull face is front or back +*/ +D3D12_CULL_MODE get_cull_face(u32 set_cull_face_value); + /** * Convert index type to DXGI_FORMAT */ diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 702c127ab7..e844e4a765 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -202,23 +202,11 @@ void D3D12GSRender::load_program() D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, }; prop.Rasterization = CD3D12_RASTERIZER_DESC; + if (!!rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE]) { - switch (rsx::method_registers[NV4097_SET_CULL_FACE]) - { - case CELL_GCM_FRONT: - prop.Rasterization.CullMode = D3D12_CULL_MODE_FRONT; - break; - case CELL_GCM_BACK: - prop.Rasterization.CullMode = D3D12_CULL_MODE_BACK; - break; - default: - prop.Rasterization.CullMode = D3D12_CULL_MODE_NONE; - break; - } + prop.Rasterization.CullMode = get_cull_face(rsx::method_registers[NV4097_SET_CULL_FACE]); } - else - prop.Rasterization.CullMode = D3D12_CULL_MODE_NONE; prop.Rasterization.FrontCounterClockwise = get_front_face_ccw(rsx::method_registers[NV4097_SET_FRONT_FACE]); diff --git a/rpcs3/Emu/RSX/VK/VKFormats.h b/rpcs3/Emu/RSX/VK/VKFormats.h index 31760b0863..376bf6f97b 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.h +++ b/rpcs3/Emu/RSX/VK/VKFormats.h @@ -15,6 +15,7 @@ namespace vk VkStencilOp get_stencil_op(u32 op); VkLogicOp get_logic_op(u32 op); VkFrontFace get_front_face_ccw(u32 ffv); + VkCullModeFlags get_cull_face(u32 cfv); VkBorderColor get_border_color(u8 color); std::tuple get_min_filter_and_mip(rsx::texture_minify_filter min_filter); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index fffde04e1a..ba930606d3 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -269,6 +269,18 @@ namespace vk } throw EXCEPTION("Unknown front face value: 0x%X", ffv); } + + VkCullModeFlags get_cull_face(u32 cfv) + { + switch (cfv) + { + case CELL_GCM_FRONT: return VK_CULL_MODE_FRONT_BIT; + case CELL_GCM_BACK: return VK_CULL_MODE_BACK_BIT; + case CELL_GCM_FRONT_AND_BACK: return VK_CULL_MODE_FRONT_AND_BACK; + default: return VK_CULL_MODE_NONE; + } + throw EXCEPTION("Unknown cull face value: 0x%X", cfv); + } } @@ -990,26 +1002,10 @@ bool VKGSRender::load_program() else properties.ds.depthTestEnable = VK_FALSE; - if (!!rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE]) - { - switch (rsx::method_registers[NV4097_SET_CULL_FACE]) - { - case CELL_GCM_FRONT: - properties.rs.cullMode = VK_CULL_MODE_FRONT_BIT; - break; - case CELL_GCM_BACK: - properties.rs.cullMode = VK_CULL_MODE_BACK_BIT; - break; - case CELL_GCM_FRONT_AND_BACK: - properties.rs.cullMode = VK_CULL_MODE_FRONT_AND_BACK; - break; - default: - properties.rs.cullMode = VK_CULL_MODE_NONE; - break; - } + if (!!rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE]) + { + properties.rs.cullMode = vk::get_cull_face(rsx::method_registers[NV4097_SET_CULL_FACE]); } - else - properties.rs.cullMode = VK_CULL_MODE_NONE; properties.rs.frontFace = vk::get_front_face_ccw(rsx::method_registers[NV4097_SET_FRONT_FACE]);