From e88e63adb36d649903a54740d9580a491cd6bf0d Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 29 Nov 2014 13:02:48 +0100 Subject: [PATCH] UnitTests: fix VertexLoaderTest --- .../VideoCommon/VertexLoaderTest.cpp | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp index 576e9a8a53..45d8a23ab1 100644 --- a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp +++ b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp @@ -74,12 +74,14 @@ protected: void ResetPointers() { - g_video_buffer_read_ptr = &input_memory[0]; - VertexManager::s_pCurBufferPointer = &output_memory[0]; m_input_pos = m_output_pos = 0; + src = DataReader(input_memory, input_memory+sizeof(input_memory)); + dst = DataReader(output_memory, output_memory+sizeof(output_memory)); } u32 m_input_pos, m_output_pos; + DataReader src; + DataReader dst; TVtxDesc m_vtx_desc; VAT m_vtx_attr; @@ -103,7 +105,9 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZ) Input(0.0f); Input(0.0f); Input(1.0f); // Convert 4 points. "7" -> primitive are points. - loader.RunVertices(m_vtx_attr, 7, 4); + int count = loader.RunVertices(m_vtx_attr, 7, 4, src, dst); + src.Skip(4 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(1.0f); ExpectOut(0.0f); ExpectOut(0.0f); @@ -113,7 +117,9 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZ) // Test that scale does nothing for floating point inputs. Input(1.0f); Input(2.0f); Input(4.0f); m_vtx_attr.g0.PosFrac = 1; - loader.RunVertices(m_vtx_attr, 7, 1); + count = loader.RunVertices(m_vtx_attr, 7, 1, src, dst); + src.Skip(1 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); ExpectOut(1.0f); ExpectOut(2.0f); ExpectOut(4.0f); } @@ -136,7 +142,9 @@ TEST_F(VertexLoaderTest, PositionDirectU16XY) Input(12345); Input(54321); // Convert 5 points. "7" -> primitive are points. - loader.RunVertices(m_vtx_attr, 7, 5); + int count = loader.RunVertices(m_vtx_attr, 7, 5, src, dst); + src.Skip(5 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(1.0f); ExpectOut(2.0f); ExpectOut(0.0f); @@ -147,7 +155,9 @@ TEST_F(VertexLoaderTest, PositionDirectU16XY) // Test that scale works on U16 inputs. Input(42); Input(24); m_vtx_attr.g0.PosFrac = 1; - loader.RunVertices(m_vtx_attr, 7, 1); + count = loader.RunVertices(m_vtx_attr, 7, 1, src, dst); + src.Skip(1 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); ExpectOut(21.0f); ExpectOut(12.0f); ExpectOut(0.0f); } @@ -165,7 +175,9 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZSpeed) for (int i = 0; i < 1000; ++i) { ResetPointers(); - loader.RunVertices(m_vtx_attr, 7, 100000); + int count = loader.RunVertices(m_vtx_attr, 7, 100000, src, dst); + src.Skip(100000 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); } } @@ -183,7 +195,9 @@ TEST_F(VertexLoaderTest, PositionDirectU16XYSpeed) for (int i = 0; i < 1000; ++i) { ResetPointers(); - loader.RunVertices(m_vtx_attr, 7, 100000); + int count = loader.RunVertices(m_vtx_attr, 7, 100000, src, dst); + src.Skip(100000 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); } } @@ -244,6 +258,8 @@ TEST_F(VertexLoaderTest, LargeFloatVertexSpeed) for (int i = 0; i < 100; ++i) { ResetPointers(); - loader.RunVertices(m_vtx_attr, 7, 100000); + int count = loader.RunVertices(m_vtx_attr, 7, 100000, src, dst); + src.Skip(100000 * loader.GetVertexSize()); + dst.Skip(count * loader.GetNativeVertexDeclaration().stride); } }