VK_KHR_maintenance2: View block-compressed add check shader_read_only_optimal
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / clipping / vktClippingUtil.hpp
1 #ifndef _VKTCLIPPINGUTIL_HPP
2 #define _VKTCLIPPINGUTIL_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Clipping tests utilities
24  *//*--------------------------------------------------------------------*/
25
26 #include "vkDefs.hpp"
27 #include "vkQueryUtil.hpp"
28 #include "vkMemUtil.hpp"
29 #include "vkRefUtil.hpp"
30 #include "vkPrograms.hpp"
31 #include "tcuVector.hpp"
32
33 namespace vkt
34 {
35 namespace clipping
36 {
37
38 class Buffer
39 {
40 public:
41                                                                                 Buffer                  (const vk::DeviceInterface&             vk,
42                                                                                                                  const vk::VkDevice                             device,
43                                                                                                                  vk::Allocator&                                 allocator,
44                                                                                                                  const vk::VkBufferCreateInfo&  bufferCreateInfo,
45                                                                                                                  const vk::MemoryRequirement    memoryRequirement)
46
47                                                                                         : m_buffer              (createBuffer(vk, device, &bufferCreateInfo))
48                                                                                         , m_allocation  (allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement))
49                                                                                 {
50                                                                                         VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
51                                                                                 }
52
53         const vk::VkBuffer&                                     get                             (void) const { return *m_buffer; }
54         const vk::VkBuffer&                                     operator*               (void) const { return get(); }
55         vk::Allocation&                                         getAllocation   (void) const { return *m_allocation; }
56
57 private:
58         const vk::Unique<vk::VkBuffer>          m_buffer;
59         const de::UniquePtr<vk::Allocation>     m_allocation;
60
61         // "deleted"
62                                                                                 Buffer                  (const Buffer&);
63         Buffer&                                                         operator=               (const Buffer&);
64 };
65
66 class Image
67 {
68 public:
69                                                                                 Image                   (const vk::DeviceInterface&             vk,
70                                                                                                                  const vk::VkDevice                             device,
71                                                                                                                  vk::Allocator&                                 allocator,
72                                                                                                                  const vk::VkImageCreateInfo&   imageCreateInfo,
73                                                                                                                  const vk::MemoryRequirement    memoryRequirement)
74
75                                                                                         : m_image               (createImage(vk, device, &imageCreateInfo))
76                                                                                         , m_allocation  (allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement))
77                                                                                 {
78                                                                                         VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
79                                                                                 }
80
81         const vk::VkImage&                                      get                             (void) const { return *m_image; }
82         const vk::VkImage&                                      operator*               (void) const { return get(); }
83         vk::Allocation&                                         getAllocation   (void) const { return *m_allocation; }
84
85 private:
86         const vk::Unique<vk::VkImage>           m_image;
87         const de::UniquePtr<vk::Allocation>     m_allocation;
88
89         // "deleted"
90                                                                                 Image                   (const Image&);
91         Image&                                                          operator=               (const Image&);
92 };
93
94 enum FeatureFlagBits
95 {
96         FEATURE_TESSELLATION_SHADER                                                     = 1u << 0,
97         FEATURE_GEOMETRY_SHADER                                                         = 1u << 1,
98         FEATURE_SHADER_FLOAT_64                                                         = 1u << 2,
99         FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS                      = 1u << 3,
100         FEATURE_FRAGMENT_STORES_AND_ATOMICS                                     = 1u << 4,
101         FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE     = 1u << 5,
102         FEATURE_DEPTH_CLAMP                                                                     = 1u << 6,
103         FEATURE_LARGE_POINTS                                                            = 1u << 7,
104         FEATURE_WIDE_LINES                                                                      = 1u << 8,
105         FEATURE_SHADER_CLIP_DISTANCE                                            = 1u << 9,
106         FEATURE_SHADER_CULL_DISTANCE                                            = 1u << 10,
107 };
108 typedef deUint32 FeatureFlags;
109
110 vk::VkBufferCreateInfo                  makeBufferCreateInfo                                            (const vk::VkDeviceSize bufferSize, const vk::VkBufferUsageFlags usage);
111 vk::Move<vk::VkCommandPool>             makeCommandPool                                                         (const vk::DeviceInterface& vk, const vk::VkDevice device, const deUint32 queueFamilyIndex);
112 vk::Move<vk::VkCommandBuffer>   makeCommandBuffer                                                       (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkCommandPool commandPool);
113 vk::Move<vk::VkDescriptorSet>   makeDescriptorSet                                                       (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorPool descriptorPool, const vk::VkDescriptorSetLayout setLayout);
114 vk::Move<vk::VkPipelineLayout>  makePipelineLayout                                                      (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorSetLayout descriptorSetLayout);
115 vk::Move<vk::VkPipelineLayout>  makePipelineLayoutWithoutDescriptors            (const vk::DeviceInterface& vk, const vk::VkDevice device);
116 vk::Move<vk::VkImageView>               makeImageView                                                           (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkImage image, const vk::VkImageViewType viewType, const vk::VkFormat format, const vk::VkImageSubresourceRange subresourceRange);
117 vk::VkBufferImageCopy                   makeBufferImageCopy                                                     (const vk::VkImageSubresourceLayers subresourceLayers, const vk::VkExtent3D extent);
118 vk::VkBufferMemoryBarrier               makeBufferMemoryBarrier                                         (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkBuffer buffer, const vk::VkDeviceSize offset, const vk::VkDeviceSize bufferSizeBytes);
119 vk::VkImageMemoryBarrier                makeImageMemoryBarrier                                          (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkImageLayout oldLayout, const vk::VkImageLayout newLayout, const vk::VkImage image, const vk::VkImageSubresourceRange subresourceRange);
120
121 void                                                    beginCommandBuffer                                                      (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer);
122 void                                                    endCommandBuffer                                                        (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer);
123 void                                                    submitCommandsAndWait                                           (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkQueue queue, const vk::VkCommandBuffer commandBuffer);
124 void                                                    requireFeatures                                                         (const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physDevice, const FeatureFlags flags);
125
126 std::string                                             getPrimitiveTopologyShortName                           (const vk::VkPrimitiveTopology topology);
127
128 } // clipping
129 } // vkt
130
131 #endif // _VKTCLIPPINGUTIL_HPP