diff --git a/rpcs3/Emu/RSX/VK/VKFormats.h b/rpcs3/Emu/RSX/VK/VKFormats.h index 9765d826de..95f2d32b5c 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.h +++ b/rpcs3/Emu/RSX/VK/VKFormats.h @@ -14,6 +14,7 @@ namespace vk VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format); VkStencilOp get_stencil_op(u32 op); VkLogicOp get_logic_op(u32 op); + VkFrontFace get_front_face_ccw(u32 ffv); std::tuple get_min_filter_and_mip(rsx::texture_minify_filter min_filter); VkFilter get_mag_filter(rsx::texture_magnify_filter mag_filter); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 2463d5bed8..699542e17f 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -258,6 +258,17 @@ namespace vk throw EXCEPTION("Unknown stencil op: 0x%X", op); } } + + VkFrontFace get_front_face_ccw(u32 ffv) + { + switch (ffv) + { + case CELL_GCM_CW: return VK_FRONT_FACE_CLOCKWISE; + case CELL_GCM_CCW: return VK_FRONT_FACE_COUNTER_CLOCKWISE; + default: + throw EXCEPTION("Unknown front face value: 0x%X", ffv); + } + } } @@ -979,6 +990,29 @@ 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; + } + } + else + properties.rs.cullMode = VK_CULL_MODE_NONE; + + properties.rs.frontFace = vk::get_front_face_ccw(rsx::method_registers[NV4097_SET_FRONT_FACE]); + size_t idx = vk::get_render_pass_location( vk::get_compatible_surface_format(m_surface.color_format).first, vk::get_compatible_depth_surface_format(m_optimal_tiling_supported_formats, m_surface.depth_format), diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index 642f39f1fb..3fad946336 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -12,7 +12,8 @@ namespace vk VkPipelineDepthStencilStateCreateInfo ds; VkPipelineColorBlendAttachmentState att_state[4]; VkPipelineColorBlendStateCreateInfo cs; - + VkPipelineRasterizationStateCreateInfo rs; + VkRenderPass render_pass; int num_targets; @@ -24,6 +25,10 @@ namespace vk return false; if (memcmp(&att_state[0], &other.att_state[0], sizeof(VkPipelineColorBlendAttachmentState))) return false; + if (memcmp(&cs, &other.cs, sizeof(VkPipelineColorBlendStateCreateInfo))) + return false; + if (memcmp(&rs, &other.rs, sizeof(VkPipelineRasterizationStateCreateInfo))) + return false; return num_targets == other.num_targets; } };