Commit 5b97287e by Geoff Lang

Revert "Don't use a helper function to get the vertex attributes."

Caused a warning on 32-bit builds. This reverts commit 20d78d24. Change-Id: I4d61024fb29978e7f1bacdd693fc6f1bc00bd0cc Reviewed-on: https://chromium-review.googlesource.com/262918Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 7159ea67
......@@ -1055,6 +1055,11 @@ void State::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GL
getVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
}
const VertexAttribute &State::getVertexAttribState(unsigned int attribNum) const
{
return getVertexArray()->getVertexAttribute(attribNum);
}
const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(unsigned int attribNum) const
{
ASSERT(static_cast<size_t>(attribNum) < mVertexAttribCurrentValues.size());
......@@ -1446,10 +1451,9 @@ bool State::hasMappedBuffer(GLenum target) const
{
if (target == GL_ARRAY_BUFFER)
{
const VertexArray *vao = getVertexArray();
for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); attribIndex++)
{
const gl::VertexAttribute &vertexAttrib = vao->getVertexAttribute(attribIndex);
const gl::VertexAttribute &vertexAttrib = getVertexAttribState(static_cast<unsigned int>(attribIndex));
gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
{
......
......@@ -229,6 +229,7 @@ class State
void setVertexAttribi(GLuint index, const GLint values[4]);
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
const void *getVertexAttribPointer(unsigned int attribNum) const;
......
......@@ -59,11 +59,6 @@ const VertexAttribute& VertexArray::getVertexAttribute(size_t attributeIndex) co
return mVertexAttributes[attributeIndex];
}
const std::vector<VertexAttribute> &VertexArray::getVertexAttributes() const
{
return mVertexAttributes;
}
void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor)
{
ASSERT(index < getMaxAttribs());
......
......@@ -37,14 +37,13 @@ class VertexArray
GLuint id() const;
const VertexAttribute& getVertexAttribute(size_t attributeIndex) const;
const std::vector<VertexAttribute> &getVertexAttributes() const;
void detachBuffer(GLuint bufferName);
void setVertexAttribDivisor(GLuint index, GLuint divisor);
void enableAttribute(unsigned int attributeIndex, bool enabledState);
void setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const VertexAttribute* getVertexAttributes() const { return &mVertexAttributes[0]; }
Buffer *getElementArrayBuffer() const { return mElementArrayBuffer.get(); }
void setElementArrayBuffer(Buffer *buffer);
GLuint getElementArrayBufferId() const { return mElementArrayBuffer.id(); }
......
......@@ -190,8 +190,8 @@ void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
Program *program,
const State &state)
{
const std::vector<VertexAttribute> &vertexAttributes = state.getVertexArray()->getVertexAttributes();
for (unsigned int attributeIndex = 0; attributeIndex < vertexAttributes.size(); attributeIndex++)
const VertexAttribute *vertexAttributes = state.getVertexArray()->getVertexAttributes();
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
int semanticIndex = program->getSemanticIndex(attributeIndex);
......
......@@ -14,7 +14,6 @@
#include "libANGLE/Buffer.h"
#include "libANGLE/Program.h"
#include "libANGLE/VertexAttribute.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/State.h"
namespace
......@@ -86,13 +85,13 @@ VertexDataManager::~VertexDataManager()
}
}
void VertexDataManager::hintUnmapAllResources(const std::vector<gl::VertexAttribute> &vertexAttributes)
void VertexDataManager::hintUnmapAllResources(const gl::State &state)
{
mStreamingBuffer->getVertexBuffer()->hintUnmapResource();
for (int i = 0; i < vertexAttributes.size(); i++)
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
const gl::VertexAttribute &attrib = vertexAttributes[i];
const gl::VertexAttribute &attrib = state.getVertexAttribState(i);
if (attrib.enabled)
{
gl::Buffer *buffer = attrib.buffer.get();
......@@ -123,25 +122,25 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
return gl::Error(GL_OUT_OF_MEMORY, "Internal streaming vertex buffer is unexpectedly NULL.");
}
const gl::VertexArray *vertexArray = state.getVertexArray();
const std::vector<gl::VertexAttribute> &vertexAttributes = vertexArray->getVertexAttributes();
// Invalidate static buffers that don't contain matching attributes
for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{
translated[attributeIndex].active = (state.getProgram()->getSemanticIndex(attributeIndex) != -1);
if (translated[attributeIndex].active && vertexAttributes[attributeIndex].enabled)
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
if (translated[attributeIndex].active && curAttrib.enabled)
{
invalidateMatchingStaticData(vertexAttributes[attributeIndex], state.getVertexAttribCurrentValue(attributeIndex));
invalidateMatchingStaticData(curAttrib, state.getVertexAttribCurrentValue(attributeIndex));
}
}
// Reserve the required space in the buffers
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
if (translated[i].active && vertexAttributes[i].enabled)
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active && curAttrib.enabled)
{
gl::Error error = reserveSpaceForAttrib(vertexAttributes[i], state.getVertexAttribCurrentValue(i), count, instances);
gl::Error error = reserveSpaceForAttrib(curAttrib, state.getVertexAttribCurrentValue(i), count, instances);
if (error.isError())
{
return error;
......@@ -152,7 +151,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
// Perform the vertex data translations
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
const gl::VertexAttribute &curAttrib = vertexAttributes[i];
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active)
{
if (curAttrib.enabled)
......@@ -162,7 +161,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
if (error.isError())
{
hintUnmapAllResources(vertexAttributes);
hintUnmapAllResources(state);
return error;
}
}
......@@ -178,7 +177,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
mCurrentValueBuffer[i]);
if (error.isError())
{
hintUnmapAllResources(vertexAttributes);
hintUnmapAllResources(state);
return error;
}
}
......@@ -186,11 +185,11 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
}
// Hint to unmap all the resources
hintUnmapAllResources(vertexAttributes);
hintUnmapAllResources(state);
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
const gl::VertexAttribute &curAttrib = vertexAttributes[i];
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active && curAttrib.enabled)
{
gl::Buffer *buffer = curAttrib.buffer.get();
......
......@@ -80,7 +80,7 @@ class VertexDataManager
size_t *cachedOffset,
StreamingVertexBufferInterface *buffer);
void hintUnmapAllResources(const std::vector<gl::VertexAttribute> &vertexAttributes);
void hintUnmapAllResources(const gl::State &state);
RendererD3D *const mRenderer;
......
......@@ -2856,6 +2856,7 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
return;
}
const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
if (!ValidateGetVertexAttribParameters(context, pname))
{
return;
......@@ -2871,7 +2872,6 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
}
}
......@@ -2890,6 +2890,8 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
return;
}
const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
if (!ValidateGetVertexAttribParameters(context, pname))
{
return;
......@@ -2906,7 +2908,6 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
}
}
......
......@@ -1379,6 +1379,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
return;
}
const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
if (!ValidateGetVertexAttribParameters(context, pname))
{
return;
......@@ -1394,7 +1396,6 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
}
}
......@@ -1420,6 +1421,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
return;
}
const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
if (!ValidateGetVertexAttribParameters(context, pname))
{
return;
......@@ -1435,7 +1438,6 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
}
else
{
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
}
}
......
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