Created a structure for holding current attribute data.

TRAC #22693 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2116 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2fa73c51
......@@ -2540,10 +2540,11 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values)
{
ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
mState.vertexAttribute[index].mCurrentValue[0] = values[0];
mState.vertexAttribute[index].mCurrentValue[1] = values[1];
mState.vertexAttribute[index].mCurrentValue[2] = values[2];
mState.vertexAttribute[index].mCurrentValue[3] = values[3];
mState.vertexAttribute[index].mCurrentValue.FloatValues[0] = values[0];
mState.vertexAttribute[index].mCurrentValue.FloatValues[1] = values[1];
mState.vertexAttribute[index].mCurrentValue.FloatValues[2] = values[2];
mState.vertexAttribute[index].mCurrentValue.FloatValues[3] = values[3];
mState.vertexAttribute[index].mCurrentValue.Type = GL_FLOAT;
}
void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
......
......@@ -77,10 +77,11 @@ class VertexAttribute
public:
VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0)
{
mCurrentValue[0] = 0.0f;
mCurrentValue[1] = 0.0f;
mCurrentValue[2] = 0.0f;
mCurrentValue[3] = 1.0f;
mCurrentValue.FloatValues[0] = 0.0f;
mCurrentValue.FloatValues[1] = 0.0f;
mCurrentValue.FloatValues[2] = 0.0f;
mCurrentValue.FloatValues[3] = 1.0f;
mCurrentValue.Type = GL_FLOAT;
}
int typeSize() const
......@@ -118,7 +119,19 @@ class VertexAttribute
BindingPointer<Buffer> mBoundBuffer; // Captured when glVertexAttribPointer is called.
bool mArrayEnabled; // From glEnable/DisableVertexAttribArray
float mCurrentValue[4]; // From glVertexAttrib
struct CurrentValueData
{
union
{
GLfloat FloatValues[4];
GLint IntValues[4];
GLuint UnsignedIntValues[4];
};
GLenum Type;
};
CurrentValueData mCurrentValue; // From glVertexAttrib
unsigned int mDivisor;
};
......
......@@ -4256,7 +4256,7 @@ void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
case GL_CURRENT_VERTEX_ATTRIB:
for (int i = 0; i < 4; ++i)
{
params[i] = attribState.mCurrentValue[i];
params[i] = attribState.mCurrentValue.FloatValues[i];
}
break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
......@@ -4314,7 +4314,7 @@ void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
case GL_CURRENT_VERTEX_ATTRIB:
for (int i = 0; i < 4; ++i)
{
float currentValue = attribState.mCurrentValue[i];
float currentValue = attribState.mCurrentValue.FloatValues[i];
params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
}
break;
......
......@@ -36,10 +36,11 @@ VertexDataManager::VertexDataManager(Renderer *renderer) : mRenderer(renderer)
{
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
mCurrentValue[i][0] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i][1] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i][2] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i][3] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i].FloatValues[0] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i].FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i].FloatValues[2] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i].FloatValues[3] = std::numeric_limits<float>::quiet_NaN();
mCurrentValue[i].Type = GL_FLOAT;
mCurrentValueBuffer[i] = NULL;
mCurrentValueOffsets[i] = 0;
}
......@@ -211,14 +212,11 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
StreamingVertexBufferInterface *buffer = mCurrentValueBuffer[i];
if (mCurrentValue[i][0] != attribs[i].mCurrentValue[0] ||
mCurrentValue[i][1] != attribs[i].mCurrentValue[1] ||
mCurrentValue[i][2] != attribs[i].mCurrentValue[2] ||
mCurrentValue[i][3] != attribs[i].mCurrentValue[3])
if (memcmp(&mCurrentValue[i], &attribs[i].mCurrentValue, sizeof(gl::VertexAttribute::CurrentValueData)) != 0)
{
unsigned int requiredSpace = sizeof(float) * 4;
buffer->reserveRawDataSpace(requiredSpace);
int streamOffset = buffer->storeRawData(attribs[i].mCurrentValue, requiredSpace);
int streamOffset = buffer->storeRawData(attribs[i].mCurrentValue.FloatValues, requiredSpace);
if (streamOffset == -1)
{
return GL_OUT_OF_MEMORY;
......
......@@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
#include "libGLESv2/Constants.h"
#include "libGLESv2/Context.h"
#include "common/angleutils.h"
namespace gl
......@@ -55,7 +56,8 @@ class VertexDataManager
StreamingVertexBufferInterface *mStreamingBuffer;
float mCurrentValue[gl::MAX_VERTEX_ATTRIBS][4];
gl::VertexAttribute::CurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
};
......
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