Hash :
2597fb64
Author :
Date :
2016-12-09T16:38:02
ES31: Refactor VertexArray for Vertex Attrib Binding
OpenGL ES3.1 feature Vertex Attrib Binding requires vertex arrays should
be split into two arrays:
1. an array of vertex buffer binding points, each of which specifies:
- a bound buffer object,
- a starting offset for vertex attribute data in that buffer object,
- a stride used by all attributes using that binding point,
- a frequency divisor used by all attributes using that binding point.
2. an array of generic vertex attribute format information records, each
of which specifies:
- a reference to one of the new buffer binding points above,
- a component count and format, and a normalization flag for the
attribute data,
- the offset of the attribute data relative to the base offset of each
vertex found at the associated binding point.
Current ANGLE implementation simply uses a struct to represent a vertex
attribute object, which does not meet the requirements above.
This patch aims to be the the basis of the implementation of all ES3.1
Vertex Attrib Binding APIs by refactoring the struct VertexAttribute and
the class VertexArray to fit the new data layout and ensuring all current
functionality is retained.
BUG=angleproject:1593
TEST=angle_unittests, angle_end2end_tests, gpu_unittests
Change-Id: Ieb41f1bf503f815fd0476d2ea045dcb863465254
Reviewed-on: https://chromium-review.googlesource.com/418880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@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
//
// 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"
namespace rx
{
class FunctionsGL;
class StateManagerGL;
class VertexArrayGL : public VertexArrayImpl
{
public:
VertexArrayGL(const gl::VertexArrayState &data,
const FunctionsGL *functions,
StateManagerGL *stateManager);
~VertexArrayGL() override;
gl::Error syncDrawArraysState(const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const;
gl::Error syncDrawElementsState(const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const GLvoid *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const GLvoid **outIndices) const;
gl::Error syncElementArrayState() const;
GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const;
void syncState(const gl::VertexArray::DirtyBits &dirtyBits) override;
private:
gl::Error syncDrawState(const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const GLvoid *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const GLvoid **outIndices) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true
gl::Error syncIndexData(GLsizei count,
GLenum type,
const GLvoid *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
gl::IndexRange *outIndexRange,
const GLvoid **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 &activeAttributesMask,
GLsizei instanceCount,
const gl::IndexRange &indexRange,
size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const;
// Stream attributes that have client data
gl::Error streamAttributes(const gl::AttributesMask &activeAttributesMask,
GLsizei instanceCount,
const gl::IndexRange &indexRange) const;
void updateNeedsStreaming(size_t attribIndex);
void updateAttribEnabled(size_t attribIndex);
void updateAttribPointer(size_t attribIndex);
void updateAttribDivisor(size_t attribIndex);
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
GLuint mVertexArrayID;
mutable BindingPointer<gl::Buffer> mAppliedElementArrayBuffer;
mutable std::vector<gl::VertexAttribute> mAppliedAttributes;
mutable std::vector<gl::VertexBinding> mAppliedBindings;
mutable size_t mStreamingElementArrayBufferSize;
mutable GLuint mStreamingElementArrayBuffer;
mutable size_t mStreamingArrayBufferSize;
mutable GLuint mStreamingArrayBuffer;
gl::AttributesMask mAttributesNeedStreaming;
};
}
#endif // LIBANGLE_RENDERER_GL_VERTEXARRAYGL_H_