author Noemi Erli <>
Thu, 24 May 2018 18:46:25 +0300
changeset 467844 ff8505d177b9
parent 467572 b7c91a6f1b0a
child 469493 0ca4869b69ea
permissions -rw-r--r--
Backed out 3 changesets (bug 1459785) for causing a=backout Backed out changeset 88675b68241a (bug 1459785) Backed out changeset b7c91a6f1b0a (bug 1459785) Backed out changeset 21af8dc00aa8 (bug 1459785)

// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// VertexArray11.h: Defines the rx::VertexArray11 class which implements rx::VertexArrayImpl.


#include "libANGLE/Framebuffer.h"
#include "libANGLE/renderer/VertexArrayImpl.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/signal_utils.h"

namespace rx
class Renderer11;

class VertexArray11 : public VertexArrayImpl, public angle::ObserverInterface
    VertexArray11(const gl::VertexArrayState &data);
    ~VertexArray11() override;
    void destroy(const gl::Context *context) override;

    void syncState(const gl::Context *context,
                   const gl::VertexArray::DirtyBits &dirtyBits) override;
    // This will flush any pending attrib updates and then check the dynamic attribs mask.
    bool hasActiveDynamicAttrib(const gl::Context *context);
    gl::Error updateDirtyAndDynamicAttribs(const gl::Context *context,
                                           VertexDataManager *vertexDataManager,
                                           const DrawCallVertexParams &vertexParams);
    void clearDirtyAndPromoteDynamicAttribs(const gl::Context *context,
                                            const DrawCallVertexParams &vertexParams);

    const std::vector<TranslatedAttribute> &getTranslatedAttribs() const;

    // Observer implementation
    void onSubjectStateChange(const gl::Context *context,
                              angle::SubjectIndex index,
                              angle::SubjectMessage message) override;

    Serial getCurrentStateSerial() const { return mCurrentStateSerial; }

    // In case of a multi-view program change, we have to update all attributes so that the divisor
    // is adjusted.
    void markAllAttributeDivisorsForAdjustment(int numViews);

    bool flushAttribUpdates(const gl::Context *context);

    // Returns true if the element array buffer needs to be translated.
    bool updateElementArrayStorage(const gl::Context *context,
                                   GLenum elementType,
                                   GLenum destElementType,
                                   const void *indices);

    TranslatedIndexData *getCachedIndexInfo();
    void setCachedIndexInfoValid();
    bool isCachedIndexInfoValid() const;

    void updateVertexAttribStorage(const gl::Context *context, size_t attribIndex);

    std::vector<VertexStorageType> mAttributeStorageTypes;
    std::vector<TranslatedAttribute> mTranslatedAttribs;

    // The mask of attributes marked as dynamic.
    gl::AttributesMask mDynamicAttribsMask;

    // A mask of attributes that need to be re-evaluated.
    gl::AttributesMask mAttribsToUpdate;

    // A set of attributes we know are dirty, and need to be re-translated.
    gl::AttributesMask mAttribsToTranslate;

    // We need to keep a safe pointer to the Buffer so we can attach the correct dirty callbacks.
    std::vector<gl::BindingPointer<gl::Buffer>> mCurrentArrayBuffers;
    gl::BindingPointer<gl::Buffer> mCurrentElementArrayBuffer;

    std::vector<angle::ObserverBinding> mOnArrayBufferDataDirty;
    angle::ObserverBinding mOnElementArrayBufferDataDirty;

    Serial mCurrentStateSerial;

    // The numViews value used to adjust the divisor.
    int mAppliedNumViewsToDivisor;

    // If the index buffer needs re-streaming.
    GLenum mLastElementType;
    unsigned int mLastDrawElementsOffset;
    IndexStorageType mCurrentElementArrayStorage;
    TranslatedIndexData mCachedIndexInfo;
    bool mCachedIndexInfoValid;

}  // namespace rx