Merge "Report Android extension pack tests as not supported" am: 03c395c60f
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / robustness / vktRobustnessUtil.hpp
1 #ifndef _VKTROBUSTNESSUTIL_HPP
2 #define _VKTROBUSTNESSUTIL_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
8  * Copyright (c) 2016 Imagination Technologies Ltd.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  *//*!
23  * \file
24  * \brief Robustness Utilities
25  *//*--------------------------------------------------------------------*/
26
27 #include "tcuDefs.hpp"
28 #include "vkDefs.hpp"
29 #include "vkRefUtil.hpp"
30 #include "vktTestCase.hpp"
31 #include "vkMemUtil.hpp"
32 #include "deUniquePtr.hpp"
33 #include "tcuVectorUtil.hpp"
34
35 namespace vkt
36 {
37 namespace robustness
38 {
39
40 vk::Move<vk::VkDevice>  createRobustBufferAccessDevice          (Context& context);
41 bool                                    areEqual                                                        (float a, float b);
42 bool                                    isValueZero                                                     (const void* valuePtr, size_t valueSize);
43 bool                                    isValueWithinBuffer                                     (const void* buffer, vk::VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes);
44 bool                                    isValueWithinBufferOrZero                       (const void* buffer, vk::VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes);
45 bool                                    verifyOutOfBoundsVec4                           (const void* vecPtr, vk::VkFormat bufferFormat);
46 void                                    populateBufferWithTestValues            (void* buffer, vk::VkDeviceSize size, vk::VkFormat format);
47 void                                    logValue                                                        (std::ostringstream& logMsg, const void* valuePtr, vk::VkFormat valueFormat, size_t valueSize);
48
49 class TestEnvironment
50 {
51 public:
52                                                                         TestEnvironment         (Context&                                       context,
53                                                                                                                  vk::VkDevice                           device,
54                                                                                                                  vk::VkDescriptorSetLayout      descriptorSetLayout,
55                                                                                                                  vk::VkDescriptorSet            descriptorSet);
56
57         virtual                                                 ~TestEnvironment        (void) {}
58
59         virtual vk::VkCommandBuffer             getCommandBuffer        (void);
60
61 protected:
62         Context&                                                m_context;
63         vk::VkDevice                                    m_device;
64         vk::VkDescriptorSetLayout               m_descriptorSetLayout;
65         vk::VkDescriptorSet                             m_descriptorSet;
66
67         vk::Move<vk::VkCommandPool>             m_commandPool;
68         vk::Move<vk::VkCommandBuffer>   m_commandBuffer;
69 };
70
71 class GraphicsEnvironment: public TestEnvironment
72 {
73 public:
74         typedef std::vector<vk::VkVertexInputBindingDescription>        VertexBindings;
75         typedef std::vector<vk::VkVertexInputAttributeDescription>      VertexAttributes;
76
77         struct DrawConfig
78         {
79                 std::vector<vk::VkBuffer>       vertexBuffers;
80                 deUint32                                        vertexCount;
81                 deUint32                                        instanceCount;
82
83                 vk::VkBuffer                            indexBuffer;
84                 deUint32                                        indexCount;
85         };
86
87                                                                         GraphicsEnvironment             (Context&                                       context,
88                                                                                                                          vk::VkDevice                           device,
89                                                                                                                          vk::VkDescriptorSetLayout      descriptorSetLayout,
90                                                                                                                          vk::VkDescriptorSet            descriptorSet,
91                                                                                                                          const VertexBindings&          vertexBindings,
92                                                                                                                          const VertexAttributes&        vertexAttributes,
93                                                                                                                          const DrawConfig&                      drawConfig);
94
95         virtual                                                 ~GraphicsEnvironment    (void) {}
96
97 private:
98         const tcu::UVec2                                m_renderSize;
99         const vk::VkFormat                              m_colorFormat;
100
101         vk::Move<vk::VkImage>                   m_colorImage;
102         de::MovePtr<vk::Allocation>             m_colorImageAlloc;
103         vk::Move<vk::VkImageView>               m_colorAttachmentView;
104         vk::Move<vk::VkRenderPass>              m_renderPass;
105         vk::Move<vk::VkFramebuffer>             m_framebuffer;
106
107         vk::Move<vk::VkShaderModule>    m_vertexShaderModule;
108         vk::Move<vk::VkShaderModule>    m_fragmentShaderModule;
109
110         vk::Move<vk::VkBuffer>                  m_vertexBuffer;
111         de::MovePtr<vk::Allocation>             m_vertexBufferAlloc;
112
113         vk::Move<vk::VkPipelineLayout>  m_pipelineLayout;
114         vk::Move<vk::VkPipeline>                m_graphicsPipeline;
115 };
116
117 class ComputeEnvironment: public TestEnvironment
118 {
119 public:
120                                                                         ComputeEnvironment              (Context&                                       context,
121                                                                                                                          vk::VkDevice                           device,
122                                                                                                                          vk::VkDescriptorSetLayout      descriptorSetLayout,
123                                                                                                                          vk::VkDescriptorSet            descriptorSet);
124
125         virtual                                                 ~ComputeEnvironment             (void) {}
126
127 private:
128         vk::Move<vk::VkShaderModule>    m_computeShaderModule;
129         vk::Move<vk::VkPipelineLayout>  m_pipelineLayout;
130         vk::Move<vk::VkPipeline>                m_computePipeline;
131 };
132
133 } // robustness
134 } // vkt
135
136 #endif // _VKTROBUSTNESSUTIL_HPP