1 // Copyright 2008 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <memory> 8 #include <string> 9 #include <unordered_map> 10 11 #include "Common/CommonTypes.h" 12 13 class DataReader; 14 class NativeVertexFormat; 15 struct PortableVertexDeclaration; 16 17 namespace VertexLoaderManager 18 { 19 using NativeVertexFormatMap = 20 std::unordered_map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>>; 21 22 void Init(); 23 void Clear(); 24 25 void MarkAllDirty(); 26 27 // Creates or obtains a pointer to a VertexFormat representing decl. 28 // If this results in a VertexFormat being created, if the game later uses a matching vertex 29 // declaration, the one that was previously created will be used. 30 NativeVertexFormat* GetOrCreateMatchingFormat(const PortableVertexDeclaration& decl); 31 32 // For vertex ubershaders, all attributes need to be present, even when the vertex 33 // format does not contain them. This function returns a vertex format with dummy 34 // offsets set to the unused attributes. 35 NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl); 36 37 // Returns -1 if buf_size is insufficient, else the amount of bytes consumed 38 int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool is_preprocess); 39 40 // For debugging 41 std::string VertexLoadersToString(); 42 43 NativeVertexFormat* GetCurrentVertexFormat(); 44 45 // Resolved pointers to array bases. Used by vertex loaders. 46 extern u8* cached_arraybases[12]; 47 void UpdateVertexArrayPointers(); 48 49 // Position cache for zfreeze (3 vertices, 4 floats each to allow SIMD overwrite). 50 // These arrays are in reverse order. 51 extern float position_cache[3][4]; 52 extern u32 position_matrix_index[4]; 53 54 // VB_HAS_X. Bitmask telling what vertex components are present. 55 extern u32 g_current_components; 56 } // namespace VertexLoaderManager 57