• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, const vk::VkPhysicalDeviceFeatures2* enabledFeatures2 = DE_NULL);
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 														 const vk::DeviceInterface&		vk,
54 														 vk::VkDevice					device,
55 														 vk::VkDescriptorSetLayout		descriptorSetLayout,
56 														 vk::VkDescriptorSet			descriptorSet);
57 
~TestEnvironment(void)58 	virtual							~TestEnvironment	(void) {}
59 
60 	virtual vk::VkCommandBuffer		getCommandBuffer	(void);
61 
62 protected:
63 	Context&						m_context;
64 	vk::VkDevice					m_device;
65 	vk::VkDescriptorSetLayout		m_descriptorSetLayout;
66 	vk::VkDescriptorSet				m_descriptorSet;
67 
68 	vk::Move<vk::VkCommandPool>		m_commandPool;
69 	vk::Move<vk::VkCommandBuffer>	m_commandBuffer;
70 };
71 
72 class GraphicsEnvironment: public TestEnvironment
73 {
74 public:
75 	typedef std::vector<vk::VkVertexInputBindingDescription>	VertexBindings;
76 	typedef std::vector<vk::VkVertexInputAttributeDescription>	VertexAttributes;
77 
78 	struct DrawConfig
79 	{
80 		std::vector<vk::VkBuffer>	vertexBuffers;
81 		deUint32					vertexCount;
82 		deUint32					instanceCount;
83 
84 		vk::VkBuffer				indexBuffer;
85 		deUint32					indexCount;
86 	};
87 
88 									GraphicsEnvironment		(Context&						context,
89 															 const vk::DeviceInterface&		vk,
90 															 vk::VkDevice					device,
91 															 vk::VkDescriptorSetLayout		descriptorSetLayout,
92 															 vk::VkDescriptorSet			descriptorSet,
93 															 const VertexBindings&			vertexBindings,
94 															 const VertexAttributes&		vertexAttributes,
95 															 const DrawConfig&				drawConfig,
96 															 bool							testPipelineRobustness = false);
97 
~GraphicsEnvironment(void)98 	virtual							~GraphicsEnvironment	(void) {}
99 
100 private:
101 	const tcu::UVec2				m_renderSize;
102 	const vk::VkFormat				m_colorFormat;
103 
104 	vk::Move<vk::VkImage>			m_colorImage;
105 	de::MovePtr<vk::Allocation>		m_colorImageAlloc;
106 	vk::Move<vk::VkImageView>		m_colorAttachmentView;
107 	vk::Move<vk::VkRenderPass>		m_renderPass;
108 	vk::Move<vk::VkFramebuffer>		m_framebuffer;
109 
110 	vk::Move<vk::VkShaderModule>	m_vertexShaderModule;
111 	vk::Move<vk::VkShaderModule>	m_fragmentShaderModule;
112 
113 	vk::Move<vk::VkBuffer>			m_vertexBuffer;
114 	de::MovePtr<vk::Allocation>		m_vertexBufferAlloc;
115 
116 	vk::Move<vk::VkPipelineLayout>	m_pipelineLayout;
117 	vk::Move<vk::VkPipeline>		m_graphicsPipeline;
118 };
119 
120 class ComputeEnvironment: public TestEnvironment
121 {
122 public:
123 									ComputeEnvironment		(Context&						context,
124 															 const vk::DeviceInterface&		vk,
125 															 vk::VkDevice					device,
126 															 vk::VkDescriptorSetLayout		descriptorSetLayout,
127 															 vk::VkDescriptorSet			descriptorSet,
128 															 bool							testPipelineRobustness = false);
129 
~ComputeEnvironment(void)130 	virtual							~ComputeEnvironment		(void) {}
131 
132 private:
133 	vk::Move<vk::VkShaderModule>	m_computeShaderModule;
134 	vk::Move<vk::VkPipelineLayout>	m_pipelineLayout;
135 	vk::Move<vk::VkPipeline>		m_computePipeline;
136 };
137 
138 } // robustness
139 } // vkt
140 
141 #endif // _VKTROBUSTNESSUTIL_HPP
142