From 1efd00227d3c38458d44193c4aa554f70a3b9c55 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 21 Dec 2014 14:29:44 +0100 Subject: [PATCH] VertexLoader: Skip vertices with position index = -1 --- Source/Core/VideoCommon/VertexLoader.cpp | 20 ++++++++++++++++++- Source/Core/VideoCommon/VertexLoader.h | 2 ++ .../VideoCommon/VertexLoader_Position.cpp | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 61303ab6f7..e2a2073ccf 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -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; } diff --git a/Source/Core/VideoCommon/VertexLoader.h b/Source/Core/VideoCommon/VertexLoader.h index 2b61e683bc..4c883a3242 100644 --- a/Source/Core/VideoCommon/VertexLoader.h +++ b/Source/Core/VideoCommon/VertexLoader.h @@ -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 diff --git a/Source/Core/VideoCommon/VertexLoader_Position.cpp b/Source/Core/VideoCommon/VertexLoader_Position.cpp index c0fac7ef93..419c041b5b 100644 --- a/Source/Core/VideoCommon/VertexLoader_Position.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Position.cpp @@ -93,6 +93,7 @@ void LOADERDECL Pos_ReadIndex(VertexLoader* loader) static_assert(N <= 3, "N > 3 is not sane!"); auto const index = DataRead(); + loader->m_vertexSkip = index == std::numeric_limits::max(); auto const data = reinterpret_cast(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::value, "Only unsigned I is sane!"); auto const index = DataRead(); + loader->m_vertexSkip = index == std::numeric_limits::max(); const T* pData = (const T*)(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION])); Vertex_Read_SSSE3(pData, *(__m128*)loader->m_posScale); LOG_VTX();