VertexLoader: Skip vertices with position index = -1

This commit is contained in:
degasus 2014-12-21 14:29:44 +01:00
parent 325e8e370e
commit 1efd00227d
3 changed files with 23 additions and 1 deletions

View File

@ -92,6 +92,17 @@ static void LOADERDECL TexMtx_Write_Float4(VertexLoader* loader)
#endif
}
static void LOADERDECL SkipVertex(VertexLoader* loader)
{
if (loader->m_vertexSkip)
{
// reset the output buffer
g_vertex_manager_write_ptr -= loader->m_native_vtx_decl.stride;
loader->m_skippedVertices++;
}
}
VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr)
: VertexLoaderBase(vtx_desc, vtx_attr)
{
@ -393,6 +404,12 @@ void VertexLoader::CompileVertexTranslator()
nat_offset += 4;
}
// indexed position formats may skip a the vertex
if (m_VtxDesc.Position & 2)
{
WriteCall(SkipVertex);
}
m_native_components = components;
m_native_vtx_decl.stride = nat_offset;
@ -440,6 +457,7 @@ int VertexLoader::RunVertices(int primitive, int count, DataReader src, DataRead
src.WritePointer(&g_video_buffer_read_ptr);
m_numLoadedVertices += count;
m_skippedVertices = 0;
// Prepare bounding box
if (!g_ActiveConfig.backend_info.bSupportsBBox)
@ -462,5 +480,5 @@ int VertexLoader::RunVertices(int primitive, int count, DataReader src, DataRead
}
#endif
return count;
return count - m_skippedVertices;
}

View File

@ -73,6 +73,8 @@ public:
u8 m_curtexmtx[8];
int m_texmtxwrite;
int m_texmtxread;
bool m_vertexSkip;
int m_skippedVertices;
private:
#ifndef USE_VERTEX_LOADER_JIT

View File

@ -93,6 +93,7 @@ void LOADERDECL Pos_ReadIndex(VertexLoader* loader)
static_assert(N <= 3, "N > 3 is not sane!");
auto const index = DataRead<I>();
loader->m_vertexSkip = index == std::numeric_limits<I>::max();
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION]));
auto const scale = loader->m_posScale[0];
DataReader dst(g_vertex_manager_write_ptr, nullptr);
@ -119,6 +120,7 @@ void LOADERDECL Pos_ReadIndex_SSSE3(VertexLoader* loader)
{
static_assert(std::is_unsigned<I>::value, "Only unsigned I is sane!");
auto const index = DataRead<I>();
loader->m_vertexSkip = index == std::numeric_limits<I>::max();
const T* pData = (const T*)(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION]));
Vertex_Read_SSSE3<T, three, true>(pData, *(__m128*)loader->m_posScale);
LOG_VTX();