diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.h b/rpcs3/Emu/RSX/Common/GLSLCommon.h index 6b6942494d..a142b7dfc8 100644 --- a/rpcs3/Emu/RSX/Common/GLSLCommon.h +++ b/rpcs3/Emu/RSX/Common/GLSLCommon.h @@ -121,8 +121,10 @@ namespace glsl OS << " bool reverse_order = false;\n"; OS << "\n"; OS << " int first_byte = (vertex_id * desc.stride) + desc.starting_offset;\n"; - OS << " for (int n = 0; n < desc.attribute_size; n++)\n"; + OS << " for (int n = 0; n < 4; n++)\n"; OS << " {\n"; + OS << " if (n == desc.attribute_size) break;\n"; + OS << "\n"; OS << " switch (desc.type)\n"; OS << " {\n"; OS << " case 0:\n"; diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp index 62c85832a8..e680652c4e 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.cpp @@ -28,7 +28,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R return false; if (binary1.data.size() != binary2.data.size()) return false; - if (!binary1.skip_vertex_input_check && binary1.rsx_vertex_inputs != binary2.rsx_vertex_inputs) + if (!binary1.skip_vertex_input_check && !binary2.skip_vertex_input_check && binary1.rsx_vertex_inputs != binary2.rsx_vertex_inputs) return false; const qword *instBuffer1 = (const qword*)binary1.data.data(); diff --git a/rpcs3/Emu/RSX/RSXFragmentProgram.h b/rpcs3/Emu/RSX/RSXFragmentProgram.h index e1a0ddded1..3281ab1b06 100644 --- a/rpcs3/Emu/RSX/RSXFragmentProgram.h +++ b/rpcs3/Emu/RSX/RSXFragmentProgram.h @@ -237,7 +237,7 @@ struct RSXFragmentProgram float texture_pitch_scale[16]; u8 textures_alpha_kill[16]; - u32 textures_zfunc[16]; + u8 textures_zfunc[16]; bool valid; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 7bf43a0a67..27b13c4b5b 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1098,18 +1098,27 @@ namespace rsx { auto &tex = rsx::method_registers.fragment_textures[i]; result.texture_pitch_scale[i] = 1.f; + result.textures_alpha_kill[i] = 0; + result.textures_zfunc[i] = 0; if (!tex.enabled()) { texture_dimensions[i] = texture_dimension_extended::texture_dimension_2d; - result.textures_alpha_kill[i] = 0; - result.textures_zfunc[i] = 0; } else { texture_dimensions[i] = tex.get_extended_texture_dimension(); - result.textures_alpha_kill[i] = tex.alpha_kill_enabled() ? 1 : 0; - result.textures_zfunc[i] = tex.zfunc(); + + if (tex.alpha_kill_enabled()) + { + //alphakill can be ignored unless a valid comparison function is set + const rsx::comparison_function func = (rsx::comparison_function)tex.zfunc(); + if (func < rsx::comparison_function::always && func > rsx::comparison_function::never) + { + result.textures_alpha_kill[i] = 1; + result.textures_zfunc[i] = (u8)func; + } + } const u32 texaddr = rsx::get_address(tex.offset(), tex.location()); const u32 raw_format = tex.format(); diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 3ef9e67158..04ea3ee536 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -453,8 +453,8 @@ namespace rsx for (u8 index = 0; index < 16; ++index) { - data_block.fp_alphakill_mask |= (fp.textures_alpha_kill[index] & 0x1) << index; - data_block.fp_zfunc_mask |= (fp.textures_zfunc[index] & 0xF) << (index << 2); + data_block.fp_alphakill_mask |= (u32)(fp.textures_alpha_kill[index] & 0x1) << index; + data_block.fp_zfunc_mask |= (u32)(fp.textures_zfunc[index] & 0xF) << (index << 2); } return data_block;