diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 5ad1198c9a..339ea8a8d1 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -465,6 +465,7 @@ std::tuple upload_untouched(gsl::span> src, gsl::span max_index = std::max(max_index, index); min_index = std::min(min_index, index); } + dst[dst_idx++] = index; } return std::make_tuple(min_index, max_index); @@ -661,7 +662,7 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, case rsx::primitive_type::polygon: for (unsigned i = 0; i < (count - 2); i++) { - typedDst[3 * i] = first; + typedDst[3 * i] = 0; typedDst[3 * i + 1] = i + 2 - 1; typedDst[3 * i + 2] = i + 2; } @@ -670,26 +671,26 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, for (unsigned i = 0; i < count / 4; i++) { // First triangle - typedDst[6 * i] = 4 * i + first; - typedDst[6 * i + 1] = 4 * i + 1 + first; - typedDst[6 * i + 2] = 4 * i + 2 + first; + typedDst[6 * i] = 4 * i; + typedDst[6 * i + 1] = 4 * i + 1; + typedDst[6 * i + 2] = 4 * i + 2; // Second triangle - typedDst[6 * i + 3] = 4 * i + 2 + first; - typedDst[6 * i + 4] = 4 * i + 3 + first; - typedDst[6 * i + 5] = 4 * i + first; + typedDst[6 * i + 3] = 4 * i + 2; + typedDst[6 * i + 4] = 4 * i + 3; + typedDst[6 * i + 5] = 4 * i; } return; case rsx::primitive_type::quad_strip: for (unsigned i = 0; i < (count - 2) / 2; i++) { // First triangle - typedDst[6 * i] = 2 * i + first; - typedDst[6 * i + 1] = 2 * i + 1 + first; - typedDst[6 * i + 2] = 2 * i + 2 + first; + typedDst[6 * i] = 2 * i; + typedDst[6 * i + 1] = 2 * i + 1; + typedDst[6 * i + 2] = 2 * i + 2; // Second triangle - typedDst[6 * i + 3] = 2 * i + 2 + first; - typedDst[6 * i + 4] = 2 * i + 1 + first; - typedDst[6 * i + 5] = 2 * i + 3 + first; + typedDst[6 * i + 3] = 2 * i + 2; + typedDst[6 * i + 4] = 2 * i + 1; + typedDst[6 * i + 5] = 2 * i + 3; } return; case rsx::primitive_type::points: @@ -726,21 +727,21 @@ namespace u32 count; std::tie(first, count) = get_first_count_from_draw_indexed_clause(first_count_arguments); - if (!expands(draw_mode)) return upload_untouched(src.subspan(first), dst, restart_index_enabled, restart_index); + if (!expands(draw_mode)) return upload_untouched(src, dst, restart_index_enabled, restart_index); switch (draw_mode) { case rsx::primitive_type::line_loop: { - const auto &returnvalue = upload_untouched(src.subspan(first), dst, restart_index_enabled, restart_index); - dst[count] = src[first]; + const auto &returnvalue = upload_untouched(src, dst, restart_index_enabled, restart_index); + dst[count] = src[0]; return returnvalue; } case rsx::primitive_type::polygon: case rsx::primitive_type::triangle_fan: - return expand_indexed_triangle_fan(src.subspan(first), dst, restart_index_enabled, restart_index); + return expand_indexed_triangle_fan(src, dst, restart_index_enabled, restart_index); case rsx::primitive_type::quads: - return expand_indexed_quads(src.subspan(first), dst, restart_index_enabled, restart_index); + return expand_indexed_quads(src, dst, restart_index_enabled, restart_index); } fmt::throw_exception("Unknown draw mode (0x%x)" HERE, (u32)draw_mode); } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index a2805a07e5..a6c13e9795 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -673,8 +673,9 @@ namespace rsx } u32 first = std::get<0>(draw_indexed_clause.front()); u32 count = std::get<0>(draw_indexed_clause.back()) + std::get<1>(draw_indexed_clause.back()) - first; + const gsl::byte* ptr = static_cast(vm::base(address)); - return{ ptr, count * type_size }; + return{ ptr + first * type_size, count * type_size }; } gsl::span thread::get_raw_vertex_buffer(const rsx::data_array_format_info& vertex_array_info, u32 base_offset, const std::vector>& vertex_ranges) const