TEST_P(VertexLoaderParamTest, PositionAll) { int addr, format, elements, frac; std::tie(addr, format, elements, frac) = GetParam(); this->m_vtx_desc.Position = addr; this->m_vtx_attr.g0.PosFormat = format; this->m_vtx_attr.g0.PosElements = elements; this->m_vtx_attr.g0.PosFrac = frac; this->m_vtx_attr.g0.ByteDequant = true; elements += 2; std::vector<float> values = { std::numeric_limits<float>::lowest(), std::numeric_limits<float>::denorm_min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::max(), std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::infinity(), -0x8000, -0x80, -1, -0, 0, 1, 123, 0x7F, 0xFF, 0x7FFF, 0xFFFF, 12345678, }; ASSERT_EQ(0u, values.size() % 2); ASSERT_EQ(0u, values.size() % 3); int count = (int)values.size() / elements; u32 elem_size = 1 << (format / 2); size_t input_size = elements * elem_size; if (addr & MASK_INDEXED) { input_size = addr - 1; for (int i = 0; i < count; i++) if (addr == INDEX8) Input<u8>(i); else Input<u16>(i); VertexLoaderManager::cached_arraybases[ARRAY_POSITION] = m_src.GetPointer(); g_main_cp_state.array_strides[ARRAY_POSITION] = elements * elem_size; } CreateAndCheckSizes(input_size, elements * sizeof(float)); for (float value : values) { switch (format) { case FORMAT_UBYTE: Input((u8)value); break; case FORMAT_BYTE: Input((s8)value); break; case FORMAT_USHORT: Input((u16)value); break; case FORMAT_SHORT: Input((s16)value); break; case FORMAT_FLOAT: Input(value); break; } } RunVertices(count); float scale = 1.f / (1u << (format == FORMAT_FLOAT ? 0 : frac)); for (auto iter = values.begin(); iter != values.end();) { float f, g; switch (format) { case FORMAT_UBYTE: f = (u8)*iter++; g = (u8)*iter++; break; case FORMAT_BYTE: f = (s8)*iter++; g = (s8)*iter++; break; case FORMAT_USHORT: f = (u16)*iter++; g = (u16)*iter++; break; case FORMAT_SHORT: f = (s16)*iter++; g = (s16)*iter++; break; case FORMAT_FLOAT: f = *iter++; g = *iter++; break; default: FAIL() << "Unknown format"; } ExpectOut(f * scale); ExpectOut(g * scale); } }
TEST_F(VertexLoaderTest, LargeFloatVertexSpeed) { // Enables most attributes in floating point indexed mode to test speed. m_vtx_desc.PosMatIdx = 1; m_vtx_desc.Tex0MatIdx = 1; m_vtx_desc.Tex1MatIdx = 1; m_vtx_desc.Tex2MatIdx = 1; m_vtx_desc.Tex3MatIdx = 1; m_vtx_desc.Tex4MatIdx = 1; m_vtx_desc.Tex5MatIdx = 1; m_vtx_desc.Tex6MatIdx = 1; m_vtx_desc.Tex7MatIdx = 1; m_vtx_desc.Position = INDEX16; m_vtx_desc.Normal = INDEX16; m_vtx_desc.Color0 = INDEX16; m_vtx_desc.Color1 = INDEX16; m_vtx_desc.Tex0Coord = INDEX16; m_vtx_desc.Tex1Coord = INDEX16; m_vtx_desc.Tex2Coord = INDEX16; m_vtx_desc.Tex3Coord = INDEX16; m_vtx_desc.Tex4Coord = INDEX16; m_vtx_desc.Tex5Coord = INDEX16; m_vtx_desc.Tex6Coord = INDEX16; m_vtx_desc.Tex7Coord = INDEX16; m_vtx_attr.g0.PosElements = 1; // XYZ m_vtx_attr.g0.PosFormat = FORMAT_FLOAT; m_vtx_attr.g0.NormalElements = 1; // NBT m_vtx_attr.g0.NormalFormat = FORMAT_FLOAT; m_vtx_attr.g0.Color0Elements = 1; // Has Alpha m_vtx_attr.g0.Color0Comp = FORMAT_32B_8888; m_vtx_attr.g0.Color1Elements = 1; // Has Alpha m_vtx_attr.g0.Color1Comp = FORMAT_32B_8888; m_vtx_attr.g0.Tex0CoordElements = 1; // ST m_vtx_attr.g0.Tex0CoordFormat = FORMAT_FLOAT; m_vtx_attr.g1.Tex1CoordElements = 1; // ST m_vtx_attr.g1.Tex1CoordFormat = FORMAT_FLOAT; m_vtx_attr.g1.Tex2CoordElements = 1; // ST m_vtx_attr.g1.Tex2CoordFormat = FORMAT_FLOAT; m_vtx_attr.g1.Tex3CoordElements = 1; // ST m_vtx_attr.g1.Tex3CoordFormat = FORMAT_FLOAT; m_vtx_attr.g1.Tex4CoordElements = 1; // ST m_vtx_attr.g1.Tex4CoordFormat = FORMAT_FLOAT; m_vtx_attr.g2.Tex5CoordElements = 1; // ST m_vtx_attr.g2.Tex5CoordFormat = FORMAT_FLOAT; m_vtx_attr.g2.Tex6CoordElements = 1; // ST m_vtx_attr.g2.Tex6CoordFormat = FORMAT_FLOAT; m_vtx_attr.g2.Tex7CoordElements = 1; // ST m_vtx_attr.g2.Tex7CoordFormat = FORMAT_FLOAT; CreateAndCheckSizes(33, 156); for (int i = 0; i < 12; i++) { VertexLoaderManager::cached_arraybases[i] = m_src.GetPointer(); g_main_cp_state.array_strides[i] = 129; } // This test is only done 100x in a row since it's ~20x slower using the // current vertex loader implementation. for (int i = 0; i < 100; ++i) RunVertices(100000); }