Commit 3d72cc79 by Jamie Madill

Pass current value type instead of the object.

This allows us to simplify the logic in VertexDataManager enough that we can start to cache attribute information. BUG=angleproject:959 Change-Id: I7b53a137d73f40f86e3acb9caebb66f9cacf8b6f Reviewed-on: https://chromium-review.googlesource.com/277283Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 2a46b4e8
......@@ -91,7 +91,7 @@ gl::Error VertexBufferInterface::discard()
}
gl::Error VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -119,7 +119,7 @@ gl::Error VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute
}
mReservedSpace = 0;
error = mVertexBuffer->storeVertexAttributes(attrib, currentValue, start, count, instances, mWritePosition, sourceData);
error = mVertexBuffer->storeVertexAttributes(attrib, currentValueType, start, count, instances, mWritePosition, sourceData);
if (error.isError())
{
return error;
......@@ -170,7 +170,7 @@ VertexBuffer* VertexBufferInterface::getVertexBuffer() const
}
bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const
GLenum currentValueType) const
{
gl::Buffer *buffer = attrib.buffer.get();
BufferD3D *storage = buffer ? GetImplAs<BufferD3D>(buffer) : NULL;
......@@ -188,7 +188,7 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att
if (attrib.type != GL_FLOAT)
{
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
gl::VertexFormat vertexFormat(attrib, currentValueType);
unsigned int outputElementSize;
getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
......@@ -292,7 +292,7 @@ gl::Error StaticVertexBufferInterface::reserveSpace(unsigned int size)
}
gl::Error StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -300,7 +300,7 @@ gl::Error StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAtt
const uint8_t *sourceData)
{
unsigned int streamOffset;
gl::Error error = VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset, sourceData);
gl::Error error = VertexBufferInterface::storeVertexAttributes(attrib, currentValueType, start, count, instances, &streamOffset, sourceData);
if (error.isError())
{
return error;
......
......@@ -38,7 +38,7 @@ class VertexBuffer : angle::NonCopyable
virtual gl::Error initialize(unsigned int size, bool dynamicUsage) = 0;
virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -77,7 +77,7 @@ class VertexBufferInterface : angle::NonCopyable
unsigned int getSerial() const;
virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -85,7 +85,7 @@ class VertexBufferInterface : angle::NonCopyable
const uint8_t *sourceData);
bool directStoragePossible(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const;
GLenum currentValueType) const;
VertexBuffer* getVertexBuffer() const;
......@@ -126,7 +126,7 @@ class StaticVertexBufferInterface : public VertexBufferInterface
~StaticVertexBufferInterface();
gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......
......@@ -137,6 +137,8 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
{
// Record the attribute now
translated[attribIndex].attribute = &vertexAttributes[attribIndex];
translated[attribIndex].currentValueType = state.getVertexAttribCurrentValue(attribIndex).Type;
translated[attribIndex].divisor = vertexAttributes[attribIndex].divisor;
if (vertexAttributes[attribIndex].enabled)
{
......@@ -152,7 +154,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
{
if (translated[i].active && translated[i].attribute->enabled)
{
gl::Error error = reserveSpaceForAttrib(*translated[i].attribute, state.getVertexAttribCurrentValue(i), count, instances);
gl::Error error = reserveSpaceForAttrib(translated[i], count, instances);
if (error.isError())
{
return error;
......@@ -167,11 +169,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
{
if (translated[i].attribute->enabled)
{
gl::Error error = storeAttribute(state.getVertexAttribCurrentValue(i),
&translated[i],
start,
count,
instances);
gl::Error error = storeAttribute(&translated[i], start, count, instances);
if (error.isError())
{
......@@ -232,24 +230,24 @@ void VertexDataManager::invalidateMatchingStaticData(const gl::VertexAttribute &
if (staticBuffer &&
staticBuffer->getBufferSize() > 0 &&
!staticBuffer->lookupAttribute(attrib, NULL) &&
!staticBuffer->directStoragePossible(attrib, currentValue))
!staticBuffer->directStoragePossible(attrib, currentValue.Type))
{
bufferImpl->invalidateStaticData();
}
}
}
gl::Error VertexDataManager::reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
gl::Error VertexDataManager::reserveSpaceForAttrib(const TranslatedAttribute &translatedAttrib,
GLsizei count,
GLsizei instances) const
{
const gl::VertexAttribute &attrib = *translatedAttrib.attribute;
gl::Buffer *buffer = attrib.buffer.get();
BufferD3D *bufferImpl = buffer ? GetImplAs<BufferD3D>(buffer) : NULL;
StaticVertexBufferInterface *staticBuffer = bufferImpl ? bufferImpl->getStaticVertexBuffer() : NULL;
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
if (!vertexBuffer->directStoragePossible(attrib, currentValue))
if (!vertexBuffer->directStoragePossible(attrib, translatedAttrib.currentValueType))
{
if (staticBuffer)
{
......@@ -279,8 +277,7 @@ gl::Error VertexDataManager::reserveSpaceForAttrib(const gl::VertexAttribute &at
return gl::Error(GL_NO_ERROR);
}
gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
gl::Error VertexDataManager::storeAttribute(TranslatedAttribute *translated,
GLint start,
GLsizei count,
GLsizei instances)
......@@ -294,7 +291,7 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueDa
BufferD3D *storage = buffer ? GetImplAs<BufferD3D>(buffer) : NULL;
StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL;
VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
bool directStorage = vertexBuffer->directStoragePossible(attrib, currentValue);
bool directStorage = vertexBuffer->directStoragePossible(attrib, translated->currentValueType);
// Instanced vertices do not apply the 'start' offset
GLint firstVertexIndex = (instances > 0 && attrib.divisor > 0 ? 0 : start);
......@@ -305,9 +302,6 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueDa
{
translated->storage = storage;
translated->serial = storage->getSerial();
translated->divisor = attrib.divisor;
translated->currentValueType = currentValue.Type;
translated->stride = ComputeVertexAttributeStride(attrib);
translated->offset = static_cast<unsigned int>(attrib.offset + translated->stride * firstVertexIndex);
......@@ -349,7 +343,7 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueDa
int startIndex = attrib.offset / ComputeVertexAttributeStride(attrib);
error = staticBuffer->storeVertexAttributes(attrib,
currentValue,
translated->currentValueType,
-startIndex,
totalCount,
0,
......@@ -380,7 +374,7 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueDa
}
error = mStreamingBuffer->storeVertexAttributes(attrib,
currentValue,
translated->currentValueType,
firstVertexIndex,
totalCount,
instances,
......@@ -394,9 +388,6 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribCurrentValueDa
translated->storage = nullptr;
translated->serial = vertexBuffer->getSerial();
translated->divisor = attrib.divisor;
translated->currentValueType = currentValue.Type;
translated->stride = outputElementSize;
translated->offset = streamOffset;
......@@ -418,7 +409,7 @@ gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribCurrentValu
const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(currentValue.FloatValues);
unsigned int streamOffset;
error = cachedState->buffer->storeVertexAttributes(attrib, currentValue, 0, 1, 0, &streamOffset, sourceData);
error = cachedState->buffer->storeVertexAttributes(attrib, currentValue.Type, 0, 1, 0, &streamOffset, sourceData);
if (error.isError())
{
return error;
......@@ -433,7 +424,6 @@ gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribCurrentValu
translated->serial = cachedState->buffer->getSerial();
translated->divisor = 0;
translated->currentValueType = currentValue.Type;
translated->stride = 0;
translated->offset = cachedState->offset;
......
......@@ -66,16 +66,14 @@ class VertexDataManager : angle::NonCopyable
size_t offset;
};
gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
gl::Error reserveSpaceForAttrib(const TranslatedAttribute &translatedAttrib,
GLsizei count,
GLsizei instances) const;
void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const;
gl::Error storeAttribute(const gl::VertexAttribCurrentValueData &currentValue,
TranslatedAttribute *translated,
gl::Error storeAttribute(TranslatedAttribute *translated,
GLint start,
GLsizei count,
GLsizei instances);
......
......@@ -104,7 +104,7 @@ void VertexBuffer11::hintUnmapResource()
}
gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -134,7 +134,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
input += inputStride * start;
}
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
gl::VertexFormat vertexFormat(attrib, currentValueType);
const D3D_FEATURE_LEVEL featureLevel = mRenderer->getRenderer11DeviceCaps().featureLevel;
const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormat, featureLevel);
ASSERT(vertexFormatInfo.copyFunction != NULL);
......
......@@ -26,7 +26,7 @@ class VertexBuffer11 : public VertexBuffer
virtual gl::Error initialize(unsigned int size, bool dynamicUsage);
gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......
......@@ -57,7 +57,7 @@ gl::Error VertexBuffer9::initialize(unsigned int size, bool dynamicUsage)
}
gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......@@ -96,7 +96,7 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib
input += inputStride * start;
}
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
gl::VertexFormat vertexFormat(attrib, currentValueType);
const d3d9::VertexFormat &d3dVertexInfo = d3d9::GetVertexFormatInfo(mRenderer->getCapsDeclTypes(), vertexFormat);
bool needsConversion = (d3dVertexInfo.conversionType & VERTEX_CONVERT_CPU) > 0;
......
......@@ -24,7 +24,7 @@ class VertexBuffer9 : public VertexBuffer
virtual gl::Error initialize(unsigned int size, bool dynamicUsage);
gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue,
GLenum currentValueType,
GLint start,
GLsizei count,
GLsizei instances,
......
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