Commit a5e44c92 by Jamie Madill

Relax alignment restrictions to allow more direct storage.

Our restriction to 4-byte alignments caused us to always convert formats like R8 or R16, or R8G8 instead of allowing D3D to handle these formats naturally. From experimentation the proper rule seems to be "4-bytes, unless the vertex format is 1- or 2-byte size." I couldn't find supporting documentation on MSDN, but it seems common sense. Change-Id: I9e38fe86790e34024d1ae912a809a3d3cdc02ccf Reviewed-on: https://chromium-review.googlesource.com/184523Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent a5d67475
...@@ -153,7 +153,15 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att ...@@ -153,7 +153,15 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att
BufferStorage *storage = buffer ? buffer->getStorage() : NULL; BufferStorage *storage = buffer ? buffer->getStorage() : NULL;
gl::VertexFormat vertexFormat(attrib, currentValue.Type); gl::VertexFormat vertexFormat(attrib, currentValue.Type);
bool isAligned = (attrib.stride() % 4 == 0) && (attrib.mOffset % 4 == 0); // Alignment restrictions: In D3D, vertex data must be aligned to
// the format stride, or to a 4-byte boundary, whichever is smaller.
// (Undocumented, and experimentally confirmed)
unsigned int outputElementSize;
getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
size_t alignment = std::min(static_cast<size_t>(outputElementSize), 4u);
bool isAligned = (static_cast<size_t>(attrib.stride()) % alignment == 0) &&
(static_cast<size_t>(attrib.mOffset) % alignment == 0);
bool requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0; bool requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) > 0;
return storage && storage->supportsDirectBinding() && !requiresConversion && isAligned; return storage && storage->supportsDirectBinding() && !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