Commit a5d67475 by Jamie Madill

Remove VertexBuffer::requiresConversion.

Since we now have Renderer methods to query formats for vertex inputs, we can get rid of the remaining calls to VertexBuffer which we used to query properties of vertex formats. Change-Id: I9e57d1d9bf80296aef271877fdd97a16d29114af Reviewed-on: https://chromium-review.googlesource.com/184522Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 7d649a00
......@@ -11,6 +11,7 @@
#include "libGLESv2/renderer/VertexBuffer.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/renderer/BufferStorage.h"
namespace rx
{
......@@ -145,6 +146,18 @@ VertexBuffer* VertexBufferInterface::getVertexBuffer() const
return mVertexBuffer;
}
bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const
{
gl::Buffer *buffer = attrib.mBoundBuffer.get();
BufferStorage *storage = buffer ? buffer->getStorage() : NULL;
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
bool isAligned = (attrib.stride() % 4 == 0) && (attrib.mOffset % 4 == 0);
bool requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0;
return storage && storage->supportsDirectBinding() && !requiresConversion && isAligned;
}
StreamingVertexBufferInterface::StreamingVertexBufferInterface(rx::Renderer *renderer, std::size_t initialSize) : VertexBufferInterface(renderer, true)
{
......
......@@ -35,9 +35,6 @@ class VertexBuffer
virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
unsigned int *outSpaceRequired) const = 0;
virtual bool requiresConversion(const gl::VertexAttribute &attrib) const = 0;
virtual bool requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const = 0;
virtual unsigned int getBufferSize() const = 0;
virtual bool setBufferSize(unsigned int size) = 0;
virtual bool discard() = 0;
......@@ -69,6 +66,9 @@ class VertexBufferInterface
virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
bool directStoragePossible(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const;
VertexBuffer* getVertexBuffer() const;
protected:
......
......@@ -15,6 +15,7 @@
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/renderer/VertexBuffer.h"
#include "libGLESv2/renderer/Renderer.h"
namespace
{
......@@ -52,19 +53,6 @@ static int StreamingBufferElementCount(const gl::VertexAttribute &attribute, int
return vertexDrawCount;
}
static bool DirectStoragePossible(VertexBufferInterface *vb, const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue)
{
gl::Buffer *buffer = attrib.mBoundBuffer.get();
BufferStorage *storage = buffer ? buffer->getStorage() : NULL;
const bool isAligned = (attrib.stride() % 4 == 0) && (attrib.mOffset % 4 == 0);
const bool requiresConversion = attrib.mArrayEnabled ?
vb->getVertexBuffer()->requiresConversion(attrib) :
vb->getVertexBuffer()->requiresConversion(currentValue);
return storage && storage->supportsDirectBinding() && !requiresConversion && isAligned;
}
VertexDataManager::VertexDataManager(Renderer *renderer) : mRenderer(renderer)
{
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
......@@ -118,7 +106,7 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL;
if (staticBuffer && staticBuffer->getBufferSize() > 0 && !staticBuffer->lookupAttribute(attribs[i], NULL) &&
!DirectStoragePossible(staticBuffer, attribs[i], currentValues[i]))
!staticBuffer->directStoragePossible(attribs[i], currentValues[i]))
{
buffer->invalidateStaticData();
}
......@@ -134,7 +122,7 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL;
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
if (!DirectStoragePossible(vertexBuffer, attribs[i], currentValues[i]))
if (!vertexBuffer->directStoragePossible(attribs[i], currentValues[i]))
{
if (staticBuffer)
{
......@@ -187,7 +175,7 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
BufferStorage *storage = buffer ? buffer->getStorage() : NULL;
bool directStorage = DirectStoragePossible(vertexBuffer, attribs[i], currentValues[i]);
bool directStorage = vertexBuffer->directStoragePossible(attribs[i], currentValues[i]);
unsigned int streamOffset = 0;
unsigned int outputElementSize = 0;
......
......@@ -173,18 +173,6 @@ bool VertexBuffer11::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei
}
}
bool VertexBuffer11::requiresConversion(const gl::VertexAttribute &attrib) const
{
gl::VertexFormat vertexFormat(attrib);
return (gl_d3d11::GetVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0;
}
bool VertexBuffer11::requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const
{
gl::VertexFormat vertexFormat(currentValue.Type, GL_FALSE, 4, GL_FALSE);
return (gl_d3d11::GetVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0;
}
unsigned int VertexBuffer11::getBufferSize() const
{
return mBufferSize;
......
......@@ -31,9 +31,6 @@ class VertexBuffer11 : public VertexBuffer
virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
unsigned int *outSpaceRequired) const;
virtual bool requiresConversion(const gl::VertexAttribute &attrib) const;
virtual bool requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const;
virtual unsigned int getBufferSize() const;
virtual bool setBufferSize(unsigned int size);
virtual bool discard();
......
......@@ -146,19 +146,6 @@ bool VertexBuffer9::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei
return spaceRequired(attrib, count, instances, outSpaceRequired);
}
bool VertexBuffer9::requiresConversion(const gl::VertexAttribute &attrib) const
{
gl::VertexFormat vertexFormat(attrib, GL_FLOAT);
return (d3d9::GetVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0;
}
bool VertexBuffer9::requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const
{
ASSERT(currentValue.Type == GL_FLOAT);
gl::VertexFormat vertexFormat(currentValue.Type, GL_FALSE, 4, GL_FALSE);
return (d3d9::GetVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0;
}
unsigned int VertexBuffer9::getBufferSize() const
{
return mBufferSize;
......
......@@ -30,9 +30,6 @@ class VertexBuffer9 : public VertexBuffer
virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances, unsigned int *outSpaceRequired) const;
virtual bool requiresConversion(const gl::VertexAttribute &attrib) const;
virtual bool requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const;
virtual unsigned int getBufferSize() const;
virtual bool setBufferSize(unsigned int size);
virtual bool discard();
......
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