Relax uvwBits to 3 in dEQP-GLES2.functional.texture.filtering.cube am: f1c8ff1f20
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / draw / vktDrawBufferObjectUtil.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Intel Corporation
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and/or associated documentation files (the
10  * "Materials"), to deal in the Materials without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Materials, and to
13  * permit persons to whom the Materials are furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice(s) and this permission notice shall be included
17  * in all copies or substantial portions of the Materials.
18  *
19  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
26  *
27  *//*!
28  * \file
29  * \brief Buffer Object Util
30  *//*--------------------------------------------------------------------*/
31
32 #include "vktDrawBufferObjectUtil.hpp"
33
34 #include "vkQueryUtil.hpp"
35
36 namespace vkt
37 {
38 namespace Draw
39 {
40
41 Buffer::Buffer (const vk::DeviceInterface& vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object_)
42         : m_allocation  (DE_NULL)
43         , m_object              (object_)
44         , m_vk                  (vk)
45         , m_device              (device)
46 {
47 }
48
49 void Buffer::bindMemory (de::MovePtr<vk::Allocation> allocation)
50 {
51         DE_ASSERT(allocation);
52         VK_CHECK(m_vk.bindBufferMemory(m_device, *m_object, allocation->getMemory(), allocation->getOffset()));
53
54         DE_ASSERT(!m_allocation);
55         m_allocation = allocation;
56 }
57
58 de::SharedPtr<Buffer> Buffer::createAndAlloc (const vk::DeviceInterface& vk,
59                                                                                           vk::VkDevice device,
60                                                                                           const vk::VkBufferCreateInfo &createInfo,
61                                                                                           vk::Allocator &allocator,
62                                                                                           vk::MemoryRequirement memoryRequirement)
63 {
64         de::SharedPtr<Buffer> ret = create(vk, device, createInfo);
65
66         vk::VkMemoryRequirements bufferRequirements = vk::getBufferMemoryRequirements(vk, device, ret->object());
67         ret->bindMemory(allocator.allocate(bufferRequirements, memoryRequirement));
68         return ret;
69 }
70
71 de::SharedPtr<Buffer> Buffer::create (const vk::DeviceInterface& vk,
72                                                                           vk::VkDevice device,
73                                                                           const vk::VkBufferCreateInfo& createInfo)
74 {
75         return de::SharedPtr<Buffer>(new Buffer(vk, device, vk::createBuffer(vk, device, &createInfo)));
76 }
77
78 } // Draw
79 } // vkt