diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 707134fa65..fa790cbbdd 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -525,7 +525,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) +std::tuple upload_untouched(gsl::span> src, gsl::span dst, bool is_primitive_restart_enabled, T primitive_restart_index, u32 base_index) { T min_index = -1; T max_index = 0; @@ -535,6 +535,7 @@ std::tuple upload_untouched(gsl::span> src, gsl::spa u32 dst_idx = 0; for (T index : src) { + index = (base_index + index) & 0x000fffff; if (is_primitive_restart_enabled && index == primitive_restart_index) { // List types do not need primitive restart. Just skip over this instead @@ -780,19 +781,19 @@ namespace std::tuple write_index_array_data_to_buffer_impl(gsl::span dst, gsl::span> src, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, - std::function expands) + std::function expands, u32 base_index) { u32 first; u32 count; std::tie(first, count) = get_first_count_from_draw_indexed_clause(first_count_arguments); - if (!expands(draw_mode)) return upload_untouched(src, dst, restart_index_enabled, restart_index); + if (!expands(draw_mode)) return upload_untouched(src, dst, restart_index_enabled, restart_index, base_index); switch (draw_mode) { case rsx::primitive_type::line_loop: { - const auto &returnvalue = upload_untouched(src, dst, restart_index_enabled, restart_index); + const auto &returnvalue = upload_untouched(src, dst, restart_index_enabled, restart_index, base_index); dst[count] = src[0]; return returnvalue; } @@ -810,16 +811,16 @@ namespace std::tuple write_index_array_data_to_buffer(gsl::span dst, gsl::span src, rsx::index_array_type type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, - std::function expands) + std::function expands, u32 base_index) { switch (type) { case rsx::index_array_type::u16: return write_index_array_data_to_buffer_impl(as_span_workaround(dst), - gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); + gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands, base_index); case rsx::index_array_type::u32: return write_index_array_data_to_buffer_impl(as_span_workaround(dst), - gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands); + gsl::as_span>(src), draw_mode, restart_index_enabled, restart_index, first_count_arguments, expands, base_index); } fmt::throw_exception("Unknown index type" HERE); } diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 2cdc7b28d5..3b496f8a99 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -34,7 +34,7 @@ u32 get_index_type_size(rsx::index_array_type type); */ std::tuple write_index_array_data_to_buffer(gsl::span dst, gsl::span src, rsx::index_array_type, rsx::primitive_type draw_mode, bool restart_index_enabled, u32 restart_index, const std::vector > &first_count_arguments, - std::function expands); + std::function expands, u32 base_index = 0); /** * Write index data needed to emulate non indexed non native primitive mode. diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index ec7007888e..d062b22eb3 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -53,7 +53,7 @@ namespace gsl::span dst{ reinterpret_cast(ptr), ::narrow(block_sz) }; std::tie(min_index, max_index, vertex_draw_count) = write_index_array_data_to_buffer(dst, raw_index_buffer, type, draw_mode, rsx::method_registers.restart_index_enabled(), rsx::method_registers.restart_index(), first_count_commands, - [](auto prim) { return !gl::is_primitive_native(prim); }); + [](auto prim) { return !gl::is_primitive_native(prim); }, rsx::method_registers.vertex_data_base_index()); return std::make_tuple(min_index, max_index, vertex_draw_count); } diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 277d3ffcad..4e2ece1e1c 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -171,7 +171,7 @@ namespace rsx::method_registers.current_draw_clause.primitive, rsx::method_registers.restart_index_enabled(), rsx::method_registers.restart_index(), command.ranges_to_fetch_in_index_buffer, - [](auto prim) { return !vk::is_primitive_native(prim); }); + [](auto prim) { return !vk::is_primitive_native(prim); }, rsx::method_registers.vertex_data_base_index()); if (min_index >= max_index) { diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 594d2e5e1f..1f9d8c5f0d 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -247,7 +247,7 @@ $(IntDir)vc$(PlatformToolsetVersion).pdb - ..\hidapi.lib;winmm.lib;OpenAL.lib;XAudio.lib;D3D12GSRender.lib;GLGSRender.lib;shlwapi.lib;VKGSRender.lib;VKstatic.1.lib;glslangd.lib;OSDependentd.lib;OGLCompilerd.lib;SPIRVd.lib;HLSLd.lib;Advapi32.lib;user32.lib;zlib.lib;..\libpng.lib;asmjit.lib;yaml-cpp.lib;emucore.lib;dxgi.lib;$(QTDIR)\lib\qtmaind.lib;shell32.lib;opengl32.lib;$(QTDIR)\lib\Qt5OpenGLd.lib;$(QTDIR)\lib\Qt5Widgetsd.lib;$(QTDIR)\lib\Qt5Quickd.lib;$(QTDIR)\lib\Qt5Guid.lib;$(QTDIR)\lib\Qt5Qmld.lib;$(QTDIR)\lib\Qt5Networkd.lib;$(QTDIR)\lib\Qt5Cored.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5WinExtrasd.lib;%(AdditionalDependencies) + gdi32.lib;..\hidapi.lib;winmm.lib;OpenAL.lib;XAudio.lib;D3D12GSRender.lib;GLGSRender.lib;shlwapi.lib;VKGSRender.lib;VKstatic.1.lib;glslangd.lib;OSDependentd.lib;OGLCompilerd.lib;SPIRVd.lib;HLSLd.lib;Advapi32.lib;user32.lib;zlib.lib;..\libpng.lib;asmjit.lib;yaml-cpp.lib;emucore.lib;dxgi.lib;$(QTDIR)\lib\qtmaind.lib;shell32.lib;opengl32.lib;$(QTDIR)\lib\Qt5OpenGLd.lib;$(QTDIR)\lib\Qt5Widgetsd.lib;$(QTDIR)\lib\Qt5Quickd.lib;$(QTDIR)\lib\Qt5Guid.lib;$(QTDIR)\lib\Qt5Qmld.lib;$(QTDIR)\lib\Qt5Networkd.lib;$(QTDIR)\lib\Qt5Cored.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5WinExtrasd.lib;%(AdditionalDependencies) ..\3rdparty\OpenAL\libs\Win64;..\Vulkan\glslang-build\hlsl\Debug;..\Vulkan\glslang-build\SPIRV\Debug;..\Vulkan\glslang-build\OGLCompilersDLL\Debug;..\Vulkan\glslang-build\glslang\OSDependent\Windows\Debug;..\Vulkan\Vulkan-build\loader\Debug;..\Vulkan\glslang-build\glslang\Debug;..\3rdparty\minidx12\Lib;..\lib\$(CONFIGURATION)-$(PLATFORM);$(QTDIR)\lib;%(AdditionalLibraryDirectories) "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) true