• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTDRAWBASECLASS_HPP
2 #define _VKTDRAWBASECLASS_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2015 The Khronos Group Inc.
8  * Copyright (c) 2015 Intel Corporation
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 Command draw Tests - Base Class
25  *//*--------------------------------------------------------------------*/
26 
27 #include "vkDefs.hpp"
28 #include "vktTestCase.hpp"
29 #include "vktDrawGroupParams.hpp"
30 
31 #include "tcuTestLog.hpp"
32 #include "tcuResource.hpp"
33 #include "tcuImageCompare.hpp"
34 #include "tcuCommandLine.hpp"
35 
36 #include "vkRefUtil.hpp"
37 #include "vkImageUtil.hpp"
38 
39 #include "deSharedPtr.hpp"
40 
41 #include "vkPrograms.hpp"
42 
43 #include "vktDrawCreateInfoUtil.hpp"
44 #include "vktDrawImageObjectUtil.hpp"
45 #include "vktDrawBufferObjectUtil.hpp"
46 
47 namespace vkt
48 {
49 namespace Draw
50 {
51 
52 struct PositionColorVertex
53 {
PositionColorVertexvkt::Draw::PositionColorVertex54 				PositionColorVertex (tcu::Vec4 position_, tcu::Vec4 color_)
55 					: position	(position_)
56 					, color		(color_)
57 				{}
58 
59 	tcu::Vec4	position;
60 	tcu::Vec4	color;
61 };
62 
63 struct VertexElementData : public PositionColorVertex
64 {
VertexElementDatavkt::Draw::VertexElementData65 				VertexElementData (tcu::Vec4 position_, tcu::Vec4 color_, deUint32 refVertexIndex_)
66 					: PositionColorVertex	(position_, color_)
67 					, refVertexIndex		(refVertexIndex_)
68 				{
69 				}
70 
71 	deUint32	refVertexIndex;
72 };
73 
74 struct ReferenceImageCoordinates
75 {
ReferenceImageCoordinatesvkt::Draw::ReferenceImageCoordinates76 	ReferenceImageCoordinates (void)
77 		: left		(-0.3)
78 		, right		(0.3)
79 		, top		(0.3)
80 		, bottom	(-0.3)
81 	{
82 	}
83 
84 	double left;
85 	double right;
86 	double top;
87 	double bottom;
88 };
89 
90 struct ReferenceImageInstancedCoordinates
91 {
ReferenceImageInstancedCoordinatesvkt::Draw::ReferenceImageInstancedCoordinates92 	ReferenceImageInstancedCoordinates (void)
93 		: left		(-0.3)
94 		, right		(0.6)
95 		, top		(0.3)
96 		, bottom	(-0.6)
97 	{
98 	}
99 
100 	double left;
101 	double right;
102 	double top;
103 	double bottom;
104 };
105 
106 class DrawTestsBaseClass : public TestInstance
107 {
108 public:
109 								DrawTestsBaseClass	(Context& context,
110 													 const char* vertexShaderName,
111 													 const char* fragmentShaderName,
112 													 const SharedGroupParams groupParams,
113 													 vk::VkPrimitiveTopology topology = vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
114 													 const uint32_t layers = 1u);
115 
116 protected:
117 	void						initialize				(void);
118 	virtual void				initPipeline			(const vk::VkDevice device);
119 	void						preRenderBarriers		(void);
120 	void						beginLegacyRender		(vk::VkCommandBuffer cmdBuffer, const vk::VkSubpassContents content = vk::VK_SUBPASS_CONTENTS_INLINE);
121 	void						endLegacyRender			(vk::VkCommandBuffer cmdBuffer);
iterate(void)122 	virtual tcu::TestStatus		iterate					(void)						{ TCU_FAIL("Implement iterate() method!");	}
123 
124 #ifndef CTS_USES_VULKANSC
125 	void						beginSecondaryCmdBuffer	(const vk::DeviceInterface& vk, const vk::VkRenderingFlagsKHR renderingFlags = 0u);
126 	void						beginDynamicRender		(vk::VkCommandBuffer cmdBuffer, const vk::VkRenderingFlagsKHR renderingFlags = 0u);
127 	void						endDynamicRender		(vk::VkCommandBuffer cmdBuffer);
128 #endif // CTS_USES_VULKANSC
129 	virtual uint32_t			getDefaultViewMask		(void) const;
130 
131 	enum
132 	{
133 		WIDTH = 256,
134 		HEIGHT = 256
135 	};
136 
137 	vk::VkFormat									m_colorAttachmentFormat;
138 
139 	const SharedGroupParams							m_groupParams;
140 	const vk::VkPrimitiveTopology					m_topology;
141 	const uint32_t									m_layers; // For multiview.
142 
143 	const vk::DeviceInterface&						m_vk;
144 
145 	vk::Move<vk::VkPipeline>						m_pipeline;
146 	vk::Move<vk::VkPipelineLayout>					m_pipelineLayout;
147 
148 	de::SharedPtr<Image>							m_colorTargetImage;
149 	vk::Move<vk::VkImageView>						m_colorTargetView;
150 
151 	// vertex buffer for vertex colors & position
152 	de::SharedPtr<Buffer>							m_vertexBuffer;
153 
154 	// vertex buffer with reference data used in VS
155 	de::SharedPtr<Buffer>							m_vertexRefDataBuffer;
156 
157 	PipelineCreateInfo::VertexInputState			m_vertexInputState;
158 
159 	vk::Move<vk::VkCommandPool>						m_cmdPool;
160 	vk::Move<vk::VkCommandBuffer>					m_cmdBuffer;
161 	vk::Move<vk::VkCommandBuffer>					m_secCmdBuffer;
162 
163 	vk::Move<vk::VkFramebuffer>						m_framebuffer;
164 	vk::Move<vk::VkRenderPass>						m_renderPass;
165 
166 	const std::string								m_vertexShaderName;
167 	const std::string								m_fragmentShaderName;
168 
169 	std::vector<VertexElementData>					m_data;
170 };
171 
172 }	// Draw
173 }	// vkt
174 
175 #endif // _VKTDRAWBASECLASS_HPP
176