Commit 25bf006a by Nicolas Capens

Optimize alignment and conversion test for float attribute types.

The generic alignment and conversion test to check for the possibility of using direct storage is relatively expensive. Float types can be tested more quickly. BUG=angle:613 Change-Id: I5ab008ce82c8b652f0392c20a80a5b198b2437a5 Reviewed-on: https://chromium-review.googlesource.com/197721Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 37f77d2e
...@@ -165,18 +165,25 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att ...@@ -165,18 +165,25 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att
return false; return false;
} }
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
// Alignment restrictions: In D3D, vertex data must be aligned to // Alignment restrictions: In D3D, vertex data must be aligned to
// the format stride, or to a 4-byte boundary, whichever is smaller. // the format stride, or to a 4-byte boundary, whichever is smaller.
// (Undocumented, and experimentally confirmed) // (Undocumented, and experimentally confirmed)
unsigned int outputElementSize; size_t alignment = 4;
getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize); bool requiresConversion = false;
size_t alignment = std::min(static_cast<size_t>(outputElementSize), 4u);
if (attrib.mType != GL_FLOAT)
{
gl::VertexFormat vertexFormat(attrib, currentValue.Type);
unsigned int outputElementSize;
getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
alignment = std::min(static_cast<size_t>(outputElementSize), 4u);
requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0;
}
bool isAligned = (static_cast<size_t>(attrib.stride()) % alignment == 0) && bool isAligned = (static_cast<size_t>(attrib.stride()) % alignment == 0) &&
(static_cast<size_t>(attrib.mOffset) % alignment == 0); (static_cast<size_t>(attrib.mOffset) % alignment == 0);
bool requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0;
return !requiresConversion && isAligned; return !requiresConversion && isAligned;
} }
......
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