Home | History | Annotate | Download | only in d3d9
      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/renderer/VertexDataManager.h"
     13 
     14 namespace gl
     15 {
     16 class VertexDataManager;
     17 }
     18 
     19 namespace rx
     20 {
     21 
     22 class VertexDeclarationCache
     23 {
     24   public:
     25     VertexDeclarationCache();
     26     ~VertexDeclarationCache();
     27 
     28     GLenum applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw);
     29 
     30     void markStateDirty();
     31 
     32   private:
     33     UINT mMaxLru;
     34 
     35     enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 32 };
     36 
     37     struct VBData
     38     {
     39         unsigned int serial;
     40         unsigned int stride;
     41         unsigned int offset;
     42     };
     43 
     44     VBData mAppliedVBs[gl::MAX_VERTEX_ATTRIBS];
     45     IDirect3DVertexDeclaration9 *mLastSetVDecl;
     46     bool mInstancingEnabled;
     47 
     48     struct VertexDeclCacheEntry
     49     {
     50         D3DVERTEXELEMENT9 cachedElements[gl::MAX_VERTEX_ATTRIBS + 1];
     51         UINT lruCount;
     52         IDirect3DVertexDeclaration9 *vertexDeclaration;
     53     } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES];
     54 };
     55 
     56 }
     57 
     58 #endif // LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_
     59