Some changes to VertexLoaderManager:

- Lazily create the native vertex format (which involves GL calls) from
RunVertices rather than RefreshLoader itself, freeing the latter to be
run from the CPU thread (hopefully).

- In order to avoid useless allocations while doing so, store the native
format inside the VertexLoader rather than using a cache entry.

- Wrap the s_vertex_loader_map in a lock, for similar reasons.
This commit is contained in:
comex
2014-08-24 23:53:28 -04:00
parent 431fb4d82a
commit 63c62b277d
3 changed files with 64 additions and 52 deletions

View File

@ -8,6 +8,8 @@
// Metroid Prime: P I16-flt N I16-s16 T0 I16-u16 T1 i16-flt
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include "Common/CommonTypes.h"
@ -114,6 +116,9 @@ public:
void AppendToString(std::string *dest) const;
int GetNumLoadedVerts() const { return m_numLoadedVertices; }
NativeVertexFormat* GetNativeVertexFormat();
static void ClearNativeVertexFormatCache() { s_native_vertex_map.clear(); }
private:
int m_VertexSize; // number of bytes of a raw GC vertex. Computed by CompileVertexTranslator.
@ -135,6 +140,9 @@ private:
int m_numLoadedVertices;
NativeVertexFormat* m_native_vertex_format;
static std::map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>> s_native_vertex_map;
void SetVAT(const VAT& vat);
void CompileVertexTranslator();