diff --git a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp index 33d92a3822..dbe1235716 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_capture.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_capture.cpp @@ -171,9 +171,9 @@ namespace rsx const u32 base_address = method_registers.index_array_address(); const u32 memory_location = method_registers.index_array_location(); - const u32 base_addr = get_address(base_address, memory_location); - const u32 type_size = get_index_type_size(method_registers.index_type()); const auto index_type = method_registers.index_type(); + const u32 type_size = get_index_type_size(index_type); + const u32 base_addr = get_address(base_address, memory_location) & ~(type_size - 1); // manually parse index buffer and copy vertex buffer u32 min_index = 0xFFFFFFFF, max_index = 0; diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index f0a7a572f6..382d762a52 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -450,7 +450,7 @@ std::vector get_subresources_layout_impl(const RsxTextur int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); const u32 texaddr = rsx::get_address(texture.offset(), texture.location()); - auto pixels = reinterpret_cast(vm::_ptr(texaddr)); + auto pixels = vm::_ptr(texaddr); const bool is_swizzled = !(texture.format() & CELL_GCM_TEXTURE_LN); const bool has_border = !texture.border_type(); diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index fec338bdd0..939f98af6c 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -2407,7 +2407,7 @@ namespace rsx subres.height_in_block = image_height; subres.pitch_in_block = full_width; subres.depth = 1; - subres.data = { reinterpret_cast(vm::base(image_base)), src.pitch * image_height }; + subres.data = { vm::_ptr(image_base), src.pitch * image_height }; subresource_layout.push_back(subres); vram_texture = upload_image_from_cpu(cmd, rsx_range, image_width, image_height, 1, 1, src.pitch, gcm_format, texture_upload_context::blit_engine_src, @@ -2539,7 +2539,7 @@ namespace rsx subres.height_in_block = dst_dimensions.height; subres.pitch_in_block = pitch_in_block; subres.depth = 1; - subres.data = { reinterpret_cast(vm::get_super_ptr(dst.rsx_address)), dst.pitch * dst_dimensions.height }; + subres.data = { vm::get_super_ptr(dst.rsx_address), dst.pitch * dst_dimensions.height }; subresource_layout.push_back(subres); cached_dest = upload_image_from_cpu(cmd, rsx_range, dst_dimensions.width, dst_dimensions.height, 1, 1, dst.pitch, diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index 2148d8c50c..414d22f2c7 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -93,7 +93,7 @@ namespace rsx::index_array_type::u32: rsx::method_registers.index_type(); - u32 type_size = ::narrow(get_index_type_size(type)); + u32 type_size = get_index_type_size(type); const u32 vertex_count = rsx::method_registers.current_draw_clause.get_elements_count(); u32 index_count = vertex_count; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 6ad71e8103..5f84da86aa 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -838,17 +838,19 @@ namespace rsx return{(const gsl::byte*)element_push_buffer.data(), ::narrow(element_push_buffer.size() * sizeof(u32))}; } - u32 address = rsx::get_address(rsx::method_registers.index_array_address(), rsx::method_registers.index_array_location()); - rsx::index_array_type type = rsx::method_registers.index_type(); + const rsx::index_array_type type = rsx::method_registers.index_type(); + const u32 type_size = get_index_type_size(type); - u32 type_size = ::narrow(get_index_type_size(type)); - bool is_primitive_restart_enabled = rsx::method_registers.restart_index_enabled(); - u32 primitive_restart_index = rsx::method_registers.restart_index(); + u32 address = rsx::get_address(rsx::method_registers.index_array_address(), rsx::method_registers.index_array_location()); + address &= ~(type_size - 1); // Force aligned indices as realhw + + const bool is_primitive_restart_enabled = rsx::method_registers.restart_index_enabled(); + const u32 primitive_restart_index = rsx::method_registers.restart_index(); const u32 first = draw_indexed_clause.min_index(); const u32 count = draw_indexed_clause.get_elements_count(); - const gsl::byte* ptr = static_cast(vm::base(address)); + const auto ptr = vm::_ptr(address); return{ ptr + first * type_size, count * type_size }; } @@ -862,7 +864,7 @@ namespace rsx const u32 first = draw_array_clause.min_index(); const u32 count = draw_array_clause.get_elements_count(); - const gsl::byte* ptr = gsl::narrow_cast(vm::base(address)); + const gsl::byte* ptr = vm::_ptr(address); return {ptr + first * vertex_array_info.stride(), count * vertex_array_info.stride() + element_size}; } diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 8da5cfdd31..ead8bbcdf3 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -132,7 +132,7 @@ namespace rsx::index_array_type::u32 : rsx::method_registers.index_type(); - u32 type_size = gsl::narrow(get_index_type_size(index_type)); + u32 type_size = get_index_type_size(index_type); u32 index_count = rsx::method_registers.current_draw_clause.get_elements_count(); if (primitives_emulated)