michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // VertexDeclarationCache.h: Defines a helper class to construct and cache vertex declarations. michael@0: michael@0: #ifndef LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ michael@0: #define LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ michael@0: michael@0: #include "libGLESv2/renderer/VertexDataManager.h" michael@0: michael@0: namespace gl michael@0: { michael@0: class VertexDataManager; michael@0: } michael@0: michael@0: namespace rx michael@0: { michael@0: michael@0: class VertexDeclarationCache michael@0: { michael@0: public: michael@0: VertexDeclarationCache(); michael@0: ~VertexDeclarationCache(); michael@0: michael@0: GLenum applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw); michael@0: michael@0: void markStateDirty(); michael@0: michael@0: private: michael@0: UINT mMaxLru; michael@0: michael@0: enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 32 }; michael@0: michael@0: struct VBData michael@0: { michael@0: unsigned int serial; michael@0: unsigned int stride; michael@0: unsigned int offset; michael@0: }; michael@0: michael@0: VBData mAppliedVBs[gl::MAX_VERTEX_ATTRIBS]; michael@0: IDirect3DVertexDeclaration9 *mLastSetVDecl; michael@0: bool mInstancingEnabled; michael@0: michael@0: struct VertexDeclCacheEntry michael@0: { michael@0: D3DVERTEXELEMENT9 cachedElements[gl::MAX_VERTEX_ATTRIBS + 1]; michael@0: UINT lruCount; michael@0: IDirect3DVertexDeclaration9 *vertexDeclaration; michael@0: } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES]; michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif // LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_