1 #ifndef _VKTROBUSTNESSUTIL_HPP
2 #define _VKTROBUSTNESSUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
8 * Copyright (c) 2016 Imagination Technologies Ltd.
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 * \brief Robustness Utilities
25 *//*--------------------------------------------------------------------*/
27 #include "tcuDefs.hpp"
29 #include "vkRefUtil.hpp"
30 #include "vktTestCase.hpp"
31 #include "vkMemUtil.hpp"
32 #include "deUniquePtr.hpp"
33 #include "tcuVectorUtil.hpp"
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);
52 TestEnvironment (Context& context,
54 vk::VkDescriptorSetLayout descriptorSetLayout,
55 vk::VkDescriptorSet descriptorSet);
57 virtual ~TestEnvironment (void) {}
59 virtual vk::VkCommandBuffer getCommandBuffer (void);
63 vk::VkDevice m_device;
64 vk::VkDescriptorSetLayout m_descriptorSetLayout;
65 vk::VkDescriptorSet m_descriptorSet;
67 vk::Move<vk::VkCommandPool> m_commandPool;
68 vk::Move<vk::VkCommandBuffer> m_commandBuffer;
71 class GraphicsEnvironment: public TestEnvironment
74 typedef std::vector<vk::VkVertexInputBindingDescription> VertexBindings;
75 typedef std::vector<vk::VkVertexInputAttributeDescription> VertexAttributes;
79 std::vector<vk::VkBuffer> vertexBuffers;
81 deUint32 instanceCount;
83 vk::VkBuffer indexBuffer;
87 GraphicsEnvironment (Context& context,
89 vk::VkDescriptorSetLayout descriptorSetLayout,
90 vk::VkDescriptorSet descriptorSet,
91 const VertexBindings& vertexBindings,
92 const VertexAttributes& vertexAttributes,
93 const DrawConfig& drawConfig);
95 virtual ~GraphicsEnvironment (void) {}
98 const tcu::UVec2 m_renderSize;
99 const vk::VkFormat m_colorFormat;
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;
107 vk::Move<vk::VkShaderModule> m_vertexShaderModule;
108 vk::Move<vk::VkShaderModule> m_fragmentShaderModule;
110 vk::Move<vk::VkBuffer> m_vertexBuffer;
111 de::MovePtr<vk::Allocation> m_vertexBufferAlloc;
113 vk::Move<vk::VkPipelineLayout> m_pipelineLayout;
114 vk::Move<vk::VkPipeline> m_graphicsPipeline;
117 class ComputeEnvironment: public TestEnvironment
120 ComputeEnvironment (Context& context,
122 vk::VkDescriptorSetLayout descriptorSetLayout,
123 vk::VkDescriptorSet descriptorSet);
125 virtual ~ComputeEnvironment (void) {}
128 vk::Move<vk::VkShaderModule> m_computeShaderModule;
129 vk::Move<vk::VkPipelineLayout> m_pipelineLayout;
130 vk::Move<vk::VkPipeline> m_computePipeline;
136 #endif // _VKTROBUSTNESSUTIL_HPP