• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 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 // VertexArray11.h: Defines the rx::VertexArray11 class which implements rx::VertexArrayImpl.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
10 #define LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
11 
12 #include "libANGLE/Framebuffer.h"
13 #include "libANGLE/renderer/VertexArrayImpl.h"
14 #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
15 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
16 
17 namespace rx
18 {
19 class Renderer11;
20 
21 class VertexArray11 : public VertexArrayImpl
22 {
23   public:
24     VertexArray11(const gl::VertexArrayState &data);
25     ~VertexArray11() override;
26     void destroy(const gl::Context *context) override;
27 
28     // Does not apply any state updates - these are done in syncStateForDraw which as access to
29     // the draw call parameters.
30     angle::Result syncState(const gl::Context *context,
31                             const gl::VertexArray::DirtyBits &dirtyBits,
32                             gl::VertexArray::DirtyAttribBitsArray *attribBits,
33                             gl::VertexArray::DirtyBindingBitsArray *bindingBits) override;
34 
35     // Applied buffer pointers are updated here.
36     angle::Result syncStateForDraw(const gl::Context *context,
37                                    GLint firstVertex,
38                                    GLsizei vertexOrIndexCount,
39                                    gl::DrawElementsType indexTypeOrInvalid,
40                                    const void *indices,
41                                    GLsizei instances,
42                                    GLint baseVertex);
43 
44     // This will check the dynamic attribs mask.
45     bool hasActiveDynamicAttrib(const gl::Context *context);
46 
47     const std::vector<TranslatedAttribute> &getTranslatedAttribs() const;
48 
getCurrentStateSerial()49     Serial getCurrentStateSerial() const { return mCurrentStateSerial; }
50 
51     // In case of a multi-view program change, we have to update all attributes so that the divisor
52     // is adjusted.
53     void markAllAttributeDivisorsForAdjustment(int numViews);
54 
55     const TranslatedIndexData &getCachedIndexInfo() const;
56     void updateCachedIndexInfo(const TranslatedIndexData &indexInfo);
57     bool isCachedIndexInfoValid() const;
58 
59     gl::DrawElementsType getCachedDestinationIndexType() const;
60 
61   private:
62     void updateVertexAttribStorage(const gl::Context *context,
63                                    StateManager11 *stateManager,
64                                    size_t attribIndex);
65     angle::Result updateDirtyAttribs(const gl::Context *context,
66                                      const gl::AttributesMask &activeDirtyAttribs);
67     angle::Result updateDynamicAttribs(const gl::Context *context,
68                                        VertexDataManager *vertexDataManager,
69                                        GLint firstVertex,
70                                        GLsizei vertexOrIndexCount,
71                                        gl::DrawElementsType indexTypeOrInvalid,
72                                        const void *indices,
73                                        GLsizei instances,
74                                        GLint baseVertex,
75                                        const gl::AttributesMask &activeDynamicAttribs);
76 
77     angle::Result updateElementArrayStorage(const gl::Context *context,
78                                             GLsizei indexCount,
79                                             gl::DrawElementsType indexType,
80                                             const void *indices,
81                                             bool restartEnabled);
82 
83     std::vector<VertexStorageType> mAttributeStorageTypes;
84     std::vector<TranslatedAttribute> mTranslatedAttribs;
85 
86     // The mask of attributes marked as dynamic.
87     gl::AttributesMask mDynamicAttribsMask;
88 
89     // A set of attributes we know are dirty, and need to be re-translated.
90     gl::AttributesMask mAttribsToTranslate;
91 
92     Serial mCurrentStateSerial;
93 
94     // The numViews value used to adjust the divisor.
95     int mAppliedNumViewsToDivisor;
96 
97     // If the index buffer needs re-streaming.
98     Optional<gl::DrawElementsType> mLastDrawElementsType;
99     Optional<const void *> mLastDrawElementsIndices;
100     Optional<bool> mLastPrimitiveRestartEnabled;
101     IndexStorageType mCurrentElementArrayStorage;
102     Optional<TranslatedIndexData> mCachedIndexInfo;
103     gl::DrawElementsType mCachedDestinationIndexType;
104 };
105 
106 }  // namespace rx
107 
108 #endif  // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
109