Hash :
fc09350a
Author :
Date :
2021-08-18T12:24:39
GL: Update VertexArrayGL to use ANGLE_GL_TRY. Bug: angleproject:3020 Change-Id: If3409d0d4bc9fdc5c990cece92461e2526c752c9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1809058 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Peng Huang <penghuang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
//
// Copyright 2015 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.
//
// VertexArrayGL.h: Defines the class interface for VertexArrayGL.
#ifndef LIBANGLE_RENDERER_GL_VERTEXARRAYGL_H_
#define LIBANGLE_RENDERER_GL_VERTEXARRAYGL_H_
#include "libANGLE/renderer/VertexArrayImpl.h"
#include "common/mathutil.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/gl/ContextGL.h"
namespace rx
{
class FunctionsGL;
class StateManagerGL;
struct VertexArrayStateGL;
class VertexArrayGL : public VertexArrayImpl
{
public:
VertexArrayGL(const gl::VertexArrayState &data, GLuint id);
VertexArrayGL(const gl::VertexArrayState &data, GLuint id, VertexArrayStateGL *sharedState);
~VertexArrayGL() override;
void destroy(const gl::Context *context) override;
angle::Result syncClientSideData(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const;
angle::Result syncDrawElementsState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
GLuint getVertexArrayID() const;
VertexArrayStateGL *getNativeState() const;
angle::Result syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
gl::VertexArray::DirtyAttribBitsArray *attribBits,
gl::VertexArray::DirtyBindingBitsArray *bindingBits) override;
angle::Result applyNumViewsToDivisor(const gl::Context *context, int numViews);
angle::Result applyActiveAttribLocationsMask(const gl::Context *context,
const gl::AttributesMask &activeMask);
angle::Result validateState(const gl::Context *context) const;
angle::Result recoverForcedStreamingAttributesForDrawArraysInstanced(
const gl::Context *context) const;
private:
angle::Result syncDrawState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true
angle::Result syncIndexData(const gl::Context *context,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
gl::IndexRange *outIndexRange,
const void **outIndices) const;
// Returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute
void computeStreamingAttributeSizes(const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange,
size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const;
// Stream attributes that have client data
angle::Result streamAttributes(const gl::Context *context,
const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange,
bool applyExtraOffsetWorkaroundForInstancedAttributes) const;
angle::Result syncDirtyAttrib(const gl::Context *context,
size_t attribIndex,
const gl::VertexArray::DirtyAttribBits &dirtyAttribBits);
angle::Result syncDirtyBinding(const gl::Context *context,
size_t bindingIndex,
const gl::VertexArray::DirtyBindingBits &dirtyBindingBits);
angle::Result updateAttribEnabled(const gl::Context *context, size_t attribIndex);
angle::Result updateAttribPointer(const gl::Context *context, size_t attribIndex);
bool supportVertexAttribBinding(const gl::Context *context) const;
angle::Result updateAttribFormat(const gl::Context *context, size_t attribIndex);
angle::Result updateAttribBinding(const gl::Context *context, size_t attribIndex);
angle::Result updateBindingBuffer(const gl::Context *context, size_t bindingIndex);
angle::Result updateBindingDivisor(const gl::Context *context, size_t bindingIndex);
angle::Result updateElementArrayBufferBinding(const gl::Context *context) const;
angle::Result callVertexAttribPointer(const gl::Context *context,
GLuint attribIndex,
const gl::VertexAttribute &attrib,
GLsizei stride,
GLintptr offset) const;
angle::Result recoverForcedStreamingAttributesForDrawArraysInstanced(
const gl::Context *context,
gl::AttributesMask *attributeMask) const;
GLuint mVertexArrayID = 0;
int mAppliedNumViews = 1;
// Remember the program's active attrib location mask so that attributes can be enabled/disabled
// based on whether they are active in the program
gl::AttributesMask mProgramActiveAttribLocationsMask;
bool mOwnsNativeState = false;
VertexArrayStateGL *mNativeState = nullptr;
mutable gl::BindingPointer<gl::Buffer> mElementArrayBuffer;
mutable std::array<gl::BindingPointer<gl::Buffer>, gl::MAX_VERTEX_ATTRIBS> mArrayBuffers;
mutable size_t mStreamingElementArrayBufferSize = 0;
mutable GLuint mStreamingElementArrayBuffer = 0;
mutable size_t mStreamingArrayBufferSize = 0;
mutable GLuint mStreamingArrayBuffer = 0;
// Used for Mac Intel instanced draw workaround
mutable gl::AttributesMask mForcedStreamingAttributesForDrawArraysInstancedMask;
mutable gl::AttributesMask mInstancedAttributesMask;
mutable std::array<GLint, gl::MAX_VERTEX_ATTRIBS> mForcedStreamingAttributesFirstOffsets;
};
ANGLE_INLINE angle::Result VertexArrayGL::syncDrawElementsState(
const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const
{
return syncDrawState(context, activeAttributesMask, 0, count, type, indices, instanceCount,
primitiveRestartEnabled, outIndices);
}
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_VERTEXARRAYGL_H_