Commit e452382a by Frank Henigman Committed by Commit Bot

Vulkan: convert/align vertex data from buffers

When we get a buffer with vertex data in an unsupported format or alignment, correct that as we copy it to a DynamicBuffer, then use the copy. Enable tests. BUG=angleproject:2405 Change-Id: I2132abea4d936f6b53d9209be7f99a0e2d8de219 Reviewed-on: https://chromium-review.googlesource.com/1141277 Commit-Queue: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5b3b5cc1
......@@ -151,14 +151,17 @@ gl::Error BufferVk::mapRange(const gl::Context *context,
gl::Error BufferVk::unmap(const gl::Context *context, GLboolean *result)
{
return unmapImpl(vk::GetImpl(context));
}
angle::Result BufferVk::unmapImpl(ContextVk *contextVk)
{
ASSERT(mBuffer.getHandle() != VK_NULL_HANDLE);
ASSERT(mBufferMemory.getHandle() != VK_NULL_HANDLE);
VkDevice device = vk::GetImpl(context)->getDevice();
mBufferMemory.unmap(device);
mBufferMemory.unmap(contextVk->getDevice());
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BufferVk::getIndexRange(const gl::Context *context,
......
......@@ -59,6 +59,7 @@ class BufferVk : public BufferImpl, public vk::CommandGraphResource
const vk::Buffer &getVkBuffer() const;
angle::Result mapImpl(ContextVk *contextVk, void **mapPtr);
angle::Result unmapImpl(ContextVk *contextVk);
private:
angle::Result setDataImpl(ContextVk *contextVk,
......
......@@ -26,7 +26,6 @@ class BufferVk;
namespace vk
{
class CommandGraphResource;
class DynamicBuffer;
} // namespace vk
class VertexArrayVk : public VertexArrayImpl
......@@ -88,6 +87,11 @@ class VertexArrayVk : public VertexArrayImpl
const gl::DrawCallParams &drawCallParams);
angle::Result streamIndexData(ContextVk *contextVk, const gl::DrawCallParams &drawCallParams);
angle::Result convertVertexBuffer(ContextVk *contextVk,
BufferVk *srcBuffer,
const gl::VertexBinding &binding,
size_t attribIndex);
void ensureConversionReleased(RendererVk *renderer, size_t attribIndex);
gl::Error onDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
......@@ -98,16 +102,18 @@ class VertexArrayVk : public VertexArrayImpl
vk::CommandBuffer *commandBuffer,
bool newCommandBuffer);
void syncDirtyAttrib(ContextVk *contextVk,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t attribIndex);
angle::Result syncDirtyAttrib(ContextVk *contextVk,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t attribIndex);
gl::AttribArray<VkBuffer> mCurrentArrayBufferHandles;
gl::AttribArray<VkDeviceSize> mCurrentArrayBufferOffsets;
gl::AttribArray<vk::CommandGraphResource *> mCurrentArrayBufferResources;
gl::AttribArray<const vk::Format *> mCurrentArrayBufferFormats;
gl::AttribArray<GLuint> mCurrentArrayBufferStrides;
gl::AttribArray<vk::DynamicBuffer> mCurrentArrayBufferConversion;
gl::AttribArray<bool> mCurrentArrayBufferConversionCanRelease;
VkBuffer mCurrentElementArrayBufferHandle;
VkDeviceSize mCurrentElementArrayBufferOffset;
vk::CommandGraphResource *mCurrentElementArrayBufferResource;
......
......@@ -396,17 +396,18 @@ void AttributeLayoutTest::GetTestCases(void)
if (IsVulkan())
{
std::cout << "cases skipped on Vulkan: fixed or non-normalized byte/short data, non-zero "
"buffer offsets"
<< std::endl;
return;
std::cout << "cases skipped on Vulkan: fixed format vertex data" << std::endl;
mTestCases.push_back({});
mTestCases.push_back({});
}
else
{
// 10. one buffer, sequential
mTestCases.push_back({Fixed(B0, 0, 8, mCoord), Float(B0, 96, 12, mColor)});
// 10. one buffer, sequential
mTestCases.push_back({Fixed(B0, 0, 8, mCoord), Float(B0, 96, 12, mColor)});
// 11. one buffer, interleaved
mTestCases.push_back({Fixed(B0, 0, 20, mCoord), Float(B0, 8, 20, mColor)});
// 11. one buffer, interleaved
mTestCases.push_back({Fixed(B0, 0, 20, mCoord), Float(B0, 8, 20, mColor)});
}
// 12. memory and buffer, float and integer
mTestCases.push_back({Float(M0, 0, 8, mCoord), SByte(B0, 0, 12, mColor)});
......
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