• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 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 LIBANGLE_RENDERER_D3D_D3D9_VERTEXDECLARATIONCACHE_H_
10 #define LIBANGLE_RENDERER_D3D_D3D9_VERTEXDECLARATIONCACHE_H_
11 
12 #include "libANGLE/Error.h"
13 #include "libANGLE/renderer/d3d/VertexDataManager.h"
14 
15 namespace gl
16 {
17 class VertexDataManager;
18 class Program;
19 }  // namespace gl
20 
21 namespace rx
22 {
23 class VertexDeclarationCache
24 {
25   public:
26     VertexDeclarationCache();
27     ~VertexDeclarationCache();
28 
29     angle::Result applyDeclaration(const gl::Context *context,
30                                    IDirect3DDevice9 *device,
31                                    const std::vector<TranslatedAttribute> &attributes,
32                                    gl::Program *program,
33                                    GLint start,
34                                    GLsizei instances,
35                                    GLsizei *repeatDraw);
36 
37     void markStateDirty();
38 
39   private:
40     UINT mMaxLru;
41 
42     enum
43     {
44         NUM_VERTEX_DECL_CACHE_ENTRIES = 32
45     };
46 
47     struct VBData
48     {
49         unsigned int serial;
50         unsigned int stride;
51         unsigned int offset;
52     };
53 
54     VBData mAppliedVBs[gl::MAX_VERTEX_ATTRIBS];
55     IDirect3DVertexDeclaration9 *mLastSetVDecl;
56     bool mInstancingEnabled;
57 
58     struct VertexDeclCacheEntry
59     {
60         D3DVERTEXELEMENT9 cachedElements[gl::MAX_VERTEX_ATTRIBS + 1];
61         UINT lruCount;
62         IDirect3DVertexDeclaration9 *vertexDeclaration;
63     } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES];
64 };
65 
66 }  // namespace rx
67 
68 #endif  // LIBANGLE_RENDERER_D3D_D3D9_VERTEXDECLARATIONCACHE_H_
69