diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 33defa05da..4cce0bf476 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -255,16 +255,28 @@ namespace rsx template void set_vertex_data_impl(thread* rsx, u32 arg) { - static const usz increment_per_array_index = (register_count * sizeof(type)) / sizeof(u32); + static constexpr usz increment_per_array_index = (register_count * sizeof(type)) / sizeof(u32); - static const usz attribute_index = index / increment_per_array_index; - static const usz vertex_subreg = index % increment_per_array_index; + static constexpr usz attribute_index = index / increment_per_array_index; + static constexpr usz vertex_subreg = index % increment_per_array_index; - const auto vtype = vertex_data_type_from_element_type::type; - ensure(vtype != rsx::vertex_base_type::cmp); + constexpr auto vtype = vertex_data_type_from_element_type::type; + static_assert(vtype != rsx::vertex_base_type::cmp); + static_assert(vtype != rsx::vertex_base_type::ub256); - // Get BE data - arg = std::bit_cast>(arg); + // Convert LE data to BE layout + if constexpr (sizeof(type) == 4) + { + arg = std::bit_cast>(arg); + } + else if constexpr (sizeof(type) == 2) + { + // 2 16-bit values packed in 1 32-bit word + const auto be_data = std::bit_cast>(arg); + + // After u32 swap, the components are in the wrong position + arg = (be_data << 16) | (be_data >> 16); + } if (rsx->in_begin_end) {