From e361e0daa6648802db2f77cb08880208f9fc0756 Mon Sep 17 00:00:00 2001 From: eladash Date: Fri, 5 Oct 2018 17:57:12 +0300 Subject: [PATCH] rsx: Fix restart index check for u16 index arrays Dont ignore upper bits of the restart index with u16 types --- rpcs3/Emu/RSX/Capture/rsx_capture.cpp | 2 +- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp index 620b4b0007..87d61ee996 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp @@ -237,7 +237,7 @@ namespace rsx for (u32 i = 0; i < idxCount; ++i) { u16 index = fifo[i]; - if (is_primitive_restart_enabled && index == (u16)primitive_restart_index) + if (is_primitive_restart_enabled && (u32)index == primitive_restart_index) continue; index = (u16)get_index_from_base(index, method_registers.vertex_data_base_index()); min_index = (u16)std::min(index, (u16)min_index); diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index b9f46006c7..ae4d19881b 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -539,7 +539,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, gsl::s namespace { template -std::tuple upload_untouched(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index, u32 base_index) +std::tuple upload_untouched(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 base_index) { T min_index = -1; T max_index = 0; @@ -549,7 +549,7 @@ std::tuple upload_untouched(gsl::span> src, gsl::spa u32 dst_idx = 0; for (T index : src) { - if (is_primitive_restart_enabled && index == primitive_restart_index) + if (is_primitive_restart_enabled && (u32)index == primitive_restart_index) { // List types do not need primitive restart. Just skip over this instead if (rsx::method_registers.current_draw_clause.is_disjoint_primitive) @@ -570,7 +570,7 @@ std::tuple upload_untouched(gsl::span> src, gsl::spa } template -std::tuple expand_indexed_triangle_fan(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index, u32 base_index) +std::tuple expand_indexed_triangle_fan(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 base_index) { const T invalid_index = (T)-1; @@ -593,7 +593,7 @@ std::tuple expand_indexed_triangle_fan(gsl::span> sr if (needs_anchor) { - if (is_primitive_restart_enabled && src[src_idx] == primitive_restart_index) + if (is_primitive_restart_enabled && (u32)src[src_idx] == primitive_restart_index) continue; anchor = index; @@ -601,7 +601,7 @@ std::tuple expand_indexed_triangle_fan(gsl::span> sr continue; } - if (is_primitive_restart_enabled && src[src_idx] == primitive_restart_index) + if (is_primitive_restart_enabled && (u32)src[src_idx] == primitive_restart_index) { needs_anchor = true; last_index = invalid_index; @@ -629,7 +629,7 @@ std::tuple expand_indexed_triangle_fan(gsl::span> sr } template -std::tuple expand_indexed_quads(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index, u32 base_index) +std::tuple expand_indexed_quads(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 base_index) { T min_index = -1; T max_index = 0; @@ -644,7 +644,7 @@ std::tuple expand_indexed_quads(gsl::span> src, gsl: { T index = src[src_idx]; index = rsx::get_index_from_base(index, base_index); - if (is_primitive_restart_enabled && src[src_idx] == primitive_restart_index) + if (is_primitive_restart_enabled && (u32)src[src_idx] == primitive_restart_index) { //empty temp buffer set_size = 0;