Commit 6d113802 by Jamie Madill

Move some methods of VertexDataManager to helper methods.

Refactoring patch only. BUG=angle:571 Change-Id: Ic318b4c4366e33b8d33f6003dd39f660f40d354a Reviewed-on: https://chromium-review.googlesource.com/210649Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent ae3000b4
......@@ -92,29 +92,14 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
return GL_OUT_OF_MEMORY;
}
// Invalidate static buffers that don't contain matching attributes
for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{
translated[attributeIndex].active = (programBinary->getSemanticIndex(attributeIndex) != -1);
}
// Invalidate static buffers that don't contain matching attributes
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
if (translated[i].active && attribs[i].enabled)
if (translated[attributeIndex].active && attribs[attributeIndex].enabled)
{
gl::Buffer *buffer = attribs[i].buffer.get();
if (buffer)
{
BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer();
if (staticBuffer && staticBuffer->getBufferSize() > 0 && !staticBuffer->lookupAttribute(attribs[i], NULL) &&
!staticBuffer->directStoragePossible(attribs[i], currentValues[i]))
{
bufferImpl->invalidateStaticData();
}
}
invalidateMatchingStaticData(attribs[attributeIndex], currentValues[attributeIndex]);
}
}
......@@ -123,34 +108,9 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
{
if (translated[i].active && attribs[i].enabled)
{
gl::Buffer *buffer = attribs[i].buffer.get();
BufferD3D *bufferImpl = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
StaticVertexBufferInterface *staticBuffer = bufferImpl ? bufferImpl->getStaticVertexBuffer() : NULL;
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
if (!vertexBuffer->directStoragePossible(attribs[i], currentValues[i]))
if (!reserveSpaceForAttrib(attribs[i], currentValues[i], count, instances))
{
if (staticBuffer)
{
if (staticBuffer->getBufferSize() == 0)
{
int totalCount = ElementsInBuffer(attribs[i], bufferImpl->getSize());
if (!staticBuffer->reserveVertexSpace(attribs[i], totalCount, 0))
{
return GL_OUT_OF_MEMORY;
}
}
}
else
{
int totalCount = StreamingBufferElementCount(attribs[i], count, instances);
ASSERT(!bufferImpl || ElementsInBuffer(attribs[i], bufferImpl->getSize()) >= totalCount);
if (!mStreamingBuffer->reserveVertexSpace(attribs[i], totalCount, instances))
{
return GL_OUT_OF_MEMORY;
}
}
return GL_OUT_OF_MEMORY;
}
}
}
......@@ -203,6 +163,64 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
return GL_NO_ERROR;
}
void VertexDataManager::invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const
{
gl::Buffer *buffer = attrib.buffer.get();
if (buffer)
{
BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer();
if (staticBuffer &&
staticBuffer->getBufferSize() > 0 &&
!staticBuffer->lookupAttribute(attrib, NULL) &&
!staticBuffer->directStoragePossible(attrib, currentValue))
{
bufferImpl->invalidateStaticData();
}
}
}
bool VertexDataManager::reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLsizei count,
GLsizei instances) const
{
gl::Buffer *buffer = attrib.buffer.get();
BufferD3D *bufferImpl = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
StaticVertexBufferInterface *staticBuffer = bufferImpl ? bufferImpl->getStaticVertexBuffer() : NULL;
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
if (!vertexBuffer->directStoragePossible(attrib, currentValue))
{
if (staticBuffer)
{
if (staticBuffer->getBufferSize() == 0)
{
int totalCount = ElementsInBuffer(attrib, bufferImpl->getSize());
if (!staticBuffer->reserveVertexSpace(attrib, totalCount, 0))
{
return false;
}
}
}
else
{
int totalCount = StreamingBufferElementCount(attrib, count, instances);
ASSERT(!bufferImpl || ElementsInBuffer(attrib, bufferImpl->getSize()) >= totalCount);
if (!mStreamingBuffer->reserveVertexSpace(attrib, totalCount, instances))
{
return false;
}
}
}
return true;
}
GLenum VertexDataManager::storeAttribute(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
......
......@@ -58,6 +58,14 @@ class VertexDataManager
private:
DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
bool reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLsizei count,
GLsizei instances) const;
void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const;
GLenum storeAttribute(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
......
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