1 // 2 // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // VertexDeclarationCache.h: Defines a helper class to construct and cache vertex declarations. 8 9 #ifndef LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ 10 #define LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ 11 12 #include "libGLESv2/Error.h" 13 #include "libGLESv2/renderer/d3d/VertexDataManager.h" 14 15 namespace gl 16 { 17 class VertexDataManager; 18 } 19 20 namespace rx 21 { 22 23 class VertexDeclarationCache 24 { 25 public: 26 VertexDeclarationCache(); 27 ~VertexDeclarationCache(); 28 29 gl::Error applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw); 30 31 void markStateDirty(); 32 33 private: 34 UINT mMaxLru; 35 36 enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 32 }; 37 38 struct VBData 39 { 40 unsigned int serial; 41 unsigned int stride; 42 unsigned int offset; 43 }; 44 45 VBData mAppliedVBs[gl::MAX_VERTEX_ATTRIBS]; 46 IDirect3DVertexDeclaration9 *mLastSetVDecl; 47 bool mInstancingEnabled; 48 49 struct VertexDeclCacheEntry 50 { 51 D3DVERTEXELEMENT9 cachedElements[gl::MAX_VERTEX_ATTRIBS + 1]; 52 UINT lruCount; 53 IDirect3DVertexDeclaration9 *vertexDeclaration; 54 } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES]; 55 }; 56 57 } 58 59 #endif // LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ 60