From: Chris Forbes Date: Wed, 10 Jan 2018 02:13:15 +0000 (-0800) Subject: Fix buffer usage flags for index and indirect buffers X-Git-Tag: upstream/1.3.5~2758^2~3^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d90b6c9ad31ef4c6f40885be0a9f59a9f24c0b5;p=platform%2Fupstream%2FVK-GL-CTS.git Fix buffer usage flags for index and indirect buffers Previously, createAndUploadBuffer would provide VK_BUFFER_USAGE_VERTEX_BUFFER_BIT for all buffers. This is no good for index buffers and indirect buffers. VK-GL-CTS: 930 Change-Id: I774beef7c7226f4fbd5670591eb66475300ee208 Components: Vulkan Affects: dEQP-VK.draw.instanced.* --- diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawInstancedTests.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawInstancedTests.cpp index 13b80e3..1e5d734 100644 --- a/external/vulkancts/modules/vulkan/draw/vktDrawInstancedTests.cpp +++ b/external/vulkancts/modules/vulkan/draw/vktDrawInstancedTests.cpp @@ -121,23 +121,23 @@ rr::PrimitiveType mapVkPrimitiveTopology (vk::VkPrimitiveTopology primitiveTopol } template -de::SharedPtr createAndUploadBuffer(const std::vector data, const vk::DeviceInterface& vk, const Context& context) +de::SharedPtr createAndUploadBuffer(const std::vector data, const vk::DeviceInterface& vk, const Context& context, vk::VkBufferUsageFlags usage) { const vk::VkDeviceSize dataSize = data.size() * sizeof(T); - de::SharedPtr vertexBuffer = Buffer::createAndAlloc(vk, context.getDevice(), - BufferCreateInfo(dataSize, vk::VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), - context.getDefaultAllocator(), - vk::MemoryRequirement::HostVisible); + de::SharedPtr buffer = Buffer::createAndAlloc(vk, context.getDevice(), + BufferCreateInfo(dataSize, usage), + context.getDefaultAllocator(), + vk::MemoryRequirement::HostVisible); - deUint8* ptr = reinterpret_cast(vertexBuffer->getBoundMemory().getHostPtr()); + deUint8* ptr = reinterpret_cast(buffer->getBoundMemory().getHostPtr()); deMemcpy(ptr, &data[0], static_cast(dataSize)); vk::flushMappedMemoryRange(vk, context.getDevice(), - vertexBuffer->getBoundMemory().getMemory(), - vertexBuffer->getBoundMemory().getOffset(), + buffer->getBoundMemory().getMemory(), + buffer->getBoundMemory().getOffset(), VK_WHOLE_SIZE); - return vertexBuffer; + return buffer; } class TestVertShader : public rr::VertexShader @@ -455,8 +455,8 @@ tcu::TestStatus InstancedDrawInstance::iterate() const deUint32 firstInstance = firstInstanceIndices[firstInstanceIndexNdx]; prepareVertexData(instanceCount, firstInstance); - const de::SharedPtr vertexBuffer = createAndUploadBuffer(m_data, m_vk, m_context); - const de::SharedPtr instancedVertexBuffer = createAndUploadBuffer(m_instancedColor, m_vk, m_context); + const de::SharedPtr vertexBuffer = createAndUploadBuffer(m_data, m_vk, m_context, vk::VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); + const de::SharedPtr instancedVertexBuffer = createAndUploadBuffer(m_instancedColor, m_vk, m_context, vk::VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); de::SharedPtr indexBuffer; de::SharedPtr indirectBuffer; m_vk.beginCommandBuffer(*m_cmdBuffer, &beginInfo); @@ -486,7 +486,7 @@ tcu::TestStatus InstancedDrawInstance::iterate() if (m_params.function == TestParams::FUNCTION_DRAW_INDEXED || m_params.function == TestParams::FUNCTION_DRAW_INDEXED_INDIRECT) { - indexBuffer = createAndUploadBuffer(m_indexes, m_vk, m_context); + indexBuffer = createAndUploadBuffer(m_indexes, m_vk, m_context, vk::VK_BUFFER_USAGE_INDEX_BUFFER_BIT); m_vk.cmdBindIndexBuffer(*m_cmdBuffer, indexBuffer->object(), 0, vk::VK_INDEX_TYPE_UINT32); } @@ -530,7 +530,7 @@ tcu::TestStatus InstancedDrawInstance::iterate() }; std::vector drawCommands; drawCommands.push_back(drawCommand); - indirectBuffer = createAndUploadBuffer(drawCommands, m_vk, m_context); + indirectBuffer = createAndUploadBuffer(drawCommands, m_vk, m_context, vk::VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); m_vk.cmdDrawIndirect(*m_cmdBuffer, indirectBuffer->object(), 0, 1u, 0u); break; @@ -547,7 +547,7 @@ tcu::TestStatus InstancedDrawInstance::iterate() }; std::vector drawCommands; drawCommands.push_back(drawCommand); - indirectBuffer = createAndUploadBuffer(drawCommands, m_vk, m_context); + indirectBuffer = createAndUploadBuffer(drawCommands, m_vk, m_context, vk::VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); m_vk.cmdDrawIndexedIndirect(*m_cmdBuffer, indirectBuffer->object(), 0, 1u, 0u); break;