From 5ef7f8bf3ec7d8079851bd77e3628f81927180ea Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Mon, 22 Feb 2016 21:36:48 +0100 Subject: [PATCH] rsx/common: Fix handling of UB256 --- rpcs3-tests/ps3-rsx-common.cpp | 15 +++++++++++++++ rpcs3-tests/rpcs3-tests.vcxproj | 3 ++- rpcs3-tests/rpcs3-tests.vcxproj.filters | 3 +++ rpcs3/Emu/RSX/Common/BufferUtils.cpp | 2 +- rpcs3/Emu/RSX/GCM.cpp | 4 ++-- rpcs3/Emu/RSX/GCM.h | 4 ++-- rpcs3/Emu/RSX/RSXThread.cpp | 19 ++++++++----------- 7 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 rpcs3-tests/ps3-rsx-common.cpp diff --git a/rpcs3-tests/ps3-rsx-common.cpp b/rpcs3-tests/ps3-rsx-common.cpp new file mode 100644 index 0000000000..42ccbf9231 --- /dev/null +++ b/rpcs3-tests/ps3-rsx-common.cpp @@ -0,0 +1,15 @@ +#include "stdafx.h" +#include "Emu\RSX\Common\BufferUtils.h" + + +TEST_CLASS(rsx_common) +{ + // Check UB256 size is correctly set in write_vertex_array_data_to_buffer + TEST_METHOD(ub256_upload) + { + std::vector dest_buffer(2200); + std::vector src_buffer(100000); // Big enough + + write_vertex_array_data_to_buffer(gsl::span(dest_buffer), src_buffer.data(), 0, 550, rsx::vertex_base_type::ub256, 4, 20); + } +}; diff --git a/rpcs3-tests/rpcs3-tests.vcxproj b/rpcs3-tests/rpcs3-tests.vcxproj index 53638401fb..2c21977ca9 100644 --- a/rpcs3-tests/rpcs3-tests.vcxproj +++ b/rpcs3-tests/rpcs3-tests.vcxproj @@ -56,7 +56,7 @@ $(VCInstallDir)UnitTest\lib;..\OpenAL\libs\Win64;..\ffmpeg\Windows\x86_64\lib;%(AdditionalLibraryDirectories) - + @@ -76,6 +76,7 @@ + Create diff --git a/rpcs3-tests/rpcs3-tests.vcxproj.filters b/rpcs3-tests/rpcs3-tests.vcxproj.filters index 3ce2b4bc5d..8b971a7217 100644 --- a/rpcs3-tests/rpcs3-tests.vcxproj.filters +++ b/rpcs3-tests/rpcs3-tests.vcxproj.filters @@ -17,6 +17,9 @@ Source Files + + Source Files + diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 2ab5677c8d..5dec363f71 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -58,6 +58,7 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, const switch (type) { case rsx::vertex_base_type::ub: + case rsx::vertex_base_type::ub256: { gsl::span dst_span = as_span_workaround(raw_dst_span); copy_whole_attribute_array(dst_span, src_ptr, vector_element_count, element_size, attribute_src_stride, first, count); @@ -72,7 +73,6 @@ void write_vertex_array_data_to_buffer(gsl::span raw_dst_span, const } case rsx::vertex_base_type::f: case rsx::vertex_base_type::s32k: - case rsx::vertex_base_type::ub256: { gsl::span dst_span = as_span_workaround(raw_dst_span); copy_whole_attribute_array>(dst_span, src_ptr, vector_element_count, element_size, attribute_src_stride, first, count); diff --git a/rpcs3/Emu/RSX/GCM.cpp b/rpcs3/Emu/RSX/GCM.cpp index 8e724eea5b..a8b0b9438f 100644 --- a/rpcs3/Emu/RSX/GCM.cpp +++ b/rpcs3/Emu/RSX/GCM.cpp @@ -1127,10 +1127,10 @@ namespace case rsx::vertex_base_type::s1: return "Short"; case rsx::vertex_base_type::f: return "Float"; case rsx::vertex_base_type::sf: return "Half float"; - case rsx::vertex_base_type::ub: return "Unsigned byte"; + case rsx::vertex_base_type::ub: return "Unsigned byte normalized"; case rsx::vertex_base_type::s32k: return "Signed int"; case rsx::vertex_base_type::cmp: return "CMP"; - case rsx::vertex_base_type::ub256: return "UB256"; + case rsx::vertex_base_type::ub256: return "Unsigned byte unormalized"; } } diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index 5d894e5ffa..882972911c 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -30,10 +30,10 @@ namespace rsx s1, ///< signed byte f, ///< float sf, ///< half float - ub, ///< unsigned byte + ub, ///< unsigned byte interpreted as 0.f and 1.f s32k, ///< signed 32bits int cmp, ///< compressed aka X11G11Z10 and always 1. W. - ub256, + ub256, ///< unsigned byte interpreted as between 0 and 255. }; vertex_base_type to_vertex_base_type(u8 in); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 237f124bad..4ec46044d7 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -136,8 +136,8 @@ namespace rsx case 3: return sizeof(u16) * 4; } - throw new EXCEPTION("Wrong vector size"); - case vertex_base_type::f: return sizeof(f32) * size; + throw EXCEPTION("Wrong vector size"); + case vertex_base_type::f: return sizeof(f32) * size; case vertex_base_type::sf: switch (size) { @@ -148,7 +148,7 @@ namespace rsx case 3: return sizeof(f16) * 4; } - throw new EXCEPTION("Wrong vector size"); + throw EXCEPTION("Wrong vector size"); case vertex_base_type::ub: switch (size) { @@ -159,15 +159,12 @@ namespace rsx case 3: return sizeof(u8) * 4; } - throw new EXCEPTION("Wrong vector size"); - case vertex_base_type::s32k: return sizeof(u32) * size; - case vertex_base_type::cmp: return sizeof(u16) * 4; - case vertex_base_type::ub256: return sizeof(u8) * 4; - - default: - throw new EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); - return 0; + throw EXCEPTION("Wrong vector size"); + case vertex_base_type::s32k: return sizeof(u32) * size; + case vertex_base_type::cmp: return sizeof(u16) * 4; + case vertex_base_type::ub256: Expects(size == 4); return sizeof(u8) * 4; } + throw EXCEPTION("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); } void tiled_region::write(const void *src, u32 width, u32 height, u32 pitch)