27 #include "GraphicsTypes.h" 29 #include "InputLayout.h" 30 #include "LockHelper.h" 31 #include "HashUtils.h" 32 #include "DeviceContextBase.h" 33 #include "BaseInterfacesGL.h" 44 VAOCache(
const VAOCache&) =
delete;
45 VAOCache( VAOCache&&) =
delete;
46 VAOCache& operator = (
const VAOCache&) =
delete;
47 VAOCache& operator = ( VAOCache&&) =
delete;
51 const GLObjectWrappers::GLVertexArrayObj& GetVAO( IPipelineState *pPSO,
52 IBuffer *pIndexBuffer,
53 VertexStreamInfo VertexStreams[],
54 Uint32 NumVertexStreams,
55 class GLContextState &GLContextState);
56 const GLObjectWrappers::GLVertexArrayObj& GetEmptyVAO();
58 void OnDestroyBuffer(IBuffer *pBuffer);
59 void OnDestroyPSO(IPipelineState *pPSO);
65 VAOCacheKey(
const IPipelineState* pso,
const IBuffer* indBuffer) :
67 pIndexBuffer(indBuffer),
78 const IPipelineState*
const pPSO;
79 const IBuffer*
const pIndexBuffer;
83 const IBuffer* pBuffer;
88 mutable size_t Hash = 0;
90 bool operator == (
const VAOCacheKey &Key)
const 92 return pPSO == Key.pPSO &&
93 pIndexBuffer == Key.pIndexBuffer &&
94 NumUsedSlots == Key.NumUsedSlots &&
95 std::memcmp(Streams, Key.Streams,
sizeof(StreamAttribs) * NumUsedSlots) == 0;
99 struct VAOCacheKeyHashFunc
101 std::size_t operator() (
const VAOCacheKey& Key )
const 105 std::size_t Seed = 0;
106 HashCombine(Seed, Key.pPSO, Key.NumUsedSlots);
107 if (Key.pIndexBuffer)
108 HashCombine(Seed, Key.pIndexBuffer);
109 for (Uint32 slot = 0; slot < Key.NumUsedSlots; ++slot)
111 auto &CurrStream = Key.Streams[slot];
112 if (CurrStream.pBuffer)
114 HashCombine(Seed, CurrStream.pBuffer);
115 HashCombine(Seed, CurrStream.Offset);
116 HashCombine(Seed, CurrStream.Stride);
126 friend class RenderDeviceGLImpl;
127 ThreadingTools::LockFlag m_CacheLockFlag;
128 std::unordered_map<VAOCacheKey, GLObjectWrappers::GLVertexArrayObj, VAOCacheKeyHashFunc> m_Cache;
129 std::unordered_multimap<const IPipelineState*, VAOCacheKey> m_PSOToKey;
130 std::unordered_multimap<const IBuffer*, VAOCacheKey> m_BuffToKey;
135 GLObjectWrappers::GLVertexArrayObj m_EmptyVAO;
static constexpr Uint32 MaxBufferSlots
Maximum number of input buffer slots. D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32...
Definition: Constants.h:33
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34