diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index 98c1a56691..110ff199ce 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -519,6 +519,12 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D)); return true; case rsx::texture_dimension_extended::texture_dimension_2d: + if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num))) + { + m_shadow_sampled_textures |= (1 << dst.tex_num); + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D) + ".r", false); //No swizzle mask on shadow lookup + return true; + } if (m_prog.redirected_textures & (1 << dst.tex_num)) SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_DEPTH_RGBA)); else @@ -547,7 +553,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num))) { m_shadow_sampled_textures |= (1 << dst.tex_num); - SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ) + ".r", false); //No swizzle mask on shadow lookup + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ) + ".r", false); //No swizzle mask on shadow lookup } else SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ)); diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index 20d27f0dc7..e0f193dd12 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -25,6 +25,8 @@ enum class FUNCTION { FUNCTION_TEXTURE_SAMPLE2D_PROJ, FUNCTION_TEXTURE_SAMPLE2D_LOD, FUNCTION_TEXTURE_SAMPLE2D_GRAD, + FUNCTION_TEXTURE_SHADOW2D, + FUNCTION_TEXTURE_SHADOW2D_PROJ, FUNCTION_TEXTURE_SAMPLECUBE, FUNCTION_TEXTURE_SAMPLECUBE_PROJ, FUNCTION_TEXTURE_SAMPLECUBE_LOD, diff --git a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp index 552f840690..4743039b05 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp @@ -52,6 +52,8 @@ std::string getFunctionImp(FUNCTION f) return "$t.SampleLevel($tsampler, $0.x, $1)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE1D_GRAD: return "$t.SampleGrad($tsampler, $0.x, $1, $2)"; + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D: //TODO + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ: case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D: return "$t.Sample($tsampler, $0.xy * $t_scale)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ: diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp index 8bf68aebd1..5e3167b960 100644 --- a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp @@ -44,6 +44,10 @@ namespace gl return "textureLod($t, $0.xy * $t_coord_scale, $1.x)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_GRAD: return "textureGrad($t, $0.xy * $t_coord_scale , $1.xy, $2.xy)"; + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D: + return "texture($t, $0.xyz)"; + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ: + return "textureProj($t, $0, $1.x)"; // Note: $1.x is bias case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE: return "texture($t, $0.xyz)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ: diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index f1c7eb1681..c98d67f7cf 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -264,6 +264,8 @@ void GLGSRender::begin() gl_state.enable(rsx::method_registers.poly_offset_line_enabled(), GL_POLYGON_OFFSET_LINE); gl_state.enable(rsx::method_registers.poly_offset_fill_enabled(), GL_POLYGON_OFFSET_FILL); + //offset_bias is the constant factor, multiplied by the implementation factor R + //offst_scale is the slope factor, multiplied by the triangle slope factor M gl_state.polygon_offset(rsx::method_registers.poly_offset_scale(), rsx::method_registers.poly_offset_bias()); if (gl_state.enable(rsx::method_registers.cull_face_enabled(), GL_CULL_FACE)) diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index f3979b09ac..b76e39317f 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -48,6 +48,10 @@ namespace vk return "textureLod($t, $0.xy * texture_parameters[$_i].xy, $1.x)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_GRAD: return "textureGrad($t, $0.xy * texture_parameters[$_i].xy, $1.xy, $2.xy)"; // Note: $1.x is bias + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D: + return "texture($t, $0.xyz)"; + case FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ: + return "textureProj($t, $0, $1.x)"; // Note: $1.x is bias case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE: return "texture($t, $0.xyz)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ: diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 545c4d5fb3..b113babd90 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -909,6 +909,18 @@ void VKGSRender::begin() vkCmdSetLineWidth(*m_current_command_buffer, actual_line_width); + if (rsx::method_registers.poly_offset_fill_enabled()) + { + //offset_bias is the constant factor, multiplied by the implementation factor R + //offst_scale is the slope factor, multiplied by the triangle slope factor M + vkCmdSetDepthBias(*m_current_command_buffer, rsx::method_registers.poly_offset_bias(), 0.f, rsx::method_registers.poly_offset_scale()); + } + else + { + //Zero bias value - disables depth bias + vkCmdSetDepthBias(*m_current_command_buffer, 0.f, 0.f, 0.f); + } + //TODO: Set up other render-state parameters into the program pipeline std::chrono::time_point stop = steady_clock::now(); @@ -1837,7 +1849,9 @@ bool VKGSRender::check_program_status() properties.rs.polygonMode = VK_POLYGON_MODE_FILL; properties.rs.depthClampEnable = VK_FALSE; properties.rs.rasterizerDiscardEnable = VK_FALSE; - properties.rs.depthBiasEnable = VK_FALSE; + + //Disabled by setting factors to 0 as needed + properties.rs.depthBiasEnable = VK_TRUE; if (rsx::method_registers.cull_face_enabled()) properties.rs.cullMode = vk::get_cull_face(rsx::method_registers.cull_face_mode()); diff --git a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h index 53cab010de..dbaf6c6337 100644 --- a/rpcs3/Emu/RSX/VK/VKProgramBuffer.h +++ b/rpcs3/Emu/RSX/VK/VKProgramBuffer.h @@ -122,6 +122,7 @@ struct VKTraits dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_WRITE_MASK; dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE; + dynamic_state_descriptors[dynamic_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BIAS; dynamic_state_info.pDynamicStates = dynamic_state_descriptors; VkPipelineVertexInputStateCreateInfo vi = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO };