Commit 7c82bc46 by Geoff Lang

Handle client data for draw calls with RendererGL.

BUG=angleproject:880 Change-Id: I67839d4934767db77cff7b501002c5aafbcbaef2 Reviewed-on: https://chromium-review.googlesource.com/257672Tested-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 84e91d39
......@@ -59,7 +59,12 @@ gl::Error RendererGL::finish()
gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode,
GLint first, GLsizei count, GLsizei instances)
{
mStateManager->setDrawState(data);
gl::Error error = mStateManager->setDrawArraysState(data, first, count);
if (error.isError())
{
return error;
}
mFunctions->drawArrays(mode, first, count);
return gl::Error(GL_NO_ERROR);
......@@ -74,8 +79,14 @@ gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei co
UNIMPLEMENTED();
}
mStateManager->setDrawState(data);
mFunctions->drawElements(mode, count, type, indices);
const GLvoid *drawIndexPointer = nullptr;
gl::Error error = mStateManager->setDrawElementsState(data, count, type, indices, &drawIndexPointer);
if (error.isError())
{
return error;
}
mFunctions->drawElements(mode, count, type, drawIndexPointer);
return gl::Error(GL_NO_ERROR);
}
......
......@@ -56,7 +56,7 @@ void StateManagerGL::bindVertexArray(GLuint vao)
void StateManagerGL::bindBuffer(GLenum type, GLuint buffer)
{
if (mBuffers[type] == 0)
if (mBuffers[type] != buffer)
{
mBuffers[type] = buffer;
mFunctions->bindBuffer(type, buffer);
......@@ -96,16 +96,42 @@ void StateManagerGL::setPixelUnpackState(GLint alignment, GLint rowLength)
}
}
void StateManagerGL::setDrawState(const gl::Data &data)
gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, GLint first, GLsizei count)
{
const gl::State &state = *data.state;
const gl::Caps &caps = *data.caps;
const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
vaoGL->syncState();
vaoGL->syncDrawArraysState(first, count);
bindVertexArray(vaoGL->getVertexArrayID());
return setGenericDrawState(data);
}
gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, GLsizei count, GLenum type, const GLvoid *indices,
const GLvoid **outIndices)
{
const gl::State &state = *data.state;
const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
gl::Error error = vaoGL->syncDrawElementsState(count, type, indices, outIndices);
if (error.isError())
{
return error;
}
bindVertexArray(vaoGL->getVertexArrayID());
return setGenericDrawState(data);
}
gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
{
const gl::State &state = *data.state;
const gl::Caps &caps = *data.caps;
const gl::Program *program = state.getProgram();
const ProgramGL *programGL = GetImplAs<ProgramGL>(program);
useProgram(programGL->getProgramID());
......@@ -154,6 +180,8 @@ void StateManagerGL::setDrawState(const gl::Data &data)
}
}
}
return gl::Error(GL_NO_ERROR);
}
}
......@@ -10,6 +10,7 @@
#define LIBANGLE_RENDERER_GL_STATEMANAGERGL_H_
#include "common/debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/renderer/gl/functionsgl_typedefs.h"
#include <map>
......@@ -37,11 +38,15 @@ class StateManagerGL
void bindTexture(GLenum type, GLuint texture);
void setPixelUnpackState(GLint alignment, GLint rowLength);
void setDrawState(const gl::Data &data);
gl::Error setDrawArraysState(const gl::Data &data, GLint first, GLsizei count);
gl::Error setDrawElementsState(const gl::Data &data, GLsizei count, GLenum type, const GLvoid *indices,
const GLvoid **outIndices);
private:
DISALLOW_COPY_AND_ASSIGN(StateManagerGL);
gl::Error setGenericDrawState(const gl::Data &data);
const FunctionsGL *mFunctions;
GLuint mProgram;
......
......@@ -28,13 +28,31 @@ class VertexArrayGL : public VertexArrayImpl
void setAttributeDivisor(size_t idx, GLuint divisor) override;
void enableAttribute(size_t idx, bool enabledState) override;
void syncState() const;
gl::Error syncDrawArraysState(GLint first, GLsizei count) const;
gl::Error syncDrawElementsState(GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const;
GLuint getVertexArrayID() const;
private:
DISALLOW_COPY_AND_ASSIGN(VertexArrayGL);
gl::Error syncDrawState(GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const;
// Check if any vertex attributes need to be streamed
bool doAttributesNeedStreaming() const;
// Apply attribute state, returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute
gl::Error syncAttributeState(bool attributesNeedStreaming, const RangeUI &indexRange, size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true
gl::Error syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming,
RangeUI *outIndexRange, const GLvoid **outIndices) const;
// Stream attributes that have client data
gl::Error streamAttributes(size_t streamingDataSize, size_t maxAttributeDataSize, const RangeUI &indexRange) const;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
......@@ -45,6 +63,12 @@ class VertexArrayGL : public VertexArrayImpl
mutable GLuint mAppliedElementArrayBuffer;
mutable std::vector<gl::VertexAttribute> mAppliedAttributes;
mutable size_t mStreamingElementArrayBufferSize;
mutable GLuint mStreamingElementArrayBuffer;
mutable size_t mStreamingArrayBufferSize;
mutable GLuint mStreamingArrayBuffer;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment