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 GLuint baseInstance, 44 bool promoteDynamic); 45 46 // This will check the dynamic attribs mask. 47 bool hasActiveDynamicAttrib(const gl::Context *context); 48 49 const std::vector<TranslatedAttribute> &getTranslatedAttribs() const; 50 getCurrentStateSerial()51 UniqueSerial getCurrentStateSerial() const { return mCurrentStateSerial; } 52 53 // In case of a multi-view program change, we have to update all attributes so that the divisor 54 // is adjusted. 55 void markAllAttributeDivisorsForAdjustment(int numViews); 56 57 const TranslatedIndexData &getCachedIndexInfo() const; 58 void updateCachedIndexInfo(const TranslatedIndexData &indexInfo); 59 bool isCachedIndexInfoValid() const; 60 61 gl::DrawElementsType getCachedDestinationIndexType() const; 62 63 private: 64 void updateVertexAttribStorage(const gl::Context *context, 65 StateManager11 *stateManager, 66 size_t attribIndex); 67 angle::Result updateDirtyAttribs(const gl::Context *context, 68 const gl::AttributesMask &activeDirtyAttribs); 69 angle::Result updateDynamicAttribs(const gl::Context *context, 70 VertexDataManager *vertexDataManager, 71 GLint firstVertex, 72 GLsizei vertexOrIndexCount, 73 gl::DrawElementsType indexTypeOrInvalid, 74 const void *indices, 75 GLsizei instances, 76 GLint baseVertex, 77 GLuint baseInstance, 78 bool promoteDynamic, 79 const gl::AttributesMask &activeDynamicAttribs); 80 81 angle::Result updateElementArrayStorage(const gl::Context *context, 82 GLsizei indexCount, 83 gl::DrawElementsType indexType, 84 const void *indices, 85 bool restartEnabled); 86 87 std::vector<VertexStorageType> mAttributeStorageTypes; 88 std::vector<TranslatedAttribute> mTranslatedAttribs; 89 90 // The mask of attributes marked as dynamic. 91 gl::AttributesMask mDynamicAttribsMask; 92 93 // A set of attributes we know are dirty, and need to be re-translated. 94 gl::AttributesMask mAttribsToTranslate; 95 96 UniqueSerial mCurrentStateSerial; 97 98 // The numViews value used to adjust the divisor. 99 int mAppliedNumViewsToDivisor; 100 101 // If the index buffer needs re-streaming. 102 Optional<gl::DrawElementsType> mLastDrawElementsType; 103 Optional<const void *> mLastDrawElementsIndices; 104 Optional<bool> mLastPrimitiveRestartEnabled; 105 IndexStorageType mCurrentElementArrayStorage; 106 Optional<TranslatedIndexData> mCachedIndexInfo; 107 gl::DrawElementsType mCachedDestinationIndexType; 108 }; 109 110 } // namespace rx 111 112 #endif // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_ 113