Commit 27464aa9 by Geoff Lang

Sync the generic vertex attribute data.

BUG=angleproject:883 Change-Id: If5616bf24c1ac5477ae80cf1d25efa70b62edea1 Reviewed-on: https://chromium-review.googlesource.com/268750Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1eb708e1
......@@ -112,12 +112,7 @@ void State::initialize(const Caps &caps, GLuint clientVersion)
mActiveSampler = 0;
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
mVertexAttribCurrentValues.resize(caps.maxVertexAttributes);
for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); ++attribIndex)
{
mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
}
mUniformBuffers.resize(caps.maxCombinedUniformBlocks);
......
......@@ -79,6 +79,15 @@ struct VertexAttribCurrentValueData
};
GLenum Type;
VertexAttribCurrentValueData()
: Type(GL_FLOAT)
{
FloatValues[0] = 0.0f;
FloatValues[1] = 0.0f;
FloatValues[2] = 0.0f;
FloatValues[3] = 1.0f;
}
void setFloatValues(const GLfloat floatValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
......
......@@ -24,6 +24,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
: mFunctions(functions),
mProgram(0),
mVAO(0),
mVertexAttribCurrentValues(rendererCaps.maxVertexAttributes),
mBuffers(),
mTextureUnitIndex(0),
mTextures(),
......@@ -345,6 +346,17 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
const gl::State &state = *data.state;
const gl::Caps &caps = *data.caps;
const gl::VertexArray *vao = state.getVertexArray();
const std::vector<gl::VertexAttribute>& attribs = vao->getVertexAttributes();
for (size_t i = 0; i < attribs.size(); i++)
{
if (!attribs[i].enabled)
{
// TODO: Don't sync this attribute if it is not used by the program.
setAttributeCurrentData(i, state.getVertexAttribCurrentValue(i));
}
}
const gl::Program *program = state.getProgram();
const ProgramGL *programGL = GetImplAs<ProgramGL>(program);
useProgram(programGL->getProgramID());
......@@ -462,6 +474,21 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
return gl::Error(GL_NO_ERROR);
}
void StateManagerGL::setAttributeCurrentData(size_t index, const gl::VertexAttribCurrentValueData &data)
{
if (mVertexAttribCurrentValues[index] != data)
{
mVertexAttribCurrentValues[index] = data;
switch (mVertexAttribCurrentValues[index].Type)
{
case GL_FLOAT: mFunctions->vertexAttrib4fv(index, mVertexAttribCurrentValues[index].FloatValues);
case GL_INT: mFunctions->vertexAttrib4iv(index, mVertexAttribCurrentValues[index].IntValues);
case GL_UNSIGNED_INT: mFunctions->vertexAttrib4uiv(index, mVertexAttribCurrentValues[index].UnsignedIntValues);
default: UNREACHABLE();
}
}
}
void StateManagerGL::setScissorTestEnabled(bool enabled)
{
if (mScissorTestEnabled != enabled)
......
......@@ -58,6 +58,8 @@ class StateManagerGL : angle::NonCopyable
private:
gl::Error setGenericDrawState(const gl::Data &data);
void setAttributeCurrentData(size_t index, const gl::VertexAttribCurrentValueData &data);
void setScissorTestEnabled(bool enabled);
void setScissor(const gl::Rectangle &scissor);
......@@ -102,7 +104,10 @@ class StateManagerGL : angle::NonCopyable
const FunctionsGL *mFunctions;
GLuint mProgram;
GLuint mVAO;
std::vector<gl::VertexAttribCurrentValueData> mVertexAttribCurrentValues;
std::map<GLenum, GLuint> mBuffers;
size_t mTextureUnitIndex;
......
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