1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * Vulkan Conformance Tests
3e5c31af7Sopenharmony_ci * ------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright (c) 2017 The Khronos Group Inc.
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
10e5c31af7Sopenharmony_ci *
11e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
17e5c31af7Sopenharmony_ci * limitations under the License.
18e5c31af7Sopenharmony_ci *
19e5c31af7Sopenharmony_ci *//*!
20e5c31af7Sopenharmony_ci * \file
21e5c31af7Sopenharmony_ci * \brief Vulkan Multi View Render Tests
22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
23e5c31af7Sopenharmony_ci
24e5c31af7Sopenharmony_ci#include "vktMultiViewRenderTests.hpp"
25e5c31af7Sopenharmony_ci#include "vktMultiViewRenderUtil.hpp"
26e5c31af7Sopenharmony_ci#include "vktMultiViewRenderPassUtil.hpp"
27e5c31af7Sopenharmony_ci#include "vktCustomInstancesDevices.hpp"
28e5c31af7Sopenharmony_ci
29e5c31af7Sopenharmony_ci#include "vktTestCase.hpp"
30e5c31af7Sopenharmony_ci#include "vkBuilderUtil.hpp"
31e5c31af7Sopenharmony_ci#include "vkRefUtil.hpp"
32e5c31af7Sopenharmony_ci#include "vkQueryUtil.hpp"
33e5c31af7Sopenharmony_ci#include "vkDeviceUtil.hpp"
34e5c31af7Sopenharmony_ci#include "vkTypeUtil.hpp"
35e5c31af7Sopenharmony_ci#include "vkPrograms.hpp"
36e5c31af7Sopenharmony_ci#include "vkPlatform.hpp"
37e5c31af7Sopenharmony_ci#include "vkMemUtil.hpp"
38e5c31af7Sopenharmony_ci#include "vkImageUtil.hpp"
39e5c31af7Sopenharmony_ci#include "vkCmdUtil.hpp"
40e5c31af7Sopenharmony_ci#include "vkObjUtil.hpp"
41e5c31af7Sopenharmony_ci#include "vkBarrierUtil.hpp"
42e5c31af7Sopenharmony_ci
43e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp"
44e5c31af7Sopenharmony_ci#include "tcuResource.hpp"
45e5c31af7Sopenharmony_ci#include "tcuImageCompare.hpp"
46e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp"
47e5c31af7Sopenharmony_ci#include "tcuTextureUtil.hpp"
48e5c31af7Sopenharmony_ci#include "tcuRGBA.hpp"
49e5c31af7Sopenharmony_ci
50e5c31af7Sopenharmony_ci#include "deRandom.hpp"
51e5c31af7Sopenharmony_ci#include "deMath.h"
52e5c31af7Sopenharmony_ci#include "deSharedPtr.hpp"
53e5c31af7Sopenharmony_ci#ifdef CTS_USES_VULKANSC
54e5c31af7Sopenharmony_ci#include "vkSafetyCriticalUtil.hpp"
55e5c31af7Sopenharmony_ci#endif
56e5c31af7Sopenharmony_ci
57e5c31af7Sopenharmony_ci#include <algorithm>
58e5c31af7Sopenharmony_ci#include <bitset>
59e5c31af7Sopenharmony_ci
60e5c31af7Sopenharmony_cinamespace vkt
61e5c31af7Sopenharmony_ci{
62e5c31af7Sopenharmony_cinamespace MultiView
63e5c31af7Sopenharmony_ci{
64e5c31af7Sopenharmony_cinamespace
65e5c31af7Sopenharmony_ci{
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ciusing namespace vk;
68e5c31af7Sopenharmony_ciusing de::MovePtr;
69e5c31af7Sopenharmony_ciusing de::UniquePtr;
70e5c31af7Sopenharmony_ciusing std::vector;
71e5c31af7Sopenharmony_ciusing std::map;
72e5c31af7Sopenharmony_ciusing std::string;
73e5c31af7Sopenharmony_ci
74e5c31af7Sopenharmony_cienum TestType
75e5c31af7Sopenharmony_ci{
76e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_MASK,
77e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_INDEX_IN_VERTEX,
78e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_INDEX_IN_FRAGMENT,
79e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_INDEX_IN_GEOMETRY,
80e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_INDEX_IN_TESELLATION,
81e5c31af7Sopenharmony_ci	TEST_TYPE_INPUT_ATTACHMENTS,
82e5c31af7Sopenharmony_ci	TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY,
83e5c31af7Sopenharmony_ci	TEST_TYPE_INSTANCED_RENDERING,
84e5c31af7Sopenharmony_ci	TEST_TYPE_INPUT_RATE_INSTANCE,
85e5c31af7Sopenharmony_ci	TEST_TYPE_DRAW_INDIRECT,
86e5c31af7Sopenharmony_ci	TEST_TYPE_DRAW_INDIRECT_INDEXED,
87e5c31af7Sopenharmony_ci	TEST_TYPE_DRAW_INDEXED,
88e5c31af7Sopenharmony_ci	TEST_TYPE_CLEAR_ATTACHMENTS,
89e5c31af7Sopenharmony_ci	TEST_TYPE_SECONDARY_CMD_BUFFER,
90e5c31af7Sopenharmony_ci	TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY,
91e5c31af7Sopenharmony_ci	TEST_TYPE_POINT_SIZE,
92e5c31af7Sopenharmony_ci	TEST_TYPE_MULTISAMPLE,
93e5c31af7Sopenharmony_ci	TEST_TYPE_QUERIES,
94e5c31af7Sopenharmony_ci	TEST_TYPE_NON_PRECISE_QUERIES,
95e5c31af7Sopenharmony_ci	TEST_TYPE_NON_PRECISE_QUERIES_WITH_AVAILABILITY,
96e5c31af7Sopenharmony_ci	TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR,
97e5c31af7Sopenharmony_ci	TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR,
98e5c31af7Sopenharmony_ci	TEST_TYPE_DEPTH,
99e5c31af7Sopenharmony_ci	TEST_TYPE_DEPTH_DIFFERENT_RANGES,
100e5c31af7Sopenharmony_ci	TEST_TYPE_STENCIL,
101e5c31af7Sopenharmony_ci	TEST_TYPE_VIEW_MASK_ITERATION,
102e5c31af7Sopenharmony_ci	TEST_TYPE_LAST
103e5c31af7Sopenharmony_ci};
104e5c31af7Sopenharmony_ci
105e5c31af7Sopenharmony_cienum RenderingType
106e5c31af7Sopenharmony_ci{
107e5c31af7Sopenharmony_ci	RENDERING_TYPE_RENDERPASS_LEGACY = 0,
108e5c31af7Sopenharmony_ci	RENDERING_TYPE_RENDERPASS2,
109e5c31af7Sopenharmony_ci	RENDERING_TYPE_DYNAMIC_RENDERING
110e5c31af7Sopenharmony_ci};
111e5c31af7Sopenharmony_ci
112e5c31af7Sopenharmony_cienum QueryType
113e5c31af7Sopenharmony_ci{
114e5c31af7Sopenharmony_ci	QUERY_TYPE_GET_QUERY_POOL_RESULTS,
115e5c31af7Sopenharmony_ci	QUERY_TYPE_CMD_COPY_QUERY_POOL_RESULTS
116e5c31af7Sopenharmony_ci};
117e5c31af7Sopenharmony_ci
118e5c31af7Sopenharmony_cistruct TestParameters
119e5c31af7Sopenharmony_ci{
120e5c31af7Sopenharmony_ci	VkExtent3D				extent;
121e5c31af7Sopenharmony_ci	vector<deUint32>		viewMasks;
122e5c31af7Sopenharmony_ci	TestType				viewIndex;
123e5c31af7Sopenharmony_ci	VkSampleCountFlagBits	samples;
124e5c31af7Sopenharmony_ci	VkFormat				colorFormat;
125e5c31af7Sopenharmony_ci	QueryType				queryType;
126e5c31af7Sopenharmony_ci	RenderingType			renderingType;
127e5c31af7Sopenharmony_ci
128e5c31af7Sopenharmony_ci	bool geometryShaderNeeded (void) const
129e5c31af7Sopenharmony_ci	{
130e5c31af7Sopenharmony_ci		return ((TEST_TYPE_VIEW_INDEX_IN_GEOMETRY == viewIndex) ||
131e5c31af7Sopenharmony_ci				(TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY == viewIndex) ||
132e5c31af7Sopenharmony_ci				(TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY == viewIndex));
133e5c31af7Sopenharmony_ci	}
134e5c31af7Sopenharmony_ci};
135e5c31af7Sopenharmony_ci
136e5c31af7Sopenharmony_ciconst int	TEST_POINT_SIZE_SMALL	= 2;
137e5c31af7Sopenharmony_ciconst int	TEST_POINT_SIZE_WIDE	= 4;
138e5c31af7Sopenharmony_ci
139e5c31af7Sopenharmony_civk::Move<vk::VkRenderPass> makeRenderPass (const DeviceInterface&		vk,
140e5c31af7Sopenharmony_ci										   const VkDevice				device,
141e5c31af7Sopenharmony_ci										   const VkFormat				colorFormat,
142e5c31af7Sopenharmony_ci										   const vector<deUint32>&		viewMasks,
143e5c31af7Sopenharmony_ci										   RenderingType				renderingType,
144e5c31af7Sopenharmony_ci										   const VkSampleCountFlagBits	samples = VK_SAMPLE_COUNT_1_BIT,
145e5c31af7Sopenharmony_ci										   const VkAttachmentLoadOp		colorLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
146e5c31af7Sopenharmony_ci										   const VkFormat				dsFormat = VK_FORMAT_UNDEFINED)
147e5c31af7Sopenharmony_ci{
148e5c31af7Sopenharmony_ci	switch (renderingType)
149e5c31af7Sopenharmony_ci	{
150e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:
151e5c31af7Sopenharmony_ci			return MultiView::makeRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, colorFormat, viewMasks, samples, colorLoadOp, dsFormat);
152e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:
153e5c31af7Sopenharmony_ci			return MultiView::makeRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, colorFormat, viewMasks, samples, colorLoadOp, dsFormat);
154e5c31af7Sopenharmony_ci		default:
155e5c31af7Sopenharmony_ci			TCU_THROW(InternalError, "Impossible");
156e5c31af7Sopenharmony_ci	}
157e5c31af7Sopenharmony_ci}
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_civk::Move<vk::VkRenderPass> makeRenderPassWithAttachments (const DeviceInterface&	vk,
160e5c31af7Sopenharmony_ci														  const VkDevice			device,
161e5c31af7Sopenharmony_ci														  const VkFormat			colorFormat,
162e5c31af7Sopenharmony_ci														  const vector<deUint32>&	viewMasks,
163e5c31af7Sopenharmony_ci														  RenderingType				renderingType)
164e5c31af7Sopenharmony_ci{
165e5c31af7Sopenharmony_ci	switch (renderingType)
166e5c31af7Sopenharmony_ci	{
167e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:
168e5c31af7Sopenharmony_ci			return MultiView::makeRenderPassWithAttachments<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, colorFormat, viewMasks, false);
169e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:
170e5c31af7Sopenharmony_ci			return MultiView::makeRenderPassWithAttachments<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, colorFormat, viewMasks, true);
171e5c31af7Sopenharmony_ci		default:
172e5c31af7Sopenharmony_ci			TCU_THROW(InternalError, "Impossible");
173e5c31af7Sopenharmony_ci	}
174e5c31af7Sopenharmony_ci}
175e5c31af7Sopenharmony_ci
176e5c31af7Sopenharmony_civk::Move<vk::VkRenderPass> makeRenderPassWithDepth (const DeviceInterface&	vk,
177e5c31af7Sopenharmony_ci													const VkDevice			device,
178e5c31af7Sopenharmony_ci													const VkFormat			colorFormat,
179e5c31af7Sopenharmony_ci													const vector<deUint32>&	viewMasks,
180e5c31af7Sopenharmony_ci													const VkFormat			dsFormat,
181e5c31af7Sopenharmony_ci													RenderingType			renderingType)
182e5c31af7Sopenharmony_ci{
183e5c31af7Sopenharmony_ci	switch (renderingType)
184e5c31af7Sopenharmony_ci	{
185e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:
186e5c31af7Sopenharmony_ci			return MultiView::makeRenderPassWithDepth<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, colorFormat, viewMasks, dsFormat);
187e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:
188e5c31af7Sopenharmony_ci			return MultiView::makeRenderPassWithDepth<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, colorFormat, viewMasks, dsFormat);
189e5c31af7Sopenharmony_ci		default:
190e5c31af7Sopenharmony_ci			TCU_THROW(InternalError, "Impossible");
191e5c31af7Sopenharmony_ci	}
192e5c31af7Sopenharmony_ci}
193e5c31af7Sopenharmony_ci
194e5c31af7Sopenharmony_citemplate<typename RenderpassSubpass>
195e5c31af7Sopenharmony_civoid cmdBeginRenderPass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassContents contents)
196e5c31af7Sopenharmony_ci{
197e5c31af7Sopenharmony_ci	const typename RenderpassSubpass::SubpassBeginInfo	subpassBeginInfo	(DE_NULL, contents);
198e5c31af7Sopenharmony_ci
199e5c31af7Sopenharmony_ci	RenderpassSubpass::cmdBeginRenderPass(vkd, cmdBuffer, pRenderPassBegin, &subpassBeginInfo);
200e5c31af7Sopenharmony_ci}
201e5c31af7Sopenharmony_ci
202e5c31af7Sopenharmony_civoid cmdBeginRenderPass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassContents contents, RenderingType renderingType)
203e5c31af7Sopenharmony_ci{
204e5c31af7Sopenharmony_ci	switch (renderingType)
205e5c31af7Sopenharmony_ci	{
206e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:	cmdBeginRenderPass<RenderpassSubpass1>(vkd, cmdBuffer, pRenderPassBegin, contents);	break;
207e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:		cmdBeginRenderPass<RenderpassSubpass2>(vkd, cmdBuffer, pRenderPassBegin, contents);	break;
208e5c31af7Sopenharmony_ci		default:								TCU_THROW(InternalError, "Impossible");
209e5c31af7Sopenharmony_ci	}
210e5c31af7Sopenharmony_ci}
211e5c31af7Sopenharmony_ci
212e5c31af7Sopenharmony_citemplate<typename RenderpassSubpass>
213e5c31af7Sopenharmony_civoid cmdNextSubpass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer, const VkSubpassContents contents)
214e5c31af7Sopenharmony_ci{
215e5c31af7Sopenharmony_ci	const typename RenderpassSubpass::SubpassBeginInfo	subpassBeginInfo	(DE_NULL, contents);
216e5c31af7Sopenharmony_ci	const typename RenderpassSubpass::SubpassEndInfo	subpassEndInfo		(DE_NULL);
217e5c31af7Sopenharmony_ci
218e5c31af7Sopenharmony_ci	RenderpassSubpass::cmdNextSubpass(vkd, cmdBuffer, &subpassBeginInfo, &subpassEndInfo);
219e5c31af7Sopenharmony_ci}
220e5c31af7Sopenharmony_ci
221e5c31af7Sopenharmony_civoid cmdNextSubpass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer, const VkSubpassContents contents, RenderingType renderingType)
222e5c31af7Sopenharmony_ci{
223e5c31af7Sopenharmony_ci	switch (renderingType)
224e5c31af7Sopenharmony_ci	{
225e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:	cmdNextSubpass<RenderpassSubpass1>(vkd, cmdBuffer, contents);	break;
226e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:		cmdNextSubpass<RenderpassSubpass2>(vkd, cmdBuffer, contents);	break;
227e5c31af7Sopenharmony_ci		default:								TCU_THROW(InternalError, "Impossible");
228e5c31af7Sopenharmony_ci	}
229e5c31af7Sopenharmony_ci}
230e5c31af7Sopenharmony_ci
231e5c31af7Sopenharmony_citemplate<typename RenderpassSubpass>
232e5c31af7Sopenharmony_civoid cmdEndRenderPass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer)
233e5c31af7Sopenharmony_ci{
234e5c31af7Sopenharmony_ci	const typename RenderpassSubpass::SubpassEndInfo	subpassEndInfo	(DE_NULL);
235e5c31af7Sopenharmony_ci
236e5c31af7Sopenharmony_ci	RenderpassSubpass::cmdEndRenderPass(vkd, cmdBuffer, &subpassEndInfo);
237e5c31af7Sopenharmony_ci}
238e5c31af7Sopenharmony_ci
239e5c31af7Sopenharmony_civoid cmdEndRenderPass (DeviceInterface& vkd, VkCommandBuffer cmdBuffer, RenderingType renderingType)
240e5c31af7Sopenharmony_ci{
241e5c31af7Sopenharmony_ci	switch (renderingType)
242e5c31af7Sopenharmony_ci	{
243e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS_LEGACY:	cmdEndRenderPass<RenderpassSubpass1>(vkd, cmdBuffer);	break;
244e5c31af7Sopenharmony_ci		case RENDERING_TYPE_RENDERPASS2:		cmdEndRenderPass<RenderpassSubpass2>(vkd, cmdBuffer);	break;
245e5c31af7Sopenharmony_ci		default:								TCU_THROW(InternalError, "Impossible");
246e5c31af7Sopenharmony_ci	}
247e5c31af7Sopenharmony_ci}
248e5c31af7Sopenharmony_ci
249e5c31af7Sopenharmony_ciclass ImageAttachment
250e5c31af7Sopenharmony_ci{
251e5c31af7Sopenharmony_cipublic:
252e5c31af7Sopenharmony_ci				ImageAttachment	(VkDevice logicalDevice, DeviceInterface& device, Allocator& allocator, const VkExtent3D extent, VkFormat colorFormat, const VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
253e5c31af7Sopenharmony_ci	VkImageView	getImageView	(void) const
254e5c31af7Sopenharmony_ci	{
255e5c31af7Sopenharmony_ci		return *m_imageView;
256e5c31af7Sopenharmony_ci	}
257e5c31af7Sopenharmony_ci	VkImage		getImage		(void) const
258e5c31af7Sopenharmony_ci	{
259e5c31af7Sopenharmony_ci		return *m_image;
260e5c31af7Sopenharmony_ci	}
261e5c31af7Sopenharmony_ciprivate:
262e5c31af7Sopenharmony_ci	Move<VkImage>			m_image;
263e5c31af7Sopenharmony_ci	MovePtr<Allocation>		m_allocationImage;
264e5c31af7Sopenharmony_ci	Move<VkImageView>		m_imageView;
265e5c31af7Sopenharmony_ci};
266e5c31af7Sopenharmony_ci
267e5c31af7Sopenharmony_ciImageAttachment::ImageAttachment (VkDevice logicalDevice, DeviceInterface& device, Allocator& allocator, const VkExtent3D extent, VkFormat colorFormat, const VkSampleCountFlagBits samples)
268e5c31af7Sopenharmony_ci{
269e5c31af7Sopenharmony_ci	const bool						depthStencilFormat			= isDepthStencilFormat(colorFormat);
270e5c31af7Sopenharmony_ci	const VkImageAspectFlags		aspectFlags					= depthStencilFormat ? VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
271e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	colorImageSubresourceRange	= makeImageSubresourceRange(aspectFlags, 0u, 1u, 0u, extent.depth);
272e5c31af7Sopenharmony_ci	const VkImageUsageFlags			imageUsageFlagsDependent	= depthStencilFormat ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
273e5c31af7Sopenharmony_ci	const VkImageUsageFlags			imageUsageFlags				= imageUsageFlagsDependent | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
274e5c31af7Sopenharmony_ci	const VkImageCreateInfo			colorAttachmentImageInfo	= makeImageCreateInfo(VK_IMAGE_TYPE_2D, extent, colorFormat, imageUsageFlags, samples);
275e5c31af7Sopenharmony_ci
276e5c31af7Sopenharmony_ci	m_image							= createImage(device, logicalDevice, &colorAttachmentImageInfo);
277e5c31af7Sopenharmony_ci	m_allocationImage				= allocator.allocate(getImageMemoryRequirements(device, logicalDevice, *m_image), MemoryRequirement::Any);
278e5c31af7Sopenharmony_ci	VK_CHECK(device.bindImageMemory(logicalDevice, *m_image, m_allocationImage->getMemory(), m_allocationImage->getOffset()));
279e5c31af7Sopenharmony_ci	m_imageView						= makeImageView(device, logicalDevice, *m_image, VK_IMAGE_VIEW_TYPE_2D_ARRAY, colorFormat, colorImageSubresourceRange);
280e5c31af7Sopenharmony_ci}
281e5c31af7Sopenharmony_ci
282e5c31af7Sopenharmony_ciclass MultiViewRenderTestInstance : public TestInstance
283e5c31af7Sopenharmony_ci{
284e5c31af7Sopenharmony_cipublic:
285e5c31af7Sopenharmony_ci									MultiViewRenderTestInstance	(Context& context, const TestParameters& parameters);
286e5c31af7Sopenharmony_ci									~MultiViewRenderTestInstance();
287e5c31af7Sopenharmony_ciprotected:
288e5c31af7Sopenharmony_ci	typedef de::SharedPtr<Unique<VkPipeline> >		PipelineSp;
289e5c31af7Sopenharmony_ci	typedef de::SharedPtr<Unique<VkShaderModule> >	ShaderModuleSP;
290e5c31af7Sopenharmony_ci
291e5c31af7Sopenharmony_ci	virtual tcu::TestStatus					iterate					(void);
292e5c31af7Sopenharmony_ci	virtual void							beforeRenderPass		(void);
293e5c31af7Sopenharmony_ci	virtual void							afterRenderPass			(void);
294e5c31af7Sopenharmony_ci	virtual void							bindResources			(void) {}
295e5c31af7Sopenharmony_ci	virtual void							draw					(const deUint32			subpassCount,
296e5c31af7Sopenharmony_ci																	 VkRenderPass			renderPass,
297e5c31af7Sopenharmony_ci																	 VkFramebuffer			frameBuffer,
298e5c31af7Sopenharmony_ci																	 vector<PipelineSp>&	pipelines);
299e5c31af7Sopenharmony_ci	virtual void							createVertexData		(void);
300e5c31af7Sopenharmony_ci	virtual MovePtr<tcu::Texture2DArray>	imageData				(void) const;
301e5c31af7Sopenharmony_ci	TestParameters							fillMissingParameters	(const TestParameters&	parameters);
302e5c31af7Sopenharmony_ci	void									createVertexBuffer		(void);
303e5c31af7Sopenharmony_ci	void									createMultiViewDevices	(void);
304e5c31af7Sopenharmony_ci	void									createCommandBuffer		(void);
305e5c31af7Sopenharmony_ci	void									createSecondaryCommandPool	(void);
306e5c31af7Sopenharmony_ci	void									madeShaderModule		(map<VkShaderStageFlagBits,ShaderModuleSP>& shaderModule, vector<VkPipelineShaderStageCreateInfo>& shaderStageParams);
307e5c31af7Sopenharmony_ci	Move<VkPipeline>						makeGraphicsPipeline	(const VkRenderPass							renderPass,
308e5c31af7Sopenharmony_ci																	 const VkPipelineLayout						pipelineLayout,
309e5c31af7Sopenharmony_ci																	 const deUint32								pipelineShaderStageCount,
310e5c31af7Sopenharmony_ci																	 const VkPipelineShaderStageCreateInfo*		pipelineShaderStageCreate,
311e5c31af7Sopenharmony_ci																	 const deUint32								subpass,
312e5c31af7Sopenharmony_ci																	 const VkVertexInputRate					vertexInputRate = VK_VERTEX_INPUT_RATE_VERTEX,
313e5c31af7Sopenharmony_ci																	 const bool									useDepthTest = false,
314e5c31af7Sopenharmony_ci																	 const bool									useStencilTest = false,
315e5c31af7Sopenharmony_ci																	 const float								minDepth = 0.0f,
316e5c31af7Sopenharmony_ci																	 const float								maxDepth = 1.0f,
317e5c31af7Sopenharmony_ci																	 const VkFormat                                                         dsFormat = VK_FORMAT_UNDEFINED);
318e5c31af7Sopenharmony_ci	void									readImage				(VkImage image, const tcu::PixelBufferAccess& dst);
319e5c31af7Sopenharmony_ci	bool									checkImage				(tcu::ConstPixelBufferAccess& dst);
320e5c31af7Sopenharmony_ci	const tcu::Vec4							getQuarterRefColor		(const deUint32 quarterNdx, const int colorNdx, const int layerNdx, const bool background = true, const deUint32 subpassNdx = 0u) const;
321e5c31af7Sopenharmony_ci	void									appendVertex			(const tcu::Vec4& coord, const tcu::Vec4& color);
322e5c31af7Sopenharmony_ci	void									setPoint				(const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& pointColor, const int pointSize, const int layerNdx, const deUint32 quarter) const;
323e5c31af7Sopenharmony_ci	void									fillTriangle			(const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx, const deUint32 quarter) const;
324e5c31af7Sopenharmony_ci	void									fillLayer				(const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx) const;
325e5c31af7Sopenharmony_ci	void									fillQuarter				(const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx, const deUint32 quarter, const deUint32 subpassNdx) const;
326e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
327e5c31af7Sopenharmony_ci	void									addRenderingSubpassDependencyIfRequired (deUint32 currentSubpassNdx);
328e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
329e5c31af7Sopenharmony_ci
330e5c31af7Sopenharmony_ci	const TestParameters			m_parameters;
331e5c31af7Sopenharmony_ci	const bool						m_useDynamicRendering;
332e5c31af7Sopenharmony_ci	const bool						m_cmdCopyQueryPoolResults;
333e5c31af7Sopenharmony_ci	const int						m_seed;
334e5c31af7Sopenharmony_ci	const deUint32					m_squareCount;
335e5c31af7Sopenharmony_ci
336e5c31af7Sopenharmony_ci	Move<VkDevice>					m_logicalDevice;
337e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
338e5c31af7Sopenharmony_ci	de::MovePtr<vk::DeviceDriver>	m_device;
339e5c31af7Sopenharmony_ci#else
340e5c31af7Sopenharmony_ci	de::MovePtr<vk::DeviceDriverSC, vk::DeinitDeviceDeleter> m_device;
341e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
342e5c31af7Sopenharmony_ci	MovePtr<Allocator>				m_allocator;
343e5c31af7Sopenharmony_ci	deUint32						m_queueFamilyIndex;
344e5c31af7Sopenharmony_ci	VkQueue							m_queue;
345e5c31af7Sopenharmony_ci	vector<tcu::Vec4>				m_vertexCoord;
346e5c31af7Sopenharmony_ci	Move<VkBuffer>					m_vertexCoordBuffer;
347e5c31af7Sopenharmony_ci	MovePtr<Allocation>				m_vertexCoordAlloc;
348e5c31af7Sopenharmony_ci	vector<tcu::Vec4>				m_vertexColor;
349e5c31af7Sopenharmony_ci	Move<VkBuffer>					m_vertexColorBuffer;
350e5c31af7Sopenharmony_ci	MovePtr<Allocation>				m_vertexColorAlloc;
351e5c31af7Sopenharmony_ci	vector<deUint32>				m_vertexIndices;
352e5c31af7Sopenharmony_ci	Move<VkBuffer>					m_vertexIndicesBuffer;
353e5c31af7Sopenharmony_ci	MovePtr<Allocation>				m_vertexIndicesAllocation;
354e5c31af7Sopenharmony_ci	Move<VkCommandPool>				m_cmdPool;
355e5c31af7Sopenharmony_ci	Move<VkCommandBuffer>			m_cmdBuffer;
356e5c31af7Sopenharmony_ci	Move<VkCommandPool>				m_cmdPoolSecondary;
357e5c31af7Sopenharmony_ci	de::SharedPtr<ImageAttachment>	m_colorAttachment;
358e5c31af7Sopenharmony_ci	VkBool32						m_hasMultiDrawIndirect;
359e5c31af7Sopenharmony_ci	vector<tcu::Vec4>				m_colorTable;
360e5c31af7Sopenharmony_ci};
361e5c31af7Sopenharmony_ci
362e5c31af7Sopenharmony_ciMultiViewRenderTestInstance::MultiViewRenderTestInstance (Context& context, const TestParameters& parameters)
363e5c31af7Sopenharmony_ci	: TestInstance				(context)
364e5c31af7Sopenharmony_ci	, m_parameters				(fillMissingParameters(parameters))
365e5c31af7Sopenharmony_ci	, m_useDynamicRendering		(parameters.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
366e5c31af7Sopenharmony_ci	, m_cmdCopyQueryPoolResults	(parameters.queryType == QUERY_TYPE_CMD_COPY_QUERY_POOL_RESULTS)
367e5c31af7Sopenharmony_ci	, m_seed					(context.getTestContext().getCommandLine().getBaseSeed())
368e5c31af7Sopenharmony_ci	, m_squareCount				(4u)
369e5c31af7Sopenharmony_ci	, m_queueFamilyIndex		(0u)
370e5c31af7Sopenharmony_ci{
371e5c31af7Sopenharmony_ci	const float v	= 0.75f;
372e5c31af7Sopenharmony_ci	const float o	= 0.25f;
373e5c31af7Sopenharmony_ci
374e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(v, o, o, 1.0f));
375e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(o, v, o, 1.0f));
376e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(o, o, v, 1.0f));
377e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(o, v, v, 1.0f));
378e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(v, o, v, 1.0f));
379e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(v, v, o, 1.0f));
380e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(o, o, o, 1.0f));
381e5c31af7Sopenharmony_ci	m_colorTable.push_back(tcu::Vec4(v, v, v, 1.0f));
382e5c31af7Sopenharmony_ci
383e5c31af7Sopenharmony_ci	createMultiViewDevices();
384e5c31af7Sopenharmony_ci
385e5c31af7Sopenharmony_ci	// Color attachment
386e5c31af7Sopenharmony_ci	m_colorAttachment = de::SharedPtr<ImageAttachment>(new ImageAttachment(*m_logicalDevice, *m_device, *m_allocator, m_parameters.extent, m_parameters.colorFormat, m_parameters.samples));
387e5c31af7Sopenharmony_ci}
388e5c31af7Sopenharmony_ci
389e5c31af7Sopenharmony_ciMultiViewRenderTestInstance::~MultiViewRenderTestInstance()
390e5c31af7Sopenharmony_ci{
391e5c31af7Sopenharmony_ci}
392e5c31af7Sopenharmony_ci
393e5c31af7Sopenharmony_citcu::TestStatus MultiViewRenderTestInstance::iterate (void)
394e5c31af7Sopenharmony_ci{
395e5c31af7Sopenharmony_ci	const deUint32								subpassCount				= static_cast<deUint32>(m_parameters.viewMasks.size());
396e5c31af7Sopenharmony_ci	Move<VkRenderPass>							renderPass;
397e5c31af7Sopenharmony_ci	Move<VkFramebuffer>							frameBuffer;
398e5c31af7Sopenharmony_ci
399e5c31af7Sopenharmony_ci	// FrameBuffer & renderPass
400e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
401e5c31af7Sopenharmony_ci	{
402e5c31af7Sopenharmony_ci		renderPass	= makeRenderPass (*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_parameters.renderingType);
403e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, m_colorAttachment->getImageView(), m_parameters.extent.width, m_parameters.extent.height);
404e5c31af7Sopenharmony_ci	}
405e5c31af7Sopenharmony_ci
406e5c31af7Sopenharmony_ci	// pipelineLayout
407e5c31af7Sopenharmony_ci	Unique<VkPipelineLayout>					pipelineLayout				(makePipelineLayout(*m_device, *m_logicalDevice));
408e5c31af7Sopenharmony_ci
409e5c31af7Sopenharmony_ci	// pipelines
410e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
411e5c31af7Sopenharmony_ci	vector<PipelineSp>							pipelines(subpassCount);
412e5c31af7Sopenharmony_ci	const VkVertexInputRate						vertexInputRate				= (TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex) ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
413e5c31af7Sopenharmony_ci
414e5c31af7Sopenharmony_ci	{
415e5c31af7Sopenharmony_ci		vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
416e5c31af7Sopenharmony_ci		madeShaderModule(shaderModule, shaderStageParams);
417e5c31af7Sopenharmony_ci		for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
418e5c31af7Sopenharmony_ci			pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(*renderPass, *pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(), subpassNdx, vertexInputRate))));
419e5c31af7Sopenharmony_ci	}
420e5c31af7Sopenharmony_ci
421e5c31af7Sopenharmony_ci	createCommandBuffer();
422e5c31af7Sopenharmony_ci	createVertexData();
423e5c31af7Sopenharmony_ci	createVertexBuffer();
424e5c31af7Sopenharmony_ci
425e5c31af7Sopenharmony_ci	draw(subpassCount, *renderPass, *frameBuffer, pipelines);
426e5c31af7Sopenharmony_ci
427e5c31af7Sopenharmony_ci	{
428e5c31af7Sopenharmony_ci		vector<deUint8>			pixelAccessData	(m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * mapVkFormat(m_parameters.colorFormat).getPixelSize());
429e5c31af7Sopenharmony_ci		tcu::PixelBufferAccess	dst				(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth, pixelAccessData.data());
430e5c31af7Sopenharmony_ci
431e5c31af7Sopenharmony_ci		readImage(m_colorAttachment->getImage(), dst);
432e5c31af7Sopenharmony_ci
433e5c31af7Sopenharmony_ci		if (!checkImage(dst))
434e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
435e5c31af7Sopenharmony_ci	}
436e5c31af7Sopenharmony_ci
437e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
438e5c31af7Sopenharmony_ci}
439e5c31af7Sopenharmony_ci
440e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::beforeRenderPass (void)
441e5c31af7Sopenharmony_ci{
442e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	subresourceRange		=
443e5c31af7Sopenharmony_ci	{
444e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,	//VkImageAspectFlags	aspectMask;
445e5c31af7Sopenharmony_ci		0u,							//deUint32				baseMipLevel;
446e5c31af7Sopenharmony_ci		1u,							//deUint32				levelCount;
447e5c31af7Sopenharmony_ci		0u,							//deUint32				baseArrayLayer;
448e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	//deUint32				layerCount;
449e5c31af7Sopenharmony_ci	};
450e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
451e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
452e5c31af7Sopenharmony_ci		0, VK_ACCESS_TRANSFER_WRITE_BIT,
453e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
454e5c31af7Sopenharmony_ci
455e5c31af7Sopenharmony_ci	const VkClearValue renderPassClearValue = makeClearValueColor(tcu::Vec4(0.0f));
456e5c31af7Sopenharmony_ci	m_device->cmdClearColorImage(*m_cmdBuffer, m_colorAttachment->getImage(),  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &renderPassClearValue.color, 1, &subresourceRange);
457e5c31af7Sopenharmony_ci
458e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
459e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
460e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
461e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
462e5c31af7Sopenharmony_ci}
463e5c31af7Sopenharmony_ci
464e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::afterRenderPass (void)
465e5c31af7Sopenharmony_ci{
466e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	subresourceRange		=
467e5c31af7Sopenharmony_ci	{
468e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,	//VkImageAspectFlags	aspectMask;
469e5c31af7Sopenharmony_ci		0u,							//deUint32				baseMipLevel;
470e5c31af7Sopenharmony_ci		1u,							//deUint32				levelCount;
471e5c31af7Sopenharmony_ci		0u,							//deUint32				baseArrayLayer;
472e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	//deUint32				layerCount;
473e5c31af7Sopenharmony_ci	};
474e5c31af7Sopenharmony_ci
475e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
476e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
477e5c31af7Sopenharmony_ci		VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
478e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
479e5c31af7Sopenharmony_ci}
480e5c31af7Sopenharmony_ci
481e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
482e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::addRenderingSubpassDependencyIfRequired (deUint32 currentSubpassNdx)
483e5c31af7Sopenharmony_ci{
484e5c31af7Sopenharmony_ci	// Get the combined view mask since the last pipeline barrier.
485e5c31af7Sopenharmony_ci	deUint32 viewMask = 0;
486e5c31af7Sopenharmony_ci
487e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0; subpassNdx < currentSubpassNdx; ++subpassNdx)
488e5c31af7Sopenharmony_ci	{
489e5c31af7Sopenharmony_ci		if ((viewMask & m_parameters.viewMasks[subpassNdx]) != 0)
490e5c31af7Sopenharmony_ci		{
491e5c31af7Sopenharmony_ci			viewMask = 0; // This subpass should have a pipeline barrier so reset the view mask.
492e5c31af7Sopenharmony_ci		}
493e5c31af7Sopenharmony_ci
494e5c31af7Sopenharmony_ci		viewMask |= m_parameters.viewMasks[subpassNdx];
495e5c31af7Sopenharmony_ci	}
496e5c31af7Sopenharmony_ci
497e5c31af7Sopenharmony_ci	// Add a pipeline barrier if the view mask for this subpass contains bits used in previous subpasses
498e5c31af7Sopenharmony_ci	// since the last pipeline barrier.
499e5c31af7Sopenharmony_ci	if ((viewMask & m_parameters.viewMasks[currentSubpassNdx]) != 0)
500e5c31af7Sopenharmony_ci	{
501e5c31af7Sopenharmony_ci		const VkImageSubresourceRange	subresourceRange		=
502e5c31af7Sopenharmony_ci		{
503e5c31af7Sopenharmony_ci			VK_IMAGE_ASPECT_COLOR_BIT,	//VkImageAspectFlags	aspectMask;
504e5c31af7Sopenharmony_ci			0u,							//deUint32				baseMipLevel;
505e5c31af7Sopenharmony_ci			1u,							//deUint32				levelCount;
506e5c31af7Sopenharmony_ci			0u,							//deUint32				baseArrayLayer;
507e5c31af7Sopenharmony_ci			m_parameters.extent.depth,	//deUint32				layerCount;
508e5c31af7Sopenharmony_ci		};
509e5c31af7Sopenharmony_ci
510e5c31af7Sopenharmony_ci		imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
511e5c31af7Sopenharmony_ci			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
512e5c31af7Sopenharmony_ci			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
513e5c31af7Sopenharmony_ci			VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
514e5c31af7Sopenharmony_ci	}
515e5c31af7Sopenharmony_ci}
516e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
517e5c31af7Sopenharmony_ci
518e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
519e5c31af7Sopenharmony_ci{
520e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
521e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
522e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
523e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
524e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
525e5c31af7Sopenharmony_ci
526e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
527e5c31af7Sopenharmony_ci
528e5c31af7Sopenharmony_ci	beforeRenderPass();
529e5c31af7Sopenharmony_ci
530e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
531e5c31af7Sopenharmony_ci	{
532e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
533e5c31af7Sopenharmony_ci		{
534e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
535e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
536e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
537e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
538e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
539e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
540e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
541e5c31af7Sopenharmony_ci		};
542e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
543e5c31af7Sopenharmony_ci	}
544e5c31af7Sopenharmony_ci
545e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
546e5c31af7Sopenharmony_ci	{
547e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
548e5c31af7Sopenharmony_ci
549e5c31af7Sopenharmony_ci		if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED)
550e5c31af7Sopenharmony_ci			m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
551e5c31af7Sopenharmony_ci
552e5c31af7Sopenharmony_ci		bindResources();
553e5c31af7Sopenharmony_ci
554e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
555e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
556e5c31af7Sopenharmony_ci		{
557e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
558e5c31af7Sopenharmony_ci
559e5c31af7Sopenharmony_ci			beginRendering(
560e5c31af7Sopenharmony_ci				*m_device,
561e5c31af7Sopenharmony_ci				*m_cmdBuffer,
562e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
563e5c31af7Sopenharmony_ci				renderArea,
564e5c31af7Sopenharmony_ci				renderPassClearValue,
565e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
566e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
567e5c31af7Sopenharmony_ci				0u,
568e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
569e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
570e5c31af7Sopenharmony_ci		}
571e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
572e5c31af7Sopenharmony_ci
573e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
574e5c31af7Sopenharmony_ci
575e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
576e5c31af7Sopenharmony_ci			if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED)
577e5c31af7Sopenharmony_ci				m_device->cmdDrawIndexed(*m_cmdBuffer, 4u, 1u, (drawNdx + subpassNdx % m_squareCount) * 4u, 0u, 0u);
578e5c31af7Sopenharmony_ci			else
579e5c31af7Sopenharmony_ci				m_device->cmdDraw(*m_cmdBuffer, 4u, 1u, (drawNdx + subpassNdx % m_squareCount) * 4u, 0u);
580e5c31af7Sopenharmony_ci
581e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
582e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
583e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
584e5c31af7Sopenharmony_ci		else
585e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
586e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
587e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
588e5c31af7Sopenharmony_ci	}
589e5c31af7Sopenharmony_ci
590e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
591e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
592e5c31af7Sopenharmony_ci
593e5c31af7Sopenharmony_ci	afterRenderPass();
594e5c31af7Sopenharmony_ci
595e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
596e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
597e5c31af7Sopenharmony_ci}
598e5c31af7Sopenharmony_ci
599e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::createVertexData (void)
600e5c31af7Sopenharmony_ci{
601e5c31af7Sopenharmony_ci	tcu::Vec4 color = tcu::Vec4(0.2f, 0.0f, 0.1f, 1.0f);
602e5c31af7Sopenharmony_ci
603e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), color);
604e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), color);
605e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), color);
606e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
607e5c31af7Sopenharmony_ci
608e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.3f, 0.0f, 0.2f, 1.0f);
609e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), color);
610e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), color);
611e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
612e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), color);
613e5c31af7Sopenharmony_ci
614e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.4f, 0.2f, 0.3f, 1.0f);
615e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), color);
616e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
617e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f,-1.0f, 1.0f, 1.0f), color);
618e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), color);
619e5c31af7Sopenharmony_ci
620e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.5f, 0.0f, 0.4f, 1.0f);
621e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
622e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), color);
623e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), color);
624e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 1.0f, 1.0f, 1.0f), color);
625e5c31af7Sopenharmony_ci
626e5c31af7Sopenharmony_ci	if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED || m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
627e5c31af7Sopenharmony_ci	{
628e5c31af7Sopenharmony_ci		const size_t		verticesCount	= m_vertexCoord.size();
629e5c31af7Sopenharmony_ci		vector<tcu::Vec4>	vertexColor		(verticesCount);
630e5c31af7Sopenharmony_ci		vector<tcu::Vec4>	vertexCoord		(verticesCount);
631e5c31af7Sopenharmony_ci
632e5c31af7Sopenharmony_ci		m_vertexIndices.clear();
633e5c31af7Sopenharmony_ci		m_vertexIndices.reserve(verticesCount);
634e5c31af7Sopenharmony_ci		for (deUint32 vertexIdx = 0; vertexIdx < verticesCount; ++vertexIdx)
635e5c31af7Sopenharmony_ci			m_vertexIndices.push_back(vertexIdx);
636e5c31af7Sopenharmony_ci
637e5c31af7Sopenharmony_ci		de::Random(m_seed).shuffle(m_vertexIndices.begin(), m_vertexIndices.end());
638e5c31af7Sopenharmony_ci
639e5c31af7Sopenharmony_ci		for (deUint32 vertexIdx = 0; vertexIdx < verticesCount; ++vertexIdx)
640e5c31af7Sopenharmony_ci			vertexColor[m_vertexIndices[vertexIdx]] = m_vertexColor[vertexIdx];
641e5c31af7Sopenharmony_ci		m_vertexColor.assign(vertexColor.begin(), vertexColor.end());
642e5c31af7Sopenharmony_ci
643e5c31af7Sopenharmony_ci		for (deUint32 vertexIdx = 0; vertexIdx < verticesCount; ++vertexIdx)
644e5c31af7Sopenharmony_ci			vertexCoord[m_vertexIndices[vertexIdx]] = m_vertexCoord[vertexIdx];
645e5c31af7Sopenharmony_ci		m_vertexCoord.assign(vertexCoord.begin(), vertexCoord.end());
646e5c31af7Sopenharmony_ci	}
647e5c31af7Sopenharmony_ci}
648e5c31af7Sopenharmony_ci
649e5c31af7Sopenharmony_ciTestParameters MultiViewRenderTestInstance::fillMissingParameters (const TestParameters& parameters)
650e5c31af7Sopenharmony_ci{
651e5c31af7Sopenharmony_ci	if (!parameters.viewMasks.empty())
652e5c31af7Sopenharmony_ci		return parameters;
653e5c31af7Sopenharmony_ci	else
654e5c31af7Sopenharmony_ci	{
655e5c31af7Sopenharmony_ci		const auto& instanceDriver	= m_context.getInstanceInterface();
656e5c31af7Sopenharmony_ci		const auto physicalDevice	= m_context.getPhysicalDevice();
657e5c31af7Sopenharmony_ci
658e5c31af7Sopenharmony_ci		VkPhysicalDeviceMultiviewProperties multiviewProperties =
659e5c31af7Sopenharmony_ci		{
660e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,		// VkStructureType	sType;
661e5c31af7Sopenharmony_ci			DE_NULL,													// void*			pNext;
662e5c31af7Sopenharmony_ci			0u,															// deUint32			maxMultiviewViewCount;
663e5c31af7Sopenharmony_ci			0u															// deUint32			maxMultiviewInstanceIndex;
664e5c31af7Sopenharmony_ci		};
665e5c31af7Sopenharmony_ci
666e5c31af7Sopenharmony_ci		VkPhysicalDeviceProperties2 deviceProperties2;
667e5c31af7Sopenharmony_ci		deviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
668e5c31af7Sopenharmony_ci		deviceProperties2.pNext = &multiviewProperties;
669e5c31af7Sopenharmony_ci
670e5c31af7Sopenharmony_ci		instanceDriver.getPhysicalDeviceProperties2(physicalDevice, &deviceProperties2);
671e5c31af7Sopenharmony_ci
672e5c31af7Sopenharmony_ci		TestParameters newParameters = parameters;
673e5c31af7Sopenharmony_ci		newParameters.extent.depth = multiviewProperties.maxMultiviewViewCount;
674e5c31af7Sopenharmony_ci
675e5c31af7Sopenharmony_ci		vector<deUint32> viewMasks(multiviewProperties.maxMultiviewViewCount);
676e5c31af7Sopenharmony_ci		for (deUint32 i = 0; i < multiviewProperties.maxMultiviewViewCount; i++)
677e5c31af7Sopenharmony_ci			viewMasks[i] = 1 << i;
678e5c31af7Sopenharmony_ci		newParameters.viewMasks = viewMasks;
679e5c31af7Sopenharmony_ci
680e5c31af7Sopenharmony_ci		return newParameters;
681e5c31af7Sopenharmony_ci	}
682e5c31af7Sopenharmony_ci}
683e5c31af7Sopenharmony_ci
684e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::createVertexBuffer (void)
685e5c31af7Sopenharmony_ci{
686e5c31af7Sopenharmony_ci	DE_ASSERT(m_vertexCoord.size() == m_vertexColor.size());
687e5c31af7Sopenharmony_ci	DE_ASSERT(m_vertexCoord.size() != 0);
688e5c31af7Sopenharmony_ci
689e5c31af7Sopenharmony_ci	const size_t	nonCoherentAtomSize	= static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize);
690e5c31af7Sopenharmony_ci
691e5c31af7Sopenharmony_ci	// Upload vertex coordinates
692e5c31af7Sopenharmony_ci	{
693e5c31af7Sopenharmony_ci		const size_t				dataSize		= static_cast<size_t>(m_vertexCoord.size() * sizeof(m_vertexCoord[0]));
694e5c31af7Sopenharmony_ci		const VkDeviceSize			bufferDataSize	= static_cast<VkDeviceSize>(deAlignSize(dataSize, nonCoherentAtomSize));
695e5c31af7Sopenharmony_ci		const VkBufferCreateInfo	bufferInfo		= makeBufferCreateInfo(bufferDataSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
696e5c31af7Sopenharmony_ci
697e5c31af7Sopenharmony_ci		m_vertexCoordBuffer	= createBuffer(*m_device, *m_logicalDevice, &bufferInfo);
698e5c31af7Sopenharmony_ci		m_vertexCoordAlloc	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *m_vertexCoordBuffer), MemoryRequirement::HostVisible);
699e5c31af7Sopenharmony_ci
700e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *m_vertexCoordBuffer, m_vertexCoordAlloc->getMemory(), m_vertexCoordAlloc->getOffset()));
701e5c31af7Sopenharmony_ci		deMemcpy(m_vertexCoordAlloc->getHostPtr(), m_vertexCoord.data(), static_cast<size_t>(dataSize));
702e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *m_vertexCoordAlloc);
703e5c31af7Sopenharmony_ci	}
704e5c31af7Sopenharmony_ci
705e5c31af7Sopenharmony_ci	// Upload vertex colors
706e5c31af7Sopenharmony_ci	{
707e5c31af7Sopenharmony_ci		const size_t				dataSize		= static_cast<size_t>(m_vertexColor.size() * sizeof(m_vertexColor[0]));
708e5c31af7Sopenharmony_ci		const VkDeviceSize			bufferDataSize	= static_cast<VkDeviceSize>(deAlignSize(dataSize, nonCoherentAtomSize));
709e5c31af7Sopenharmony_ci		const VkBufferCreateInfo	bufferInfo		= makeBufferCreateInfo(bufferDataSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
710e5c31af7Sopenharmony_ci
711e5c31af7Sopenharmony_ci		m_vertexColorBuffer	= createBuffer(*m_device, *m_logicalDevice, &bufferInfo);
712e5c31af7Sopenharmony_ci		m_vertexColorAlloc	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *m_vertexColorBuffer), MemoryRequirement::HostVisible);
713e5c31af7Sopenharmony_ci
714e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *m_vertexColorBuffer, m_vertexColorAlloc->getMemory(), m_vertexColorAlloc->getOffset()));
715e5c31af7Sopenharmony_ci		deMemcpy(m_vertexColorAlloc->getHostPtr(), m_vertexColor.data(), static_cast<size_t>(dataSize));
716e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *m_vertexColorAlloc);
717e5c31af7Sopenharmony_ci	}
718e5c31af7Sopenharmony_ci
719e5c31af7Sopenharmony_ci	// Upload vertex indices
720e5c31af7Sopenharmony_ci	if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED || m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
721e5c31af7Sopenharmony_ci	{
722e5c31af7Sopenharmony_ci		const size_t				dataSize		= static_cast<size_t>(m_vertexIndices.size() * sizeof(m_vertexIndices[0]));
723e5c31af7Sopenharmony_ci		const VkDeviceSize			bufferDataSize	= static_cast<VkDeviceSize>(deAlignSize(dataSize, nonCoherentAtomSize));
724e5c31af7Sopenharmony_ci		const VkBufferCreateInfo	bufferInfo		= makeBufferCreateInfo(bufferDataSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
725e5c31af7Sopenharmony_ci
726e5c31af7Sopenharmony_ci		DE_ASSERT(m_vertexIndices.size() == m_vertexCoord.size());
727e5c31af7Sopenharmony_ci
728e5c31af7Sopenharmony_ci		m_vertexIndicesBuffer		= createBuffer(*m_device, *m_logicalDevice, &bufferInfo);
729e5c31af7Sopenharmony_ci		m_vertexIndicesAllocation	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *m_vertexIndicesBuffer), MemoryRequirement::HostVisible);
730e5c31af7Sopenharmony_ci
731e5c31af7Sopenharmony_ci		// Init host buffer data
732e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *m_vertexIndicesBuffer, m_vertexIndicesAllocation->getMemory(), m_vertexIndicesAllocation->getOffset()));
733e5c31af7Sopenharmony_ci		deMemcpy(m_vertexIndicesAllocation->getHostPtr(), m_vertexIndices.data(), static_cast<size_t>(dataSize));
734e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *m_vertexIndicesAllocation);
735e5c31af7Sopenharmony_ci	}
736e5c31af7Sopenharmony_ci	else
737e5c31af7Sopenharmony_ci		DE_ASSERT(m_vertexIndices.empty());
738e5c31af7Sopenharmony_ci}
739e5c31af7Sopenharmony_ci
740e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::createMultiViewDevices (void)
741e5c31af7Sopenharmony_ci{
742e5c31af7Sopenharmony_ci	const auto&								instanceDriver			= m_context.getInstanceInterface();
743e5c31af7Sopenharmony_ci	const VkPhysicalDevice					physicalDevice			= m_context.getPhysicalDevice();
744e5c31af7Sopenharmony_ci	const vector<VkQueueFamilyProperties>	queueFamilyProperties	= getPhysicalDeviceQueueFamilyProperties(instanceDriver, physicalDevice);
745e5c31af7Sopenharmony_ci
746e5c31af7Sopenharmony_ci	for (; m_queueFamilyIndex < queueFamilyProperties.size(); ++m_queueFamilyIndex)
747e5c31af7Sopenharmony_ci	{
748e5c31af7Sopenharmony_ci		if ((queueFamilyProperties[m_queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0)
749e5c31af7Sopenharmony_ci			break;
750e5c31af7Sopenharmony_ci	}
751e5c31af7Sopenharmony_ci
752e5c31af7Sopenharmony_ci	const float								queuePriorities			= 1.0f;
753e5c31af7Sopenharmony_ci	const VkDeviceQueueCreateInfo			queueInfo				=
754e5c31af7Sopenharmony_ci	{
755e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,					//VkStructureType			sType;
756e5c31af7Sopenharmony_ci		DE_NULL,													//const void*				pNext;
757e5c31af7Sopenharmony_ci		(VkDeviceQueueCreateFlags)0u,								//VkDeviceQueueCreateFlags	flags;
758e5c31af7Sopenharmony_ci		m_queueFamilyIndex,											//deUint32					queueFamilyIndex;
759e5c31af7Sopenharmony_ci		1u,															//deUint32					queueCount;
760e5c31af7Sopenharmony_ci		&queuePriorities											//const float*				pQueuePriorities;
761e5c31af7Sopenharmony_ci	};
762e5c31af7Sopenharmony_ci
763e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
764e5c31af7Sopenharmony_ci	VkPhysicalDeviceDynamicRenderingFeatures dynamicRenderingFeatures	=
765e5c31af7Sopenharmony_ci	{
766e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES,	// VkStructureType			sType;
767e5c31af7Sopenharmony_ci		DE_NULL,														// void*					pNext;
768e5c31af7Sopenharmony_ci		DE_FALSE,														// VkBool32					dynamicRendering
769e5c31af7Sopenharmony_ci	};
770e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
771e5c31af7Sopenharmony_ci
772e5c31af7Sopenharmony_ci	VkPhysicalDeviceMultiviewFeatures		multiviewFeatures		=
773e5c31af7Sopenharmony_ci	{
774e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES,		// VkStructureType			sType;
775e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
776e5c31af7Sopenharmony_ci		&dynamicRenderingFeatures,									// void*					pNext;
777e5c31af7Sopenharmony_ci#else
778e5c31af7Sopenharmony_ci		DE_NULL,													// void*					pNext;
779e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
780e5c31af7Sopenharmony_ci		DE_FALSE,													// VkBool32					multiview;
781e5c31af7Sopenharmony_ci		DE_FALSE,													// VkBool32					multiviewGeometryShader;
782e5c31af7Sopenharmony_ci		DE_FALSE,													// VkBool32					multiviewTessellationShader;
783e5c31af7Sopenharmony_ci	};
784e5c31af7Sopenharmony_ci
785e5c31af7Sopenharmony_ci	VkPhysicalDeviceFeatures2				enabledFeatures;
786e5c31af7Sopenharmony_ci	enabledFeatures.sType					= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
787e5c31af7Sopenharmony_ci	enabledFeatures.pNext					= &multiviewFeatures;
788e5c31af7Sopenharmony_ci
789e5c31af7Sopenharmony_ci	instanceDriver.getPhysicalDeviceFeatures2(physicalDevice, &enabledFeatures);
790e5c31af7Sopenharmony_ci
791e5c31af7Sopenharmony_ci	if (!multiviewFeatures.multiview)
792e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "MultiView not supported");
793e5c31af7Sopenharmony_ci
794e5c31af7Sopenharmony_ci	if (m_parameters.geometryShaderNeeded() && !multiviewFeatures.multiviewGeometryShader)
795e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Geometry shader is not supported");
796e5c31af7Sopenharmony_ci
797e5c31af7Sopenharmony_ci	if (TEST_TYPE_VIEW_INDEX_IN_TESELLATION == m_parameters.viewIndex && !multiviewFeatures.multiviewTessellationShader)
798e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Tessellation shader is not supported");
799e5c31af7Sopenharmony_ci
800e5c31af7Sopenharmony_ci	VkPhysicalDeviceMultiviewProperties	multiviewProperties			=
801e5c31af7Sopenharmony_ci	{
802e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,		//VkStructureType	sType;
803e5c31af7Sopenharmony_ci		DE_NULL,													//void*				pNext;
804e5c31af7Sopenharmony_ci		0u,															//deUint32			maxMultiviewViewCount;
805e5c31af7Sopenharmony_ci		0u															//deUint32			maxMultiviewInstanceIndex;
806e5c31af7Sopenharmony_ci	};
807e5c31af7Sopenharmony_ci
808e5c31af7Sopenharmony_ci	VkPhysicalDeviceProperties2			propertiesDeviceProperties2;
809e5c31af7Sopenharmony_ci	propertiesDeviceProperties2.sType	= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
810e5c31af7Sopenharmony_ci	propertiesDeviceProperties2.pNext	= &multiviewProperties;
811e5c31af7Sopenharmony_ci
812e5c31af7Sopenharmony_ci	instanceDriver.getPhysicalDeviceProperties2(physicalDevice, &propertiesDeviceProperties2);
813e5c31af7Sopenharmony_ci
814e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
815e5c31af7Sopenharmony_ci	if (multiviewProperties.maxMultiviewViewCount < 6u)
816e5c31af7Sopenharmony_ci		TCU_FAIL("maxMultiviewViewCount below min value");
817e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
818e5c31af7Sopenharmony_ci
819e5c31af7Sopenharmony_ci	if (multiviewProperties.maxMultiviewInstanceIndex < 134217727u) //134217727u = 2^27 -1
820e5c31af7Sopenharmony_ci		TCU_FAIL("maxMultiviewInstanceIndex below min value");
821e5c31af7Sopenharmony_ci
822e5c31af7Sopenharmony_ci	if (multiviewProperties.maxMultiviewViewCount <m_parameters.extent.depth)
823e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Limit MaxMultiviewViewCount to small to run this test");
824e5c31af7Sopenharmony_ci
825e5c31af7Sopenharmony_ci	m_hasMultiDrawIndirect = enabledFeatures.features.multiDrawIndirect;
826e5c31af7Sopenharmony_ci
827e5c31af7Sopenharmony_ci	{
828e5c31af7Sopenharmony_ci		vector<const char*>				deviceExtensions;
829e5c31af7Sopenharmony_ci
830e5c31af7Sopenharmony_ci		if (!isCoreDeviceExtension(m_context.getUsedApiVersion(), "VK_KHR_multiview"))
831e5c31af7Sopenharmony_ci			deviceExtensions.push_back("VK_KHR_multiview");
832e5c31af7Sopenharmony_ci
833e5c31af7Sopenharmony_ci		if ((m_parameters.renderingType == RENDERING_TYPE_RENDERPASS2) &&
834e5c31af7Sopenharmony_ci			!isCoreDeviceExtension(m_context.getUsedApiVersion(), "VK_KHR_create_renderpass2"))
835e5c31af7Sopenharmony_ci			deviceExtensions.push_back("VK_KHR_create_renderpass2");
836e5c31af7Sopenharmony_ci		if ((m_parameters.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) &&
837e5c31af7Sopenharmony_ci			!isCoreDeviceExtension(m_context.getUsedApiVersion(), "VK_KHR_dynamic_rendering"))
838e5c31af7Sopenharmony_ci			deviceExtensions.push_back("VK_KHR_dynamic_rendering");
839e5c31af7Sopenharmony_ci
840e5c31af7Sopenharmony_ci		if (m_parameters.viewIndex == TEST_TYPE_DEPTH_DIFFERENT_RANGES)
841e5c31af7Sopenharmony_ci			deviceExtensions.push_back("VK_EXT_depth_range_unrestricted");
842e5c31af7Sopenharmony_ci
843e5c31af7Sopenharmony_ci		void* pNext												= &enabledFeatures;
844e5c31af7Sopenharmony_ci#ifdef CTS_USES_VULKANSC
845e5c31af7Sopenharmony_ci		VkDeviceObjectReservationCreateInfo memReservationInfo	= m_context.getTestContext().getCommandLine().isSubProcess() ? m_context.getResourceInterface()->getStatMax() : resetDeviceObjectReservationCreateInfo();
846e5c31af7Sopenharmony_ci		memReservationInfo.pNext								= pNext;
847e5c31af7Sopenharmony_ci		pNext													= &memReservationInfo;
848e5c31af7Sopenharmony_ci
849e5c31af7Sopenharmony_ci		VkPhysicalDeviceVulkanSC10Features sc10Features			= createDefaultSC10Features();
850e5c31af7Sopenharmony_ci		sc10Features.pNext										= pNext;
851e5c31af7Sopenharmony_ci		pNext													= &sc10Features;
852e5c31af7Sopenharmony_ci
853e5c31af7Sopenharmony_ci		VkPipelineCacheCreateInfo			pcCI;
854e5c31af7Sopenharmony_ci		std::vector<VkPipelinePoolSize>		poolSizes;
855e5c31af7Sopenharmony_ci		if (m_context.getTestContext().getCommandLine().isSubProcess())
856e5c31af7Sopenharmony_ci		{
857e5c31af7Sopenharmony_ci			if (m_context.getResourceInterface()->getCacheDataSize() > 0)
858e5c31af7Sopenharmony_ci			{
859e5c31af7Sopenharmony_ci				pcCI =
860e5c31af7Sopenharmony_ci				{
861e5c31af7Sopenharmony_ci					VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,			// VkStructureType				sType;
862e5c31af7Sopenharmony_ci					DE_NULL,												// const void*					pNext;
863e5c31af7Sopenharmony_ci					VK_PIPELINE_CACHE_CREATE_READ_ONLY_BIT |
864e5c31af7Sopenharmony_ci						VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT,	// VkPipelineCacheCreateFlags	flags;
865e5c31af7Sopenharmony_ci					m_context.getResourceInterface()->getCacheDataSize(),	// deUintptr					initialDataSize;
866e5c31af7Sopenharmony_ci					m_context.getResourceInterface()->getCacheData()		// const void*					pInitialData;
867e5c31af7Sopenharmony_ci				};
868e5c31af7Sopenharmony_ci				memReservationInfo.pipelineCacheCreateInfoCount		= 1;
869e5c31af7Sopenharmony_ci				memReservationInfo.pPipelineCacheCreateInfos		= &pcCI;
870e5c31af7Sopenharmony_ci			}
871e5c31af7Sopenharmony_ci
872e5c31af7Sopenharmony_ci			poolSizes							= m_context.getResourceInterface()->getPipelinePoolSizes();
873e5c31af7Sopenharmony_ci			if (!poolSizes.empty())
874e5c31af7Sopenharmony_ci			{
875e5c31af7Sopenharmony_ci				memReservationInfo.pipelinePoolSizeCount		= deUint32(poolSizes.size());
876e5c31af7Sopenharmony_ci				memReservationInfo.pPipelinePoolSizes			= poolSizes.data();
877e5c31af7Sopenharmony_ci			}
878e5c31af7Sopenharmony_ci		}
879e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
880e5c31af7Sopenharmony_ci
881e5c31af7Sopenharmony_ci		const VkDeviceCreateInfo		deviceInfo			=
882e5c31af7Sopenharmony_ci		{
883e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,							//VkStructureType					sType;
884e5c31af7Sopenharmony_ci			pNext,															//const void*						pNext;
885e5c31af7Sopenharmony_ci			0u,																//VkDeviceCreateFlags				flags;
886e5c31af7Sopenharmony_ci			1u,																//deUint32							queueCreateInfoCount;
887e5c31af7Sopenharmony_ci			&queueInfo,														//const VkDeviceQueueCreateInfo*	pQueueCreateInfos;
888e5c31af7Sopenharmony_ci			0u,																//deUint32							enabledLayerCount;
889e5c31af7Sopenharmony_ci			DE_NULL,														//const char* const*				ppEnabledLayerNames;
890e5c31af7Sopenharmony_ci			static_cast<deUint32>(deviceExtensions.size()),					//deUint32							enabledExtensionCount;
891e5c31af7Sopenharmony_ci			deviceExtensions.empty() ? DE_NULL : &deviceExtensions[0],		//const char* const*				pEnabledExtensionNames;
892e5c31af7Sopenharmony_ci			DE_NULL															//const VkPhysicalDeviceFeatures*	pEnabledFeatures;
893e5c31af7Sopenharmony_ci		};
894e5c31af7Sopenharmony_ci
895e5c31af7Sopenharmony_ci		const auto instance = m_context.getInstance();
896e5c31af7Sopenharmony_ci
897e5c31af7Sopenharmony_ci		m_logicalDevice					= createCustomDevice(m_context.getTestContext().getCommandLine().isValidationEnabled(), m_context.getPlatformInterface(), instance, instanceDriver, physicalDevice, &deviceInfo);
898e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
899e5c31af7Sopenharmony_ci		m_device						= de::MovePtr<DeviceDriver>(new DeviceDriver(m_context.getPlatformInterface(), instance, *m_logicalDevice, m_context.getUsedApiVersion()));
900e5c31af7Sopenharmony_ci#else
901e5c31af7Sopenharmony_ci		m_device						= de::MovePtr<DeviceDriverSC, DeinitDeviceDeleter>(new DeviceDriverSC(m_context.getPlatformInterface(), instance, *m_logicalDevice, m_context.getTestContext().getCommandLine(), m_context.getResourceInterface(), m_context.getDeviceVulkanSC10Properties(), m_context.getDeviceProperties(), m_context.getUsedApiVersion()), vk::DeinitDeviceDeleter(m_context.getResourceInterface().get(), *m_logicalDevice));
902e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
903e5c31af7Sopenharmony_ci		m_allocator						= MovePtr<Allocator>(new SimpleAllocator(*m_device, *m_logicalDevice, getPhysicalDeviceMemoryProperties(instanceDriver, physicalDevice)));
904e5c31af7Sopenharmony_ci		m_device->getDeviceQueue		(*m_logicalDevice, m_queueFamilyIndex, 0u, &m_queue);
905e5c31af7Sopenharmony_ci	}
906e5c31af7Sopenharmony_ci}
907e5c31af7Sopenharmony_ci
908e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::createCommandBuffer (void)
909e5c31af7Sopenharmony_ci{
910e5c31af7Sopenharmony_ci	// cmdPool
911e5c31af7Sopenharmony_ci	{
912e5c31af7Sopenharmony_ci		const VkCommandPoolCreateInfo cmdPoolParams =
913e5c31af7Sopenharmony_ci		{
914e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,			// VkStructureType		sType;
915e5c31af7Sopenharmony_ci			DE_NULL,											// const void*			pNext;
916e5c31af7Sopenharmony_ci			VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,	// VkCmdPoolCreateFlags	flags;
917e5c31af7Sopenharmony_ci			m_queueFamilyIndex,									// deUint32				queueFamilyIndex;
918e5c31af7Sopenharmony_ci		};
919e5c31af7Sopenharmony_ci		m_cmdPool = createCommandPool(*m_device, *m_logicalDevice, &cmdPoolParams);
920e5c31af7Sopenharmony_ci	}
921e5c31af7Sopenharmony_ci
922e5c31af7Sopenharmony_ci	// cmdBuffer
923e5c31af7Sopenharmony_ci	{
924e5c31af7Sopenharmony_ci		const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
925e5c31af7Sopenharmony_ci		{
926e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,		// VkStructureType		sType;
927e5c31af7Sopenharmony_ci			DE_NULL,											// const void*			pNext;
928e5c31af7Sopenharmony_ci			*m_cmdPool,											// VkCommandPool		commandPool;
929e5c31af7Sopenharmony_ci			VK_COMMAND_BUFFER_LEVEL_PRIMARY,					// VkCommandBufferLevel	level;
930e5c31af7Sopenharmony_ci			1u,													// deUint32				bufferCount;
931e5c31af7Sopenharmony_ci		};
932e5c31af7Sopenharmony_ci		m_cmdBuffer	= allocateCommandBuffer(*m_device, *m_logicalDevice, &cmdBufferAllocateInfo);
933e5c31af7Sopenharmony_ci	}
934e5c31af7Sopenharmony_ci}
935e5c31af7Sopenharmony_ci
936e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::createSecondaryCommandPool(void)
937e5c31af7Sopenharmony_ci{
938e5c31af7Sopenharmony_ci	// cmdPool
939e5c31af7Sopenharmony_ci	{
940e5c31af7Sopenharmony_ci		const VkCommandPoolCreateInfo cmdPoolParams =
941e5c31af7Sopenharmony_ci		{
942e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,			// VkStructureType		sType;
943e5c31af7Sopenharmony_ci			DE_NULL,											// const void*			pNext;
944e5c31af7Sopenharmony_ci			VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,	// VkCmdPoolCreateFlags	flags;
945e5c31af7Sopenharmony_ci			m_queueFamilyIndex,									// deUint32				queueFamilyIndex;
946e5c31af7Sopenharmony_ci		};
947e5c31af7Sopenharmony_ci		m_cmdPoolSecondary = createCommandPool(*m_device, *m_logicalDevice, &cmdPoolParams);
948e5c31af7Sopenharmony_ci	}
949e5c31af7Sopenharmony_ci}
950e5c31af7Sopenharmony_ci
951e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::madeShaderModule (map<VkShaderStageFlagBits, ShaderModuleSP>& shaderModule, vector<VkPipelineShaderStageCreateInfo>& shaderStageParams)
952e5c31af7Sopenharmony_ci{
953e5c31af7Sopenharmony_ci	// create shaders modules
954e5c31af7Sopenharmony_ci	switch (m_parameters.viewIndex)
955e5c31af7Sopenharmony_ci	{
956e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_MASK:
957e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_VERTEX:
958e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_FRAGMENT:
959e5c31af7Sopenharmony_ci		case TEST_TYPE_INSTANCED_RENDERING:
960e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_RATE_INSTANCE:
961e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDIRECT:
962e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDIRECT_INDEXED:
963e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDEXED:
964e5c31af7Sopenharmony_ci		case TEST_TYPE_CLEAR_ATTACHMENTS:
965e5c31af7Sopenharmony_ci		case TEST_TYPE_SECONDARY_CMD_BUFFER:
966e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_ATTACHMENTS:
967e5c31af7Sopenharmony_ci		case TEST_TYPE_POINT_SIZE:
968e5c31af7Sopenharmony_ci		case TEST_TYPE_MULTISAMPLE:
969e5c31af7Sopenharmony_ci		case TEST_TYPE_QUERIES:
970e5c31af7Sopenharmony_ci		case TEST_TYPE_NON_PRECISE_QUERIES:
971e5c31af7Sopenharmony_ci		case TEST_TYPE_NON_PRECISE_QUERIES_WITH_AVAILABILITY:
972e5c31af7Sopenharmony_ci		case TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR:
973e5c31af7Sopenharmony_ci		case TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR:
974e5c31af7Sopenharmony_ci		case TEST_TYPE_DEPTH:
975e5c31af7Sopenharmony_ci		case TEST_TYPE_DEPTH_DIFFERENT_RANGES:
976e5c31af7Sopenharmony_ci		case TEST_TYPE_STENCIL:
977e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_VERTEX_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("vertex"), 0))));
978e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_FRAGMENT_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("fragment"), 0))));
979e5c31af7Sopenharmony_ci			break;
980e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_GEOMETRY:
981e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY:
982e5c31af7Sopenharmony_ci		case TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY:
983e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_VERTEX_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("vertex"), 0))));
984e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_GEOMETRY_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("geometry"), 0))));
985e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_FRAGMENT_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("fragment"), 0))));
986e5c31af7Sopenharmony_ci			break;
987e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_TESELLATION:
988e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_VERTEX_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("vertex"), 0))));
989e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT]		= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("tessellation_control"), 0))));
990e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT]	= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("tessellation_evaluation"), 0))));
991e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_FRAGMENT_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("fragment"), 0))));
992e5c31af7Sopenharmony_ci			break;
993e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_MASK_ITERATION:
994e5c31af7Sopenharmony_ci		{
995e5c31af7Sopenharmony_ci			const auto	vk12Support	= m_context.contextSupports(vk::ApiVersion(0u, 1u, 2u, 0u));
996e5c31af7Sopenharmony_ci			const auto	vertShaderName = vk12Support ? "vert-spv15" : "vert-spv10";
997e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_VERTEX_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get(vertShaderName), 0))));
998e5c31af7Sopenharmony_ci			shaderModule[VK_SHADER_STAGE_FRAGMENT_BIT]					= (ShaderModuleSP(new Unique<VkShaderModule>(createShaderModule(*m_device, *m_logicalDevice, m_context.getBinaryCollection().get("view_mask_iteration"), 0))));
999e5c31af7Sopenharmony_ci			break;
1000e5c31af7Sopenharmony_ci		}
1001e5c31af7Sopenharmony_ci		default:
1002e5c31af7Sopenharmony_ci			DE_ASSERT(0);
1003e5c31af7Sopenharmony_ci		break;
1004e5c31af7Sopenharmony_ci	}
1005e5c31af7Sopenharmony_ci
1006e5c31af7Sopenharmony_ci	VkPipelineShaderStageCreateInfo	pipelineShaderStage	=
1007e5c31af7Sopenharmony_ci	{
1008e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType						sType;
1009e5c31af7Sopenharmony_ci			DE_NULL,												// const void*							pNext;
1010e5c31af7Sopenharmony_ci			(VkPipelineShaderStageCreateFlags)0,					// VkPipelineShaderStageCreateFlags		flags;
1011e5c31af7Sopenharmony_ci			(VkShaderStageFlagBits)0,								// VkShaderStageFlagBits				stage;
1012e5c31af7Sopenharmony_ci			(VkShaderModule)0,										// VkShaderModule						module;
1013e5c31af7Sopenharmony_ci			"main",													// const char*							pName;
1014e5c31af7Sopenharmony_ci			(const VkSpecializationInfo*)DE_NULL,					// const VkSpecializationInfo*			pSpecializationInfo;
1015e5c31af7Sopenharmony_ci	};
1016e5c31af7Sopenharmony_ci
1017e5c31af7Sopenharmony_ci	for (map<VkShaderStageFlagBits, ShaderModuleSP>::iterator it=shaderModule.begin(); it!=shaderModule.end(); ++it)
1018e5c31af7Sopenharmony_ci	{
1019e5c31af7Sopenharmony_ci		pipelineShaderStage.stage	= it->first;
1020e5c31af7Sopenharmony_ci		pipelineShaderStage.module	= **it->second;
1021e5c31af7Sopenharmony_ci		shaderStageParams.push_back(pipelineShaderStage);
1022e5c31af7Sopenharmony_ci	}
1023e5c31af7Sopenharmony_ci}
1024e5c31af7Sopenharmony_ci
1025e5c31af7Sopenharmony_ciMove<VkPipeline> MultiViewRenderTestInstance::makeGraphicsPipeline (const VkRenderPass							renderPass,
1026e5c31af7Sopenharmony_ci																	const VkPipelineLayout						pipelineLayout,
1027e5c31af7Sopenharmony_ci																	const deUint32								pipelineShaderStageCount,
1028e5c31af7Sopenharmony_ci																	const VkPipelineShaderStageCreateInfo*		pipelineShaderStageCreate,
1029e5c31af7Sopenharmony_ci																	const deUint32								subpass,
1030e5c31af7Sopenharmony_ci																	const VkVertexInputRate						vertexInputRate,
1031e5c31af7Sopenharmony_ci																	const bool									useDepthTest,
1032e5c31af7Sopenharmony_ci																	const bool									useStencilTest,
1033e5c31af7Sopenharmony_ci																	const float									minDepth,
1034e5c31af7Sopenharmony_ci																	const float									maxDepth,
1035e5c31af7Sopenharmony_ci																	const VkFormat								dsFormat)
1036e5c31af7Sopenharmony_ci{
1037e5c31af7Sopenharmony_ci	const VkVertexInputBindingDescription			vertexInputBindingDescriptions[]	=
1038e5c31af7Sopenharmony_ci	{
1039e5c31af7Sopenharmony_ci		{
1040e5c31af7Sopenharmony_ci			0u,													// binding;
1041e5c31af7Sopenharmony_ci			static_cast<deUint32>(sizeof(m_vertexCoord[0])),	// stride;
1042e5c31af7Sopenharmony_ci			vertexInputRate										// inputRate
1043e5c31af7Sopenharmony_ci		},
1044e5c31af7Sopenharmony_ci		{
1045e5c31af7Sopenharmony_ci			1u,													// binding;
1046e5c31af7Sopenharmony_ci			static_cast<deUint32>(sizeof(m_vertexColor[0])),	// stride;
1047e5c31af7Sopenharmony_ci			vertexInputRate										// inputRate
1048e5c31af7Sopenharmony_ci		}
1049e5c31af7Sopenharmony_ci	};
1050e5c31af7Sopenharmony_ci
1051e5c31af7Sopenharmony_ci	const VkVertexInputAttributeDescription			vertexInputAttributeDescriptions[]	=
1052e5c31af7Sopenharmony_ci	{
1053e5c31af7Sopenharmony_ci		{
1054e5c31af7Sopenharmony_ci			0u,											// deUint32	location;
1055e5c31af7Sopenharmony_ci			0u,											// deUint32	binding;
1056e5c31af7Sopenharmony_ci			VK_FORMAT_R32G32B32A32_SFLOAT,				// VkFormat	format;
1057e5c31af7Sopenharmony_ci			0u											// deUint32	offset;
1058e5c31af7Sopenharmony_ci		},	// VertexElementData::position
1059e5c31af7Sopenharmony_ci		{
1060e5c31af7Sopenharmony_ci			1u,											// deUint32	location;
1061e5c31af7Sopenharmony_ci			1u,											// deUint32	binding;
1062e5c31af7Sopenharmony_ci			VK_FORMAT_R32G32B32A32_SFLOAT,				// VkFormat	format;
1063e5c31af7Sopenharmony_ci			0u											// deUint32	offset;
1064e5c31af7Sopenharmony_ci		},	// VertexElementData::color
1065e5c31af7Sopenharmony_ci	};
1066e5c31af7Sopenharmony_ci
1067e5c31af7Sopenharmony_ci	const VkPipelineVertexInputStateCreateInfo		vertexInputStateParams				=
1068e5c31af7Sopenharmony_ci	{
1069e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,		// VkStructureType							sType;
1070e5c31af7Sopenharmony_ci		NULL,															// const void*								pNext;
1071e5c31af7Sopenharmony_ci		0u,																// VkPipelineVertexInputStateCreateFlags	flags;
1072e5c31af7Sopenharmony_ci		DE_LENGTH_OF_ARRAY(vertexInputBindingDescriptions),				// deUint32									vertexBindingDescriptionCount;
1073e5c31af7Sopenharmony_ci		vertexInputBindingDescriptions,									// const VkVertexInputBindingDescription*	pVertexBindingDescriptions;
1074e5c31af7Sopenharmony_ci		DE_LENGTH_OF_ARRAY(vertexInputAttributeDescriptions),			// deUint32									vertexAttributeDescriptionCount;
1075e5c31af7Sopenharmony_ci		vertexInputAttributeDescriptions								// const VkVertexInputAttributeDescription*	pVertexAttributeDescriptions;
1076e5c31af7Sopenharmony_ci	};
1077e5c31af7Sopenharmony_ci
1078e5c31af7Sopenharmony_ci	const VkPrimitiveTopology						topology							= (TEST_TYPE_VIEW_INDEX_IN_TESELLATION == m_parameters.viewIndex) ? VK_PRIMITIVE_TOPOLOGY_PATCH_LIST :
1079e5c31af7Sopenharmony_ci																						  (TEST_TYPE_POINT_SIZE == m_parameters.viewIndex) ? VK_PRIMITIVE_TOPOLOGY_POINT_LIST :
1080e5c31af7Sopenharmony_ci																						  VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
1081e5c31af7Sopenharmony_ci
1082e5c31af7Sopenharmony_ci	const VkPipelineInputAssemblyStateCreateInfo	inputAssemblyStateParams			=
1083e5c31af7Sopenharmony_ci	{
1084e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType							sType;
1085e5c31af7Sopenharmony_ci		DE_NULL,														// const void*								pNext;
1086e5c31af7Sopenharmony_ci		0u,																// VkPipelineInputAssemblyStateCreateFlags	flags;
1087e5c31af7Sopenharmony_ci		topology,														// VkPrimitiveTopology						topology;
1088e5c31af7Sopenharmony_ci		VK_FALSE,														// VkBool32									primitiveRestartEnable;
1089e5c31af7Sopenharmony_ci	};
1090e5c31af7Sopenharmony_ci
1091e5c31af7Sopenharmony_ci	const VkViewport	viewport	= makeViewport(0.0f, 0.0f, (float)m_parameters.extent.width, (float)m_parameters.extent.height, minDepth, maxDepth);
1092e5c31af7Sopenharmony_ci	const VkRect2D		scissor		= makeRect2D(m_parameters.extent);
1093e5c31af7Sopenharmony_ci
1094e5c31af7Sopenharmony_ci	const VkPipelineViewportStateCreateInfo			viewportStateParams					=
1095e5c31af7Sopenharmony_ci	{
1096e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,	// VkStructureType						sType;
1097e5c31af7Sopenharmony_ci		DE_NULL,												// const void*							pNext;
1098e5c31af7Sopenharmony_ci		0u,														// VkPipelineViewportStateCreateFlags	flags;
1099e5c31af7Sopenharmony_ci		1u,														// deUint32								viewportCount;
1100e5c31af7Sopenharmony_ci		&viewport,												// const VkViewport*					pViewports;
1101e5c31af7Sopenharmony_ci		1u,														// deUint32								scissorCount;
1102e5c31af7Sopenharmony_ci		&scissor												// const VkRect2D*						pScissors;
1103e5c31af7Sopenharmony_ci	};
1104e5c31af7Sopenharmony_ci
1105e5c31af7Sopenharmony_ci	const VkPipelineRasterizationStateCreateInfo	rasterStateParams					=
1106e5c31af7Sopenharmony_ci	{
1107e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,	// VkStructureType							sType;
1108e5c31af7Sopenharmony_ci		DE_NULL,													// const void*								pNext;
1109e5c31af7Sopenharmony_ci		0u,															// VkPipelineRasterizationStateCreateFlags	flags;
1110e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									depthClampEnable;
1111e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									rasterizerDiscardEnable;
1112e5c31af7Sopenharmony_ci		VK_POLYGON_MODE_FILL,										// VkPolygonMode							polygonMode;
1113e5c31af7Sopenharmony_ci		VK_CULL_MODE_NONE,											// VkCullModeFlags							cullMode;
1114e5c31af7Sopenharmony_ci		VK_FRONT_FACE_COUNTER_CLOCKWISE,							// VkFrontFace								frontFace;
1115e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									depthBiasEnable;
1116e5c31af7Sopenharmony_ci		0.0f,														// float									depthBiasConstantFactor;
1117e5c31af7Sopenharmony_ci		0.0f,														// float									depthBiasClamp;
1118e5c31af7Sopenharmony_ci		0.0f,														// float									depthBiasSlopeFactor;
1119e5c31af7Sopenharmony_ci		1.0f,														// float									lineWidth;
1120e5c31af7Sopenharmony_ci	};
1121e5c31af7Sopenharmony_ci
1122e5c31af7Sopenharmony_ci	const VkSampleCountFlagBits						sampleCountFlagBits					= (TEST_TYPE_MULTISAMPLE == m_parameters.viewIndex) ? VK_SAMPLE_COUNT_4_BIT :
1123e5c31af7Sopenharmony_ci																						  VK_SAMPLE_COUNT_1_BIT;
1124e5c31af7Sopenharmony_ci	const VkPipelineMultisampleStateCreateInfo		multisampleStateParams				=
1125e5c31af7Sopenharmony_ci	{
1126e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,	// VkStructureType							sType;
1127e5c31af7Sopenharmony_ci		DE_NULL,													// const void*								pNext;
1128e5c31af7Sopenharmony_ci		0u,															// VkPipelineMultisampleStateCreateFlags	flags;
1129e5c31af7Sopenharmony_ci		sampleCountFlagBits,										// VkSampleCountFlagBits					rasterizationSamples;
1130e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									sampleShadingEnable;
1131e5c31af7Sopenharmony_ci		0.0f,														// float									minSampleShading;
1132e5c31af7Sopenharmony_ci		DE_NULL,													// const VkSampleMask*						pSampleMask;
1133e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									alphaToCoverageEnable;
1134e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									alphaToOneEnable;
1135e5c31af7Sopenharmony_ci	};
1136e5c31af7Sopenharmony_ci
1137e5c31af7Sopenharmony_ci	VkPipelineDepthStencilStateCreateInfo			depthStencilStateParams				=
1138e5c31af7Sopenharmony_ci	{
1139e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,	// VkStructureType							sType;
1140e5c31af7Sopenharmony_ci		DE_NULL,													// const void*								pNext;
1141e5c31af7Sopenharmony_ci		0u,															// VkPipelineDepthStencilStateCreateFlags	flags;
1142e5c31af7Sopenharmony_ci		useDepthTest ? VK_TRUE : VK_FALSE,							// VkBool32									depthTestEnable;
1143e5c31af7Sopenharmony_ci		useDepthTest ? VK_TRUE : VK_FALSE,							// VkBool32									depthWriteEnable;
1144e5c31af7Sopenharmony_ci		VK_COMPARE_OP_LESS_OR_EQUAL,								// VkCompareOp								depthCompareOp;
1145e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32									depthBoundsTestEnable;
1146e5c31af7Sopenharmony_ci		useStencilTest ? VK_TRUE : VK_FALSE,						// VkBool32									stencilTestEnable;
1147e5c31af7Sopenharmony_ci		// VkStencilOpState front;
1148e5c31af7Sopenharmony_ci		{
1149e5c31af7Sopenharmony_ci			VK_STENCIL_OP_KEEP,					// VkStencilOp	failOp;
1150e5c31af7Sopenharmony_ci			VK_STENCIL_OP_INCREMENT_AND_CLAMP,	// VkStencilOp	passOp;
1151e5c31af7Sopenharmony_ci			VK_STENCIL_OP_KEEP,					// VkStencilOp	depthFailOp;
1152e5c31af7Sopenharmony_ci			VK_COMPARE_OP_ALWAYS,				// VkCompareOp	compareOp;
1153e5c31af7Sopenharmony_ci			~0u,								// deUint32		compareMask;
1154e5c31af7Sopenharmony_ci			~0u,								// deUint32		writeMask;
1155e5c31af7Sopenharmony_ci			0u,									// deUint32		reference;
1156e5c31af7Sopenharmony_ci		},
1157e5c31af7Sopenharmony_ci		// VkStencilOpState back;
1158e5c31af7Sopenharmony_ci		{
1159e5c31af7Sopenharmony_ci			VK_STENCIL_OP_KEEP,					// VkStencilOp	failOp;
1160e5c31af7Sopenharmony_ci			VK_STENCIL_OP_INCREMENT_AND_CLAMP,	// VkStencilOp	passOp;
1161e5c31af7Sopenharmony_ci			VK_STENCIL_OP_KEEP,					// VkStencilOp	depthFailOp;
1162e5c31af7Sopenharmony_ci			VK_COMPARE_OP_ALWAYS,				// VkCompareOp	compareOp;
1163e5c31af7Sopenharmony_ci			~0u,								// deUint32		compareMask;
1164e5c31af7Sopenharmony_ci			~0u,								// deUint32		writeMask;
1165e5c31af7Sopenharmony_ci			0u,									// deUint32		reference;
1166e5c31af7Sopenharmony_ci		},
1167e5c31af7Sopenharmony_ci		0.0f,	// float	minDepthBounds;
1168e5c31af7Sopenharmony_ci		1.0f,	// float	maxDepthBounds;
1169e5c31af7Sopenharmony_ci	};
1170e5c31af7Sopenharmony_ci
1171e5c31af7Sopenharmony_ci	const VkPipelineColorBlendAttachmentState		colorBlendAttachmentState			=
1172e5c31af7Sopenharmony_ci	{
1173e5c31af7Sopenharmony_ci		VK_FALSE,								// VkBool32					blendEnable;
1174e5c31af7Sopenharmony_ci		VK_BLEND_FACTOR_SRC_ALPHA,				// VkBlendFactor			srcColorBlendFactor;
1175e5c31af7Sopenharmony_ci		VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,	// VkBlendFactor			dstColorBlendFactor;
1176e5c31af7Sopenharmony_ci		VK_BLEND_OP_ADD,						// VkBlendOp				colorBlendOp;
1177e5c31af7Sopenharmony_ci		VK_BLEND_FACTOR_ONE,					// VkBlendFactor			srcAlphaBlendFactor;
1178e5c31af7Sopenharmony_ci		VK_BLEND_FACTOR_ONE,					// VkBlendFactor			dstAlphaBlendFactor;
1179e5c31af7Sopenharmony_ci		VK_BLEND_OP_ADD,						// VkBlendOp				alphaBlendOp;
1180e5c31af7Sopenharmony_ci		VK_COLOR_COMPONENT_R_BIT |				// VkColorComponentFlags	colorWriteMask;
1181e5c31af7Sopenharmony_ci		VK_COLOR_COMPONENT_G_BIT |
1182e5c31af7Sopenharmony_ci		VK_COLOR_COMPONENT_B_BIT |
1183e5c31af7Sopenharmony_ci		VK_COLOR_COMPONENT_A_BIT
1184e5c31af7Sopenharmony_ci	};
1185e5c31af7Sopenharmony_ci
1186e5c31af7Sopenharmony_ci	const VkPipelineColorBlendStateCreateInfo		colorBlendStateParams				=
1187e5c31af7Sopenharmony_ci	{
1188e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	// VkStructureType								sType;
1189e5c31af7Sopenharmony_ci		DE_NULL,													// const void*									pNext;
1190e5c31af7Sopenharmony_ci		0u,															// VkPipelineColorBlendStateCreateFlags			flags;
1191e5c31af7Sopenharmony_ci		VK_FALSE,													// VkBool32										logicOpEnable;
1192e5c31af7Sopenharmony_ci		VK_LOGIC_OP_COPY,											// VkLogicOp									logicOp;
1193e5c31af7Sopenharmony_ci		1u,															// deUint32										attachmentCount;
1194e5c31af7Sopenharmony_ci		&colorBlendAttachmentState,									// const VkPipelineColorBlendAttachmentState*	pAttachments;
1195e5c31af7Sopenharmony_ci		{ 0.0f, 0.0f, 0.0f, 0.0f },									// float										blendConst[4];
1196e5c31af7Sopenharmony_ci	};
1197e5c31af7Sopenharmony_ci
1198e5c31af7Sopenharmony_ci	VkPipelineTessellationStateCreateInfo			TessellationState					=
1199e5c31af7Sopenharmony_ci	{
1200e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,	// VkStructureType							sType;
1201e5c31af7Sopenharmony_ci		DE_NULL,													// const void*								pNext;
1202e5c31af7Sopenharmony_ci		(VkPipelineTessellationStateCreateFlags)0,					// VkPipelineTessellationStateCreateFlags	flags;
1203e5c31af7Sopenharmony_ci		4u															// deUint32									patchControlPoints;
1204e5c31af7Sopenharmony_ci	};
1205e5c31af7Sopenharmony_ci
1206e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
1207e5c31af7Sopenharmony_ci	VkPipelineRenderingCreateInfoKHR				renderingCreateInfo
1208e5c31af7Sopenharmony_ci	{
1209e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
1210e5c31af7Sopenharmony_ci		DE_NULL,
1211e5c31af7Sopenharmony_ci		m_parameters.viewMasks[subpass],
1212e5c31af7Sopenharmony_ci		1u,
1213e5c31af7Sopenharmony_ci		&m_parameters.colorFormat,
1214e5c31af7Sopenharmony_ci		dsFormat,
1215e5c31af7Sopenharmony_ci		dsFormat
1216e5c31af7Sopenharmony_ci	};
1217e5c31af7Sopenharmony_ci#else
1218e5c31af7Sopenharmony_ci	DE_UNREF(dsFormat);
1219e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
1220e5c31af7Sopenharmony_ci
1221e5c31af7Sopenharmony_ci	const VkGraphicsPipelineCreateInfo				graphicsPipelineParams
1222e5c31af7Sopenharmony_ci	{
1223e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,												// VkStructureType									sType;
1224e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
1225e5c31af7Sopenharmony_ci		(renderPass == 0) ? &renderingCreateInfo : DE_NULL,												// const void*										pNext;
1226e5c31af7Sopenharmony_ci#else
1227e5c31af7Sopenharmony_ci		DE_NULL,																						// const void*										pNext;
1228e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
1229e5c31af7Sopenharmony_ci		(VkPipelineCreateFlags)0u,																		// VkPipelineCreateFlags							flags;
1230e5c31af7Sopenharmony_ci		pipelineShaderStageCount,																		// deUint32											stageCount;
1231e5c31af7Sopenharmony_ci		pipelineShaderStageCreate,																		// const VkPipelineShaderStageCreateInfo*			pStages;
1232e5c31af7Sopenharmony_ci		&vertexInputStateParams,																		// const VkPipelineVertexInputStateCreateInfo*		pVertexInputState;
1233e5c31af7Sopenharmony_ci		&inputAssemblyStateParams,																		// const VkPipelineInputAssemblyStateCreateInfo*	pInputAssemblyState;
1234e5c31af7Sopenharmony_ci		(TEST_TYPE_VIEW_INDEX_IN_TESELLATION == m_parameters.viewIndex)? &TessellationState : DE_NULL,	// const VkPipelineTessellationStateCreateInfo*		pTessellationState;
1235e5c31af7Sopenharmony_ci		&viewportStateParams,																			// const VkPipelineViewportStateCreateInfo*			pViewportState;
1236e5c31af7Sopenharmony_ci		&rasterStateParams,																				// const VkPipelineRasterizationStateCreateInfo*	pRasterState;
1237e5c31af7Sopenharmony_ci		&multisampleStateParams,																		// const VkPipelineMultisampleStateCreateInfo*		pMultisampleState;
1238e5c31af7Sopenharmony_ci		&depthStencilStateParams,																		// const VkPipelineDepthStencilStateCreateInfo*		pDepthStencilState;
1239e5c31af7Sopenharmony_ci		&colorBlendStateParams,																			// const VkPipelineColorBlendStateCreateInfo*		pColorBlendState;
1240e5c31af7Sopenharmony_ci		(const VkPipelineDynamicStateCreateInfo*)DE_NULL,												// const VkPipelineDynamicStateCreateInfo*			pDynamicState;
1241e5c31af7Sopenharmony_ci		pipelineLayout,																					// VkPipelineLayout									layout;
1242e5c31af7Sopenharmony_ci		renderPass,																						// VkRenderPass										renderPass;
1243e5c31af7Sopenharmony_ci		subpass,																						// deUint32											subpass;
1244e5c31af7Sopenharmony_ci		0u,																								// VkPipeline										basePipelineHandle;
1245e5c31af7Sopenharmony_ci		0,																								// deInt32											basePipelineIndex;
1246e5c31af7Sopenharmony_ci	};
1247e5c31af7Sopenharmony_ci
1248e5c31af7Sopenharmony_ci	return createGraphicsPipeline(*m_device, *m_logicalDevice, DE_NULL, &graphicsPipelineParams);
1249e5c31af7Sopenharmony_ci}
1250e5c31af7Sopenharmony_ci
1251e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::readImage (VkImage image, const tcu::PixelBufferAccess& dst)
1252e5c31af7Sopenharmony_ci{
1253e5c31af7Sopenharmony_ci	Move<VkBuffer>				buffer;
1254e5c31af7Sopenharmony_ci	MovePtr<Allocation>			bufferAlloc;
1255e5c31af7Sopenharmony_ci	const VkDeviceSize			pixelDataSize	= dst.getWidth() * dst.getHeight() * dst.getDepth() * mapVkFormat(m_parameters.colorFormat).getPixelSize();
1256e5c31af7Sopenharmony_ci
1257e5c31af7Sopenharmony_ci	// Create destination buffer
1258e5c31af7Sopenharmony_ci	{
1259e5c31af7Sopenharmony_ci		const VkBufferCreateInfo bufferParams	=
1260e5c31af7Sopenharmony_ci		{
1261e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,	// VkStructureType		sType;
1262e5c31af7Sopenharmony_ci			DE_NULL,								// const void*			pNext;
1263e5c31af7Sopenharmony_ci			0u,										// VkBufferCreateFlags	flags;
1264e5c31af7Sopenharmony_ci			pixelDataSize,							// VkDeviceSize			size;
1265e5c31af7Sopenharmony_ci			VK_BUFFER_USAGE_TRANSFER_DST_BIT,		// VkBufferUsageFlags	usage;
1266e5c31af7Sopenharmony_ci			VK_SHARING_MODE_EXCLUSIVE,				// VkSharingMode		sharingMode;
1267e5c31af7Sopenharmony_ci			1u,										// deUint32				queueFamilyIndexCount;
1268e5c31af7Sopenharmony_ci			&m_queueFamilyIndex,					// const deUint32*		pQueueFamilyIndices;
1269e5c31af7Sopenharmony_ci		};
1270e5c31af7Sopenharmony_ci
1271e5c31af7Sopenharmony_ci		buffer		= createBuffer(*m_device, *m_logicalDevice, &bufferParams);
1272e5c31af7Sopenharmony_ci		bufferAlloc	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *buffer), MemoryRequirement::HostVisible);
1273e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
1274e5c31af7Sopenharmony_ci
1275e5c31af7Sopenharmony_ci		deMemset(bufferAlloc->getHostPtr(), 0, static_cast<size_t>(pixelDataSize));
1276e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *bufferAlloc);
1277e5c31af7Sopenharmony_ci	}
1278e5c31af7Sopenharmony_ci
1279e5c31af7Sopenharmony_ci	const VkBufferMemoryBarrier	bufferBarrier	=
1280e5c31af7Sopenharmony_ci	{
1281e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,	// VkStructureType	sType;
1282e5c31af7Sopenharmony_ci		DE_NULL,									// const void*		pNext;
1283e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT,				// VkAccessFlags	srcAccessMask;
1284e5c31af7Sopenharmony_ci		VK_ACCESS_HOST_READ_BIT,					// VkAccessFlags	dstAccessMask;
1285e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,					// deUint32			srcQueueFamilyIndex;
1286e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,					// deUint32			dstQueueFamilyIndex;
1287e5c31af7Sopenharmony_ci		*buffer,									// VkBuffer			buffer;
1288e5c31af7Sopenharmony_ci		0u,											// VkDeviceSize		offset;
1289e5c31af7Sopenharmony_ci		pixelDataSize								// VkDeviceSize		size;
1290e5c31af7Sopenharmony_ci	};
1291e5c31af7Sopenharmony_ci
1292e5c31af7Sopenharmony_ci	// Copy image to buffer
1293e5c31af7Sopenharmony_ci	const VkImageAspectFlags	aspect			= getAspectFlags(dst.getFormat());
1294e5c31af7Sopenharmony_ci	const VkBufferImageCopy		copyRegion		=
1295e5c31af7Sopenharmony_ci	{
1296e5c31af7Sopenharmony_ci		0u,										// VkDeviceSize				bufferOffset;
1297e5c31af7Sopenharmony_ci		(deUint32)dst.getWidth(),				// deUint32					bufferRowLength;
1298e5c31af7Sopenharmony_ci		(deUint32)dst.getHeight(),				// deUint32					bufferImageHeight;
1299e5c31af7Sopenharmony_ci		{
1300e5c31af7Sopenharmony_ci			aspect,								// VkImageAspectFlags		aspect;
1301e5c31af7Sopenharmony_ci			0u,									// deUint32					mipLevel;
1302e5c31af7Sopenharmony_ci			0u,									// deUint32					baseArrayLayer;
1303e5c31af7Sopenharmony_ci			m_parameters.extent.depth,			// deUint32					layerCount;
1304e5c31af7Sopenharmony_ci		},										// VkImageSubresourceLayers	imageSubresource;
1305e5c31af7Sopenharmony_ci		{ 0, 0, 0 },							// VkOffset3D				imageOffset;
1306e5c31af7Sopenharmony_ci		{ m_parameters.extent.width, m_parameters.extent.height, 1u }	// VkExtent3D				imageExtent;
1307e5c31af7Sopenharmony_ci	};
1308e5c31af7Sopenharmony_ci
1309e5c31af7Sopenharmony_ci	beginCommandBuffer (*m_device, *m_cmdBuffer);
1310e5c31af7Sopenharmony_ci	{
1311e5c31af7Sopenharmony_ci		VkImageSubresourceRange	subresourceRange	=
1312e5c31af7Sopenharmony_ci		{
1313e5c31af7Sopenharmony_ci			aspect,						// VkImageAspectFlags	aspectMask;
1314e5c31af7Sopenharmony_ci			0u,							// deUint32				baseMipLevel;
1315e5c31af7Sopenharmony_ci			1u,							// deUint32				mipLevels;
1316e5c31af7Sopenharmony_ci			0u,							// deUint32				baseArraySlice;
1317e5c31af7Sopenharmony_ci			m_parameters.extent.depth,	// deUint32				arraySize;
1318e5c31af7Sopenharmony_ci		};
1319e5c31af7Sopenharmony_ci
1320e5c31af7Sopenharmony_ci		imageBarrier (*m_device, *m_cmdBuffer, image, subresourceRange,
1321e5c31af7Sopenharmony_ci			VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1322e5c31af7Sopenharmony_ci			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT,
1323e5c31af7Sopenharmony_ci			VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1324e5c31af7Sopenharmony_ci
1325e5c31af7Sopenharmony_ci		m_device->cmdCopyImageToBuffer(*m_cmdBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, &copyRegion);
1326e5c31af7Sopenharmony_ci		m_device->cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0u, DE_NULL);
1327e5c31af7Sopenharmony_ci	}
1328e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
1329e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
1330e5c31af7Sopenharmony_ci
1331e5c31af7Sopenharmony_ci	// Read buffer data
1332e5c31af7Sopenharmony_ci	invalidateAlloc(*m_device, *m_logicalDevice, *bufferAlloc);
1333e5c31af7Sopenharmony_ci	tcu::copy(dst, tcu::ConstPixelBufferAccess(dst.getFormat(), dst.getSize(), bufferAlloc->getHostPtr()));
1334e5c31af7Sopenharmony_ci}
1335e5c31af7Sopenharmony_ci
1336e5c31af7Sopenharmony_cibool MultiViewRenderTestInstance::checkImage (tcu::ConstPixelBufferAccess& renderedFrame)
1337e5c31af7Sopenharmony_ci{
1338e5c31af7Sopenharmony_ci	const MovePtr<tcu::Texture2DArray>	referenceFrame	= imageData();
1339e5c31af7Sopenharmony_ci	const bool							result			= tcu::floatThresholdCompare(m_context.getTestContext().getLog(),
1340e5c31af7Sopenharmony_ci															"Result", "Image comparison result", referenceFrame->getLevel(0), renderedFrame, tcu::Vec4(0.01f), tcu::COMPARE_LOG_EVERYTHING);
1341e5c31af7Sopenharmony_ci
1342e5c31af7Sopenharmony_ci	if (!result)
1343e5c31af7Sopenharmony_ci		for (deUint32 layerNdx = 0u; layerNdx < m_parameters.extent.depth; layerNdx++)
1344e5c31af7Sopenharmony_ci		{
1345e5c31af7Sopenharmony_ci			tcu::ConstPixelBufferAccess ref (mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, 1u, referenceFrame->getLevel(0).getPixelPtr(0, 0, layerNdx));
1346e5c31af7Sopenharmony_ci			tcu::ConstPixelBufferAccess dst (mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, 1u, renderedFrame.getPixelPtr(0 ,0, layerNdx));
1347e5c31af7Sopenharmony_ci			tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Result", "Image comparison result", ref, dst, tcu::Vec4(0.01f), tcu::COMPARE_LOG_EVERYTHING);
1348e5c31af7Sopenharmony_ci		}
1349e5c31af7Sopenharmony_ci
1350e5c31af7Sopenharmony_ci	return result;
1351e5c31af7Sopenharmony_ci}
1352e5c31af7Sopenharmony_ci
1353e5c31af7Sopenharmony_ciconst tcu::Vec4 MultiViewRenderTestInstance::getQuarterRefColor (const deUint32 quarterNdx, const int colorNdx, const int layerNdx, const bool background, const deUint32 subpassNdx) const
1354e5c31af7Sopenharmony_ci{
1355e5c31af7Sopenharmony_ci	// this function is used for genrating same colors while rendering and while creating reference
1356e5c31af7Sopenharmony_ci
1357e5c31af7Sopenharmony_ci	switch (m_parameters.viewIndex)
1358e5c31af7Sopenharmony_ci	{
1359e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_MASK:
1360e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_MASK_ITERATION:
1361e5c31af7Sopenharmony_ci			return m_vertexColor[colorNdx];
1362e5c31af7Sopenharmony_ci
1363e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDEXED:
1364e5c31af7Sopenharmony_ci			return m_vertexColor[m_vertexIndices[colorNdx]];
1365e5c31af7Sopenharmony_ci
1366e5c31af7Sopenharmony_ci		case TEST_TYPE_INSTANCED_RENDERING:
1367e5c31af7Sopenharmony_ci			return m_vertexColor[0] + tcu::Vec4(0.0, static_cast<float>(layerNdx) * 0.10f, static_cast<float>(quarterNdx + 1u) * 0.10f, 0.0);
1368e5c31af7Sopenharmony_ci
1369e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_RATE_INSTANCE:
1370e5c31af7Sopenharmony_ci			return m_vertexColor[colorNdx / 4] + tcu::Vec4(0.0, static_cast<float>(layerNdx) * 0.10f, static_cast<float>(quarterNdx + 1u) * 0.10f, 0.0);
1371e5c31af7Sopenharmony_ci
1372e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDIRECT_INDEXED:
1373e5c31af7Sopenharmony_ci			return m_vertexColor[m_vertexIndices[colorNdx]] + tcu::Vec4(0.0, static_cast<float>(layerNdx) * 0.10f, 0.0, 0.0);
1374e5c31af7Sopenharmony_ci
1375e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_VERTEX:
1376e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_FRAGMENT:
1377e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_GEOMETRY:
1378e5c31af7Sopenharmony_ci		case TEST_TYPE_VIEW_INDEX_IN_TESELLATION:
1379e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_ATTACHMENTS:
1380e5c31af7Sopenharmony_ci		case TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY:
1381e5c31af7Sopenharmony_ci		case TEST_TYPE_DRAW_INDIRECT:
1382e5c31af7Sopenharmony_ci		case TEST_TYPE_CLEAR_ATTACHMENTS:
1383e5c31af7Sopenharmony_ci		case TEST_TYPE_SECONDARY_CMD_BUFFER:
1384e5c31af7Sopenharmony_ci		case TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY:
1385e5c31af7Sopenharmony_ci			return m_vertexColor[colorNdx] + tcu::Vec4(0.0, static_cast<float>(layerNdx) * 0.10f, 0.0, 0.0);
1386e5c31af7Sopenharmony_ci
1387e5c31af7Sopenharmony_ci		case TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR:
1388e5c31af7Sopenharmony_ci			if (background)
1389e5c31af7Sopenharmony_ci				return m_colorTable[4 + quarterNdx % 4];
1390e5c31af7Sopenharmony_ci			else
1391e5c31af7Sopenharmony_ci				return m_colorTable[layerNdx % 4];
1392e5c31af7Sopenharmony_ci
1393e5c31af7Sopenharmony_ci		case TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR:
1394e5c31af7Sopenharmony_ci			if (background)
1395e5c31af7Sopenharmony_ci				return m_colorTable[4 + quarterNdx % 4];
1396e5c31af7Sopenharmony_ci			else
1397e5c31af7Sopenharmony_ci				return m_colorTable[0];
1398e5c31af7Sopenharmony_ci
1399e5c31af7Sopenharmony_ci		case TEST_TYPE_POINT_SIZE:
1400e5c31af7Sopenharmony_ci		case TEST_TYPE_MULTISAMPLE:
1401e5c31af7Sopenharmony_ci			if (background)
1402e5c31af7Sopenharmony_ci				return tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f);
1403e5c31af7Sopenharmony_ci			else
1404e5c31af7Sopenharmony_ci				return m_vertexColor[colorNdx];
1405e5c31af7Sopenharmony_ci
1406e5c31af7Sopenharmony_ci		case TEST_TYPE_DEPTH:
1407e5c31af7Sopenharmony_ci			if (background)
1408e5c31af7Sopenharmony_ci				if (subpassNdx < 4)
1409e5c31af7Sopenharmony_ci					return tcu::Vec4(0.66f, 0.0f, 0.0f, 1.0f);
1410e5c31af7Sopenharmony_ci				else
1411e5c31af7Sopenharmony_ci					return tcu::Vec4(0.33f, 0.0f, 0.0f, 1.0f);
1412e5c31af7Sopenharmony_ci			else
1413e5c31af7Sopenharmony_ci				return tcu::Vec4(0.99f, 0.0f, 0.0f, 1.0f);
1414e5c31af7Sopenharmony_ci
1415e5c31af7Sopenharmony_ci		case TEST_TYPE_DEPTH_DIFFERENT_RANGES:
1416e5c31af7Sopenharmony_ci			// for quads from partA generate  1.20, 0.90, 0.60,  0.30
1417e5c31af7Sopenharmony_ci			// for quads from partB generate  0.55, 0.35, 0.15, -0.05
1418e5c31af7Sopenharmony_ci			// depth ranges in views are <0;0.5>, <0;1> or <0.5;1> so
1419e5c31af7Sopenharmony_ci			// at least one quad from partA/partB will always be drawn
1420e5c31af7Sopenharmony_ci			if (subpassNdx < 4)
1421e5c31af7Sopenharmony_ci				return tcu::Vec4(1.2f - 0.3f * static_cast<float>(subpassNdx), 0.0f, 0.0f, 1.0f);
1422e5c31af7Sopenharmony_ci			return tcu::Vec4(0.55f - 0.2f * static_cast<float>(subpassNdx % 4), 0.0f, 0.0f, 1.0f);
1423e5c31af7Sopenharmony_ci
1424e5c31af7Sopenharmony_ci		case TEST_TYPE_STENCIL:
1425e5c31af7Sopenharmony_ci			if (background)
1426e5c31af7Sopenharmony_ci				return tcu::Vec4(0.33f, 0.0f, 0.0f, 0.0f); // Increment value
1427e5c31af7Sopenharmony_ci			else
1428e5c31af7Sopenharmony_ci				return tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
1429e5c31af7Sopenharmony_ci
1430e5c31af7Sopenharmony_ci		default:
1431e5c31af7Sopenharmony_ci			TCU_THROW(InternalError, "Impossible");
1432e5c31af7Sopenharmony_ci	}
1433e5c31af7Sopenharmony_ci}
1434e5c31af7Sopenharmony_ci
1435e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::setPoint (const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& pointColor, const int pointSize, const int layerNdx, const deUint32 quarter) const
1436e5c31af7Sopenharmony_ci{
1437e5c31af7Sopenharmony_ci	DE_ASSERT(TEST_POINT_SIZE_WIDE > TEST_POINT_SIZE_SMALL);
1438e5c31af7Sopenharmony_ci
1439e5c31af7Sopenharmony_ci	const int	pointOffset	= 1 + TEST_POINT_SIZE_WIDE / 2 - (pointSize + 1) / 2;
1440e5c31af7Sopenharmony_ci	const int	offsetX		= pointOffset + static_cast<int>((quarter == 0u || quarter == 1u) ? 0 : m_parameters.extent.width / 2u);
1441e5c31af7Sopenharmony_ci	const int	offsetY		= pointOffset + static_cast<int>((quarter == 0u || quarter == 2u) ? 0 : m_parameters.extent.height / 2u);
1442e5c31af7Sopenharmony_ci
1443e5c31af7Sopenharmony_ci	for (int y = 0; y < pointSize; ++y)
1444e5c31af7Sopenharmony_ci	for (int x = 0; x < pointSize; ++x)
1445e5c31af7Sopenharmony_ci		pixelBuffer.setPixel(pointColor, offsetX + x, offsetY + y, layerNdx);
1446e5c31af7Sopenharmony_ci}
1447e5c31af7Sopenharmony_ci
1448e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::fillTriangle (const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx, const deUint32 quarter) const
1449e5c31af7Sopenharmony_ci{
1450e5c31af7Sopenharmony_ci	const int		offsetX				= static_cast<int>((quarter == 0u || quarter == 1u) ? 0 : m_parameters.extent.width / 2u);
1451e5c31af7Sopenharmony_ci	const int		offsetY				= static_cast<int>((quarter == 0u || quarter == 2u) ? 0 : m_parameters.extent.height / 2u);
1452e5c31af7Sopenharmony_ci	const int		maxY				= static_cast<int>(m_parameters.extent.height / 2u);
1453e5c31af7Sopenharmony_ci	const tcu::Vec4	multisampledColor	= tcu::Vec4(color[0], color[1], color[2], color[3]) * 0.5f;
1454e5c31af7Sopenharmony_ci
1455e5c31af7Sopenharmony_ci	for (int y = 0; y < maxY; ++y)
1456e5c31af7Sopenharmony_ci	{
1457e5c31af7Sopenharmony_ci		for (int x = 0; x < y; ++x)
1458e5c31af7Sopenharmony_ci			pixelBuffer.setPixel(color, offsetX + x, offsetY + (maxY - 1) - y, layerNdx);
1459e5c31af7Sopenharmony_ci
1460e5c31af7Sopenharmony_ci		// Multisampled pixel is on the triangle margin
1461e5c31af7Sopenharmony_ci		pixelBuffer.setPixel(multisampledColor, offsetX + y, offsetY + (maxY - 1) - y, layerNdx);
1462e5c31af7Sopenharmony_ci	}
1463e5c31af7Sopenharmony_ci}
1464e5c31af7Sopenharmony_ci
1465e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::fillLayer (const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx) const
1466e5c31af7Sopenharmony_ci{
1467e5c31af7Sopenharmony_ci	for (deUint32 y = 0u; y < m_parameters.extent.height; ++y)
1468e5c31af7Sopenharmony_ci	for (deUint32 x = 0u; x < m_parameters.extent.width; ++x)
1469e5c31af7Sopenharmony_ci		pixelBuffer.setPixel(color, x, y, layerNdx);
1470e5c31af7Sopenharmony_ci}
1471e5c31af7Sopenharmony_ci
1472e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::fillQuarter (const tcu::PixelBufferAccess& pixelBuffer, const tcu::Vec4& color, const int layerNdx, const deUint32 quarter, const deUint32 subpassNdx) const
1473e5c31af7Sopenharmony_ci{
1474e5c31af7Sopenharmony_ci	const int h		= m_parameters.extent.height;
1475e5c31af7Sopenharmony_ci	const int h2	= h / 2;
1476e5c31af7Sopenharmony_ci	const int w		= m_parameters.extent.width;
1477e5c31af7Sopenharmony_ci	const int w2	= w / 2;
1478e5c31af7Sopenharmony_ci	int xStart		= 0;
1479e5c31af7Sopenharmony_ci	int xEnd		= 0;
1480e5c31af7Sopenharmony_ci	int yStart		= 0;
1481e5c31af7Sopenharmony_ci	int yEnd		= 0;
1482e5c31af7Sopenharmony_ci
1483e5c31af7Sopenharmony_ci	switch (quarter)
1484e5c31af7Sopenharmony_ci	{
1485e5c31af7Sopenharmony_ci		case 0:	xStart = 0u; xEnd = w2; yStart = 0u; yEnd = h2; break;
1486e5c31af7Sopenharmony_ci		case 1:	xStart = 0u; xEnd = w2; yStart = h2; yEnd = h;  break;
1487e5c31af7Sopenharmony_ci		case 2:	xStart = w2; xEnd = w;  yStart = 0u; yEnd = h2; break;
1488e5c31af7Sopenharmony_ci		case 3:	xStart = w2; xEnd = w;  yStart = h2; yEnd = h;  break;
1489e5c31af7Sopenharmony_ci		default: TCU_THROW(InternalError, "Impossible");
1490e5c31af7Sopenharmony_ci	}
1491e5c31af7Sopenharmony_ci
1492e5c31af7Sopenharmony_ci	if (TEST_TYPE_STENCIL == m_parameters.viewIndex ||
1493e5c31af7Sopenharmony_ci		TEST_TYPE_DEPTH == m_parameters.viewIndex ||
1494e5c31af7Sopenharmony_ci		TEST_TYPE_DEPTH_DIFFERENT_RANGES == m_parameters.viewIndex)
1495e5c31af7Sopenharmony_ci	{
1496e5c31af7Sopenharmony_ci		if (subpassNdx < 4)
1497e5c31af7Sopenharmony_ci		{	// Part A: Horizontal bars near X axis
1498e5c31af7Sopenharmony_ci			yStart	= h2 + (yStart - h2) / 2;
1499e5c31af7Sopenharmony_ci			yEnd	= h2 + (yEnd - h2) / 2;
1500e5c31af7Sopenharmony_ci		}
1501e5c31af7Sopenharmony_ci		else
1502e5c31af7Sopenharmony_ci		{	// Part B: Vertical bars near Y axis (drawn twice)
1503e5c31af7Sopenharmony_ci			xStart	= w2 + (xStart - w2) / 2;
1504e5c31af7Sopenharmony_ci			xEnd	= w2 + (xEnd - w2) / 2;
1505e5c31af7Sopenharmony_ci		}
1506e5c31af7Sopenharmony_ci
1507e5c31af7Sopenharmony_ci		// Update pixels in area
1508e5c31af7Sopenharmony_ci		if (TEST_TYPE_STENCIL == m_parameters.viewIndex)
1509e5c31af7Sopenharmony_ci		{
1510e5c31af7Sopenharmony_ci			for (int y = yStart; y < yEnd; ++y)
1511e5c31af7Sopenharmony_ci			for (int x = xStart; x < xEnd; ++x)
1512e5c31af7Sopenharmony_ci				pixelBuffer.setPixel(pixelBuffer.getPixel(x, y, layerNdx) + color, x, y, layerNdx);
1513e5c31af7Sopenharmony_ci		}
1514e5c31af7Sopenharmony_ci
1515e5c31af7Sopenharmony_ci		if (TEST_TYPE_DEPTH == m_parameters.viewIndex ||
1516e5c31af7Sopenharmony_ci			TEST_TYPE_DEPTH_DIFFERENT_RANGES == m_parameters.viewIndex)
1517e5c31af7Sopenharmony_ci		{
1518e5c31af7Sopenharmony_ci			for (int y = yStart; y < yEnd; ++y)
1519e5c31af7Sopenharmony_ci			for (int x = xStart; x < xEnd; ++x)
1520e5c31af7Sopenharmony_ci			{
1521e5c31af7Sopenharmony_ci				const tcu::Vec4		currentColor	= pixelBuffer.getPixel(x, y, layerNdx);
1522e5c31af7Sopenharmony_ci				const tcu::Vec4&	newColor		= (currentColor[0] < color[0]) ? currentColor : color;
1523e5c31af7Sopenharmony_ci
1524e5c31af7Sopenharmony_ci				pixelBuffer.setPixel(newColor, x, y, layerNdx);
1525e5c31af7Sopenharmony_ci			}
1526e5c31af7Sopenharmony_ci		}
1527e5c31af7Sopenharmony_ci	}
1528e5c31af7Sopenharmony_ci	else
1529e5c31af7Sopenharmony_ci	{
1530e5c31af7Sopenharmony_ci		for (int y = yStart; y < yEnd; ++y)
1531e5c31af7Sopenharmony_ci		for (int x = xStart; x < xEnd; ++x)
1532e5c31af7Sopenharmony_ci			pixelBuffer.setPixel(color , x, y, layerNdx);
1533e5c31af7Sopenharmony_ci	}
1534e5c31af7Sopenharmony_ci}
1535e5c31af7Sopenharmony_ci
1536e5c31af7Sopenharmony_ciMovePtr<tcu::Texture2DArray> MultiViewRenderTestInstance::imageData (void) const
1537e5c31af7Sopenharmony_ci{
1538e5c31af7Sopenharmony_ci	MovePtr<tcu::Texture2DArray>	referenceFrame	= MovePtr<tcu::Texture2DArray>(new tcu::Texture2DArray(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth));
1539e5c31af7Sopenharmony_ci	const deUint32					subpassCount	= static_cast<deUint32>(m_parameters.viewMasks.size());
1540e5c31af7Sopenharmony_ci	referenceFrame->allocLevel(0);
1541e5c31af7Sopenharmony_ci
1542e5c31af7Sopenharmony_ci	deMemset (referenceFrame->getLevel(0).getDataPtr(), 0, m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth* mapVkFormat(m_parameters.colorFormat).getPixelSize());
1543e5c31af7Sopenharmony_ci
1544e5c31af7Sopenharmony_ci	if (TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR == m_parameters.viewIndex || TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR == m_parameters.viewIndex)
1545e5c31af7Sopenharmony_ci	{
1546e5c31af7Sopenharmony_ci		deUint32	clearedViewMask	= 0;
1547e5c31af7Sopenharmony_ci
1548e5c31af7Sopenharmony_ci		// Start from last clear command color, which actually takes effect
1549e5c31af7Sopenharmony_ci		for (int subpassNdx = static_cast<int>(subpassCount) - 1; subpassNdx >= 0; --subpassNdx)
1550e5c31af7Sopenharmony_ci		{
1551e5c31af7Sopenharmony_ci			deUint32	subpassToClearViewMask	= m_parameters.viewMasks[subpassNdx] & ~clearedViewMask;
1552e5c31af7Sopenharmony_ci
1553e5c31af7Sopenharmony_ci			if (subpassToClearViewMask == 0)
1554e5c31af7Sopenharmony_ci				continue;
1555e5c31af7Sopenharmony_ci
1556e5c31af7Sopenharmony_ci			for (deUint32 layerNdx = 0; layerNdx < m_parameters.extent.depth; ++layerNdx)
1557e5c31af7Sopenharmony_ci				if ((subpassToClearViewMask & (1 << layerNdx)) != 0 && (clearedViewMask & (1 << layerNdx)) == 0)
1558e5c31af7Sopenharmony_ci					fillLayer(referenceFrame->getLevel(0), getQuarterRefColor(0u, 0u, subpassNdx, false), layerNdx);
1559e5c31af7Sopenharmony_ci
1560e5c31af7Sopenharmony_ci			// These has been cleared. Exclude these layers from upcoming attempts to clear
1561e5c31af7Sopenharmony_ci			clearedViewMask |= subpassToClearViewMask;
1562e5c31af7Sopenharmony_ci		}
1563e5c31af7Sopenharmony_ci	}
1564e5c31af7Sopenharmony_ci
1565e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
1566e5c31af7Sopenharmony_ci	{
1567e5c31af7Sopenharmony_ci		int			layerNdx	= 0;
1568e5c31af7Sopenharmony_ci		deUint32	mask		= m_parameters.viewMasks[subpassNdx];
1569e5c31af7Sopenharmony_ci
1570e5c31af7Sopenharmony_ci		// iterate over image layers
1571e5c31af7Sopenharmony_ci		while (mask > 0u)
1572e5c31af7Sopenharmony_ci		{
1573e5c31af7Sopenharmony_ci			int colorNdx	= 0;
1574e5c31af7Sopenharmony_ci
1575e5c31af7Sopenharmony_ci			if (mask & 1u)
1576e5c31af7Sopenharmony_ci			{
1577e5c31af7Sopenharmony_ci				if (TEST_TYPE_CLEAR_ATTACHMENTS == m_parameters.viewIndex)
1578e5c31af7Sopenharmony_ci				{
1579e5c31af7Sopenharmony_ci					struct ColorDataRGBA
1580e5c31af7Sopenharmony_ci					{
1581e5c31af7Sopenharmony_ci						deUint8	r;
1582e5c31af7Sopenharmony_ci						deUint8	g;
1583e5c31af7Sopenharmony_ci						deUint8	b;
1584e5c31af7Sopenharmony_ci						deUint8	a;
1585e5c31af7Sopenharmony_ci					};
1586e5c31af7Sopenharmony_ci
1587e5c31af7Sopenharmony_ci					ColorDataRGBA	clear		=
1588e5c31af7Sopenharmony_ci					{
1589e5c31af7Sopenharmony_ci						tcu::floatToU8 (1.0f),
1590e5c31af7Sopenharmony_ci						tcu::floatToU8 (0.0f),
1591e5c31af7Sopenharmony_ci						tcu::floatToU8 (0.0f),
1592e5c31af7Sopenharmony_ci						tcu::floatToU8 (1.0f)
1593e5c31af7Sopenharmony_ci					};
1594e5c31af7Sopenharmony_ci
1595e5c31af7Sopenharmony_ci					ColorDataRGBA*	dataSrc		= (ColorDataRGBA*)referenceFrame->getLevel(0).getPixelPtr(0, 0, layerNdx);
1596e5c31af7Sopenharmony_ci					ColorDataRGBA*	dataDes		= dataSrc + 1;
1597e5c31af7Sopenharmony_ci					deUint32		copySize	= 1u;
1598e5c31af7Sopenharmony_ci					deUint32		layerSize	= m_parameters.extent.width * m_parameters.extent.height - copySize;
1599e5c31af7Sopenharmony_ci					deMemcpy(dataSrc, &clear, sizeof(ColorDataRGBA));
1600e5c31af7Sopenharmony_ci
1601e5c31af7Sopenharmony_ci					while (layerSize > 0)
1602e5c31af7Sopenharmony_ci					{
1603e5c31af7Sopenharmony_ci						deMemcpy(dataDes, dataSrc, copySize * sizeof(ColorDataRGBA));
1604e5c31af7Sopenharmony_ci						dataDes = dataDes + copySize;
1605e5c31af7Sopenharmony_ci						layerSize = layerSize - copySize;
1606e5c31af7Sopenharmony_ci						copySize = 2u * copySize;
1607e5c31af7Sopenharmony_ci						if (copySize >= layerSize)
1608e5c31af7Sopenharmony_ci							copySize = layerSize;
1609e5c31af7Sopenharmony_ci					}
1610e5c31af7Sopenharmony_ci				}
1611e5c31af7Sopenharmony_ci
1612e5c31af7Sopenharmony_ci				const deUint32 subpassQuarterNdx = subpassNdx % m_squareCount;
1613e5c31af7Sopenharmony_ci				if (subpassQuarterNdx == 0u || TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
1614e5c31af7Sopenharmony_ci				{
1615e5c31af7Sopenharmony_ci					const tcu::Vec4 color = getQuarterRefColor(0u, colorNdx, layerNdx, true, subpassNdx);
1616e5c31af7Sopenharmony_ci
1617e5c31af7Sopenharmony_ci					fillQuarter(referenceFrame->getLevel(0), color, layerNdx, 0u, subpassNdx);
1618e5c31af7Sopenharmony_ci				}
1619e5c31af7Sopenharmony_ci
1620e5c31af7Sopenharmony_ci				colorNdx += 4;
1621e5c31af7Sopenharmony_ci				if (subpassQuarterNdx == 1u || subpassCount == 1u || TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
1622e5c31af7Sopenharmony_ci				{
1623e5c31af7Sopenharmony_ci					const tcu::Vec4 color = getQuarterRefColor(1u, colorNdx, layerNdx, true, subpassNdx);
1624e5c31af7Sopenharmony_ci
1625e5c31af7Sopenharmony_ci					fillQuarter(referenceFrame->getLevel(0), color, layerNdx, 1u, subpassNdx);
1626e5c31af7Sopenharmony_ci				}
1627e5c31af7Sopenharmony_ci
1628e5c31af7Sopenharmony_ci				colorNdx += 4;
1629e5c31af7Sopenharmony_ci				if (subpassQuarterNdx == 2u || subpassCount == 1u || TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
1630e5c31af7Sopenharmony_ci				{
1631e5c31af7Sopenharmony_ci					const tcu::Vec4 color = getQuarterRefColor(2u, colorNdx, layerNdx, true, subpassNdx);
1632e5c31af7Sopenharmony_ci
1633e5c31af7Sopenharmony_ci					fillQuarter(referenceFrame->getLevel(0), color, layerNdx, 2u, subpassNdx);
1634e5c31af7Sopenharmony_ci				}
1635e5c31af7Sopenharmony_ci
1636e5c31af7Sopenharmony_ci				colorNdx += 4;
1637e5c31af7Sopenharmony_ci				if (subpassQuarterNdx == 3u || subpassCount == 1u || TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
1638e5c31af7Sopenharmony_ci				{
1639e5c31af7Sopenharmony_ci					const tcu::Vec4 color = getQuarterRefColor(3u, colorNdx, layerNdx, true, subpassNdx);
1640e5c31af7Sopenharmony_ci
1641e5c31af7Sopenharmony_ci					fillQuarter(referenceFrame->getLevel(0), color, layerNdx, 3u, subpassNdx);
1642e5c31af7Sopenharmony_ci				}
1643e5c31af7Sopenharmony_ci
1644e5c31af7Sopenharmony_ci				if (TEST_TYPE_CLEAR_ATTACHMENTS == m_parameters.viewIndex)
1645e5c31af7Sopenharmony_ci				{
1646e5c31af7Sopenharmony_ci					const tcu::Vec4	color	(0.0f, 0.0f, 1.0f, 1.0f);
1647e5c31af7Sopenharmony_ci					const int		maxY	= static_cast<int>(static_cast<float>(m_parameters.extent.height) * 0.75f);
1648e5c31af7Sopenharmony_ci					const int		maxX	= static_cast<int>(static_cast<float>(m_parameters.extent.width) * 0.75f);
1649e5c31af7Sopenharmony_ci					for (int y = static_cast<int>(m_parameters.extent.height / 4u); y < maxY; ++y)
1650e5c31af7Sopenharmony_ci					for (int x = static_cast<int>(m_parameters.extent.width / 4u); x < maxX; ++x)
1651e5c31af7Sopenharmony_ci						referenceFrame->getLevel(0).setPixel(color, x, y, layerNdx);
1652e5c31af7Sopenharmony_ci				}
1653e5c31af7Sopenharmony_ci
1654e5c31af7Sopenharmony_ci				if (TEST_TYPE_POINT_SIZE == m_parameters.viewIndex)
1655e5c31af7Sopenharmony_ci				{
1656e5c31af7Sopenharmony_ci					const deUint32	vertexPerPrimitive	= 1u;
1657e5c31af7Sopenharmony_ci					const deUint32	unusedQuarterNdx	= 0u;
1658e5c31af7Sopenharmony_ci					const int		pointSize			= static_cast<int>(layerNdx == 0u ? TEST_POINT_SIZE_WIDE : TEST_POINT_SIZE_SMALL);
1659e5c31af7Sopenharmony_ci
1660e5c31af7Sopenharmony_ci					if (subpassCount == 1)
1661e5c31af7Sopenharmony_ci						for (deUint32 drawNdx = 0u; drawNdx < m_squareCount; ++drawNdx)
1662e5c31af7Sopenharmony_ci							setPoint(referenceFrame->getLevel(0), getQuarterRefColor(unusedQuarterNdx, vertexPerPrimitive * drawNdx, layerNdx, false), pointSize, layerNdx, drawNdx);
1663e5c31af7Sopenharmony_ci					else
1664e5c31af7Sopenharmony_ci						setPoint(referenceFrame->getLevel(0), getQuarterRefColor(unusedQuarterNdx, vertexPerPrimitive * subpassQuarterNdx, layerNdx, false), pointSize, layerNdx, subpassQuarterNdx);
1665e5c31af7Sopenharmony_ci				}
1666e5c31af7Sopenharmony_ci
1667e5c31af7Sopenharmony_ci				if (TEST_TYPE_MULTISAMPLE == m_parameters.viewIndex)
1668e5c31af7Sopenharmony_ci				{
1669e5c31af7Sopenharmony_ci					const deUint32	vertexPerPrimitive	= 3u;
1670e5c31af7Sopenharmony_ci					const deUint32	unusedQuarterNdx	= 0u;
1671e5c31af7Sopenharmony_ci
1672e5c31af7Sopenharmony_ci					if (subpassCount == 1)
1673e5c31af7Sopenharmony_ci						for (deUint32 drawNdx = 0u; drawNdx < m_squareCount; ++drawNdx)
1674e5c31af7Sopenharmony_ci							fillTriangle(referenceFrame->getLevel(0), getQuarterRefColor(unusedQuarterNdx, vertexPerPrimitive * drawNdx, layerNdx, false), layerNdx, drawNdx);
1675e5c31af7Sopenharmony_ci					else
1676e5c31af7Sopenharmony_ci						fillTriangle(referenceFrame->getLevel(0), getQuarterRefColor(unusedQuarterNdx, vertexPerPrimitive * subpassQuarterNdx, layerNdx, false), layerNdx, subpassQuarterNdx);
1677e5c31af7Sopenharmony_ci				}
1678e5c31af7Sopenharmony_ci			}
1679e5c31af7Sopenharmony_ci
1680e5c31af7Sopenharmony_ci			mask = mask >> 1;
1681e5c31af7Sopenharmony_ci			++layerNdx;
1682e5c31af7Sopenharmony_ci		}
1683e5c31af7Sopenharmony_ci	}
1684e5c31af7Sopenharmony_ci	return referenceFrame;
1685e5c31af7Sopenharmony_ci}
1686e5c31af7Sopenharmony_ci
1687e5c31af7Sopenharmony_civoid MultiViewRenderTestInstance::appendVertex (const tcu::Vec4& coord, const tcu::Vec4& color)
1688e5c31af7Sopenharmony_ci{
1689e5c31af7Sopenharmony_ci	m_vertexCoord.push_back(coord);
1690e5c31af7Sopenharmony_ci	m_vertexColor.push_back(color);
1691e5c31af7Sopenharmony_ci}
1692e5c31af7Sopenharmony_ci
1693e5c31af7Sopenharmony_ciclass MultiViewAttachmentsTestInstance : public MultiViewRenderTestInstance
1694e5c31af7Sopenharmony_ci{
1695e5c31af7Sopenharmony_cipublic:
1696e5c31af7Sopenharmony_ci						MultiViewAttachmentsTestInstance	(Context& context, const TestParameters& parameters);
1697e5c31af7Sopenharmony_ciprotected:
1698e5c31af7Sopenharmony_ci	tcu::TestStatus		iterate								(void) override;
1699e5c31af7Sopenharmony_ci	void				beforeRenderPass					(void) override;
1700e5c31af7Sopenharmony_ci	void				bindResources						(void) override;
1701e5c31af7Sopenharmony_ci	void				setImageData						(VkImage image);
1702e5c31af7Sopenharmony_ci	de::SharedPtr<ImageAttachment>	m_inputAttachment;
1703e5c31af7Sopenharmony_ci	Move<VkDescriptorPool>			m_descriptorPool;
1704e5c31af7Sopenharmony_ci	Move<VkDescriptorSet>			m_descriptorSet;
1705e5c31af7Sopenharmony_ci	Move<VkDescriptorSetLayout>		m_descriptorSetLayout;
1706e5c31af7Sopenharmony_ci	Move<VkPipelineLayout>			m_pipelineLayout;
1707e5c31af7Sopenharmony_ci
1708e5c31af7Sopenharmony_ci};
1709e5c31af7Sopenharmony_ci
1710e5c31af7Sopenharmony_ciMultiViewAttachmentsTestInstance::MultiViewAttachmentsTestInstance (Context& context, const TestParameters& parameters)
1711e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
1712e5c31af7Sopenharmony_ci{
1713e5c31af7Sopenharmony_ci}
1714e5c31af7Sopenharmony_ci
1715e5c31af7Sopenharmony_citcu::TestStatus MultiViewAttachmentsTestInstance::iterate (void)
1716e5c31af7Sopenharmony_ci{
1717e5c31af7Sopenharmony_ci	const deUint32								subpassCount			= static_cast<deUint32>(m_parameters.viewMasks.size());
1718e5c31af7Sopenharmony_ci	Move<VkRenderPass>							renderPass;
1719e5c31af7Sopenharmony_ci	Move<VkFramebuffer>							frameBuffer;
1720e5c31af7Sopenharmony_ci
1721e5c31af7Sopenharmony_ci	// All color attachment
1722e5c31af7Sopenharmony_ci	m_colorAttachment	= de::SharedPtr<ImageAttachment>(new ImageAttachment(*m_logicalDevice, *m_device, *m_allocator, m_parameters.extent, m_parameters.colorFormat));
1723e5c31af7Sopenharmony_ci	m_inputAttachment	= de::SharedPtr<ImageAttachment>(new ImageAttachment(*m_logicalDevice, *m_device, *m_allocator, m_parameters.extent, m_parameters.colorFormat));
1724e5c31af7Sopenharmony_ci
1725e5c31af7Sopenharmony_ci	// FrameBuffer & renderPass
1726e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
1727e5c31af7Sopenharmony_ci	{
1728e5c31af7Sopenharmony_ci		vector<VkImageView> attachments
1729e5c31af7Sopenharmony_ci		{
1730e5c31af7Sopenharmony_ci			m_colorAttachment->getImageView(),
1731e5c31af7Sopenharmony_ci			m_inputAttachment->getImageView()
1732e5c31af7Sopenharmony_ci		};
1733e5c31af7Sopenharmony_ci		renderPass	= makeRenderPassWithAttachments(*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_parameters.renderingType);
1734e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, static_cast<deUint32>(attachments.size()), attachments.data(), m_parameters.extent.width, m_parameters.extent.height);
1735e5c31af7Sopenharmony_ci	}
1736e5c31af7Sopenharmony_ci
1737e5c31af7Sopenharmony_ci	// pipelineLayout
1738e5c31af7Sopenharmony_ci	m_descriptorSetLayout	= makeDescriptorSetLayout(*m_device, *m_logicalDevice);
1739e5c31af7Sopenharmony_ci	m_pipelineLayout		= makePipelineLayout(*m_device, *m_logicalDevice, m_descriptorSetLayout.get());
1740e5c31af7Sopenharmony_ci
1741e5c31af7Sopenharmony_ci	// pipelines
1742e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
1743e5c31af7Sopenharmony_ci	vector<PipelineSp>							pipelines(subpassCount);
1744e5c31af7Sopenharmony_ci
1745e5c31af7Sopenharmony_ci	{
1746e5c31af7Sopenharmony_ci		vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
1747e5c31af7Sopenharmony_ci		madeShaderModule(shaderModule, shaderStageParams);
1748e5c31af7Sopenharmony_ci		for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
1749e5c31af7Sopenharmony_ci			pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(*renderPass, *m_pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(), subpassNdx))));
1750e5c31af7Sopenharmony_ci	}
1751e5c31af7Sopenharmony_ci
1752e5c31af7Sopenharmony_ci	createVertexData();
1753e5c31af7Sopenharmony_ci	createVertexBuffer();
1754e5c31af7Sopenharmony_ci
1755e5c31af7Sopenharmony_ci	createCommandBuffer();
1756e5c31af7Sopenharmony_ci	setImageData(m_inputAttachment->getImage());
1757e5c31af7Sopenharmony_ci	draw(subpassCount, *renderPass, *frameBuffer, pipelines);
1758e5c31af7Sopenharmony_ci
1759e5c31af7Sopenharmony_ci	{
1760e5c31af7Sopenharmony_ci		vector<deUint8>			pixelAccessData	(m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * mapVkFormat(m_parameters.colorFormat).getPixelSize());
1761e5c31af7Sopenharmony_ci		tcu::PixelBufferAccess	dst				(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth, pixelAccessData.data());
1762e5c31af7Sopenharmony_ci
1763e5c31af7Sopenharmony_ci		readImage (m_colorAttachment->getImage(), dst);
1764e5c31af7Sopenharmony_ci		if (!checkImage(dst))
1765e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
1766e5c31af7Sopenharmony_ci	}
1767e5c31af7Sopenharmony_ci
1768e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
1769e5c31af7Sopenharmony_ci}
1770e5c31af7Sopenharmony_ci
1771e5c31af7Sopenharmony_civoid MultiViewAttachmentsTestInstance::beforeRenderPass (void)
1772e5c31af7Sopenharmony_ci{
1773e5c31af7Sopenharmony_ci	const VkDescriptorPoolSize poolSize =
1774e5c31af7Sopenharmony_ci	{
1775e5c31af7Sopenharmony_ci		vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1776e5c31af7Sopenharmony_ci		1u
1777e5c31af7Sopenharmony_ci	};
1778e5c31af7Sopenharmony_ci
1779e5c31af7Sopenharmony_ci	const VkDescriptorPoolCreateInfo createInfo =
1780e5c31af7Sopenharmony_ci	{
1781e5c31af7Sopenharmony_ci		vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
1782e5c31af7Sopenharmony_ci		DE_NULL,
1783e5c31af7Sopenharmony_ci		VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
1784e5c31af7Sopenharmony_ci		1u,
1785e5c31af7Sopenharmony_ci		1u,
1786e5c31af7Sopenharmony_ci		&poolSize
1787e5c31af7Sopenharmony_ci	};
1788e5c31af7Sopenharmony_ci
1789e5c31af7Sopenharmony_ci	m_descriptorPool = createDescriptorPool(*m_device, *m_logicalDevice, &createInfo);
1790e5c31af7Sopenharmony_ci
1791e5c31af7Sopenharmony_ci	const VkDescriptorSetAllocateInfo	allocateInfo =
1792e5c31af7Sopenharmony_ci	{
1793e5c31af7Sopenharmony_ci		vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
1794e5c31af7Sopenharmony_ci		DE_NULL,
1795e5c31af7Sopenharmony_ci		*m_descriptorPool,
1796e5c31af7Sopenharmony_ci		1u,
1797e5c31af7Sopenharmony_ci		&m_descriptorSetLayout.get()
1798e5c31af7Sopenharmony_ci	};
1799e5c31af7Sopenharmony_ci
1800e5c31af7Sopenharmony_ci	m_descriptorSet	= vk::allocateDescriptorSet(*m_device, *m_logicalDevice, &allocateInfo);
1801e5c31af7Sopenharmony_ci
1802e5c31af7Sopenharmony_ci	const VkDescriptorImageInfo	imageInfo =
1803e5c31af7Sopenharmony_ci	{
1804e5c31af7Sopenharmony_ci		(VkSampler)0,
1805e5c31af7Sopenharmony_ci		m_inputAttachment->getImageView(),
1806e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_GENERAL
1807e5c31af7Sopenharmony_ci	};
1808e5c31af7Sopenharmony_ci
1809e5c31af7Sopenharmony_ci	const VkWriteDescriptorSet	write =
1810e5c31af7Sopenharmony_ci	{
1811e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,	//VkStructureType				sType;
1812e5c31af7Sopenharmony_ci		DE_NULL,								//const void*					pNext;
1813e5c31af7Sopenharmony_ci		*m_descriptorSet,						//VkDescriptorSet				dstSet;
1814e5c31af7Sopenharmony_ci		0u,										//deUint32						dstBinding;
1815e5c31af7Sopenharmony_ci		0u,										//deUint32						dstArrayElement;
1816e5c31af7Sopenharmony_ci		1u,										//deUint32						descriptorCount;
1817e5c31af7Sopenharmony_ci		VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,	//VkDescriptorType				descriptorType;
1818e5c31af7Sopenharmony_ci		&imageInfo,								//const VkDescriptorImageInfo*	pImageInfo;
1819e5c31af7Sopenharmony_ci		DE_NULL,								//const VkDescriptorBufferInfo*	pBufferInfo;
1820e5c31af7Sopenharmony_ci		DE_NULL,								//const VkBufferView*			pTexelBufferView;
1821e5c31af7Sopenharmony_ci	};
1822e5c31af7Sopenharmony_ci
1823e5c31af7Sopenharmony_ci	m_device->updateDescriptorSets(*m_logicalDevice, (deUint32)1u, &write, 0u, DE_NULL);
1824e5c31af7Sopenharmony_ci
1825e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	subresourceRange	=
1826e5c31af7Sopenharmony_ci	{
1827e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,	//VkImageAspectFlags	aspectMask;
1828e5c31af7Sopenharmony_ci		0u,							//deUint32				baseMipLevel;
1829e5c31af7Sopenharmony_ci		1u,							//deUint32				levelCount;
1830e5c31af7Sopenharmony_ci		0u,							//deUint32				baseArrayLayer;
1831e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	//deUint32				layerCount;
1832e5c31af7Sopenharmony_ci	};
1833e5c31af7Sopenharmony_ci
1834e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
1835e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1836e5c31af7Sopenharmony_ci		0, VK_ACCESS_TRANSFER_WRITE_BIT,
1837e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1838e5c31af7Sopenharmony_ci
1839e5c31af7Sopenharmony_ci	const VkClearValue renderPassClearValue = makeClearValueColor(tcu::Vec4(0.0f));
1840e5c31af7Sopenharmony_ci	m_device->cmdClearColorImage(*m_cmdBuffer, m_colorAttachment->getImage(),  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &renderPassClearValue.color, 1, &subresourceRange);
1841e5c31af7Sopenharmony_ci
1842e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
1843e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1844e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
1845e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
1846e5c31af7Sopenharmony_ci}
1847e5c31af7Sopenharmony_ci
1848e5c31af7Sopenharmony_civoid MultiViewAttachmentsTestInstance::bindResources (void)
1849e5c31af7Sopenharmony_ci{
1850e5c31af7Sopenharmony_ci	m_device->cmdBindDescriptorSets(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &(*m_descriptorSet), 0u, NULL);
1851e5c31af7Sopenharmony_ci}
1852e5c31af7Sopenharmony_ci
1853e5c31af7Sopenharmony_civoid MultiViewAttachmentsTestInstance::setImageData (VkImage image)
1854e5c31af7Sopenharmony_ci{
1855e5c31af7Sopenharmony_ci	const MovePtr<tcu::Texture2DArray>		data		= imageData();
1856e5c31af7Sopenharmony_ci	Move<VkBuffer>					buffer;
1857e5c31af7Sopenharmony_ci	const deUint32					bufferSize	= m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * tcu::getPixelSize(mapVkFormat(m_parameters.colorFormat));
1858e5c31af7Sopenharmony_ci	MovePtr<Allocation>				bufferAlloc;
1859e5c31af7Sopenharmony_ci
1860e5c31af7Sopenharmony_ci	// Create source buffer
1861e5c31af7Sopenharmony_ci	{
1862e5c31af7Sopenharmony_ci		const VkBufferCreateInfo		bufferParams			=
1863e5c31af7Sopenharmony_ci		{
1864e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,		// VkStructureType		sType;
1865e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
1866e5c31af7Sopenharmony_ci			0u,											// VkBufferCreateFlags	flags;
1867e5c31af7Sopenharmony_ci			bufferSize,									// VkDeviceSize			size;
1868e5c31af7Sopenharmony_ci			VK_BUFFER_USAGE_TRANSFER_SRC_BIT,			// VkBufferUsageFlags	usage;
1869e5c31af7Sopenharmony_ci			VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode		sharingMode;
1870e5c31af7Sopenharmony_ci			1u,											// deUint32				queueFamilyIndexCount;
1871e5c31af7Sopenharmony_ci			&m_queueFamilyIndex,						// const deUint32*		pQueueFamilyIndices;
1872e5c31af7Sopenharmony_ci		};
1873e5c31af7Sopenharmony_ci
1874e5c31af7Sopenharmony_ci		buffer		= createBuffer(*m_device, *m_logicalDevice, &bufferParams);
1875e5c31af7Sopenharmony_ci		bufferAlloc = m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *buffer), MemoryRequirement::HostVisible);
1876e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
1877e5c31af7Sopenharmony_ci	}
1878e5c31af7Sopenharmony_ci
1879e5c31af7Sopenharmony_ci	// Barriers for copying buffer to image
1880e5c31af7Sopenharmony_ci	const VkBufferMemoryBarrier				preBufferBarrier		=
1881e5c31af7Sopenharmony_ci	{
1882e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,		// VkStructureType	sType;
1883e5c31af7Sopenharmony_ci		DE_NULL,										// const void*		pNext;
1884e5c31af7Sopenharmony_ci		VK_ACCESS_HOST_WRITE_BIT,						// VkAccessFlags	srcAccessMask;
1885e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_READ_BIT,					// VkAccessFlags	dstAccessMask;
1886e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,						// deUint32			srcQueueFamilyIndex;
1887e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,						// deUint32			dstQueueFamilyIndex;
1888e5c31af7Sopenharmony_ci		*buffer,										// VkBuffer			buffer;
1889e5c31af7Sopenharmony_ci		0u,												// VkDeviceSize		offset;
1890e5c31af7Sopenharmony_ci		bufferSize										// VkDeviceSize		size;
1891e5c31af7Sopenharmony_ci	};
1892e5c31af7Sopenharmony_ci
1893e5c31af7Sopenharmony_ci	const VkImageAspectFlags				formatAspect			= getAspectFlags(mapVkFormat(m_parameters.colorFormat));
1894e5c31af7Sopenharmony_ci	VkImageSubresourceRange					subresourceRange		=
1895e5c31af7Sopenharmony_ci	{												// VkImageSubresourceRange	subresourceRange;
1896e5c31af7Sopenharmony_ci		formatAspect,				// VkImageAspectFlags	aspect;
1897e5c31af7Sopenharmony_ci		0u,							// deUint32				baseMipLevel;
1898e5c31af7Sopenharmony_ci		1u,							// deUint32				mipLevels;
1899e5c31af7Sopenharmony_ci		0u,							// deUint32				baseArraySlice;
1900e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	// deUint32				arraySize;
1901e5c31af7Sopenharmony_ci	};
1902e5c31af7Sopenharmony_ci
1903e5c31af7Sopenharmony_ci	const VkBufferImageCopy					copyRegion				=
1904e5c31af7Sopenharmony_ci	{
1905e5c31af7Sopenharmony_ci		0u,															// VkDeviceSize				bufferOffset;
1906e5c31af7Sopenharmony_ci		(deUint32)data->getLevel(0).getWidth(),						// deUint32					bufferRowLength;
1907e5c31af7Sopenharmony_ci		(deUint32)data->getLevel(0).getHeight(),					// deUint32					bufferImageHeight;
1908e5c31af7Sopenharmony_ci		{
1909e5c31af7Sopenharmony_ci			VK_IMAGE_ASPECT_COLOR_BIT,								// VkImageAspectFlags		aspect;
1910e5c31af7Sopenharmony_ci			0u,														// deUint32					mipLevel;
1911e5c31af7Sopenharmony_ci			0u,														// deUint32					baseArrayLayer;
1912e5c31af7Sopenharmony_ci			m_parameters.extent.depth,								// deUint32					layerCount;
1913e5c31af7Sopenharmony_ci		},															// VkImageSubresourceLayers	imageSubresource;
1914e5c31af7Sopenharmony_ci		{ 0, 0, 0 },												// VkOffset3D				imageOffset;
1915e5c31af7Sopenharmony_ci		{m_parameters.extent.width, m_parameters.extent.height, 1u}	// VkExtent3D				imageExtent;
1916e5c31af7Sopenharmony_ci	};
1917e5c31af7Sopenharmony_ci
1918e5c31af7Sopenharmony_ci	// Write buffer data
1919e5c31af7Sopenharmony_ci	deMemcpy(bufferAlloc->getHostPtr(), data->getLevel(0).getDataPtr(), bufferSize);
1920e5c31af7Sopenharmony_ci	flushAlloc(*m_device, *m_logicalDevice, *bufferAlloc);
1921e5c31af7Sopenharmony_ci
1922e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
1923e5c31af7Sopenharmony_ci
1924e5c31af7Sopenharmony_ci	m_device->cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &preBufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
1925e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, image, subresourceRange,
1926e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1927e5c31af7Sopenharmony_ci		0u, VK_ACCESS_TRANSFER_WRITE_BIT,
1928e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1929e5c31af7Sopenharmony_ci	m_device->cmdCopyBufferToImage(*m_cmdBuffer, *buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, &copyRegion);
1930e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, image, subresourceRange,
1931e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
1932e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
1933e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1934e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
1935e5c31af7Sopenharmony_ci
1936e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
1937e5c31af7Sopenharmony_ci}
1938e5c31af7Sopenharmony_ci
1939e5c31af7Sopenharmony_ciclass MultiViewInstancedTestInstance : public MultiViewRenderTestInstance
1940e5c31af7Sopenharmony_ci{
1941e5c31af7Sopenharmony_cipublic:
1942e5c31af7Sopenharmony_ci						MultiViewInstancedTestInstance	(Context& context, const TestParameters& parameters);
1943e5c31af7Sopenharmony_ciprotected:
1944e5c31af7Sopenharmony_ci	void				createVertexData				(void);
1945e5c31af7Sopenharmony_ci	void				draw							(const deUint32			subpassCount,
1946e5c31af7Sopenharmony_ci														 VkRenderPass			renderPass,
1947e5c31af7Sopenharmony_ci														 VkFramebuffer			frameBuffer,
1948e5c31af7Sopenharmony_ci														 vector<PipelineSp>&	pipelines);
1949e5c31af7Sopenharmony_ci};
1950e5c31af7Sopenharmony_ci
1951e5c31af7Sopenharmony_ciMultiViewInstancedTestInstance::MultiViewInstancedTestInstance (Context& context, const TestParameters& parameters)
1952e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
1953e5c31af7Sopenharmony_ci{
1954e5c31af7Sopenharmony_ci}
1955e5c31af7Sopenharmony_ci
1956e5c31af7Sopenharmony_civoid MultiViewInstancedTestInstance::createVertexData (void)
1957e5c31af7Sopenharmony_ci{
1958e5c31af7Sopenharmony_ci	const tcu::Vec4 color = tcu::Vec4(0.2f, 0.0f, 0.1f, 1.0f);
1959e5c31af7Sopenharmony_ci
1960e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), color);
1961e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), color);
1962e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), color);
1963e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
1964e5c31af7Sopenharmony_ci}
1965e5c31af7Sopenharmony_ci
1966e5c31af7Sopenharmony_civoid MultiViewInstancedTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
1967e5c31af7Sopenharmony_ci{
1968e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
1969e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
1970e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
1971e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
1972e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
1973e5c31af7Sopenharmony_ci
1974e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
1975e5c31af7Sopenharmony_ci
1976e5c31af7Sopenharmony_ci	beforeRenderPass();
1977e5c31af7Sopenharmony_ci
1978e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
1979e5c31af7Sopenharmony_ci	{
1980e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo		renderPassBeginInfo =
1981e5c31af7Sopenharmony_ci		{
1982e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
1983e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
1984e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
1985e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
1986e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
1987e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
1988e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
1989e5c31af7Sopenharmony_ci		};
1990e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
1991e5c31af7Sopenharmony_ci	}
1992e5c31af7Sopenharmony_ci
1993e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
1994e5c31af7Sopenharmony_ci	{
1995e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
1996e5c31af7Sopenharmony_ci
1997e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
1998e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
1999e5c31af7Sopenharmony_ci		{
2000e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2001e5c31af7Sopenharmony_ci
2002e5c31af7Sopenharmony_ci			beginRendering(
2003e5c31af7Sopenharmony_ci				*m_device,
2004e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2005e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2006e5c31af7Sopenharmony_ci				renderArea,
2007e5c31af7Sopenharmony_ci				renderPassClearValue,
2008e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2009e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2010e5c31af7Sopenharmony_ci				0u,
2011e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2012e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2013e5c31af7Sopenharmony_ci		}
2014e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2015e5c31af7Sopenharmony_ci
2016e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2017e5c31af7Sopenharmony_ci
2018e5c31af7Sopenharmony_ci		m_device->cmdDraw(*m_cmdBuffer, 4u, drawCountPerSubpass, 0u, subpassNdx % m_squareCount);
2019e5c31af7Sopenharmony_ci
2020e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2021e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2022e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2023e5c31af7Sopenharmony_ci		else
2024e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2025e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2026e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2027e5c31af7Sopenharmony_ci	}
2028e5c31af7Sopenharmony_ci
2029e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2030e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2031e5c31af7Sopenharmony_ci
2032e5c31af7Sopenharmony_ci	afterRenderPass();
2033e5c31af7Sopenharmony_ci
2034e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2035e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2036e5c31af7Sopenharmony_ci}
2037e5c31af7Sopenharmony_ci
2038e5c31af7Sopenharmony_ciclass MultiViewInputRateInstanceTestInstance : public MultiViewRenderTestInstance
2039e5c31af7Sopenharmony_ci{
2040e5c31af7Sopenharmony_cipublic:
2041e5c31af7Sopenharmony_ci				MultiViewInputRateInstanceTestInstance	(Context& context, const TestParameters& parameters);
2042e5c31af7Sopenharmony_ciprotected:
2043e5c31af7Sopenharmony_ci	void		createVertexData						(void);
2044e5c31af7Sopenharmony_ci
2045e5c31af7Sopenharmony_ci	void		draw									(const deUint32			subpassCount,
2046e5c31af7Sopenharmony_ci														 VkRenderPass			renderPass,
2047e5c31af7Sopenharmony_ci														 VkFramebuffer			frameBuffer,
2048e5c31af7Sopenharmony_ci														 vector<PipelineSp>&	pipelines);
2049e5c31af7Sopenharmony_ci};
2050e5c31af7Sopenharmony_ci
2051e5c31af7Sopenharmony_ciMultiViewInputRateInstanceTestInstance::MultiViewInputRateInstanceTestInstance (Context& context, const TestParameters& parameters)
2052e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2053e5c31af7Sopenharmony_ci{
2054e5c31af7Sopenharmony_ci}
2055e5c31af7Sopenharmony_ci
2056e5c31af7Sopenharmony_civoid MultiViewInputRateInstanceTestInstance::createVertexData (void)
2057e5c31af7Sopenharmony_ci{
2058e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), tcu::Vec4(0.2f, 0.0f, 0.1f, 1.0f));
2059e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.3f, 0.0f, 0.2f, 1.0f));
2060e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), tcu::Vec4(0.4f, 0.2f, 0.3f, 1.0f));
2061e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.5f, 0.0f, 0.4f, 1.0f));
2062e5c31af7Sopenharmony_ci}
2063e5c31af7Sopenharmony_ci
2064e5c31af7Sopenharmony_civoid MultiViewInputRateInstanceTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2065e5c31af7Sopenharmony_ci{
2066e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2067e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2068e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2069e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2070e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2071e5c31af7Sopenharmony_ci
2072e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2073e5c31af7Sopenharmony_ci
2074e5c31af7Sopenharmony_ci	beforeRenderPass();
2075e5c31af7Sopenharmony_ci
2076e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2077e5c31af7Sopenharmony_ci	{
2078e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo		renderPassBeginInfo =
2079e5c31af7Sopenharmony_ci		{
2080e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2081e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
2082e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
2083e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
2084e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
2085e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
2086e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
2087e5c31af7Sopenharmony_ci		};
2088e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2089e5c31af7Sopenharmony_ci	}
2090e5c31af7Sopenharmony_ci
2091e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2092e5c31af7Sopenharmony_ci	{
2093e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2094e5c31af7Sopenharmony_ci
2095e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2096e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2097e5c31af7Sopenharmony_ci		{
2098e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2099e5c31af7Sopenharmony_ci
2100e5c31af7Sopenharmony_ci			beginRendering(
2101e5c31af7Sopenharmony_ci				*m_device,
2102e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2103e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2104e5c31af7Sopenharmony_ci				renderArea,
2105e5c31af7Sopenharmony_ci				renderPassClearValue,
2106e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2107e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2108e5c31af7Sopenharmony_ci				0u,
2109e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2110e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2111e5c31af7Sopenharmony_ci		}
2112e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2113e5c31af7Sopenharmony_ci
2114e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2115e5c31af7Sopenharmony_ci
2116e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2117e5c31af7Sopenharmony_ci			m_device->cmdDraw(*m_cmdBuffer, 4u, 4u, 0u, 0u);
2118e5c31af7Sopenharmony_ci
2119e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2120e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2121e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2122e5c31af7Sopenharmony_ci		else
2123e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2124e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2125e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2126e5c31af7Sopenharmony_ci	}
2127e5c31af7Sopenharmony_ci
2128e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2129e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2130e5c31af7Sopenharmony_ci
2131e5c31af7Sopenharmony_ci	afterRenderPass();
2132e5c31af7Sopenharmony_ci
2133e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2134e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2135e5c31af7Sopenharmony_ci}
2136e5c31af7Sopenharmony_ci
2137e5c31af7Sopenharmony_ciclass MultiViewDrawIndirectTestInstance : public MultiViewRenderTestInstance
2138e5c31af7Sopenharmony_ci{
2139e5c31af7Sopenharmony_cipublic:
2140e5c31af7Sopenharmony_ci				MultiViewDrawIndirectTestInstance	(Context& context, const TestParameters& parameters);
2141e5c31af7Sopenharmony_ciprotected:
2142e5c31af7Sopenharmony_ci
2143e5c31af7Sopenharmony_ci	void		draw								(const deUint32			subpassCount,
2144e5c31af7Sopenharmony_ci													 VkRenderPass			renderPass,
2145e5c31af7Sopenharmony_ci													 VkFramebuffer			frameBuffer,
2146e5c31af7Sopenharmony_ci													 vector<PipelineSp>&	pipelines);
2147e5c31af7Sopenharmony_ci};
2148e5c31af7Sopenharmony_ci
2149e5c31af7Sopenharmony_ciMultiViewDrawIndirectTestInstance::MultiViewDrawIndirectTestInstance (Context& context, const TestParameters& parameters)
2150e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2151e5c31af7Sopenharmony_ci{
2152e5c31af7Sopenharmony_ci}
2153e5c31af7Sopenharmony_ci
2154e5c31af7Sopenharmony_civoid MultiViewDrawIndirectTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2155e5c31af7Sopenharmony_ci{
2156e5c31af7Sopenharmony_ci	typedef de::SharedPtr<Unique<VkBuffer> >		BufferSP;
2157e5c31af7Sopenharmony_ci	typedef de::SharedPtr<UniquePtr<Allocation> >	AllocationSP;
2158e5c31af7Sopenharmony_ci
2159e5c31af7Sopenharmony_ci	const size_t					nonCoherentAtomSize		= static_cast<size_t>(m_context.getDeviceProperties().limits.nonCoherentAtomSize);
2160e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2161e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2162e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2163e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2164e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2165e5c31af7Sopenharmony_ci	const deUint32					strideInBuffer			= (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2166e5c31af7Sopenharmony_ci															? static_cast<deUint32>(sizeof(vk::VkDrawIndexedIndirectCommand))
2167e5c31af7Sopenharmony_ci															: static_cast<deUint32>(sizeof(vk::VkDrawIndirectCommand));
2168e5c31af7Sopenharmony_ci	vector< BufferSP >				indirectBuffers			(subpassCount);
2169e5c31af7Sopenharmony_ci	vector< AllocationSP >			indirectAllocations		(subpassCount);
2170e5c31af7Sopenharmony_ci
2171e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2172e5c31af7Sopenharmony_ci	{
2173e5c31af7Sopenharmony_ci		vector<VkDrawIndirectCommand>			drawCommands;
2174e5c31af7Sopenharmony_ci		vector<VkDrawIndexedIndirectCommand>	drawCommandsIndexed;
2175e5c31af7Sopenharmony_ci
2176e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2177e5c31af7Sopenharmony_ci		{
2178e5c31af7Sopenharmony_ci			if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2179e5c31af7Sopenharmony_ci			{
2180e5c31af7Sopenharmony_ci				const VkDrawIndexedIndirectCommand	drawCommandIndexed	=
2181e5c31af7Sopenharmony_ci				{
2182e5c31af7Sopenharmony_ci					4u,												//  deUint32	indexCount;
2183e5c31af7Sopenharmony_ci					1u,												//  deUint32	instanceCount;
2184e5c31af7Sopenharmony_ci					(drawNdx + subpassNdx % m_squareCount) * 4u,	//  deUint32	firstIndex;
2185e5c31af7Sopenharmony_ci					0u,												//  deInt32		vertexOffset;
2186e5c31af7Sopenharmony_ci					0u,												//  deUint32	firstInstance;
2187e5c31af7Sopenharmony_ci				};
2188e5c31af7Sopenharmony_ci
2189e5c31af7Sopenharmony_ci				drawCommandsIndexed.push_back(drawCommandIndexed);
2190e5c31af7Sopenharmony_ci			}
2191e5c31af7Sopenharmony_ci			else
2192e5c31af7Sopenharmony_ci			{
2193e5c31af7Sopenharmony_ci				const VkDrawIndirectCommand	drawCommand	=
2194e5c31af7Sopenharmony_ci				{
2195e5c31af7Sopenharmony_ci					4u,												//  deUint32	vertexCount;
2196e5c31af7Sopenharmony_ci					1u,												//  deUint32	instanceCount;
2197e5c31af7Sopenharmony_ci					(drawNdx + subpassNdx % m_squareCount) * 4u,	//  deUint32	firstVertex;
2198e5c31af7Sopenharmony_ci					0u												//  deUint32	firstInstance;
2199e5c31af7Sopenharmony_ci				};
2200e5c31af7Sopenharmony_ci
2201e5c31af7Sopenharmony_ci				drawCommands.push_back(drawCommand);
2202e5c31af7Sopenharmony_ci			}
2203e5c31af7Sopenharmony_ci		}
2204e5c31af7Sopenharmony_ci
2205e5c31af7Sopenharmony_ci		const size_t				drawCommandsLength	= (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2206e5c31af7Sopenharmony_ci														? drawCommandsIndexed.size()
2207e5c31af7Sopenharmony_ci														: drawCommands.size();
2208e5c31af7Sopenharmony_ci		const void*					drawCommandsDataPtr	= (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2209e5c31af7Sopenharmony_ci														? (void*)&drawCommandsIndexed[0]
2210e5c31af7Sopenharmony_ci														: (void*)&drawCommands[0];
2211e5c31af7Sopenharmony_ci		const size_t				dataSize			= static_cast<size_t>(drawCommandsLength * strideInBuffer);
2212e5c31af7Sopenharmony_ci		const VkDeviceSize			bufferDataSize		= static_cast<VkDeviceSize>(deAlignSize(dataSize, nonCoherentAtomSize));
2213e5c31af7Sopenharmony_ci		const VkBufferCreateInfo	bufferInfo			= makeBufferCreateInfo(bufferDataSize, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT);
2214e5c31af7Sopenharmony_ci		Move<VkBuffer>				indirectBuffer		= createBuffer(*m_device, *m_logicalDevice, &bufferInfo);
2215e5c31af7Sopenharmony_ci		MovePtr<Allocation>			allocationBuffer	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *indirectBuffer),  MemoryRequirement::HostVisible);
2216e5c31af7Sopenharmony_ci
2217e5c31af7Sopenharmony_ci		DE_ASSERT(drawCommandsLength != 0);
2218e5c31af7Sopenharmony_ci
2219e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *indirectBuffer, allocationBuffer->getMemory(), allocationBuffer->getOffset()));
2220e5c31af7Sopenharmony_ci
2221e5c31af7Sopenharmony_ci		deMemcpy(allocationBuffer->getHostPtr(), drawCommandsDataPtr, static_cast<size_t>(dataSize));
2222e5c31af7Sopenharmony_ci
2223e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *allocationBuffer);
2224e5c31af7Sopenharmony_ci		indirectBuffers[subpassNdx] = (BufferSP(new Unique<VkBuffer>(indirectBuffer)));
2225e5c31af7Sopenharmony_ci		indirectAllocations[subpassNdx] = (AllocationSP(new UniquePtr<Allocation>(allocationBuffer)));
2226e5c31af7Sopenharmony_ci	}
2227e5c31af7Sopenharmony_ci
2228e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2229e5c31af7Sopenharmony_ci
2230e5c31af7Sopenharmony_ci	beforeRenderPass();
2231e5c31af7Sopenharmony_ci
2232e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2233e5c31af7Sopenharmony_ci	{
2234e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
2235e5c31af7Sopenharmony_ci		{
2236e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2237e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
2238e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
2239e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
2240e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
2241e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
2242e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
2243e5c31af7Sopenharmony_ci		};
2244e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2245e5c31af7Sopenharmony_ci	}
2246e5c31af7Sopenharmony_ci
2247e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2248e5c31af7Sopenharmony_ci	{
2249e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2250e5c31af7Sopenharmony_ci
2251e5c31af7Sopenharmony_ci		if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2252e5c31af7Sopenharmony_ci			m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
2253e5c31af7Sopenharmony_ci
2254e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2255e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2256e5c31af7Sopenharmony_ci		{
2257e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2258e5c31af7Sopenharmony_ci
2259e5c31af7Sopenharmony_ci			beginRendering(
2260e5c31af7Sopenharmony_ci				*m_device,
2261e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2262e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2263e5c31af7Sopenharmony_ci				renderArea,
2264e5c31af7Sopenharmony_ci				renderPassClearValue,
2265e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2266e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2267e5c31af7Sopenharmony_ci				0u,
2268e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2269e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2270e5c31af7Sopenharmony_ci		}
2271e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2272e5c31af7Sopenharmony_ci
2273e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2274e5c31af7Sopenharmony_ci
2275e5c31af7Sopenharmony_ci		if (m_hasMultiDrawIndirect)
2276e5c31af7Sopenharmony_ci		{
2277e5c31af7Sopenharmony_ci			if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2278e5c31af7Sopenharmony_ci				m_device->cmdDrawIndexedIndirect(*m_cmdBuffer, **indirectBuffers[subpassNdx], 0u, drawCountPerSubpass, strideInBuffer);
2279e5c31af7Sopenharmony_ci			else
2280e5c31af7Sopenharmony_ci				m_device->cmdDrawIndirect(*m_cmdBuffer, **indirectBuffers[subpassNdx], 0u, drawCountPerSubpass, strideInBuffer);
2281e5c31af7Sopenharmony_ci		}
2282e5c31af7Sopenharmony_ci		else
2283e5c31af7Sopenharmony_ci		{
2284e5c31af7Sopenharmony_ci			for (deUint32 drawNdx = 0; drawNdx < drawCountPerSubpass; drawNdx++)
2285e5c31af7Sopenharmony_ci			{
2286e5c31af7Sopenharmony_ci				if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
2287e5c31af7Sopenharmony_ci					m_device->cmdDrawIndexedIndirect(*m_cmdBuffer, **indirectBuffers[subpassNdx], drawNdx * strideInBuffer, 1, strideInBuffer);
2288e5c31af7Sopenharmony_ci				else
2289e5c31af7Sopenharmony_ci					m_device->cmdDrawIndirect(*m_cmdBuffer, **indirectBuffers[subpassNdx], drawNdx * strideInBuffer, 1, strideInBuffer);
2290e5c31af7Sopenharmony_ci			}
2291e5c31af7Sopenharmony_ci		}
2292e5c31af7Sopenharmony_ci
2293e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2294e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2295e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2296e5c31af7Sopenharmony_ci		else
2297e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2298e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2299e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2300e5c31af7Sopenharmony_ci	}
2301e5c31af7Sopenharmony_ci
2302e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2303e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2304e5c31af7Sopenharmony_ci
2305e5c31af7Sopenharmony_ci	afterRenderPass();
2306e5c31af7Sopenharmony_ci
2307e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2308e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2309e5c31af7Sopenharmony_ci}
2310e5c31af7Sopenharmony_ci
2311e5c31af7Sopenharmony_ciclass MultiViewClearAttachmentsTestInstance : public MultiViewRenderTestInstance
2312e5c31af7Sopenharmony_ci{
2313e5c31af7Sopenharmony_cipublic:
2314e5c31af7Sopenharmony_ci				MultiViewClearAttachmentsTestInstance	(Context& context, const TestParameters& parameters);
2315e5c31af7Sopenharmony_ciprotected:
2316e5c31af7Sopenharmony_ci	void		draw									(const deUint32			subpassCount,
2317e5c31af7Sopenharmony_ci														 VkRenderPass			renderPass,
2318e5c31af7Sopenharmony_ci														 VkFramebuffer			frameBuffer,
2319e5c31af7Sopenharmony_ci														 vector<PipelineSp>&	pipelines);
2320e5c31af7Sopenharmony_ci};
2321e5c31af7Sopenharmony_ci
2322e5c31af7Sopenharmony_ciMultiViewClearAttachmentsTestInstance::MultiViewClearAttachmentsTestInstance (Context& context, const TestParameters& parameters)
2323e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2324e5c31af7Sopenharmony_ci{
2325e5c31af7Sopenharmony_ci}
2326e5c31af7Sopenharmony_ci
2327e5c31af7Sopenharmony_civoid MultiViewClearAttachmentsTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2328e5c31af7Sopenharmony_ci{
2329e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2330e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2331e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2332e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2333e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2334e5c31af7Sopenharmony_ci
2335e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2336e5c31af7Sopenharmony_ci
2337e5c31af7Sopenharmony_ci	beforeRenderPass();
2338e5c31af7Sopenharmony_ci
2339e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2340e5c31af7Sopenharmony_ci	{
2341e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
2342e5c31af7Sopenharmony_ci		{
2343e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2344e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
2345e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
2346e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
2347e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
2348e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
2349e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
2350e5c31af7Sopenharmony_ci		};
2351e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2352e5c31af7Sopenharmony_ci	}
2353e5c31af7Sopenharmony_ci
2354e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2355e5c31af7Sopenharmony_ci	{
2356e5c31af7Sopenharmony_ci		VkClearAttachment	clearAttachment	=
2357e5c31af7Sopenharmony_ci		{
2358e5c31af7Sopenharmony_ci			VK_IMAGE_ASPECT_COLOR_BIT,								// VkImageAspectFlags	aspectMask
2359e5c31af7Sopenharmony_ci			0u,														// deUint32				colorAttachment
2360e5c31af7Sopenharmony_ci			makeClearValueColor(tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f))	// VkClearValue			clearValue
2361e5c31af7Sopenharmony_ci		};
2362e5c31af7Sopenharmony_ci
2363e5c31af7Sopenharmony_ci		const VkOffset2D	offset[2]		=
2364e5c31af7Sopenharmony_ci		{
2365e5c31af7Sopenharmony_ci			{0, 0},
2366e5c31af7Sopenharmony_ci			{static_cast<deInt32>(static_cast<float>(m_parameters.extent.width) * 0.25f), static_cast<deInt32>(static_cast<float>(m_parameters.extent.height) * 0.25f)}
2367e5c31af7Sopenharmony_ci		};
2368e5c31af7Sopenharmony_ci
2369e5c31af7Sopenharmony_ci		const VkExtent2D	extent[2]		=
2370e5c31af7Sopenharmony_ci		{
2371e5c31af7Sopenharmony_ci			{m_parameters.extent.width, m_parameters.extent.height},
2372e5c31af7Sopenharmony_ci			{static_cast<deUint32>(static_cast<float>(m_parameters.extent.width) * 0.5f), static_cast<deUint32>(static_cast<float>(m_parameters.extent.height) * 0.5f)}
2373e5c31af7Sopenharmony_ci		};
2374e5c31af7Sopenharmony_ci
2375e5c31af7Sopenharmony_ci		const VkRect2D		rect2D[2]		=
2376e5c31af7Sopenharmony_ci		{
2377e5c31af7Sopenharmony_ci			{offset[0], extent[0]},
2378e5c31af7Sopenharmony_ci			{offset[1], extent[1]}
2379e5c31af7Sopenharmony_ci		};
2380e5c31af7Sopenharmony_ci
2381e5c31af7Sopenharmony_ci		VkClearRect			clearRect		=
2382e5c31af7Sopenharmony_ci		{
2383e5c31af7Sopenharmony_ci			rect2D[0],	// VkRect2D	rect
2384e5c31af7Sopenharmony_ci			0u,			// deUint32	baseArrayLayer
2385e5c31af7Sopenharmony_ci			1u,			// deUint32	layerCount
2386e5c31af7Sopenharmony_ci		};
2387e5c31af7Sopenharmony_ci
2388e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2389e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2390e5c31af7Sopenharmony_ci		{
2391e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2392e5c31af7Sopenharmony_ci
2393e5c31af7Sopenharmony_ci			beginRendering(
2394e5c31af7Sopenharmony_ci				*m_device,
2395e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2396e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2397e5c31af7Sopenharmony_ci				renderArea,
2398e5c31af7Sopenharmony_ci				renderPassClearValue,
2399e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2400e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2401e5c31af7Sopenharmony_ci				0u,
2402e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2403e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2404e5c31af7Sopenharmony_ci		}
2405e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2406e5c31af7Sopenharmony_ci
2407e5c31af7Sopenharmony_ci		m_device->cmdClearAttachments(*m_cmdBuffer, 1u, &clearAttachment, 1u, &clearRect);
2408e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2409e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2410e5c31af7Sopenharmony_ci
2411e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2412e5c31af7Sopenharmony_ci			m_device->cmdDraw(*m_cmdBuffer, 4u, 1u, (drawNdx + subpassNdx % m_squareCount) * 4u, 0u);
2413e5c31af7Sopenharmony_ci
2414e5c31af7Sopenharmony_ci		clearRect.rect = rect2D[1];
2415e5c31af7Sopenharmony_ci		clearAttachment.clearValue = makeClearValueColor(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
2416e5c31af7Sopenharmony_ci		m_device->cmdClearAttachments(*m_cmdBuffer, 1u, &clearAttachment, 1u, &clearRect);
2417e5c31af7Sopenharmony_ci
2418e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2419e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2420e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2421e5c31af7Sopenharmony_ci		else
2422e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2423e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2424e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2425e5c31af7Sopenharmony_ci	}
2426e5c31af7Sopenharmony_ci
2427e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2428e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2429e5c31af7Sopenharmony_ci
2430e5c31af7Sopenharmony_ci	afterRenderPass();
2431e5c31af7Sopenharmony_ci
2432e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2433e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2434e5c31af7Sopenharmony_ci}
2435e5c31af7Sopenharmony_ci
2436e5c31af7Sopenharmony_ciclass MultiViewSecondaryCommandBufferTestInstance : public MultiViewRenderTestInstance
2437e5c31af7Sopenharmony_ci{
2438e5c31af7Sopenharmony_cipublic:
2439e5c31af7Sopenharmony_ci				MultiViewSecondaryCommandBufferTestInstance	(Context& context, const TestParameters& parameters);
2440e5c31af7Sopenharmony_ciprotected:
2441e5c31af7Sopenharmony_ci	void		draw										(const deUint32			subpassCount,
2442e5c31af7Sopenharmony_ci															 VkRenderPass			renderPass,
2443e5c31af7Sopenharmony_ci															 VkFramebuffer			frameBuffer,
2444e5c31af7Sopenharmony_ci															 vector<PipelineSp>&	pipelines);
2445e5c31af7Sopenharmony_ci};
2446e5c31af7Sopenharmony_ci
2447e5c31af7Sopenharmony_ciMultiViewSecondaryCommandBufferTestInstance::MultiViewSecondaryCommandBufferTestInstance (Context& context, const TestParameters& parameters)
2448e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2449e5c31af7Sopenharmony_ci{
2450e5c31af7Sopenharmony_ci}
2451e5c31af7Sopenharmony_ci
2452e5c31af7Sopenharmony_civoid MultiViewSecondaryCommandBufferTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2453e5c31af7Sopenharmony_ci{
2454e5c31af7Sopenharmony_ci	typedef de::SharedPtr<Unique<VkCommandBuffer> >	VkCommandBufferSp;
2455e5c31af7Sopenharmony_ci
2456e5c31af7Sopenharmony_ci	createSecondaryCommandPool();
2457e5c31af7Sopenharmony_ci
2458e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2459e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2460e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2461e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2462e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2463e5c31af7Sopenharmony_ci
2464e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2465e5c31af7Sopenharmony_ci
2466e5c31af7Sopenharmony_ci	beforeRenderPass();
2467e5c31af7Sopenharmony_ci
2468e5c31af7Sopenharmony_ci	const VkRenderPassBeginInfo renderPassBeginInfo
2469e5c31af7Sopenharmony_ci	{
2470e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2471e5c31af7Sopenharmony_ci		DE_NULL,									// const void*			pNext;
2472e5c31af7Sopenharmony_ci		renderPass,									// VkRenderPass			renderPass;
2473e5c31af7Sopenharmony_ci		frameBuffer,								// VkFramebuffer		framebuffer;
2474e5c31af7Sopenharmony_ci		renderArea,									// VkRect2D				renderArea;
2475e5c31af7Sopenharmony_ci		1u,											// uint32_t				clearValueCount;
2476e5c31af7Sopenharmony_ci		&renderPassClearValue,						// const VkClearValue*	pClearValues;
2477e5c31af7Sopenharmony_ci	};
2478e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2479e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, m_parameters.renderingType);
2480e5c31af7Sopenharmony_ci
2481e5c31af7Sopenharmony_ci	//Create secondary buffer
2482e5c31af7Sopenharmony_ci	const VkCommandBufferAllocateInfo	cmdBufferAllocateInfo	=
2483e5c31af7Sopenharmony_ci	{
2484e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,	// VkStructureType			sType;
2485e5c31af7Sopenharmony_ci		DE_NULL,										// const void*				pNext;
2486e5c31af7Sopenharmony_ci		*m_cmdPoolSecondary,							// VkCommandPool			commandPool;
2487e5c31af7Sopenharmony_ci		VK_COMMAND_BUFFER_LEVEL_SECONDARY,				// VkCommandBufferLevel		level;
2488e5c31af7Sopenharmony_ci		1u,												// deUint32					bufferCount;
2489e5c31af7Sopenharmony_ci	};
2490e5c31af7Sopenharmony_ci	vector<VkCommandBufferSp>	cmdBufferSecondary;
2491e5c31af7Sopenharmony_ci
2492e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2493e5c31af7Sopenharmony_ci	{
2494e5c31af7Sopenharmony_ci		cmdBufferSecondary.push_back(VkCommandBufferSp(new Unique<VkCommandBuffer>(allocateCommandBuffer(*m_device, *m_logicalDevice, &cmdBufferAllocateInfo))));
2495e5c31af7Sopenharmony_ci
2496e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2497e5c31af7Sopenharmony_ci		const VkCommandBufferInheritanceRenderingInfoKHR secCmdBufInheritRenderingInfo
2498e5c31af7Sopenharmony_ci		{
2499e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,	// VkStructureType							sType;
2500e5c31af7Sopenharmony_ci			DE_NULL,															// const void*								pNext;
2501e5c31af7Sopenharmony_ci			0u,																	// VkRenderingFlagsKHR						flags;
2502e5c31af7Sopenharmony_ci			m_parameters.viewMasks[subpassNdx],									// uint32_t									viewMask;
2503e5c31af7Sopenharmony_ci			1u,																	// uint32_t									colorAttachmentCount;
2504e5c31af7Sopenharmony_ci			&m_parameters.colorFormat,											// const VkFormat*							pColorAttachmentFormats;
2505e5c31af7Sopenharmony_ci			VK_FORMAT_UNDEFINED,												// VkFormat									depthAttachmentFormat;
2506e5c31af7Sopenharmony_ci			VK_FORMAT_UNDEFINED,												// VkFormat									stencilAttachmentFormat;
2507e5c31af7Sopenharmony_ci			m_parameters.samples												// VkSampleCountFlagBits					rasterizationSamples;
2508e5c31af7Sopenharmony_ci		};
2509e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2510e5c31af7Sopenharmony_ci
2511e5c31af7Sopenharmony_ci		const VkCommandBufferInheritanceInfo secCmdBufInheritInfo
2512e5c31af7Sopenharmony_ci		{
2513e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,					// VkStructureType							sType;
2514e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2515e5c31af7Sopenharmony_ci			m_useDynamicRendering ? &secCmdBufInheritRenderingInfo : DE_NULL,	// const void*								pNext;
2516e5c31af7Sopenharmony_ci#else
2517e5c31af7Sopenharmony_ci			DE_NULL,															// const void*								pNext;
2518e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2519e5c31af7Sopenharmony_ci			renderPass,															// VkRenderPass								renderPass;
2520e5c31af7Sopenharmony_ci			subpassNdx,															// deUint32									subpass;
2521e5c31af7Sopenharmony_ci			frameBuffer,														// VkFramebuffer							framebuffer;
2522e5c31af7Sopenharmony_ci			VK_FALSE,															// VkBool32									occlusionQueryEnable;
2523e5c31af7Sopenharmony_ci			(VkQueryControlFlags)0u,											// VkQueryControlFlags						queryFlags;
2524e5c31af7Sopenharmony_ci			(VkQueryPipelineStatisticFlags)0u,									// VkQueryPipelineStatisticFlags			pipelineStatistics;
2525e5c31af7Sopenharmony_ci		};
2526e5c31af7Sopenharmony_ci
2527e5c31af7Sopenharmony_ci		const VkCommandBufferBeginInfo info
2528e5c31af7Sopenharmony_ci		{
2529e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,						// VkStructureType							sType;
2530e5c31af7Sopenharmony_ci			DE_NULL,															// const void*								pNext;
2531e5c31af7Sopenharmony_ci			VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT,					// VkCommandBufferUsageFlags				flags;
2532e5c31af7Sopenharmony_ci			&secCmdBufInheritInfo,												// const VkCommandBufferInheritanceInfo*	pInheritanceInfo;
2533e5c31af7Sopenharmony_ci		};
2534e5c31af7Sopenharmony_ci
2535e5c31af7Sopenharmony_ci		VK_CHECK(m_device->beginCommandBuffer(cmdBufferSecondary.back().get()->get(), &info));
2536e5c31af7Sopenharmony_ci
2537e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(cmdBufferSecondary.back().get()->get(), 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2538e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(cmdBufferSecondary.back().get()->get(), VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2539e5c31af7Sopenharmony_ci
2540e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2541e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2542e5c31af7Sopenharmony_ci		{
2543e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2544e5c31af7Sopenharmony_ci
2545e5c31af7Sopenharmony_ci			beginRendering(
2546e5c31af7Sopenharmony_ci				*m_device,
2547e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2548e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2549e5c31af7Sopenharmony_ci				renderArea,
2550e5c31af7Sopenharmony_ci				renderPassClearValue,
2551e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2552e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2553e5c31af7Sopenharmony_ci				VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR,
2554e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2555e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2556e5c31af7Sopenharmony_ci		}
2557e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2558e5c31af7Sopenharmony_ci
2559e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2560e5c31af7Sopenharmony_ci			m_device->cmdDraw(cmdBufferSecondary.back().get()->get(), 4u, 1u, (drawNdx + subpassNdx % m_squareCount) * 4u, 0u);
2561e5c31af7Sopenharmony_ci
2562e5c31af7Sopenharmony_ci		VK_CHECK(m_device->endCommandBuffer(cmdBufferSecondary.back().get()->get()));
2563e5c31af7Sopenharmony_ci
2564e5c31af7Sopenharmony_ci		m_device->cmdExecuteCommands(*m_cmdBuffer, 1u, &cmdBufferSecondary.back().get()->get());
2565e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2566e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2567e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2568e5c31af7Sopenharmony_ci		else
2569e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2570e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2571e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, m_parameters.renderingType);
2572e5c31af7Sopenharmony_ci	}
2573e5c31af7Sopenharmony_ci
2574e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2575e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2576e5c31af7Sopenharmony_ci
2577e5c31af7Sopenharmony_ci	afterRenderPass();
2578e5c31af7Sopenharmony_ci
2579e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2580e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2581e5c31af7Sopenharmony_ci}
2582e5c31af7Sopenharmony_ci
2583e5c31af7Sopenharmony_ciclass MultiViewPointSizeTestInstance : public MultiViewRenderTestInstance
2584e5c31af7Sopenharmony_ci{
2585e5c31af7Sopenharmony_cipublic:
2586e5c31af7Sopenharmony_ci				MultiViewPointSizeTestInstance	(Context& context, const TestParameters& parameters);
2587e5c31af7Sopenharmony_ciprotected:
2588e5c31af7Sopenharmony_ci	void		validatePointSize				(const VkPhysicalDeviceLimits& limits, const deUint32 pointSize);
2589e5c31af7Sopenharmony_ci	void		createVertexData				(void);
2590e5c31af7Sopenharmony_ci	void		draw							(const deUint32			subpassCount,
2591e5c31af7Sopenharmony_ci												 VkRenderPass			renderPass,
2592e5c31af7Sopenharmony_ci												 VkFramebuffer			frameBuffer,
2593e5c31af7Sopenharmony_ci												 vector<PipelineSp>&	pipelines);
2594e5c31af7Sopenharmony_ci};
2595e5c31af7Sopenharmony_ci
2596e5c31af7Sopenharmony_ciMultiViewPointSizeTestInstance::MultiViewPointSizeTestInstance (Context& context, const TestParameters& parameters)
2597e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2598e5c31af7Sopenharmony_ci{
2599e5c31af7Sopenharmony_ci	const auto&						vki					= m_context.getInstanceInterface();
2600e5c31af7Sopenharmony_ci	const auto						physDevice			= m_context.getPhysicalDevice();
2601e5c31af7Sopenharmony_ci	const VkPhysicalDeviceLimits	limits				= getPhysicalDeviceProperties(vki, physDevice).limits;
2602e5c31af7Sopenharmony_ci
2603e5c31af7Sopenharmony_ci	validatePointSize(limits, static_cast<deUint32>(TEST_POINT_SIZE_WIDE));
2604e5c31af7Sopenharmony_ci	validatePointSize(limits, static_cast<deUint32>(TEST_POINT_SIZE_SMALL));
2605e5c31af7Sopenharmony_ci}
2606e5c31af7Sopenharmony_ci
2607e5c31af7Sopenharmony_civoid MultiViewPointSizeTestInstance::validatePointSize (const VkPhysicalDeviceLimits& limits, const deUint32 pointSize)
2608e5c31af7Sopenharmony_ci{
2609e5c31af7Sopenharmony_ci	const float	testPointSizeFloat	= static_cast<float>(pointSize);
2610e5c31af7Sopenharmony_ci	float		granuleCount		= 0.0f;
2611e5c31af7Sopenharmony_ci
2612e5c31af7Sopenharmony_ci	if (!de::inRange(testPointSizeFloat, limits.pointSizeRange[0], limits.pointSizeRange[1]))
2613e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Required point size is outside of the the limits range");
2614e5c31af7Sopenharmony_ci
2615e5c31af7Sopenharmony_ci	granuleCount = static_cast<float>(deCeilFloatToInt32((testPointSizeFloat - limits.pointSizeRange[0]) / limits.pointSizeGranularity));
2616e5c31af7Sopenharmony_ci
2617e5c31af7Sopenharmony_ci	if (limits.pointSizeRange[0] + granuleCount * limits.pointSizeGranularity != testPointSizeFloat)
2618e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Granuliraty does not allow to get required point size");
2619e5c31af7Sopenharmony_ci
2620e5c31af7Sopenharmony_ci	DE_ASSERT(pointSize + 1 <= m_parameters.extent.width / 2);
2621e5c31af7Sopenharmony_ci	DE_ASSERT(pointSize + 1 <= m_parameters.extent.height / 2);
2622e5c31af7Sopenharmony_ci}
2623e5c31af7Sopenharmony_ci
2624e5c31af7Sopenharmony_civoid MultiViewPointSizeTestInstance::createVertexData (void)
2625e5c31af7Sopenharmony_ci{
2626e5c31af7Sopenharmony_ci	const float		pixelStepX	= 2.0f / static_cast<float>(m_parameters.extent.width);
2627e5c31af7Sopenharmony_ci	const float		pixelStepY	= 2.0f / static_cast<float>(m_parameters.extent.height);
2628e5c31af7Sopenharmony_ci	const int		pointMargin	= 1 + TEST_POINT_SIZE_WIDE / 2;
2629e5c31af7Sopenharmony_ci
2630e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f + pointMargin * pixelStepX,-1.0f + pointMargin * pixelStepY, 1.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
2631e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f + pointMargin * pixelStepX, 0.0f + pointMargin * pixelStepY, 1.0f, 1.0f), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
2632e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f + pointMargin * pixelStepX,-1.0f + pointMargin * pixelStepY, 1.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
2633e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f + pointMargin * pixelStepX, 0.0f + pointMargin * pixelStepY, 1.0f, 1.0f), tcu::Vec4(1.0f, 0.5f, 0.3f, 1.0f));
2634e5c31af7Sopenharmony_ci}
2635e5c31af7Sopenharmony_ci
2636e5c31af7Sopenharmony_civoid MultiViewPointSizeTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2637e5c31af7Sopenharmony_ci{
2638e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2639e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2640e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2641e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2642e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2643e5c31af7Sopenharmony_ci
2644e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2645e5c31af7Sopenharmony_ci
2646e5c31af7Sopenharmony_ci	beforeRenderPass();
2647e5c31af7Sopenharmony_ci
2648e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2649e5c31af7Sopenharmony_ci	{
2650e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
2651e5c31af7Sopenharmony_ci		{
2652e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2653e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
2654e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
2655e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
2656e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
2657e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
2658e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
2659e5c31af7Sopenharmony_ci		};
2660e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2661e5c31af7Sopenharmony_ci	}
2662e5c31af7Sopenharmony_ci
2663e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2664e5c31af7Sopenharmony_ci	{
2665e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2666e5c31af7Sopenharmony_ci
2667e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2668e5c31af7Sopenharmony_ci
2669e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2670e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2671e5c31af7Sopenharmony_ci		{
2672e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2673e5c31af7Sopenharmony_ci
2674e5c31af7Sopenharmony_ci			beginRendering(
2675e5c31af7Sopenharmony_ci				*m_device,
2676e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2677e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2678e5c31af7Sopenharmony_ci				renderArea,
2679e5c31af7Sopenharmony_ci				renderPassClearValue,
2680e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2681e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2682e5c31af7Sopenharmony_ci				0u,
2683e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2684e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2685e5c31af7Sopenharmony_ci		}
2686e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2687e5c31af7Sopenharmony_ci
2688e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2689e5c31af7Sopenharmony_ci			m_device->cmdDraw(*m_cmdBuffer, 1u, 1u, drawNdx + subpassNdx % m_squareCount, 0u);
2690e5c31af7Sopenharmony_ci
2691e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2692e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2693e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2694e5c31af7Sopenharmony_ci		else
2695e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2696e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2697e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2698e5c31af7Sopenharmony_ci	}
2699e5c31af7Sopenharmony_ci
2700e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2701e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2702e5c31af7Sopenharmony_ci
2703e5c31af7Sopenharmony_ci	afterRenderPass();
2704e5c31af7Sopenharmony_ci
2705e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2706e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2707e5c31af7Sopenharmony_ci}
2708e5c31af7Sopenharmony_ci
2709e5c31af7Sopenharmony_ciclass MultiViewMultsampleTestInstance : public MultiViewRenderTestInstance
2710e5c31af7Sopenharmony_ci{
2711e5c31af7Sopenharmony_cipublic:
2712e5c31af7Sopenharmony_ci					MultiViewMultsampleTestInstance	(Context& context, const TestParameters& parameters);
2713e5c31af7Sopenharmony_ciprotected:
2714e5c31af7Sopenharmony_ci	tcu::TestStatus	iterate							(void);
2715e5c31af7Sopenharmony_ci	void			createVertexData				(void);
2716e5c31af7Sopenharmony_ci
2717e5c31af7Sopenharmony_ci	void			draw							(const deUint32			subpassCount,
2718e5c31af7Sopenharmony_ci													 VkRenderPass			renderPass,
2719e5c31af7Sopenharmony_ci													 VkFramebuffer			frameBuffer,
2720e5c31af7Sopenharmony_ci													 vector<PipelineSp>&	pipelines);
2721e5c31af7Sopenharmony_ci	void			afterRenderPass					(void);
2722e5c31af7Sopenharmony_ciprivate:
2723e5c31af7Sopenharmony_ci	de::SharedPtr<ImageAttachment>	m_resolveAttachment;
2724e5c31af7Sopenharmony_ci};
2725e5c31af7Sopenharmony_ci
2726e5c31af7Sopenharmony_ciMultiViewMultsampleTestInstance::MultiViewMultsampleTestInstance (Context& context, const TestParameters& parameters)
2727e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2728e5c31af7Sopenharmony_ci{
2729e5c31af7Sopenharmony_ci	// Color attachment
2730e5c31af7Sopenharmony_ci	m_resolveAttachment = de::SharedPtr<ImageAttachment>(new ImageAttachment(*m_logicalDevice, *m_device, *m_allocator, m_parameters.extent, m_parameters.colorFormat, VK_SAMPLE_COUNT_1_BIT));
2731e5c31af7Sopenharmony_ci}
2732e5c31af7Sopenharmony_ci
2733e5c31af7Sopenharmony_citcu::TestStatus MultiViewMultsampleTestInstance::iterate (void)
2734e5c31af7Sopenharmony_ci{
2735e5c31af7Sopenharmony_ci	const deUint32								subpassCount				= static_cast<deUint32>(m_parameters.viewMasks.size());
2736e5c31af7Sopenharmony_ci	Move<VkRenderPass>							renderPass;
2737e5c31af7Sopenharmony_ci	Move<VkFramebuffer>							frameBuffer;
2738e5c31af7Sopenharmony_ci
2739e5c31af7Sopenharmony_ci	// FrameBuffer & renderPass
2740e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
2741e5c31af7Sopenharmony_ci	{
2742e5c31af7Sopenharmony_ci		renderPass	= makeRenderPass (*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_parameters.renderingType, VK_SAMPLE_COUNT_4_BIT);
2743e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, m_colorAttachment->getImageView(), m_parameters.extent.width, m_parameters.extent.height);
2744e5c31af7Sopenharmony_ci	}
2745e5c31af7Sopenharmony_ci
2746e5c31af7Sopenharmony_ci	// pipelineLayout
2747e5c31af7Sopenharmony_ci	Unique<VkPipelineLayout>					pipelineLayout				(makePipelineLayout(*m_device, *m_logicalDevice));
2748e5c31af7Sopenharmony_ci
2749e5c31af7Sopenharmony_ci	// pipelines
2750e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
2751e5c31af7Sopenharmony_ci	vector<PipelineSp>							pipelines(subpassCount);
2752e5c31af7Sopenharmony_ci	const VkVertexInputRate						vertexInputRate				= (TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex) ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
2753e5c31af7Sopenharmony_ci
2754e5c31af7Sopenharmony_ci	{
2755e5c31af7Sopenharmony_ci		vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
2756e5c31af7Sopenharmony_ci		madeShaderModule(shaderModule, shaderStageParams);
2757e5c31af7Sopenharmony_ci		for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
2758e5c31af7Sopenharmony_ci			pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(*renderPass, *pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(), subpassNdx, vertexInputRate))));
2759e5c31af7Sopenharmony_ci	}
2760e5c31af7Sopenharmony_ci
2761e5c31af7Sopenharmony_ci	createCommandBuffer();
2762e5c31af7Sopenharmony_ci	createVertexData();
2763e5c31af7Sopenharmony_ci	createVertexBuffer();
2764e5c31af7Sopenharmony_ci
2765e5c31af7Sopenharmony_ci	draw(subpassCount, *renderPass, *frameBuffer, pipelines);
2766e5c31af7Sopenharmony_ci
2767e5c31af7Sopenharmony_ci	{
2768e5c31af7Sopenharmony_ci		vector<deUint8>			pixelAccessData	(m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * mapVkFormat(m_parameters.colorFormat).getPixelSize());
2769e5c31af7Sopenharmony_ci		tcu::PixelBufferAccess	dst				(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth, pixelAccessData.data());
2770e5c31af7Sopenharmony_ci
2771e5c31af7Sopenharmony_ci		readImage(m_resolveAttachment->getImage(), dst);
2772e5c31af7Sopenharmony_ci
2773e5c31af7Sopenharmony_ci		if (!checkImage(dst))
2774e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
2775e5c31af7Sopenharmony_ci	}
2776e5c31af7Sopenharmony_ci
2777e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
2778e5c31af7Sopenharmony_ci}
2779e5c31af7Sopenharmony_ci
2780e5c31af7Sopenharmony_civoid MultiViewMultsampleTestInstance::createVertexData (void)
2781e5c31af7Sopenharmony_ci{
2782e5c31af7Sopenharmony_ci	tcu::Vec4	color	= tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
2783e5c31af7Sopenharmony_ci
2784e5c31af7Sopenharmony_ci	color	= tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f);
2785e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), color);
2786e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-1.0f, 1.0f, 1.0f), color);
2787e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), color);
2788e5c31af7Sopenharmony_ci
2789e5c31af7Sopenharmony_ci	color	= tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f);
2790e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), color);
2791e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 1.0f, 1.0f), color);
2792e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
2793e5c31af7Sopenharmony_ci
2794e5c31af7Sopenharmony_ci	color	= tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f);
2795e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
2796e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 1.0f, 1.0f), color);
2797e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f,-1.0f, 1.0f, 1.0f), color);
2798e5c31af7Sopenharmony_ci
2799e5c31af7Sopenharmony_ci	color	= tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
2800e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, 1.0f, 1.0f), color);
2801e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), color);
2802e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, 1.0f, 1.0f), color);
2803e5c31af7Sopenharmony_ci}
2804e5c31af7Sopenharmony_ci
2805e5c31af7Sopenharmony_civoid MultiViewMultsampleTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
2806e5c31af7Sopenharmony_ci{
2807e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
2808e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
2809e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
2810e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
2811e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
2812e5c31af7Sopenharmony_ci	const deUint32					vertexPerPrimitive		= 3u;
2813e5c31af7Sopenharmony_ci	const VkImageSubresourceLayers	subresourceLayer		=
2814e5c31af7Sopenharmony_ci	{
2815e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,	//  VkImageAspectFlags	aspectMask;
2816e5c31af7Sopenharmony_ci		0u,							//  deUint32			mipLevel;
2817e5c31af7Sopenharmony_ci		0u,							//  deUint32			baseArrayLayer;
2818e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	//  deUint32			layerCount;
2819e5c31af7Sopenharmony_ci	};
2820e5c31af7Sopenharmony_ci	const VkImageResolve			imageResolveRegion		=
2821e5c31af7Sopenharmony_ci	{
2822e5c31af7Sopenharmony_ci		subresourceLayer,															//  VkImageSubresourceLayers	srcSubresource;
2823e5c31af7Sopenharmony_ci		makeOffset3D(0, 0, 0),														//  VkOffset3D					srcOffset;
2824e5c31af7Sopenharmony_ci		subresourceLayer,															//  VkImageSubresourceLayers	dstSubresource;
2825e5c31af7Sopenharmony_ci		makeOffset3D(0, 0, 0),														//  VkOffset3D					dstOffset;
2826e5c31af7Sopenharmony_ci		makeExtent3D(m_parameters.extent.width, m_parameters.extent.height, 1u),	//  VkExtent3D					extent;
2827e5c31af7Sopenharmony_ci	};
2828e5c31af7Sopenharmony_ci
2829e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
2830e5c31af7Sopenharmony_ci
2831e5c31af7Sopenharmony_ci	beforeRenderPass();
2832e5c31af7Sopenharmony_ci
2833e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2834e5c31af7Sopenharmony_ci	{
2835e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
2836e5c31af7Sopenharmony_ci		{
2837e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
2838e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
2839e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
2840e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
2841e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
2842e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
2843e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
2844e5c31af7Sopenharmony_ci		};
2845e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2846e5c31af7Sopenharmony_ci	}
2847e5c31af7Sopenharmony_ci
2848e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
2849e5c31af7Sopenharmony_ci	{
2850e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
2851e5c31af7Sopenharmony_ci
2852e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
2853e5c31af7Sopenharmony_ci
2854e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2855e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2856e5c31af7Sopenharmony_ci		{
2857e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
2858e5c31af7Sopenharmony_ci
2859e5c31af7Sopenharmony_ci			beginRendering(
2860e5c31af7Sopenharmony_ci				*m_device,
2861e5c31af7Sopenharmony_ci				*m_cmdBuffer,
2862e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
2863e5c31af7Sopenharmony_ci				renderArea,
2864e5c31af7Sopenharmony_ci				renderPassClearValue,
2865e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
2866e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
2867e5c31af7Sopenharmony_ci				0u,
2868e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
2869e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
2870e5c31af7Sopenharmony_ci		}
2871e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2872e5c31af7Sopenharmony_ci
2873e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
2874e5c31af7Sopenharmony_ci			m_device->cmdDraw(*m_cmdBuffer, vertexPerPrimitive, 1u, (drawNdx + subpassNdx % m_squareCount) * vertexPerPrimitive, 0u);
2875e5c31af7Sopenharmony_ci
2876e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
2877e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
2878e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
2879e5c31af7Sopenharmony_ci		else
2880e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
2881e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
2882e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
2883e5c31af7Sopenharmony_ci	}
2884e5c31af7Sopenharmony_ci
2885e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
2886e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
2887e5c31af7Sopenharmony_ci
2888e5c31af7Sopenharmony_ci	afterRenderPass();
2889e5c31af7Sopenharmony_ci
2890e5c31af7Sopenharmony_ci	m_device->cmdResolveImage(*m_cmdBuffer, m_colorAttachment->getImage(), VK_IMAGE_LAYOUT_GENERAL, m_resolveAttachment->getImage(), VK_IMAGE_LAYOUT_GENERAL, 1u, &imageResolveRegion);
2891e5c31af7Sopenharmony_ci
2892e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
2893e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
2894e5c31af7Sopenharmony_ci}
2895e5c31af7Sopenharmony_ci
2896e5c31af7Sopenharmony_civoid MultiViewMultsampleTestInstance::afterRenderPass (void)
2897e5c31af7Sopenharmony_ci{
2898e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	subresourceRange		=
2899e5c31af7Sopenharmony_ci	{
2900e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,	//  VkImageAspectFlags	aspectMask;
2901e5c31af7Sopenharmony_ci		0u,							//  deUint32			baseMipLevel;
2902e5c31af7Sopenharmony_ci		1u,							//  deUint32			levelCount;
2903e5c31af7Sopenharmony_ci		0u,							//  deUint32			baseArrayLayer;
2904e5c31af7Sopenharmony_ci		m_parameters.extent.depth,	//  deUint32			layerCount;
2905e5c31af7Sopenharmony_ci	};
2906e5c31af7Sopenharmony_ci
2907e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_colorAttachment->getImage(), subresourceRange,
2908e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
2909e5c31af7Sopenharmony_ci		VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT,
2910e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
2911e5c31af7Sopenharmony_ci
2912e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_resolveAttachment->getImage(), subresourceRange,
2913e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL,
2914e5c31af7Sopenharmony_ci		0u, VK_ACCESS_TRANSFER_WRITE_BIT,
2915e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
2916e5c31af7Sopenharmony_ci}
2917e5c31af7Sopenharmony_ci
2918e5c31af7Sopenharmony_ciclass MultiViewQueriesTestInstance : public MultiViewRenderTestInstance
2919e5c31af7Sopenharmony_ci{
2920e5c31af7Sopenharmony_cipublic:
2921e5c31af7Sopenharmony_ci						MultiViewQueriesTestInstance	(Context& context, const TestParameters& parameters);
2922e5c31af7Sopenharmony_ciprotected:
2923e5c31af7Sopenharmony_ci	tcu::TestStatus		iterate							(void);
2924e5c31af7Sopenharmony_ci	void				createVertexData				(void);
2925e5c31af7Sopenharmony_ci
2926e5c31af7Sopenharmony_ci	void				draw							(const deUint32			subpassCount,
2927e5c31af7Sopenharmony_ci														 VkRenderPass			renderPass,
2928e5c31af7Sopenharmony_ci														 VkFramebuffer			frameBuffer,
2929e5c31af7Sopenharmony_ci														 vector<PipelineSp>&	pipelines);
2930e5c31af7Sopenharmony_ci	deUint32			getUsedViewsCount				(const deUint32			viewMaskIndex);
2931e5c31af7Sopenharmony_ci	deUint32			getQueryCountersNumber			();
2932e5c31af7Sopenharmony_ciprivate:
2933e5c31af7Sopenharmony_ci	const deUint32				m_verticesPerPrimitive;
2934e5c31af7Sopenharmony_ci	const VkQueryControlFlags	m_occlusionQueryFlags;
2935e5c31af7Sopenharmony_ci	deUint64					m_timestampMask;
2936e5c31af7Sopenharmony_ci	vector<deUint64>			m_timestampStartValues;
2937e5c31af7Sopenharmony_ci	vector<deUint64>			m_timestampEndValues;
2938e5c31af7Sopenharmony_ci	vector<uint64_t>			m_timestampStartAvailabilityValues;
2939e5c31af7Sopenharmony_ci	vector<uint64_t>			m_timestampEndAvailabilityValues;
2940e5c31af7Sopenharmony_ci	vector<deBool>				m_counterSeriesStart;
2941e5c31af7Sopenharmony_ci	vector<deBool>				m_counterSeriesEnd;
2942e5c31af7Sopenharmony_ci	vector<deUint64>			m_occlusionValues;
2943e5c31af7Sopenharmony_ci	vector<deUint64>			m_occlusionExpectedValues;
2944e5c31af7Sopenharmony_ci	vector<uint64_t>			m_occlusionAvailabilityValues;
2945e5c31af7Sopenharmony_ci	deUint32					m_occlusionObjectsOffset;
2946e5c31af7Sopenharmony_ci	vector<deUint64>			m_occlusionObjectPixelsCount;
2947e5c31af7Sopenharmony_ci};
2948e5c31af7Sopenharmony_ci
2949e5c31af7Sopenharmony_ciMultiViewQueriesTestInstance::MultiViewQueriesTestInstance (Context& context, const TestParameters& parameters)
2950e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
2951e5c31af7Sopenharmony_ci	, m_verticesPerPrimitive		(4u)
2952e5c31af7Sopenharmony_ci	, m_occlusionQueryFlags			((parameters.viewIndex == TEST_TYPE_QUERIES) * VK_QUERY_CONTROL_PRECISE_BIT)
2953e5c31af7Sopenharmony_ci	, m_occlusionObjectsOffset		(0)
2954e5c31af7Sopenharmony_ci{
2955e5c31af7Sopenharmony_ci	// Generate the timestamp mask
2956e5c31af7Sopenharmony_ci	const auto&	vki				= m_context.getInstanceInterface();
2957e5c31af7Sopenharmony_ci	const auto	physicalDevice	= m_context.getPhysicalDevice();
2958e5c31af7Sopenharmony_ci
2959e5c31af7Sopenharmony_ci	const std::vector<VkQueueFamilyProperties>	queueProperties	= vk::getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
2960e5c31af7Sopenharmony_ci
2961e5c31af7Sopenharmony_ci	if(queueProperties[0].timestampValidBits == 0)
2962e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, "Device does not support timestamp.");
2963e5c31af7Sopenharmony_ci
2964e5c31af7Sopenharmony_ci	m_timestampMask = 0xFFFFFFFFFFFFFFFFull >> (64 - queueProperties[0].timestampValidBits);
2965e5c31af7Sopenharmony_ci}
2966e5c31af7Sopenharmony_ci
2967e5c31af7Sopenharmony_civoid verifyAvailabilityBits (const std::vector<uint64_t>& bits, const char* setName)
2968e5c31af7Sopenharmony_ci{
2969e5c31af7Sopenharmony_ci	constexpr auto invalidValue = uint64_t{0};
2970e5c31af7Sopenharmony_ci	for (size_t i = 0u; i < bits.size(); ++i)
2971e5c31af7Sopenharmony_ci	{
2972e5c31af7Sopenharmony_ci		if (bits[i] == invalidValue)
2973e5c31af7Sopenharmony_ci			TCU_FAIL(setName + std::string(" availability bit ") + de::toString(i) + " is " + de::toString(invalidValue));
2974e5c31af7Sopenharmony_ci	}
2975e5c31af7Sopenharmony_ci}
2976e5c31af7Sopenharmony_ci
2977e5c31af7Sopenharmony_citcu::TestStatus MultiViewQueriesTestInstance::iterate (void)
2978e5c31af7Sopenharmony_ci{
2979e5c31af7Sopenharmony_ci	const deUint32								subpassCount			= static_cast<deUint32>(m_parameters.viewMasks.size());
2980e5c31af7Sopenharmony_ci	Move<VkRenderPass>							renderPass;
2981e5c31af7Sopenharmony_ci	Move<VkFramebuffer>							frameBuffer;
2982e5c31af7Sopenharmony_ci	Unique<VkPipelineLayout>					pipelineLayout			(makePipelineLayout(*m_device, *m_logicalDevice));
2983e5c31af7Sopenharmony_ci	vector<PipelineSp>							pipelines				(subpassCount);
2984e5c31af7Sopenharmony_ci	deUint64									occlusionValue			= 0;
2985e5c31af7Sopenharmony_ci	deUint64									occlusionExpectedValue	= 0;
2986e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
2987e5c31af7Sopenharmony_ci
2988e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
2989e5c31af7Sopenharmony_ci	{
2990e5c31af7Sopenharmony_ci		renderPass	= makeRenderPass (*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_parameters.renderingType);
2991e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, m_colorAttachment->getImageView(), m_parameters.extent.width, m_parameters.extent.height);
2992e5c31af7Sopenharmony_ci	}
2993e5c31af7Sopenharmony_ci
2994e5c31af7Sopenharmony_ci	{
2995e5c31af7Sopenharmony_ci		vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
2996e5c31af7Sopenharmony_ci
2997e5c31af7Sopenharmony_ci		madeShaderModule(shaderModule, shaderStageParams);
2998e5c31af7Sopenharmony_ci		for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
2999e5c31af7Sopenharmony_ci			pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(*renderPass, *pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(), subpassNdx))));
3000e5c31af7Sopenharmony_ci	}
3001e5c31af7Sopenharmony_ci
3002e5c31af7Sopenharmony_ci	createCommandBuffer();
3003e5c31af7Sopenharmony_ci	createVertexData();
3004e5c31af7Sopenharmony_ci	createVertexBuffer();
3005e5c31af7Sopenharmony_ci
3006e5c31af7Sopenharmony_ci	draw(subpassCount, *renderPass, *frameBuffer, pipelines);
3007e5c31af7Sopenharmony_ci
3008e5c31af7Sopenharmony_ci	DE_ASSERT(!m_occlusionValues.empty());
3009e5c31af7Sopenharmony_ci	DE_ASSERT(m_occlusionValues.size() == m_occlusionExpectedValues.size());
3010e5c31af7Sopenharmony_ci	DE_ASSERT(m_occlusionValues.size() == m_counterSeriesEnd.size());
3011e5c31af7Sopenharmony_ci	for (size_t ndx = 0; ndx < m_counterSeriesEnd.size(); ++ndx)
3012e5c31af7Sopenharmony_ci	{
3013e5c31af7Sopenharmony_ci		occlusionValue			+= m_occlusionValues[ndx];
3014e5c31af7Sopenharmony_ci		occlusionExpectedValue	+= m_occlusionExpectedValues[ndx];
3015e5c31af7Sopenharmony_ci
3016e5c31af7Sopenharmony_ci		if (m_counterSeriesEnd[ndx])
3017e5c31af7Sopenharmony_ci		{
3018e5c31af7Sopenharmony_ci			if (m_parameters.viewIndex == TEST_TYPE_QUERIES)
3019e5c31af7Sopenharmony_ci			{
3020e5c31af7Sopenharmony_ci				if (occlusionExpectedValue != occlusionValue)
3021e5c31af7Sopenharmony_ci					return tcu::TestStatus::fail("occlusion, result:" + de::toString(occlusionValue) + ", expected:" + de::toString(occlusionExpectedValue));
3022e5c31af7Sopenharmony_ci			}
3023e5c31af7Sopenharmony_ci			else // verify non precise occlusion query
3024e5c31af7Sopenharmony_ci			{
3025e5c31af7Sopenharmony_ci				if (occlusionValue == 0)
3026e5c31af7Sopenharmony_ci					return tcu::TestStatus::fail("occlusion, result: 0, expected non zero value");
3027e5c31af7Sopenharmony_ci			}
3028e5c31af7Sopenharmony_ci		}
3029e5c31af7Sopenharmony_ci	}
3030e5c31af7Sopenharmony_ci	verifyAvailabilityBits(m_occlusionAvailabilityValues, "occlusion");
3031e5c31af7Sopenharmony_ci
3032e5c31af7Sopenharmony_ci	DE_ASSERT(!m_timestampStartValues.empty());
3033e5c31af7Sopenharmony_ci	DE_ASSERT(m_timestampStartValues.size() == m_timestampEndValues.size());
3034e5c31af7Sopenharmony_ci	DE_ASSERT(m_timestampStartValues.size() == m_counterSeriesStart.size());
3035e5c31af7Sopenharmony_ci	for (size_t ndx = 0; ndx < m_timestampStartValues.size(); ++ndx)
3036e5c31af7Sopenharmony_ci	{
3037e5c31af7Sopenharmony_ci		if (m_counterSeriesStart[ndx])
3038e5c31af7Sopenharmony_ci		{
3039e5c31af7Sopenharmony_ci			if (m_timestampEndValues[ndx] > 0 && m_timestampEndValues[ndx] >= m_timestampStartValues[ndx])
3040e5c31af7Sopenharmony_ci				continue;
3041e5c31af7Sopenharmony_ci		}
3042e5c31af7Sopenharmony_ci		else
3043e5c31af7Sopenharmony_ci		{
3044e5c31af7Sopenharmony_ci			if (m_timestampEndValues[ndx] > 0 && m_timestampEndValues[ndx] >= m_timestampStartValues[ndx])
3045e5c31af7Sopenharmony_ci				continue;
3046e5c31af7Sopenharmony_ci
3047e5c31af7Sopenharmony_ci			if (m_timestampEndValues[ndx] == 0 && m_timestampStartValues[ndx] == 0)
3048e5c31af7Sopenharmony_ci				continue;
3049e5c31af7Sopenharmony_ci		}
3050e5c31af7Sopenharmony_ci
3051e5c31af7Sopenharmony_ci		return tcu::TestStatus::fail("timestamp");
3052e5c31af7Sopenharmony_ci	}
3053e5c31af7Sopenharmony_ci	verifyAvailabilityBits(m_timestampStartAvailabilityValues, "timestamp start");
3054e5c31af7Sopenharmony_ci	verifyAvailabilityBits(m_timestampEndAvailabilityValues, "timestamp end");
3055e5c31af7Sopenharmony_ci
3056e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
3057e5c31af7Sopenharmony_ci}
3058e5c31af7Sopenharmony_ci
3059e5c31af7Sopenharmony_civoid MultiViewQueriesTestInstance::createVertexData (void)
3060e5c31af7Sopenharmony_ci{
3061e5c31af7Sopenharmony_ci	tcu::Vec4 color = tcu::Vec4(0.2f, 0.0f, 0.1f, 1.0f);
3062e5c31af7Sopenharmony_ci
3063e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-1.0f, 0.0f, 1.0f), color);
3064e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 0.0f, 1.0f), color);
3065e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 0.0f, 1.0f), color);
3066e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), color);
3067e5c31af7Sopenharmony_ci
3068e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.3f, 0.0f, 0.2f, 1.0f);
3069e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, 0.0f, 1.0f), color);
3070e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), color);
3071e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), color);
3072e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, 0.0f, 1.0f), color);
3073e5c31af7Sopenharmony_ci
3074e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.4f, 0.2f, 0.3f, 1.0f);
3075e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, 0.0f, 1.0f), color);
3076e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), color);
3077e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f,-1.0f, 0.0f, 1.0f), color);
3078e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, 0.0f, 1.0f), color);
3079e5c31af7Sopenharmony_ci
3080e5c31af7Sopenharmony_ci	color = tcu::Vec4(0.5f, 0.0f, 0.4f, 1.0f);
3081e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), color);
3082e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, 0.0f, 1.0f), color);
3083e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, 0.0f, 1.0f), color);
3084e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), color);
3085e5c31af7Sopenharmony_ci
3086e5c31af7Sopenharmony_ci	// Create occluded square objects as zoom out of main
3087e5c31af7Sopenharmony_ci	const deUint32	mainObjectsVerticesCount		= static_cast<deUint32>(m_vertexCoord.size());
3088e5c31af7Sopenharmony_ci	const deUint32	mainObjectsCount				= mainObjectsVerticesCount / m_verticesPerPrimitive;
3089e5c31af7Sopenharmony_ci	const deUint32	occlusionObjectMultiplierX[]	= { 1, 2, 2, 1 };
3090e5c31af7Sopenharmony_ci	const deUint32	occlusionObjectMultiplierY[]	= { 1, 1, 3, 3 };
3091e5c31af7Sopenharmony_ci	const deUint32	occlusionObjectDivisor			= 4u;
3092e5c31af7Sopenharmony_ci	const float		occlusionObjectDivisorFloat		= static_cast<float>(occlusionObjectDivisor);
3093e5c31af7Sopenharmony_ci
3094e5c31af7Sopenharmony_ci	DE_ASSERT(0 == m_parameters.extent.width  % (2 * occlusionObjectDivisor));
3095e5c31af7Sopenharmony_ci	DE_ASSERT(0 == m_parameters.extent.height % (2 * occlusionObjectDivisor));
3096e5c31af7Sopenharmony_ci	DE_ASSERT(DE_LENGTH_OF_ARRAY(occlusionObjectMultiplierX) == mainObjectsCount);
3097e5c31af7Sopenharmony_ci	DE_ASSERT(DE_LENGTH_OF_ARRAY(occlusionObjectMultiplierY) == mainObjectsCount);
3098e5c31af7Sopenharmony_ci
3099e5c31af7Sopenharmony_ci	for (size_t objectNdx = 0; objectNdx < mainObjectsCount; ++objectNdx)
3100e5c31af7Sopenharmony_ci	{
3101e5c31af7Sopenharmony_ci		const size_t	objectStart			= objectNdx * m_verticesPerPrimitive;
3102e5c31af7Sopenharmony_ci		const float		xRatio				= static_cast<float>(occlusionObjectMultiplierX[objectNdx]) / occlusionObjectDivisorFloat;
3103e5c31af7Sopenharmony_ci		const float		yRatio				= static_cast<float>(occlusionObjectMultiplierY[objectNdx]) / occlusionObjectDivisorFloat;
3104e5c31af7Sopenharmony_ci		const double	areaRatio			= static_cast<double>(xRatio) * static_cast<double>(yRatio);
3105e5c31af7Sopenharmony_ci		const deUint64	occludedPixelsCount	= static_cast<deUint64>(areaRatio * (m_parameters.extent.width / 2) * (m_parameters.extent.height / 2));
3106e5c31af7Sopenharmony_ci
3107e5c31af7Sopenharmony_ci		m_occlusionObjectPixelsCount.push_back(occludedPixelsCount);
3108e5c31af7Sopenharmony_ci
3109e5c31af7Sopenharmony_ci		for (size_t vertexNdx = 0; vertexNdx < m_verticesPerPrimitive; ++vertexNdx)
3110e5c31af7Sopenharmony_ci		{
3111e5c31af7Sopenharmony_ci			const float		occludedObjectVertexXCoord	= m_vertexCoord[objectStart + vertexNdx][0] * xRatio;
3112e5c31af7Sopenharmony_ci			const float		occludedObjectVertexYCoord	= m_vertexCoord[objectStart + vertexNdx][1] * yRatio;
3113e5c31af7Sopenharmony_ci			const tcu::Vec4	occludedObjectVertexCoord	= tcu::Vec4(occludedObjectVertexXCoord, occludedObjectVertexYCoord, 1.0f, 1.0f);
3114e5c31af7Sopenharmony_ci
3115e5c31af7Sopenharmony_ci			appendVertex(occludedObjectVertexCoord, m_vertexColor[objectStart + vertexNdx]);
3116e5c31af7Sopenharmony_ci		}
3117e5c31af7Sopenharmony_ci	}
3118e5c31af7Sopenharmony_ci
3119e5c31af7Sopenharmony_ci	m_occlusionObjectsOffset = mainObjectsVerticesCount;
3120e5c31af7Sopenharmony_ci}
3121e5c31af7Sopenharmony_ci
3122e5c31af7Sopenharmony_ci// Extract single values or pairs of consecutive values from src and store them in dst1 and dst2.
3123e5c31af7Sopenharmony_ci// If ds2 is not null, src is processed as containing pairs of values.
3124e5c31af7Sopenharmony_ci// The first value will be stored in ds1 and the second one in dst2.
3125e5c31af7Sopenharmony_civoid unpackValues (const std::vector<uint64_t>& src, std::vector<uint64_t>* dst1, std::vector<uint64_t>* dst2)
3126e5c31af7Sopenharmony_ci{
3127e5c31af7Sopenharmony_ci	if (!dst2)
3128e5c31af7Sopenharmony_ci	{
3129e5c31af7Sopenharmony_ci		std::copy(begin(src), end(src), begin(*dst1));
3130e5c31af7Sopenharmony_ci		return;
3131e5c31af7Sopenharmony_ci	}
3132e5c31af7Sopenharmony_ci
3133e5c31af7Sopenharmony_ci	constexpr size_t sz0 = 0;
3134e5c31af7Sopenharmony_ci	constexpr size_t sz1 = 1;
3135e5c31af7Sopenharmony_ci	constexpr size_t sz2 = 2;
3136e5c31af7Sopenharmony_ci
3137e5c31af7Sopenharmony_ci	DE_UNREF(sz0); // For release builds.
3138e5c31af7Sopenharmony_ci	DE_ASSERT(src.size() % sz2 == sz0);
3139e5c31af7Sopenharmony_ci
3140e5c31af7Sopenharmony_ci	for (size_t i = 0; i < src.size(); i += sz2)
3141e5c31af7Sopenharmony_ci	{
3142e5c31af7Sopenharmony_ci		const auto j = i / sz2;
3143e5c31af7Sopenharmony_ci		dst1->at(j) = src.at(i);
3144e5c31af7Sopenharmony_ci		dst2->at(j) = src.at(i + sz1);
3145e5c31af7Sopenharmony_ci	}
3146e5c31af7Sopenharmony_ci}
3147e5c31af7Sopenharmony_ci
3148e5c31af7Sopenharmony_civoid MultiViewQueriesTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
3149e5c31af7Sopenharmony_ci{
3150e5c31af7Sopenharmony_ci	const VkRect2D				renderArea						= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
3151e5c31af7Sopenharmony_ci	const VkClearValue			renderPassClearValue			= makeClearValueColor(tcu::Vec4(0.0f));
3152e5c31af7Sopenharmony_ci	const VkBuffer				vertexBuffers[]					= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
3153e5c31af7Sopenharmony_ci	const VkDeviceSize			vertexBufferOffsets[]			= {                   0u,                   0u };
3154e5c31af7Sopenharmony_ci	const deUint32				drawCountPerSubpass				= (subpassCount == 1) ? m_squareCount : 1u;
3155e5c31af7Sopenharmony_ci	const deUint32				queryCountersNumber				= (subpassCount == 1) ? m_squareCount * getUsedViewsCount(0) : getQueryCountersNumber();
3156e5c31af7Sopenharmony_ci
3157e5c31af7Sopenharmony_ci	const VkQueryPoolCreateInfo	occlusionQueryPoolCreateInfo	=
3158e5c31af7Sopenharmony_ci	{
3159e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,	//  VkStructureType					sType;
3160e5c31af7Sopenharmony_ci		DE_NULL,									//  const void*						pNext;
3161e5c31af7Sopenharmony_ci		(VkQueryPoolCreateFlags)0,					//  VkQueryPoolCreateFlags			flags;
3162e5c31af7Sopenharmony_ci		VK_QUERY_TYPE_OCCLUSION,					//  VkQueryType						queryType;
3163e5c31af7Sopenharmony_ci		queryCountersNumber,						//  deUint32						queryCount;
3164e5c31af7Sopenharmony_ci		0u,											//  VkQueryPipelineStatisticFlags	pipelineStatistics;
3165e5c31af7Sopenharmony_ci	};
3166e5c31af7Sopenharmony_ci	const VkQueryPoolCreateInfo	timestampQueryPoolCreateInfo	=
3167e5c31af7Sopenharmony_ci	{
3168e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,	//  VkStructureType					sType;
3169e5c31af7Sopenharmony_ci		DE_NULL,									//  const void*						pNext;
3170e5c31af7Sopenharmony_ci		(VkQueryPoolCreateFlags)0,					//  VkQueryPoolCreateFlags			flags;
3171e5c31af7Sopenharmony_ci		VK_QUERY_TYPE_TIMESTAMP,					//  VkQueryType						queryType;
3172e5c31af7Sopenharmony_ci		queryCountersNumber,						//  deUint32						queryCount;
3173e5c31af7Sopenharmony_ci		0u,											//  VkQueryPipelineStatisticFlags	pipelineStatistics;
3174e5c31af7Sopenharmony_ci	};
3175e5c31af7Sopenharmony_ci	const Unique<VkQueryPool>	occlusionQueryPool				(createQueryPool(*m_device, *m_logicalDevice, &occlusionQueryPoolCreateInfo));
3176e5c31af7Sopenharmony_ci	const Unique<VkQueryPool>	timestampStartQueryPool			(createQueryPool(*m_device, *m_logicalDevice, &timestampQueryPoolCreateInfo));
3177e5c31af7Sopenharmony_ci	const Unique<VkQueryPool>	timestampEndQueryPool			(createQueryPool(*m_device, *m_logicalDevice, &timestampQueryPoolCreateInfo));
3178e5c31af7Sopenharmony_ci	deUint32					queryStartIndex					= 0;
3179e5c31af7Sopenharmony_ci
3180e5c31af7Sopenharmony_ci	const bool					withAvailability				= (m_parameters.viewIndex == TEST_TYPE_NON_PRECISE_QUERIES_WITH_AVAILABILITY);
3181e5c31af7Sopenharmony_ci	const uint32_t				valuesPerQuery					= (withAvailability ? 2u : 1u);
3182e5c31af7Sopenharmony_ci	const uint32_t				valuesNumber					= queryCountersNumber * valuesPerQuery;
3183e5c31af7Sopenharmony_ci	const auto					queryStride						= static_cast<VkDeviceSize>(sizeof(uint64_t) * valuesPerQuery);
3184e5c31af7Sopenharmony_ci	const auto					extraFlag						= (withAvailability ? VK_QUERY_RESULT_WITH_AVAILABILITY_BIT : static_cast<VkQueryResultFlagBits>(0));
3185e5c31af7Sopenharmony_ci	const auto					queryFlags						= (VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT | extraFlag);
3186e5c31af7Sopenharmony_ci
3187e5c31af7Sopenharmony_ci	vk::BufferWithMemory		queryBuffer						(m_context.getDeviceInterface(), *m_logicalDevice, *m_allocator, makeBufferCreateInfo(valuesNumber * sizeof(uint64_t), VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT), vk::MemoryRequirement::HostVisible);
3188e5c31af7Sopenharmony_ci
3189e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
3190e5c31af7Sopenharmony_ci
3191e5c31af7Sopenharmony_ci	beforeRenderPass();
3192e5c31af7Sopenharmony_ci
3193e5c31af7Sopenharmony_ci	// Query pools must be reset before use
3194e5c31af7Sopenharmony_ci	m_device->cmdResetQueryPool(*m_cmdBuffer, *occlusionQueryPool, queryStartIndex, queryCountersNumber);
3195e5c31af7Sopenharmony_ci	m_device->cmdResetQueryPool(*m_cmdBuffer, *timestampStartQueryPool, queryStartIndex, queryCountersNumber);
3196e5c31af7Sopenharmony_ci	m_device->cmdResetQueryPool(*m_cmdBuffer, *timestampEndQueryPool, queryStartIndex, queryCountersNumber);
3197e5c31af7Sopenharmony_ci
3198e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
3199e5c31af7Sopenharmony_ci	{
3200e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo	renderPassBeginInfo
3201e5c31af7Sopenharmony_ci		{
3202e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	//  VkStructureType		sType;
3203e5c31af7Sopenharmony_ci			DE_NULL,									//  const void*			pNext;
3204e5c31af7Sopenharmony_ci			renderPass,									//  VkRenderPass		renderPass;
3205e5c31af7Sopenharmony_ci			frameBuffer,								//  VkFramebuffer		framebuffer;
3206e5c31af7Sopenharmony_ci			renderArea,									//  VkRect2D			renderArea;
3207e5c31af7Sopenharmony_ci			1u,											//  uint32_t			clearValueCount;
3208e5c31af7Sopenharmony_ci			&renderPassClearValue,						//  const VkClearValue*	pClearValues;
3209e5c31af7Sopenharmony_ci		};
3210e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
3211e5c31af7Sopenharmony_ci	}
3212e5c31af7Sopenharmony_ci
3213e5c31af7Sopenharmony_ci	m_occlusionExpectedValues.reserve(queryCountersNumber);
3214e5c31af7Sopenharmony_ci	m_counterSeriesStart.reserve(queryCountersNumber);
3215e5c31af7Sopenharmony_ci	m_counterSeriesEnd.reserve(queryCountersNumber);
3216e5c31af7Sopenharmony_ci
3217e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
3218e5c31af7Sopenharmony_ci	{
3219e5c31af7Sopenharmony_ci		deUint32	queryCountersToUse	= getUsedViewsCount(subpassNdx);
3220e5c31af7Sopenharmony_ci
3221e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
3222e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
3223e5c31af7Sopenharmony_ci
3224e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
3225e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
3226e5c31af7Sopenharmony_ci		{
3227e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
3228e5c31af7Sopenharmony_ci
3229e5c31af7Sopenharmony_ci			beginRendering(
3230e5c31af7Sopenharmony_ci				*m_device,
3231e5c31af7Sopenharmony_ci				*m_cmdBuffer,
3232e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
3233e5c31af7Sopenharmony_ci				renderArea,
3234e5c31af7Sopenharmony_ci				renderPassClearValue,
3235e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
3236e5c31af7Sopenharmony_ci				(subpassNdx ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_CLEAR),
3237e5c31af7Sopenharmony_ci				0u,
3238e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
3239e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
3240e5c31af7Sopenharmony_ci		}
3241e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
3242e5c31af7Sopenharmony_ci
3243e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
3244e5c31af7Sopenharmony_ci		{
3245e5c31af7Sopenharmony_ci			const deUint32 primitiveNumber	= drawNdx + subpassNdx % m_squareCount;
3246e5c31af7Sopenharmony_ci			const deUint32 firstVertex		= primitiveNumber * m_verticesPerPrimitive;
3247e5c31af7Sopenharmony_ci
3248e5c31af7Sopenharmony_ci			m_device->cmdWriteTimestamp(*m_cmdBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, *timestampStartQueryPool, queryStartIndex);
3249e5c31af7Sopenharmony_ci			{
3250e5c31af7Sopenharmony_ci				m_device->cmdDraw(*m_cmdBuffer, m_verticesPerPrimitive, 1u, firstVertex, 0u);
3251e5c31af7Sopenharmony_ci
3252e5c31af7Sopenharmony_ci				// Render occluded object
3253e5c31af7Sopenharmony_ci				m_device->cmdBeginQuery(*m_cmdBuffer, *occlusionQueryPool, queryStartIndex, m_occlusionQueryFlags);
3254e5c31af7Sopenharmony_ci				m_device->cmdDraw(*m_cmdBuffer, m_verticesPerPrimitive, 1u, m_occlusionObjectsOffset + firstVertex, 0u);
3255e5c31af7Sopenharmony_ci				m_device->cmdEndQuery(*m_cmdBuffer, *occlusionQueryPool, queryStartIndex);
3256e5c31af7Sopenharmony_ci
3257e5c31af7Sopenharmony_ci				for (deUint32 viewMaskNdx = 0; viewMaskNdx < queryCountersToUse; ++viewMaskNdx)
3258e5c31af7Sopenharmony_ci				{
3259e5c31af7Sopenharmony_ci					m_occlusionExpectedValues.push_back(m_occlusionObjectPixelsCount[primitiveNumber]);
3260e5c31af7Sopenharmony_ci					m_counterSeriesStart.push_back(viewMaskNdx == 0);
3261e5c31af7Sopenharmony_ci					m_counterSeriesEnd.push_back(viewMaskNdx + 1 == queryCountersToUse);
3262e5c31af7Sopenharmony_ci				}
3263e5c31af7Sopenharmony_ci			}
3264e5c31af7Sopenharmony_ci			m_device->cmdWriteTimestamp(*m_cmdBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, *timestampEndQueryPool, queryStartIndex);
3265e5c31af7Sopenharmony_ci
3266e5c31af7Sopenharmony_ci			queryStartIndex += queryCountersToUse;
3267e5c31af7Sopenharmony_ci		}
3268e5c31af7Sopenharmony_ci
3269e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
3270e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
3271e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
3272e5c31af7Sopenharmony_ci		else
3273e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
3274e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
3275e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
3276e5c31af7Sopenharmony_ci	}
3277e5c31af7Sopenharmony_ci
3278e5c31af7Sopenharmony_ci	DE_ASSERT(queryStartIndex == queryCountersNumber);
3279e5c31af7Sopenharmony_ci
3280e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
3281e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
3282e5c31af7Sopenharmony_ci
3283e5c31af7Sopenharmony_ci	afterRenderPass();
3284e5c31af7Sopenharmony_ci
3285e5c31af7Sopenharmony_ci	if (m_cmdCopyQueryPoolResults)
3286e5c31af7Sopenharmony_ci		m_device->cmdCopyQueryPoolResults(*m_cmdBuffer, *occlusionQueryPool, 0u, queryCountersNumber, *queryBuffer, 0u, queryStride, queryFlags);
3287e5c31af7Sopenharmony_ci
3288e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
3289e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
3290e5c31af7Sopenharmony_ci
3291e5c31af7Sopenharmony_ci	// These vectors will temporarily hold results.
3292e5c31af7Sopenharmony_ci	std::vector<uint64_t>	occlusionQueryResultsBuffer			(valuesNumber, 0u);
3293e5c31af7Sopenharmony_ci	std::vector<uint64_t>	timestampStartQueryResultsBuffer	(valuesNumber, 0u);
3294e5c31af7Sopenharmony_ci	std::vector<uint64_t>	timestampEndQueryResultsBuffer		(valuesNumber, 0u);
3295e5c31af7Sopenharmony_ci
3296e5c31af7Sopenharmony_ci	m_occlusionValues.resize(queryCountersNumber);
3297e5c31af7Sopenharmony_ci	m_timestampStartValues.resize(queryCountersNumber);
3298e5c31af7Sopenharmony_ci	m_timestampEndValues.resize(queryCountersNumber);
3299e5c31af7Sopenharmony_ci
3300e5c31af7Sopenharmony_ci	if (withAvailability)
3301e5c31af7Sopenharmony_ci	{
3302e5c31af7Sopenharmony_ci		m_occlusionAvailabilityValues.resize(queryCountersNumber);
3303e5c31af7Sopenharmony_ci		m_timestampStartAvailabilityValues.resize(queryCountersNumber);
3304e5c31af7Sopenharmony_ci		m_timestampEndAvailabilityValues.resize(queryCountersNumber);
3305e5c31af7Sopenharmony_ci	}
3306e5c31af7Sopenharmony_ci
3307e5c31af7Sopenharmony_ci	if (m_cmdCopyQueryPoolResults)
3308e5c31af7Sopenharmony_ci	{
3309e5c31af7Sopenharmony_ci		memcpy(occlusionQueryResultsBuffer.data(), queryBuffer.getAllocation().getHostPtr(), de::dataSize(occlusionQueryResultsBuffer));
3310e5c31af7Sopenharmony_ci		memcpy(timestampStartQueryResultsBuffer.data(), queryBuffer.getAllocation().getHostPtr(), de::dataSize(timestampStartQueryResultsBuffer));
3311e5c31af7Sopenharmony_ci		memcpy(timestampEndQueryResultsBuffer.data(), queryBuffer.getAllocation().getHostPtr(), de::dataSize(timestampEndQueryResultsBuffer));
3312e5c31af7Sopenharmony_ci	}
3313e5c31af7Sopenharmony_ci	else
3314e5c31af7Sopenharmony_ci	{
3315e5c31af7Sopenharmony_ci		m_device->getQueryPoolResults(*m_logicalDevice, *occlusionQueryPool, 0u, queryCountersNumber, de::dataSize(occlusionQueryResultsBuffer), de::dataOrNull(occlusionQueryResultsBuffer), queryStride, queryFlags);
3316e5c31af7Sopenharmony_ci		m_device->getQueryPoolResults(*m_logicalDevice, *timestampStartQueryPool, 0u, queryCountersNumber, de::dataSize(timestampStartQueryResultsBuffer), de::dataOrNull(timestampStartQueryResultsBuffer), queryStride, queryFlags);
3317e5c31af7Sopenharmony_ci		m_device->getQueryPoolResults(*m_logicalDevice, *timestampEndQueryPool, 0u, queryCountersNumber, de::dataSize(timestampEndQueryResultsBuffer), de::dataOrNull(timestampEndQueryResultsBuffer), queryStride, queryFlags);
3318e5c31af7Sopenharmony_ci	}
3319e5c31af7Sopenharmony_ci
3320e5c31af7Sopenharmony_ci	unpackValues(occlusionQueryResultsBuffer, &m_occlusionValues, (withAvailability ? &m_occlusionAvailabilityValues : nullptr));
3321e5c31af7Sopenharmony_ci	unpackValues(timestampStartQueryResultsBuffer, &m_timestampStartValues, (withAvailability ? &m_timestampStartAvailabilityValues : nullptr));
3322e5c31af7Sopenharmony_ci	unpackValues(timestampEndQueryResultsBuffer, &m_timestampEndValues, (withAvailability ? &m_timestampEndAvailabilityValues : nullptr));
3323e5c31af7Sopenharmony_ci
3324e5c31af7Sopenharmony_ci	for (deUint32 ndx = 0; ndx < m_timestampStartValues.size(); ++ndx)
3325e5c31af7Sopenharmony_ci		m_timestampStartValues[ndx] &= m_timestampMask;
3326e5c31af7Sopenharmony_ci
3327e5c31af7Sopenharmony_ci	for (deUint32 ndx = 0; ndx < m_timestampEndValues.size(); ++ndx)
3328e5c31af7Sopenharmony_ci		m_timestampEndValues[ndx] &= m_timestampMask;
3329e5c31af7Sopenharmony_ci}
3330e5c31af7Sopenharmony_ci
3331e5c31af7Sopenharmony_cideUint32 MultiViewQueriesTestInstance::getUsedViewsCount (const deUint32 viewMaskIndex)
3332e5c31af7Sopenharmony_ci{
3333e5c31af7Sopenharmony_ci	deUint32 result = 0;
3334e5c31af7Sopenharmony_ci
3335e5c31af7Sopenharmony_ci	for (deUint32 viewMask = m_parameters.viewMasks[viewMaskIndex]; viewMask != 0; viewMask >>= 1)
3336e5c31af7Sopenharmony_ci		if ((viewMask & 1) != 0)
3337e5c31af7Sopenharmony_ci			result++;
3338e5c31af7Sopenharmony_ci
3339e5c31af7Sopenharmony_ci	return result;
3340e5c31af7Sopenharmony_ci}
3341e5c31af7Sopenharmony_ci
3342e5c31af7Sopenharmony_cideUint32 MultiViewQueriesTestInstance::getQueryCountersNumber ()
3343e5c31af7Sopenharmony_ci{
3344e5c31af7Sopenharmony_ci	deUint32 result = 0;
3345e5c31af7Sopenharmony_ci
3346e5c31af7Sopenharmony_ci	for (deUint32 i = 0; i < m_parameters.viewMasks.size(); ++i)
3347e5c31af7Sopenharmony_ci		result += getUsedViewsCount(i);
3348e5c31af7Sopenharmony_ci
3349e5c31af7Sopenharmony_ci	return result;
3350e5c31af7Sopenharmony_ci}
3351e5c31af7Sopenharmony_ci
3352e5c31af7Sopenharmony_ciclass MultiViewReadbackTestInstance : public MultiViewRenderTestInstance
3353e5c31af7Sopenharmony_ci{
3354e5c31af7Sopenharmony_cipublic:
3355e5c31af7Sopenharmony_ci						MultiViewReadbackTestInstance	(Context& context, const TestParameters& parameters);
3356e5c31af7Sopenharmony_ciprotected:
3357e5c31af7Sopenharmony_ci	tcu::TestStatus		iterate							(void);
3358e5c31af7Sopenharmony_ci	void				drawClears						(const deUint32				subpassCount,
3359e5c31af7Sopenharmony_ci														 VkRenderPass				renderPass,
3360e5c31af7Sopenharmony_ci														 VkFramebuffer				frameBuffer,
3361e5c31af7Sopenharmony_ci														 vector<PipelineSp>&		pipelines,
3362e5c31af7Sopenharmony_ci														 const bool					clearPass);
3363e5c31af7Sopenharmony_ci	void				clear							(const VkCommandBuffer		commandBuffer,
3364e5c31af7Sopenharmony_ci														 const VkRect2D&			clearRect2D,
3365e5c31af7Sopenharmony_ci														 const tcu::Vec4&			clearColor);
3366e5c31af7Sopenharmony_ciprivate:
3367e5c31af7Sopenharmony_ci	vector<VkRect2D>	m_quarters;
3368e5c31af7Sopenharmony_ci};
3369e5c31af7Sopenharmony_ci
3370e5c31af7Sopenharmony_ciMultiViewReadbackTestInstance::MultiViewReadbackTestInstance (Context& context, const TestParameters& parameters)
3371e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
3372e5c31af7Sopenharmony_ci{
3373e5c31af7Sopenharmony_ci	const deUint32 halfWidth	= m_parameters.extent.width / 2;
3374e5c31af7Sopenharmony_ci	const deUint32 halfHeight	= m_parameters.extent.height / 2;
3375e5c31af7Sopenharmony_ci
3376e5c31af7Sopenharmony_ci	for (deInt32 x = 0; x < 2; ++x)
3377e5c31af7Sopenharmony_ci	for (deInt32 y = 0; y < 2; ++y)
3378e5c31af7Sopenharmony_ci	{
3379e5c31af7Sopenharmony_ci		const deInt32	offsetX	= static_cast<deInt32>(halfWidth) * x;
3380e5c31af7Sopenharmony_ci		const deInt32	offsetY	= static_cast<deInt32>(halfHeight) * y;
3381e5c31af7Sopenharmony_ci		const VkRect2D	area	= { { offsetX, offsetY}, {halfWidth, halfHeight} };
3382e5c31af7Sopenharmony_ci
3383e5c31af7Sopenharmony_ci		m_quarters.push_back(area);
3384e5c31af7Sopenharmony_ci	}
3385e5c31af7Sopenharmony_ci}
3386e5c31af7Sopenharmony_ci
3387e5c31af7Sopenharmony_citcu::TestStatus MultiViewReadbackTestInstance::iterate (void)
3388e5c31af7Sopenharmony_ci{
3389e5c31af7Sopenharmony_ci	const deUint32	subpassCount	= static_cast<deUint32>(m_parameters.viewMasks.size());
3390e5c31af7Sopenharmony_ci
3391e5c31af7Sopenharmony_ci	createCommandBuffer();
3392e5c31af7Sopenharmony_ci
3393e5c31af7Sopenharmony_ci	for (deUint32 pass = 0; pass < 2; ++pass)
3394e5c31af7Sopenharmony_ci	{
3395e5c31af7Sopenharmony_ci		const bool									fullClearPass	= (pass == 0);
3396e5c31af7Sopenharmony_ci		const VkAttachmentLoadOp					loadOp			= (!fullClearPass) ? VK_ATTACHMENT_LOAD_OP_LOAD :
3397e5c31af7Sopenharmony_ci																	  (m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR) ? VK_ATTACHMENT_LOAD_OP_CLEAR :
3398e5c31af7Sopenharmony_ci																	  (m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR) ? VK_ATTACHMENT_LOAD_OP_DONT_CARE :
3399e5c31af7Sopenharmony_ci																	  VK_ATTACHMENT_LOAD_OP_DONT_CARE;
3400e5c31af7Sopenharmony_ci		Move<VkRenderPass>							renderPass;
3401e5c31af7Sopenharmony_ci		Move<VkFramebuffer>							frameBuffer;
3402e5c31af7Sopenharmony_ci		Unique<VkPipelineLayout>					pipelineLayout	(makePipelineLayout(*m_device, *m_logicalDevice));
3403e5c31af7Sopenharmony_ci		vector<PipelineSp>							pipelines		(subpassCount);
3404e5c31af7Sopenharmony_ci		map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
3405e5c31af7Sopenharmony_ci
3406e5c31af7Sopenharmony_ci		if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
3407e5c31af7Sopenharmony_ci		{
3408e5c31af7Sopenharmony_ci			renderPass	= makeRenderPass (*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_parameters.renderingType, VK_SAMPLE_COUNT_1_BIT, loadOp);
3409e5c31af7Sopenharmony_ci			frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, m_colorAttachment->getImageView(), m_parameters.extent.width, m_parameters.extent.height);
3410e5c31af7Sopenharmony_ci		}
3411e5c31af7Sopenharmony_ci
3412e5c31af7Sopenharmony_ci		{
3413e5c31af7Sopenharmony_ci			vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
3414e5c31af7Sopenharmony_ci			madeShaderModule(shaderModule, shaderStageParams);
3415e5c31af7Sopenharmony_ci			for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
3416e5c31af7Sopenharmony_ci				pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(*renderPass, *pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(), subpassNdx))));
3417e5c31af7Sopenharmony_ci		}
3418e5c31af7Sopenharmony_ci
3419e5c31af7Sopenharmony_ci		drawClears(subpassCount, *renderPass, *frameBuffer, pipelines, fullClearPass);
3420e5c31af7Sopenharmony_ci	}
3421e5c31af7Sopenharmony_ci
3422e5c31af7Sopenharmony_ci	{
3423e5c31af7Sopenharmony_ci		vector<deUint8>			pixelAccessData	(m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * mapVkFormat(m_parameters.colorFormat).getPixelSize());
3424e5c31af7Sopenharmony_ci		tcu::PixelBufferAccess	dst				(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth, pixelAccessData.data());
3425e5c31af7Sopenharmony_ci
3426e5c31af7Sopenharmony_ci		readImage(m_colorAttachment->getImage(), dst);
3427e5c31af7Sopenharmony_ci
3428e5c31af7Sopenharmony_ci		if (!checkImage(dst))
3429e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
3430e5c31af7Sopenharmony_ci	}
3431e5c31af7Sopenharmony_ci
3432e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
3433e5c31af7Sopenharmony_ci}
3434e5c31af7Sopenharmony_ci
3435e5c31af7Sopenharmony_civoid MultiViewReadbackTestInstance::drawClears (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines, const bool clearPass)
3436e5c31af7Sopenharmony_ci{
3437e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
3438e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(m_colorTable[0]);
3439e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
3440e5c31af7Sopenharmony_ci	const bool						withClearColor			= (clearPass && m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR);
3441e5c31af7Sopenharmony_ci
3442e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
3443e5c31af7Sopenharmony_ci
3444e5c31af7Sopenharmony_ci	if (clearPass)
3445e5c31af7Sopenharmony_ci		beforeRenderPass();
3446e5c31af7Sopenharmony_ci
3447e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
3448e5c31af7Sopenharmony_ci	{
3449e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
3450e5c31af7Sopenharmony_ci		{
3451e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,			//  VkStructureType		sType;
3452e5c31af7Sopenharmony_ci			DE_NULL,											//  const void*			pNext;
3453e5c31af7Sopenharmony_ci			renderPass,											//  VkRenderPass		renderPass;
3454e5c31af7Sopenharmony_ci			frameBuffer,										//  VkFramebuffer		framebuffer;
3455e5c31af7Sopenharmony_ci			renderArea,											//  VkRect2D			renderArea;
3456e5c31af7Sopenharmony_ci			withClearColor ? 1u : 0u,							//  uint32_t			clearValueCount;
3457e5c31af7Sopenharmony_ci			withClearColor ? &renderPassClearValue : DE_NULL,	//  const VkClearValue*	pClearValues;
3458e5c31af7Sopenharmony_ci		};
3459e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
3460e5c31af7Sopenharmony_ci	}
3461e5c31af7Sopenharmony_ci
3462e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
3463e5c31af7Sopenharmony_ci	{
3464e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
3465e5c31af7Sopenharmony_ci
3466e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
3467e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
3468e5c31af7Sopenharmony_ci		{
3469e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
3470e5c31af7Sopenharmony_ci
3471e5c31af7Sopenharmony_ci			VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_LOAD;
3472e5c31af7Sopenharmony_ci			if (clearPass)
3473e5c31af7Sopenharmony_ci			{
3474e5c31af7Sopenharmony_ci				if (m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR)
3475e5c31af7Sopenharmony_ci					loadOperation = VK_ATTACHMENT_LOAD_OP_CLEAR;
3476e5c31af7Sopenharmony_ci				else if (m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR)
3477e5c31af7Sopenharmony_ci					loadOperation = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
3478e5c31af7Sopenharmony_ci				else
3479e5c31af7Sopenharmony_ci					loadOperation = VK_ATTACHMENT_LOAD_OP_MAX_ENUM;
3480e5c31af7Sopenharmony_ci			}
3481e5c31af7Sopenharmony_ci
3482e5c31af7Sopenharmony_ci			beginRendering(
3483e5c31af7Sopenharmony_ci				*m_device,
3484e5c31af7Sopenharmony_ci				*m_cmdBuffer,
3485e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),
3486e5c31af7Sopenharmony_ci				renderArea,
3487e5c31af7Sopenharmony_ci				renderPassClearValue,
3488e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
3489e5c31af7Sopenharmony_ci				loadOperation,
3490e5c31af7Sopenharmony_ci				0u,
3491e5c31af7Sopenharmony_ci				m_parameters.extent.depth,
3492e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx]);
3493e5c31af7Sopenharmony_ci		}
3494e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
3495e5c31af7Sopenharmony_ci
3496e5c31af7Sopenharmony_ci		if (clearPass)
3497e5c31af7Sopenharmony_ci		{
3498e5c31af7Sopenharmony_ci			if (m_parameters.viewIndex == TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR)
3499e5c31af7Sopenharmony_ci				clear(*m_cmdBuffer, renderArea, m_colorTable[subpassNdx % 4]);
3500e5c31af7Sopenharmony_ci		}
3501e5c31af7Sopenharmony_ci		else
3502e5c31af7Sopenharmony_ci		{
3503e5c31af7Sopenharmony_ci			for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
3504e5c31af7Sopenharmony_ci			{
3505e5c31af7Sopenharmony_ci				const deUint32 primitiveNumber	= drawNdx + subpassNdx % m_squareCount;
3506e5c31af7Sopenharmony_ci
3507e5c31af7Sopenharmony_ci				clear(*m_cmdBuffer, m_quarters[primitiveNumber], m_colorTable[4 + primitiveNumber]);
3508e5c31af7Sopenharmony_ci			}
3509e5c31af7Sopenharmony_ci		}
3510e5c31af7Sopenharmony_ci
3511e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
3512e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
3513e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
3514e5c31af7Sopenharmony_ci		else
3515e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
3516e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
3517e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
3518e5c31af7Sopenharmony_ci	}
3519e5c31af7Sopenharmony_ci
3520e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
3521e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
3522e5c31af7Sopenharmony_ci
3523e5c31af7Sopenharmony_ci	if (!clearPass)
3524e5c31af7Sopenharmony_ci		afterRenderPass();
3525e5c31af7Sopenharmony_ci
3526e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
3527e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
3528e5c31af7Sopenharmony_ci}
3529e5c31af7Sopenharmony_ci
3530e5c31af7Sopenharmony_civoid MultiViewReadbackTestInstance::clear (const VkCommandBuffer commandBuffer, const VkRect2D& clearRect2D, const tcu::Vec4& clearColor)
3531e5c31af7Sopenharmony_ci{
3532e5c31af7Sopenharmony_ci	const VkClearRect		clearRect		=
3533e5c31af7Sopenharmony_ci	{
3534e5c31af7Sopenharmony_ci		clearRect2D,						//  VkRect2D	rect
3535e5c31af7Sopenharmony_ci		0u,									//  deUint32	baseArrayLayer
3536e5c31af7Sopenharmony_ci		1u,									//  deUint32	layerCount
3537e5c31af7Sopenharmony_ci	};
3538e5c31af7Sopenharmony_ci	const VkClearAttachment	clearAttachment	=
3539e5c31af7Sopenharmony_ci	{
3540e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_COLOR_BIT,			//  VkImageAspectFlags	aspectMask
3541e5c31af7Sopenharmony_ci		0u,									//  deUint32			colorAttachment
3542e5c31af7Sopenharmony_ci		makeClearValueColor(clearColor)		//  VkClearValue		clearValue
3543e5c31af7Sopenharmony_ci	};
3544e5c31af7Sopenharmony_ci
3545e5c31af7Sopenharmony_ci	m_device->cmdClearAttachments(commandBuffer, 1u, &clearAttachment, 1u, &clearRect);
3546e5c31af7Sopenharmony_ci}
3547e5c31af7Sopenharmony_ci
3548e5c31af7Sopenharmony_ciclass MultiViewDepthStencilTestInstance : public MultiViewRenderTestInstance
3549e5c31af7Sopenharmony_ci{
3550e5c31af7Sopenharmony_cipublic:
3551e5c31af7Sopenharmony_ci									MultiViewDepthStencilTestInstance	(Context& context, const TestParameters& parameters);
3552e5c31af7Sopenharmony_ciprotected:
3553e5c31af7Sopenharmony_ci	tcu::TestStatus					iterate								(void) override;
3554e5c31af7Sopenharmony_ci	void							createVertexData					(void) override;
3555e5c31af7Sopenharmony_ci
3556e5c31af7Sopenharmony_ci	void							draw								(const deUint32					subpassCount,
3557e5c31af7Sopenharmony_ci																		 VkRenderPass					renderPass,
3558e5c31af7Sopenharmony_ci																		 VkFramebuffer					frameBuffer,
3559e5c31af7Sopenharmony_ci																		 vector<PipelineSp>&			pipelines) override;
3560e5c31af7Sopenharmony_ci	void							beforeRenderPass							(void) override;
3561e5c31af7Sopenharmony_ci	void							afterRenderPass							(void) override;
3562e5c31af7Sopenharmony_ci	vector<VkImageView>				makeAttachmentsVector				(void);
3563e5c31af7Sopenharmony_ci	MovePtr<tcu::Texture2DArray>	imageData							(void) const override;
3564e5c31af7Sopenharmony_ci	void							readImage							(VkImage						image,
3565e5c31af7Sopenharmony_ci																		 const tcu::PixelBufferAccess&	dst);
3566e5c31af7Sopenharmony_ci	vector<tcu::Vec2>				getDepthRanges						(void) const;
3567e5c31af7Sopenharmony_ci
3568e5c31af7Sopenharmony_ciprivate:
3569e5c31af7Sopenharmony_ci	VkFormat						m_dsFormat;
3570e5c31af7Sopenharmony_ci	de::SharedPtr<ImageAttachment>	m_dsAttachment;
3571e5c31af7Sopenharmony_ci	bool							m_depthTest;
3572e5c31af7Sopenharmony_ci	bool							m_stencilTest;
3573e5c31af7Sopenharmony_ci};
3574e5c31af7Sopenharmony_ci
3575e5c31af7Sopenharmony_ciMultiViewDepthStencilTestInstance::MultiViewDepthStencilTestInstance (Context& context, const TestParameters& parameters)
3576e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
3577e5c31af7Sopenharmony_ci	, m_dsFormat					(VK_FORMAT_UNDEFINED)
3578e5c31af7Sopenharmony_ci	, m_depthTest					(m_parameters.viewIndex == TEST_TYPE_DEPTH ||
3579e5c31af7Sopenharmony_ci									 m_parameters.viewIndex == TEST_TYPE_DEPTH_DIFFERENT_RANGES)
3580e5c31af7Sopenharmony_ci	, m_stencilTest					(m_parameters.viewIndex == TEST_TYPE_STENCIL)
3581e5c31af7Sopenharmony_ci{
3582e5c31af7Sopenharmony_ci	const VkFormat formats[] = { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT };
3583e5c31af7Sopenharmony_ci
3584e5c31af7Sopenharmony_ci	for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(formats); ++ndx)
3585e5c31af7Sopenharmony_ci	{
3586e5c31af7Sopenharmony_ci		const VkFormat				format				= formats[ndx];
3587e5c31af7Sopenharmony_ci		const auto&					vki					= m_context.getInstanceInterface();
3588e5c31af7Sopenharmony_ci		const auto					physicalDevice		= m_context.getPhysicalDevice();
3589e5c31af7Sopenharmony_ci		const VkFormatProperties	formatProperties	= getPhysicalDeviceFormatProperties(vki, physicalDevice, format);
3590e5c31af7Sopenharmony_ci
3591e5c31af7Sopenharmony_ci		if ((formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
3592e5c31af7Sopenharmony_ci		{
3593e5c31af7Sopenharmony_ci			m_dsFormat = format;
3594e5c31af7Sopenharmony_ci
3595e5c31af7Sopenharmony_ci			break;
3596e5c31af7Sopenharmony_ci		}
3597e5c31af7Sopenharmony_ci	}
3598e5c31af7Sopenharmony_ci
3599e5c31af7Sopenharmony_ci	if (m_dsFormat == VK_FORMAT_UNDEFINED)
3600e5c31af7Sopenharmony_ci		TCU_FAIL("Supported depth/stencil format not found, that violates specification");
3601e5c31af7Sopenharmony_ci
3602e5c31af7Sopenharmony_ci	// Depth/stencil attachment
3603e5c31af7Sopenharmony_ci	m_dsAttachment = de::SharedPtr<ImageAttachment>(new ImageAttachment(*m_logicalDevice, *m_device, *m_allocator, m_parameters.extent, m_dsFormat));
3604e5c31af7Sopenharmony_ci}
3605e5c31af7Sopenharmony_ci
3606e5c31af7Sopenharmony_civector<VkImageView>	MultiViewDepthStencilTestInstance::makeAttachmentsVector (void)
3607e5c31af7Sopenharmony_ci{
3608e5c31af7Sopenharmony_ci	vector<VkImageView> attachments;
3609e5c31af7Sopenharmony_ci
3610e5c31af7Sopenharmony_ci	attachments.push_back(m_colorAttachment->getImageView());
3611e5c31af7Sopenharmony_ci	attachments.push_back(m_dsAttachment->getImageView());
3612e5c31af7Sopenharmony_ci
3613e5c31af7Sopenharmony_ci	return attachments;
3614e5c31af7Sopenharmony_ci}
3615e5c31af7Sopenharmony_ci
3616e5c31af7Sopenharmony_ciMovePtr<tcu::Texture2DArray> MultiViewDepthStencilTestInstance::imageData(void) const
3617e5c31af7Sopenharmony_ci{
3618e5c31af7Sopenharmony_ci	MovePtr<tcu::Texture2DArray>	referenceFrame		= MovePtr<tcu::Texture2DArray>(new tcu::Texture2DArray(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth));
3619e5c31af7Sopenharmony_ci	const deUint32					subpassCount		= static_cast<deUint32>(m_parameters.viewMasks.size());
3620e5c31af7Sopenharmony_ci	const vector<tcu::Vec2>			depthRanges			= getDepthRanges();
3621e5c31af7Sopenharmony_ci
3622e5c31af7Sopenharmony_ci	referenceFrame->allocLevel(0);
3623e5c31af7Sopenharmony_ci	deMemset(referenceFrame->getLevel(0).getDataPtr(), 0, m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth* mapVkFormat(m_parameters.colorFormat).getPixelSize());
3624e5c31af7Sopenharmony_ci
3625e5c31af7Sopenharmony_ci	for (deUint32 layerNdx = 0; layerNdx < m_parameters.extent.depth; ++layerNdx)
3626e5c31af7Sopenharmony_ci		fillLayer(referenceFrame->getLevel(0), getQuarterRefColor(0u, 0u, 0u, false), layerNdx);
3627e5c31af7Sopenharmony_ci
3628e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
3629e5c31af7Sopenharmony_ci	{
3630e5c31af7Sopenharmony_ci		int					layerNdx			= 0;
3631e5c31af7Sopenharmony_ci		deUint32			mask				= m_parameters.viewMasks[subpassNdx];
3632e5c31af7Sopenharmony_ci		const tcu::Vec2&	depthRange			= depthRanges[subpassNdx];
3633e5c31af7Sopenharmony_ci		const float			depthMin			= depthRange[0];
3634e5c31af7Sopenharmony_ci		const float			depthMax			= depthRange[1];
3635e5c31af7Sopenharmony_ci
3636e5c31af7Sopenharmony_ci		// iterate over image layers
3637e5c31af7Sopenharmony_ci		while (mask > 0u)
3638e5c31af7Sopenharmony_ci		{
3639e5c31af7Sopenharmony_ci			if (mask & 1u)
3640e5c31af7Sopenharmony_ci			{
3641e5c31af7Sopenharmony_ci				const deUint32	subpassQuarterNdx	= subpassNdx % m_squareCount;
3642e5c31af7Sopenharmony_ci				const int		colorNdx			= subpassQuarterNdx * 4;
3643e5c31af7Sopenharmony_ci				tcu::Vec4		color				= getQuarterRefColor(subpassQuarterNdx, colorNdx, layerNdx, true, subpassNdx);
3644e5c31af7Sopenharmony_ci
3645e5c31af7Sopenharmony_ci				if (m_parameters.viewIndex == TEST_TYPE_DEPTH_DIFFERENT_RANGES)
3646e5c31af7Sopenharmony_ci				{
3647e5c31af7Sopenharmony_ci					// quads with depth out of range should be cliiped
3648e5c31af7Sopenharmony_ci					// to simplify code we are drawing them with background color
3649e5c31af7Sopenharmony_ci					if ((color.x() < 0.0f) || (color.x() > 1.0f))
3650e5c31af7Sopenharmony_ci						color.x() = 1.0f;
3651e5c31af7Sopenharmony_ci					else
3652e5c31af7Sopenharmony_ci					{
3653e5c31af7Sopenharmony_ci						const float depthClamped = de::clamp(color.x(), 0.0f, 1.0f);
3654e5c31af7Sopenharmony_ci						color.x() = depthClamped * depthMax + (1.0f - depthClamped) * depthMin;
3655e5c31af7Sopenharmony_ci					}
3656e5c31af7Sopenharmony_ci				}
3657e5c31af7Sopenharmony_ci
3658e5c31af7Sopenharmony_ci				fillQuarter(referenceFrame->getLevel(0), color, layerNdx, subpassQuarterNdx, subpassNdx);
3659e5c31af7Sopenharmony_ci			}
3660e5c31af7Sopenharmony_ci
3661e5c31af7Sopenharmony_ci			mask = mask >> 1;
3662e5c31af7Sopenharmony_ci			++layerNdx;
3663e5c31af7Sopenharmony_ci		}
3664e5c31af7Sopenharmony_ci	}
3665e5c31af7Sopenharmony_ci	return referenceFrame;
3666e5c31af7Sopenharmony_ci}
3667e5c31af7Sopenharmony_ci
3668e5c31af7Sopenharmony_civoid MultiViewDepthStencilTestInstance::readImage (VkImage image, const tcu::PixelBufferAccess& dst)
3669e5c31af7Sopenharmony_ci{
3670e5c31af7Sopenharmony_ci	const VkFormat				bufferFormat	= m_depthTest ? getDepthBufferFormat(m_dsFormat) :
3671e5c31af7Sopenharmony_ci												  m_stencilTest ? getStencilBufferFormat(m_dsFormat) :
3672e5c31af7Sopenharmony_ci												  VK_FORMAT_UNDEFINED;
3673e5c31af7Sopenharmony_ci	const deUint32				imagePixelSize	= static_cast<deUint32>(tcu::getPixelSize(mapVkFormat(bufferFormat)));
3674e5c31af7Sopenharmony_ci	const VkDeviceSize			pixelDataSize	= dst.getWidth() * dst.getHeight() * dst.getDepth() * imagePixelSize;
3675e5c31af7Sopenharmony_ci	const tcu::TextureFormat	tcuBufferFormat	= mapVkFormat(bufferFormat);
3676e5c31af7Sopenharmony_ci	Move<VkBuffer>				buffer;
3677e5c31af7Sopenharmony_ci	MovePtr<Allocation>			bufferAlloc;
3678e5c31af7Sopenharmony_ci
3679e5c31af7Sopenharmony_ci	// Create destination buffer
3680e5c31af7Sopenharmony_ci	{
3681e5c31af7Sopenharmony_ci		const VkBufferCreateInfo bufferParams	=
3682e5c31af7Sopenharmony_ci		{
3683e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,	// VkStructureType		sType;
3684e5c31af7Sopenharmony_ci			DE_NULL,								// const void*			pNext;
3685e5c31af7Sopenharmony_ci			0u,										// VkBufferCreateFlags	flags;
3686e5c31af7Sopenharmony_ci			pixelDataSize,							// VkDeviceSize			size;
3687e5c31af7Sopenharmony_ci			VK_BUFFER_USAGE_TRANSFER_DST_BIT,		// VkBufferUsageFlags	usage;
3688e5c31af7Sopenharmony_ci			VK_SHARING_MODE_EXCLUSIVE,				// VkSharingMode		sharingMode;
3689e5c31af7Sopenharmony_ci			1u,										// deUint32				queueFamilyIndexCount;
3690e5c31af7Sopenharmony_ci			&m_queueFamilyIndex,					// const deUint32*		pQueueFamilyIndices;
3691e5c31af7Sopenharmony_ci		};
3692e5c31af7Sopenharmony_ci
3693e5c31af7Sopenharmony_ci		buffer		= createBuffer(*m_device, *m_logicalDevice, &bufferParams);
3694e5c31af7Sopenharmony_ci		bufferAlloc	= m_allocator->allocate(getBufferMemoryRequirements(*m_device, *m_logicalDevice, *buffer), MemoryRequirement::HostVisible);
3695e5c31af7Sopenharmony_ci		VK_CHECK(m_device->bindBufferMemory(*m_logicalDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
3696e5c31af7Sopenharmony_ci
3697e5c31af7Sopenharmony_ci		deMemset(bufferAlloc->getHostPtr(), 0xCC, static_cast<size_t>(pixelDataSize));
3698e5c31af7Sopenharmony_ci		flushAlloc(*m_device, *m_logicalDevice, *bufferAlloc);
3699e5c31af7Sopenharmony_ci	}
3700e5c31af7Sopenharmony_ci
3701e5c31af7Sopenharmony_ci	const VkBufferMemoryBarrier	bufferBarrier	=
3702e5c31af7Sopenharmony_ci	{
3703e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,	// VkStructureType	sType;
3704e5c31af7Sopenharmony_ci		DE_NULL,									// const void*		pNext;
3705e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT,				// VkAccessFlags	srcAccessMask;
3706e5c31af7Sopenharmony_ci		VK_ACCESS_HOST_READ_BIT,					// VkAccessFlags	dstAccessMask;
3707e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,					// deUint32			srcQueueFamilyIndex;
3708e5c31af7Sopenharmony_ci		VK_QUEUE_FAMILY_IGNORED,					// deUint32			dstQueueFamilyIndex;
3709e5c31af7Sopenharmony_ci		*buffer,									// VkBuffer			buffer;
3710e5c31af7Sopenharmony_ci		0u,											// VkDeviceSize		offset;
3711e5c31af7Sopenharmony_ci		pixelDataSize								// VkDeviceSize		size;
3712e5c31af7Sopenharmony_ci	};
3713e5c31af7Sopenharmony_ci
3714e5c31af7Sopenharmony_ci	// Copy image to buffer
3715e5c31af7Sopenharmony_ci	const VkImageAspectFlags	aspect			= m_depthTest ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_DEPTH_BIT) :
3716e5c31af7Sopenharmony_ci												  m_stencilTest ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_STENCIL_BIT) :
3717e5c31af7Sopenharmony_ci												  static_cast<VkImageAspectFlags>(0u);
3718e5c31af7Sopenharmony_ci	const VkBufferImageCopy		copyRegion		=
3719e5c31af7Sopenharmony_ci	{
3720e5c31af7Sopenharmony_ci		0u,											// VkDeviceSize				bufferOffset;
3721e5c31af7Sopenharmony_ci		(deUint32)dst.getWidth(),					// deUint32					bufferRowLength;
3722e5c31af7Sopenharmony_ci		(deUint32)dst.getHeight(),					// deUint32					bufferImageHeight;
3723e5c31af7Sopenharmony_ci		{
3724e5c31af7Sopenharmony_ci			aspect,									// VkImageAspectFlags		aspect;
3725e5c31af7Sopenharmony_ci			0u,										// deUint32					mipLevel;
3726e5c31af7Sopenharmony_ci			0u,										// deUint32					baseArrayLayer;
3727e5c31af7Sopenharmony_ci			m_parameters.extent.depth,				// deUint32					layerCount;
3728e5c31af7Sopenharmony_ci		},											// VkImageSubresourceLayers	imageSubresource;
3729e5c31af7Sopenharmony_ci		{ 0, 0, 0 },								// VkOffset3D				imageOffset;
3730e5c31af7Sopenharmony_ci		{											// VkExtent3D				imageExtent;
3731e5c31af7Sopenharmony_ci			m_parameters.extent.width,
3732e5c31af7Sopenharmony_ci			m_parameters.extent.height,
3733e5c31af7Sopenharmony_ci			1u
3734e5c31af7Sopenharmony_ci		}
3735e5c31af7Sopenharmony_ci	};
3736e5c31af7Sopenharmony_ci
3737e5c31af7Sopenharmony_ci	beginCommandBuffer (*m_device, *m_cmdBuffer);
3738e5c31af7Sopenharmony_ci	{
3739e5c31af7Sopenharmony_ci		m_device->cmdCopyImageToBuffer(*m_cmdBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, &copyRegion);
3740e5c31af7Sopenharmony_ci		m_device->cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0u, DE_NULL);
3741e5c31af7Sopenharmony_ci	}
3742e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
3743e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
3744e5c31af7Sopenharmony_ci
3745e5c31af7Sopenharmony_ci	// Read buffer data
3746e5c31af7Sopenharmony_ci	invalidateAlloc(*m_device, *m_logicalDevice, *bufferAlloc);
3747e5c31af7Sopenharmony_ci
3748e5c31af7Sopenharmony_ci	if (m_depthTest)
3749e5c31af7Sopenharmony_ci	{
3750e5c31af7Sopenharmony_ci		// Translate depth into color space
3751e5c31af7Sopenharmony_ci		tcu::ConstPixelBufferAccess	pixelBuffer	(tcuBufferFormat, dst.getSize(), bufferAlloc->getHostPtr());
3752e5c31af7Sopenharmony_ci
3753e5c31af7Sopenharmony_ci		for (int z = 0; z < pixelBuffer.getDepth(); z++)
3754e5c31af7Sopenharmony_ci		for (int y = 0; y < pixelBuffer.getHeight(); y++)
3755e5c31af7Sopenharmony_ci		for (int x = 0; x < pixelBuffer.getWidth(); x++)
3756e5c31af7Sopenharmony_ci		{
3757e5c31af7Sopenharmony_ci			const float		depth	= pixelBuffer.getPixDepth(x, y, z);
3758e5c31af7Sopenharmony_ci			const tcu::Vec4	color	= tcu::Vec4(depth, 0.0f, 0.0f, 1.0f);
3759e5c31af7Sopenharmony_ci
3760e5c31af7Sopenharmony_ci			dst.setPixel(color, x, y, z);
3761e5c31af7Sopenharmony_ci		}
3762e5c31af7Sopenharmony_ci	}
3763e5c31af7Sopenharmony_ci
3764e5c31af7Sopenharmony_ci	if (m_stencilTest)
3765e5c31af7Sopenharmony_ci	{
3766e5c31af7Sopenharmony_ci		// Translate stencil into color space
3767e5c31af7Sopenharmony_ci		tcu::ConstPixelBufferAccess	pixelBuffer	(tcuBufferFormat, dst.getSize(), bufferAlloc->getHostPtr());
3768e5c31af7Sopenharmony_ci		const tcu::Vec4				baseColor		= getQuarterRefColor(0u, 0u, 0u, false);
3769e5c31af7Sopenharmony_ci		const tcu::Vec4				colorStep		= getQuarterRefColor(0u, 0u, 0u, true);
3770e5c31af7Sopenharmony_ci		const tcu::Vec4				colorMap[4]		=
3771e5c31af7Sopenharmony_ci		{
3772e5c31af7Sopenharmony_ci			baseColor,
3773e5c31af7Sopenharmony_ci			tcu::Vec4(1.0f * colorStep[0], 0.0f, 0.0f, 1.0),
3774e5c31af7Sopenharmony_ci			tcu::Vec4(2.0f * colorStep[0], 0.0f, 0.0f, 1.0),
3775e5c31af7Sopenharmony_ci			tcu::Vec4(3.0f * colorStep[0], 0.0f, 0.0f, 1.0),
3776e5c31af7Sopenharmony_ci		};
3777e5c31af7Sopenharmony_ci		const tcu::Vec4				invalidColor	= tcu::Vec4(0.0f);
3778e5c31af7Sopenharmony_ci
3779e5c31af7Sopenharmony_ci		for (int z = 0; z < pixelBuffer.getDepth(); z++)
3780e5c31af7Sopenharmony_ci		for (int y = 0; y < pixelBuffer.getHeight(); y++)
3781e5c31af7Sopenharmony_ci		for (int x = 0; x < pixelBuffer.getWidth(); x++)
3782e5c31af7Sopenharmony_ci		{
3783e5c31af7Sopenharmony_ci			const int			stencilInt	= pixelBuffer.getPixStencil(x, y, z);
3784e5c31af7Sopenharmony_ci			const tcu::Vec4&	color		= de::inRange(stencilInt, 0, DE_LENGTH_OF_ARRAY(colorMap)) ? colorMap[stencilInt] : invalidColor;
3785e5c31af7Sopenharmony_ci
3786e5c31af7Sopenharmony_ci			dst.setPixel(color, x, y, z);
3787e5c31af7Sopenharmony_ci		}
3788e5c31af7Sopenharmony_ci	}
3789e5c31af7Sopenharmony_ci}
3790e5c31af7Sopenharmony_ci
3791e5c31af7Sopenharmony_citcu::TestStatus MultiViewDepthStencilTestInstance::iterate (void)
3792e5c31af7Sopenharmony_ci{
3793e5c31af7Sopenharmony_ci	const deUint32								subpassCount	= static_cast<deUint32>(m_parameters.viewMasks.size());
3794e5c31af7Sopenharmony_ci	Move<VkRenderPass>							renderPass;
3795e5c31af7Sopenharmony_ci	vector<VkImageView>							attachments		(makeAttachmentsVector());
3796e5c31af7Sopenharmony_ci	Move<VkFramebuffer>							frameBuffer;
3797e5c31af7Sopenharmony_ci	Unique<VkPipelineLayout>					pipelineLayout	(makePipelineLayout(*m_device, *m_logicalDevice));
3798e5c31af7Sopenharmony_ci	vector<PipelineSp>							pipelines		(subpassCount);
3799e5c31af7Sopenharmony_ci	const vector<tcu::Vec2>						depthRanges		(getDepthRanges());
3800e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
3801e5c31af7Sopenharmony_ci
3802e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
3803e5c31af7Sopenharmony_ci	{
3804e5c31af7Sopenharmony_ci		renderPass	= makeRenderPassWithDepth(*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_dsFormat, m_parameters.renderingType);
3805e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, static_cast<deUint32>(attachments.size()), attachments.data(), m_parameters.extent.width, m_parameters.extent.height, 1u);
3806e5c31af7Sopenharmony_ci	}
3807e5c31af7Sopenharmony_ci
3808e5c31af7Sopenharmony_ci	if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
3809e5c31af7Sopenharmony_ci	{
3810e5c31af7Sopenharmony_ci		renderPass	= makeRenderPassWithDepth(*m_device, *m_logicalDevice, m_parameters.colorFormat, m_parameters.viewMasks, m_dsFormat, m_parameters.renderingType);
3811e5c31af7Sopenharmony_ci		frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, static_cast<deUint32>(attachments.size()), attachments.data(), m_parameters.extent.width, m_parameters.extent.height, 1u);
3812e5c31af7Sopenharmony_ci	}
3813e5c31af7Sopenharmony_ci
3814e5c31af7Sopenharmony_ci	{
3815e5c31af7Sopenharmony_ci		vector<VkPipelineShaderStageCreateInfo>	shaderStageParams;
3816e5c31af7Sopenharmony_ci		madeShaderModule(shaderModule, shaderStageParams);
3817e5c31af7Sopenharmony_ci		for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
3818e5c31af7Sopenharmony_ci		{
3819e5c31af7Sopenharmony_ci			const tcu::Vec2& depthRange = depthRanges[subpassNdx];
3820e5c31af7Sopenharmony_ci			const float depthMin		= depthRange[0];
3821e5c31af7Sopenharmony_ci			const float depthMax		= depthRange[1];
3822e5c31af7Sopenharmony_ci
3823e5c31af7Sopenharmony_ci			pipelines[subpassNdx] = (PipelineSp(new Unique<VkPipeline>(makeGraphicsPipeline(
3824e5c31af7Sopenharmony_ci				*renderPass, *pipelineLayout, static_cast<deUint32>(shaderStageParams.size()), shaderStageParams.data(),
3825e5c31af7Sopenharmony_ci				subpassNdx, VK_VERTEX_INPUT_RATE_VERTEX, m_depthTest, m_stencilTest, depthMin, depthMax, m_dsFormat))));
3826e5c31af7Sopenharmony_ci		}
3827e5c31af7Sopenharmony_ci	}
3828e5c31af7Sopenharmony_ci
3829e5c31af7Sopenharmony_ci	createCommandBuffer();
3830e5c31af7Sopenharmony_ci	createVertexData();
3831e5c31af7Sopenharmony_ci	createVertexBuffer();
3832e5c31af7Sopenharmony_ci
3833e5c31af7Sopenharmony_ci	draw(subpassCount, *renderPass, *frameBuffer, pipelines);
3834e5c31af7Sopenharmony_ci
3835e5c31af7Sopenharmony_ci	{
3836e5c31af7Sopenharmony_ci		vector<deUint8>			pixelAccessData	(m_parameters.extent.width * m_parameters.extent.height * m_parameters.extent.depth * mapVkFormat(m_parameters.colorFormat).getPixelSize());
3837e5c31af7Sopenharmony_ci		tcu::PixelBufferAccess	dst				(mapVkFormat(m_parameters.colorFormat), m_parameters.extent.width, m_parameters.extent.height, m_parameters.extent.depth, pixelAccessData.data());
3838e5c31af7Sopenharmony_ci
3839e5c31af7Sopenharmony_ci		readImage(m_dsAttachment->getImage(), dst);
3840e5c31af7Sopenharmony_ci
3841e5c31af7Sopenharmony_ci		if (!checkImage(dst))
3842e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
3843e5c31af7Sopenharmony_ci	}
3844e5c31af7Sopenharmony_ci
3845e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
3846e5c31af7Sopenharmony_ci}
3847e5c31af7Sopenharmony_ci
3848e5c31af7Sopenharmony_civoid MultiViewDepthStencilTestInstance::createVertexData (void)
3849e5c31af7Sopenharmony_ci{
3850e5c31af7Sopenharmony_ci/*
3851e5c31af7Sopenharmony_ci	partA - draw vertical quads, marked with 1
3852e5c31af7Sopenharmony_ci
3853e5c31af7Sopenharmony_ci	ViewMasks
3854e5c31af7Sopenharmony_ci	0011
3855e5c31af7Sopenharmony_ci	0110
3856e5c31af7Sopenharmony_ci	1100
3857e5c31af7Sopenharmony_ci	1001
3858e5c31af7Sopenharmony_ci
3859e5c31af7Sopenharmony_ci	Layer3  Layer2  Layer1  Layer0
3860e5c31af7Sopenharmony_ci	  ^       ^       ^       ^
3861e5c31af7Sopenharmony_ci	00|10   00|10   01|00   01|00
3862e5c31af7Sopenharmony_ci	00|10   00|10   01|00   01|00
3863e5c31af7Sopenharmony_ci	--+-->  --+-->  --+-->  --+-->
3864e5c31af7Sopenharmony_ci	00|10   01|00   01|00   00|10
3865e5c31af7Sopenharmony_ci	00|10   01|00   01|00   00|10
3866e5c31af7Sopenharmony_ci
3867e5c31af7Sopenharmony_ci
3868e5c31af7Sopenharmony_ci	partB - draw horizontal quads, marked with 2
3869e5c31af7Sopenharmony_ci
3870e5c31af7Sopenharmony_ci	ViewMasks
3871e5c31af7Sopenharmony_ci	0110
3872e5c31af7Sopenharmony_ci	1100
3873e5c31af7Sopenharmony_ci	1001
3874e5c31af7Sopenharmony_ci	0011
3875e5c31af7Sopenharmony_ci
3876e5c31af7Sopenharmony_ci	Layer3  Layer2  Layer1  Layer0
3877e5c31af7Sopenharmony_ci	  ^       ^       ^       ^
3878e5c31af7Sopenharmony_ci	00|00   00|00   00|00   00|00
3879e5c31af7Sopenharmony_ci	00|22   22|00   22|00   00|22
3880e5c31af7Sopenharmony_ci	--+-->  --+-->  --+-->  --+-->
3881e5c31af7Sopenharmony_ci	22|00   22|00   00|22   00|22
3882e5c31af7Sopenharmony_ci	00|00   00|00   00|00   00|00
3883e5c31af7Sopenharmony_ci
3884e5c31af7Sopenharmony_ci
3885e5c31af7Sopenharmony_ci	Final - after drawing quads from partA and partB (3 marks where quads overlap)
3886e5c31af7Sopenharmony_ci
3887e5c31af7Sopenharmony_ci	Layer3  Layer2  Layer1  Layer0
3888e5c31af7Sopenharmony_ci	  ^       ^       ^       ^
3889e5c31af7Sopenharmony_ci	00|10   00|10   01|00   01|00
3890e5c31af7Sopenharmony_ci	00|32   22|10   23|00   01|22
3891e5c31af7Sopenharmony_ci	--+-->  --+-->  --+-->  --+-->
3892e5c31af7Sopenharmony_ci	22|10   23|00   01|22   00|32
3893e5c31af7Sopenharmony_ci	00|10   01|00   01|00   00|10
3894e5c31af7Sopenharmony_ci*/
3895e5c31af7Sopenharmony_ci	tcu::Vec4	color	(0.0f, 0.0f, 0.0f, 1.0f); // is not essential in this test
3896e5c31af7Sopenharmony_ci	float		depth	(getQuarterRefColor(0u, 0u, 0u, true, 0u)[0]);
3897e5c31af7Sopenharmony_ci
3898e5c31af7Sopenharmony_ci	// part A - four horizontal quads
3899e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f,-0.5f, depth, 1.0f), color);		// when testing TEST_TYPE_DEPTH_DIFFERENT_RANGES
3900e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, depth, 1.0f), color);		// this quad will have depth 1.2
3901e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-0.5f, depth, 1.0f), color);		// and will be clipped in all views
3902e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3903e5c31af7Sopenharmony_ci
3904e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 1u)[0];
3905e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.0f, depth, 1.0f), color);
3906e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-1.0f, 0.5f, depth, 1.0f), color);
3907e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3908e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.5f, depth, 1.0f), color);
3909e5c31af7Sopenharmony_ci
3910e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 2u)[0];
3911e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-0.5f, depth, 1.0f), color);
3912e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3913e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f,-0.5f, depth, 1.0f), color);
3914e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, depth, 1.0f), color);
3915e5c31af7Sopenharmony_ci
3916e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 3u)[0];
3917e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3918e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.5f, depth, 1.0f), color);
3919e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.0f, depth, 1.0f), color);
3920e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 1.0f, 0.5f, depth, 1.0f), color);
3921e5c31af7Sopenharmony_ci
3922e5c31af7Sopenharmony_ci	// part B - four vertical quads
3923e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 4u)[0];
3924e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-0.5f,-1.0f, depth, 1.0f), color);
3925e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-0.5f, 0.0f, depth, 1.0f), color);
3926e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, depth, 1.0f), color);
3927e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3928e5c31af7Sopenharmony_ci
3929e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 5u)[0];
3930e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-0.5f, 0.0f, depth, 1.0f), color);
3931e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4(-0.5f, 1.0f, depth, 1.0f), color);
3932e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3933e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, depth, 1.0f), color);
3934e5c31af7Sopenharmony_ci
3935e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 6u)[0];
3936e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f,-1.0f, depth, 1.0f), color);
3937e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);
3938e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.5f,-1.0f, depth, 1.0f), color);
3939e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.5f, 0.0f, depth, 1.0f), color);
3940e5c31af7Sopenharmony_ci
3941e5c31af7Sopenharmony_ci	depth = getQuarterRefColor(0u, 0u, 0u, true, 7u)[0];			// when testing TEST_TYPE_DEPTH_DIFFERENT_RANGES
3942e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 0.0f, depth, 1.0f), color);		// this quad will have depth -0.05
3943e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.0f, 1.0f, depth, 1.0f), color);		// and will be clipped in all views
3944e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.5f, 0.0f, depth, 1.0f), color);
3945e5c31af7Sopenharmony_ci	appendVertex(tcu::Vec4( 0.5f, 1.0f, depth, 1.0f), color);
3946e5c31af7Sopenharmony_ci}
3947e5c31af7Sopenharmony_ci
3948e5c31af7Sopenharmony_civector<tcu::Vec2> MultiViewDepthStencilTestInstance::getDepthRanges(void) const
3949e5c31af7Sopenharmony_ci{
3950e5c31af7Sopenharmony_ci	if (TEST_TYPE_DEPTH_DIFFERENT_RANGES == m_parameters.viewIndex)
3951e5c31af7Sopenharmony_ci	{
3952e5c31af7Sopenharmony_ci		DE_ASSERT(m_parameters.viewMasks.size() == 12);
3953e5c31af7Sopenharmony_ci		return
3954e5c31af7Sopenharmony_ci		{
3955e5c31af7Sopenharmony_ci			// ranges used when four quads from part A are drawn
3956e5c31af7Sopenharmony_ci			{0.0f, 1.0f},
3957e5c31af7Sopenharmony_ci			{0.5f, 1.0f},
3958e5c31af7Sopenharmony_ci			{0.0f, 0.5f},
3959e5c31af7Sopenharmony_ci			{0.0f, 1.0f},
3960e5c31af7Sopenharmony_ci
3961e5c31af7Sopenharmony_ci			// ranges used when four quads from part B are drawn
3962e5c31af7Sopenharmony_ci			{0.0f, 0.5f},
3963e5c31af7Sopenharmony_ci			{0.0f, 1.0f},
3964e5c31af7Sopenharmony_ci			{0.5f, 1.0f},
3965e5c31af7Sopenharmony_ci			{0.0f, 0.5f},
3966e5c31af7Sopenharmony_ci
3967e5c31af7Sopenharmony_ci			// ranges used when part B is drawn once again
3968e5c31af7Sopenharmony_ci			{0.5f, 1.0f},
3969e5c31af7Sopenharmony_ci			{0.0f, 0.5f},
3970e5c31af7Sopenharmony_ci			{0.0f, 0.5f},
3971e5c31af7Sopenharmony_ci			{0.0f, 1.0f},
3972e5c31af7Sopenharmony_ci		};
3973e5c31af7Sopenharmony_ci	}
3974e5c31af7Sopenharmony_ci
3975e5c31af7Sopenharmony_ci	// by defaul use <0; 1> range for all subpasses
3976e5c31af7Sopenharmony_ci	return { m_parameters.viewMasks.size(), tcu::Vec2(0.0f, 1.0f) };
3977e5c31af7Sopenharmony_ci}
3978e5c31af7Sopenharmony_ci
3979e5c31af7Sopenharmony_civoid MultiViewDepthStencilTestInstance::draw (const deUint32 subpassCount, VkRenderPass renderPass, VkFramebuffer frameBuffer, vector<PipelineSp>& pipelines)
3980e5c31af7Sopenharmony_ci{
3981e5c31af7Sopenharmony_ci	const VkRect2D					renderArea				= { { 0, 0 }, { m_parameters.extent.width, m_parameters.extent.height } };
3982e5c31af7Sopenharmony_ci	const VkClearValue				renderPassClearValue	= makeClearValueColor(tcu::Vec4(0.0f));
3983e5c31af7Sopenharmony_ci	const VkBuffer					vertexBuffers[]			= { *m_vertexCoordBuffer, *m_vertexColorBuffer };
3984e5c31af7Sopenharmony_ci	const VkDeviceSize				vertexBufferOffsets[]	= {                   0u,                   0u };
3985e5c31af7Sopenharmony_ci	const deUint32					drawCountPerSubpass		= (subpassCount == 1) ? m_squareCount : 1u;
3986e5c31af7Sopenharmony_ci	const deUint32					vertexPerPrimitive		= 4u;
3987e5c31af7Sopenharmony_ci
3988e5c31af7Sopenharmony_ci	beginCommandBuffer(*m_device, *m_cmdBuffer);
3989e5c31af7Sopenharmony_ci
3990e5c31af7Sopenharmony_ci	beforeRenderPass();
3991e5c31af7Sopenharmony_ci
3992e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
3993e5c31af7Sopenharmony_ci	{
3994e5c31af7Sopenharmony_ci		const VkRenderPassBeginInfo renderPassBeginInfo
3995e5c31af7Sopenharmony_ci		{
3996e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
3997e5c31af7Sopenharmony_ci			DE_NULL,									// const void*			pNext;
3998e5c31af7Sopenharmony_ci			renderPass,									// VkRenderPass			renderPass;
3999e5c31af7Sopenharmony_ci			frameBuffer,								// VkFramebuffer		framebuffer;
4000e5c31af7Sopenharmony_ci			renderArea,									// VkRect2D				renderArea;
4001e5c31af7Sopenharmony_ci			1u,											// uint32_t				clearValueCount;
4002e5c31af7Sopenharmony_ci			&renderPassClearValue,						// const VkClearValue*	pClearValues;
4003e5c31af7Sopenharmony_ci		};
4004e5c31af7Sopenharmony_ci		cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
4005e5c31af7Sopenharmony_ci	}
4006e5c31af7Sopenharmony_ci
4007e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
4008e5c31af7Sopenharmony_ci	{
4009e5c31af7Sopenharmony_ci		deUint32 firstVertexOffset = (subpassNdx < 4) ? 0u : m_squareCount * vertexPerPrimitive;
4010e5c31af7Sopenharmony_ci
4011e5c31af7Sopenharmony_ci		m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
4012e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **pipelines[subpassNdx]);
4013e5c31af7Sopenharmony_ci
4014e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4015e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
4016e5c31af7Sopenharmony_ci		{
4017e5c31af7Sopenharmony_ci			addRenderingSubpassDependencyIfRequired(subpassNdx);
4018e5c31af7Sopenharmony_ci
4019e5c31af7Sopenharmony_ci			VkRenderingAttachmentInfoKHR colorAttachment
4020e5c31af7Sopenharmony_ci			{
4021e5c31af7Sopenharmony_ci				vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,	// VkStructureType						sType;
4022e5c31af7Sopenharmony_ci				DE_NULL,												// const void*							pNext;
4023e5c31af7Sopenharmony_ci				m_colorAttachment->getImageView(),						// VkImageView							imageView;
4024e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,				// VkImageLayout						imageLayout;
4025e5c31af7Sopenharmony_ci				VK_RESOLVE_MODE_NONE,									// VkResolveModeFlagBits				resolveMode;
4026e5c31af7Sopenharmony_ci				DE_NULL,												// VkImageView							resolveImageView;
4027e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_UNDEFINED,								// VkImageLayout						resolveImageLayout;
4028e5c31af7Sopenharmony_ci				VK_ATTACHMENT_LOAD_OP_LOAD,								// VkAttachmentLoadOp					loadOp;
4029e5c31af7Sopenharmony_ci				vk::VK_ATTACHMENT_STORE_OP_STORE,						// VkAttachmentStoreOp					storeOp;
4030e5c31af7Sopenharmony_ci				renderPassClearValue									// VkClearValue							clearValue;
4031e5c31af7Sopenharmony_ci			};
4032e5c31af7Sopenharmony_ci
4033e5c31af7Sopenharmony_ci			VkRenderingAttachmentInfoKHR dsAttachment
4034e5c31af7Sopenharmony_ci			{
4035e5c31af7Sopenharmony_ci				VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,		// VkStructureType						sType;
4036e5c31af7Sopenharmony_ci				DE_NULL,												// const void*							pNext;
4037e5c31af7Sopenharmony_ci				m_dsAttachment->getImageView(),							// VkImageView							imageView;
4038e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,		// VkImageLayout						imageLayout;
4039e5c31af7Sopenharmony_ci				VK_RESOLVE_MODE_NONE,									// VkResolveModeFlagBits				resolveMode;
4040e5c31af7Sopenharmony_ci				DE_NULL,												// VkImageView							resolveImageView;
4041e5c31af7Sopenharmony_ci				VK_IMAGE_LAYOUT_UNDEFINED,								// VkImageLayout						resolveImageLayout;
4042e5c31af7Sopenharmony_ci				VK_ATTACHMENT_LOAD_OP_LOAD,								// VkAttachmentLoadOp					loadOp;
4043e5c31af7Sopenharmony_ci				VK_ATTACHMENT_STORE_OP_STORE,							// VkAttachmentStoreOp					storeOp;
4044e5c31af7Sopenharmony_ci				makeClearValueDepthStencil(0.0f, 0)						// VkClearValue							clearValue;
4045e5c31af7Sopenharmony_ci			};
4046e5c31af7Sopenharmony_ci
4047e5c31af7Sopenharmony_ci			vk::VkRenderingInfoKHR renderingInfo
4048e5c31af7Sopenharmony_ci			{
4049e5c31af7Sopenharmony_ci				vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
4050e5c31af7Sopenharmony_ci				DE_NULL,
4051e5c31af7Sopenharmony_ci				0u,														// VkRenderingFlagsKHR					flags;
4052e5c31af7Sopenharmony_ci				renderArea,												// VkRect2D								renderArea;
4053e5c31af7Sopenharmony_ci				m_parameters.extent.depth,								// deUint32								layerCount;
4054e5c31af7Sopenharmony_ci				m_parameters.viewMasks[subpassNdx],						// deUint32								viewMask;
4055e5c31af7Sopenharmony_ci				1u,														// deUint32								colorAttachmentCount;
4056e5c31af7Sopenharmony_ci				&colorAttachment,										// const VkRenderingAttachmentInfoKHR*	pColorAttachments;
4057e5c31af7Sopenharmony_ci				(m_depthTest ? &dsAttachment : DE_NULL),				// const VkRenderingAttachmentInfoKHR*	pDepthAttachment;
4058e5c31af7Sopenharmony_ci				(m_stencilTest ? &dsAttachment : DE_NULL),				// const VkRenderingAttachmentInfoKHR*	pStencilAttachment;
4059e5c31af7Sopenharmony_ci			};
4060e5c31af7Sopenharmony_ci
4061e5c31af7Sopenharmony_ci			m_device->cmdBeginRendering(*m_cmdBuffer, &renderingInfo);
4062e5c31af7Sopenharmony_ci		}
4063e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4064e5c31af7Sopenharmony_ci
4065e5c31af7Sopenharmony_ci		for (deUint32 drawNdx = 0u; drawNdx < drawCountPerSubpass; ++drawNdx)
4066e5c31af7Sopenharmony_ci			m_device->cmdDraw(*m_cmdBuffer, vertexPerPrimitive, 1u, firstVertexOffset + (drawNdx + subpassNdx % m_squareCount) * vertexPerPrimitive, 0u);
4067e5c31af7Sopenharmony_ci
4068e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4069e5c31af7Sopenharmony_ci		if (m_useDynamicRendering)
4070e5c31af7Sopenharmony_ci			endRendering(*m_device, *m_cmdBuffer);
4071e5c31af7Sopenharmony_ci		else
4072e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4073e5c31af7Sopenharmony_ci			if (subpassNdx < subpassCount - 1u)
4074e5c31af7Sopenharmony_ci			cmdNextSubpass(*m_device, *m_cmdBuffer, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
4075e5c31af7Sopenharmony_ci	}
4076e5c31af7Sopenharmony_ci
4077e5c31af7Sopenharmony_ci	if (!m_useDynamicRendering)
4078e5c31af7Sopenharmony_ci		cmdEndRenderPass(*m_device, *m_cmdBuffer, m_parameters.renderingType);
4079e5c31af7Sopenharmony_ci
4080e5c31af7Sopenharmony_ci	afterRenderPass();
4081e5c31af7Sopenharmony_ci
4082e5c31af7Sopenharmony_ci	VK_CHECK(m_device->endCommandBuffer(*m_cmdBuffer));
4083e5c31af7Sopenharmony_ci	submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, *m_cmdBuffer);
4084e5c31af7Sopenharmony_ci}
4085e5c31af7Sopenharmony_ci
4086e5c31af7Sopenharmony_civoid MultiViewDepthStencilTestInstance::beforeRenderPass (void)
4087e5c31af7Sopenharmony_ci{
4088e5c31af7Sopenharmony_ci	MultiViewRenderTestInstance::beforeRenderPass();
4089e5c31af7Sopenharmony_ci
4090e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	subresourceRange		=
4091e5c31af7Sopenharmony_ci	{
4092e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT,	//VkImageAspectFlags	aspectMask;
4093e5c31af7Sopenharmony_ci		0u,															//deUint32				baseMipLevel;
4094e5c31af7Sopenharmony_ci		1u,															//deUint32				levelCount;
4095e5c31af7Sopenharmony_ci		0u,															//deUint32				baseArrayLayer;
4096e5c31af7Sopenharmony_ci		m_parameters.extent.depth,									//deUint32				layerCount;
4097e5c31af7Sopenharmony_ci	};
4098e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_dsAttachment->getImage(), subresourceRange,
4099e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
4100e5c31af7Sopenharmony_ci		0, VK_ACCESS_TRANSFER_WRITE_BIT,
4101e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
4102e5c31af7Sopenharmony_ci
4103e5c31af7Sopenharmony_ci	const tcu::Vec4		baseColor	= getQuarterRefColor(0u, 0u, 0u, false);
4104e5c31af7Sopenharmony_ci	const float			clearDepth	= baseColor[0];
4105e5c31af7Sopenharmony_ci	const VkClearValue	clearValue	= makeClearValueDepthStencil(clearDepth, 0);
4106e5c31af7Sopenharmony_ci
4107e5c31af7Sopenharmony_ci	m_device->cmdClearDepthStencilImage(*m_cmdBuffer, m_dsAttachment->getImage(),  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearValue.depthStencil, 1, &subresourceRange);
4108e5c31af7Sopenharmony_ci
4109e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_dsAttachment->getImage(), subresourceRange,
4110e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
4111e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
4112e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
4113e5c31af7Sopenharmony_ci}
4114e5c31af7Sopenharmony_ci
4115e5c31af7Sopenharmony_civoid MultiViewDepthStencilTestInstance::afterRenderPass (void)
4116e5c31af7Sopenharmony_ci{
4117e5c31af7Sopenharmony_ci	MultiViewRenderTestInstance::afterRenderPass();
4118e5c31af7Sopenharmony_ci
4119e5c31af7Sopenharmony_ci	const VkImageSubresourceRange	dsSubresourceRange		=
4120e5c31af7Sopenharmony_ci	{
4121e5c31af7Sopenharmony_ci		VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT,	//  VkImageAspectFlags	aspectMask;
4122e5c31af7Sopenharmony_ci		0u,															//  deUint32			baseMipLevel;
4123e5c31af7Sopenharmony_ci		1u,															//  deUint32			levelCount;
4124e5c31af7Sopenharmony_ci		0u,															//  deUint32			baseArrayLayer;
4125e5c31af7Sopenharmony_ci		m_parameters.extent.depth,									//  deUint32			layerCount;
4126e5c31af7Sopenharmony_ci	};
4127e5c31af7Sopenharmony_ci
4128e5c31af7Sopenharmony_ci	imageBarrier(*m_device, *m_cmdBuffer, m_dsAttachment->getImage(), dsSubresourceRange,
4129e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4130e5c31af7Sopenharmony_ci		VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT,
4131e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
4132e5c31af7Sopenharmony_ci}
4133e5c31af7Sopenharmony_ci
4134e5c31af7Sopenharmony_ciclass MultiViewMaskIterationTestInstance : public MultiViewRenderTestInstance
4135e5c31af7Sopenharmony_ci{
4136e5c31af7Sopenharmony_cipublic:
4137e5c31af7Sopenharmony_ci	MultiViewMaskIterationTestInstance	(Context& context, const TestParameters& parameters);
4138e5c31af7Sopenharmony_ciprotected:
4139e5c31af7Sopenharmony_ci	void								beforeRender	(const VkCommandBuffer cmdBuffer);
4140e5c31af7Sopenharmony_ci	void								afterRender		(const VkCommandBuffer cmdBuffer);
4141e5c31af7Sopenharmony_ci	tcu::TestStatus						iterate			(void) override;
4142e5c31af7Sopenharmony_ci
4143e5c31af7Sopenharmony_ci	using ImageWithBufferPtr = std::unique_ptr<ImageWithBuffer>;
4144e5c31af7Sopenharmony_ci	ImageWithBufferPtr					m_colorImage;
4145e5c31af7Sopenharmony_ci	tcu::IVec3							m_dim;
4146e5c31af7Sopenharmony_ci	uint32_t							m_layerCount;
4147e5c31af7Sopenharmony_ci	VkImageSubresourceRange				m_colorSRR;
4148e5c31af7Sopenharmony_ci	VkClearValue						m_clearValue;
4149e5c31af7Sopenharmony_ci};
4150e5c31af7Sopenharmony_ci
4151e5c31af7Sopenharmony_ciMultiViewMaskIterationTestInstance::MultiViewMaskIterationTestInstance (Context& context, const TestParameters& parameters)
4152e5c31af7Sopenharmony_ci	: MultiViewRenderTestInstance	(context, parameters)
4153e5c31af7Sopenharmony_ci{
4154e5c31af7Sopenharmony_ci	m_dim					=	tcu::IVec3(m_parameters.extent.width, m_parameters.extent.height, 1);
4155e5c31af7Sopenharmony_ci	m_layerCount			=	m_parameters.extent.depth;
4156e5c31af7Sopenharmony_ci	const auto	colorUsage	=	(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT);
4157e5c31af7Sopenharmony_ci	m_colorSRR				=	makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, m_layerCount);
4158e5c31af7Sopenharmony_ci	m_colorImage			=	ImageWithBufferPtr (new ImageWithBuffer(*m_device, *m_logicalDevice, *m_allocator, makeExtent3D(m_dim), m_parameters.colorFormat, colorUsage, VK_IMAGE_TYPE_2D, m_colorSRR, m_layerCount));
4159e5c31af7Sopenharmony_ci	m_clearValue			=	makeClearValueColor(tcu::Vec4(0));
4160e5c31af7Sopenharmony_ci}
4161e5c31af7Sopenharmony_ci
4162e5c31af7Sopenharmony_ci
4163e5c31af7Sopenharmony_civoid MultiViewMaskIterationTestInstance::beforeRender (const VkCommandBuffer cmdBuffer)
4164e5c31af7Sopenharmony_ci{
4165e5c31af7Sopenharmony_ci	imageBarrier(*m_device, cmdBuffer, m_colorImage->getImage(), m_colorSRR,
4166e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
4167e5c31af7Sopenharmony_ci		0, VK_ACCESS_TRANSFER_WRITE_BIT,
4168e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
4169e5c31af7Sopenharmony_ci
4170e5c31af7Sopenharmony_ci
4171e5c31af7Sopenharmony_ci	m_device->cmdClearColorImage(cmdBuffer, m_colorImage->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_clearValue.color, 1u, &m_colorSRR);
4172e5c31af7Sopenharmony_ci
4173e5c31af7Sopenharmony_ci	imageBarrier(*m_device, cmdBuffer, m_colorImage->getImage(), m_colorSRR,
4174e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4175e5c31af7Sopenharmony_ci		VK_ACCESS_TRANSFER_WRITE_BIT, (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT),
4176e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
4177e5c31af7Sopenharmony_ci}
4178e5c31af7Sopenharmony_ci
4179e5c31af7Sopenharmony_civoid MultiViewMaskIterationTestInstance::afterRender (const VkCommandBuffer cmdBuffer)
4180e5c31af7Sopenharmony_ci{
4181e5c31af7Sopenharmony_ci	imageBarrier(*m_device, cmdBuffer, m_colorImage->getImage(), m_colorSRR,
4182e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4183e5c31af7Sopenharmony_ci		(VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT), VK_ACCESS_TRANSFER_READ_BIT,
4184e5c31af7Sopenharmony_ci		VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
4185e5c31af7Sopenharmony_ci}
4186e5c31af7Sopenharmony_ci
4187e5c31af7Sopenharmony_citcu::TestStatus MultiViewMaskIterationTestInstance::iterate (void)
4188e5c31af7Sopenharmony_ci{
4189e5c31af7Sopenharmony_ci	bool			failure			=	false;
4190e5c31af7Sopenharmony_ci	const deUint32	subpassCount	=	static_cast<deUint32>(m_parameters.viewMasks.size());
4191e5c31af7Sopenharmony_ci	const auto		fbExtent		=	makeExtent3D(m_dim);
4192e5c31af7Sopenharmony_ci	const auto		colorSRL		=	makeImageSubresourceLayers(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, m_layerCount);
4193e5c31af7Sopenharmony_ci
4194e5c31af7Sopenharmony_ci	map<VkShaderStageFlagBits, ShaderModuleSP>	shaderModule;
4195e5c31af7Sopenharmony_ci	vector<VkPipelineShaderStageCreateInfo>		shaderStageParams;
4196e5c31af7Sopenharmony_ci	madeShaderModule(shaderModule, shaderStageParams);
4197e5c31af7Sopenharmony_ci	const VkShaderModule vertexShaderModule = shaderModule[VK_SHADER_STAGE_VERTEX_BIT]->get();
4198e5c31af7Sopenharmony_ci	const VkShaderModule fragShaderModule	= shaderModule[VK_SHADER_STAGE_FRAGMENT_BIT]->get();
4199e5c31af7Sopenharmony_ci
4200e5c31af7Sopenharmony_ci	const std::vector<VkViewport>	viewports	(1u, makeViewport(fbExtent));
4201e5c31af7Sopenharmony_ci	const std::vector<VkRect2D>		scissors	(1u, makeRect2D(fbExtent));
4202e5c31af7Sopenharmony_ci	const auto pipelineLayout		= makePipelineLayout(*m_device, *m_logicalDevice, VK_NULL_HANDLE);
4203e5c31af7Sopenharmony_ci
4204e5c31af7Sopenharmony_ci	const auto colorBlendAttState	= makePipelineColorBlendAttachmentState(VK_FALSE, VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD, VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD, (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT));
4205e5c31af7Sopenharmony_ci
4206e5c31af7Sopenharmony_ci	const VkPipelineVertexInputStateCreateInfo	vertexInputStateCreateInfo	= initVulkanStructure();
4207e5c31af7Sopenharmony_ci
4208e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4209e5c31af7Sopenharmony_ci	VkRenderingAttachmentInfoKHR renderingAttInfo =
4210e5c31af7Sopenharmony_ci	{
4211e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,//	VkStructureType			sType;
4212e5c31af7Sopenharmony_ci		nullptr,										//	const void*				pNext;
4213e5c31af7Sopenharmony_ci		m_colorImage->getImageView(),					//	VkImageView				imageView;
4214e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,		//	VkImageLayout			imageLayout;
4215e5c31af7Sopenharmony_ci		VK_RESOLVE_MODE_NONE,							//	VkResolveModeFlagBits	resolveMode;
4216e5c31af7Sopenharmony_ci		VK_NULL_HANDLE,									//	VkImageView				resolveImageView;
4217e5c31af7Sopenharmony_ci		VK_IMAGE_LAYOUT_UNDEFINED,						//	VkImageLayout			resolveImageLayout;
4218e5c31af7Sopenharmony_ci		VK_ATTACHMENT_LOAD_OP_LOAD,						//	VkAttachmentLoadOp		loadOp;
4219e5c31af7Sopenharmony_ci		VK_ATTACHMENT_STORE_OP_STORE,					//	VkAttachmentStoreOp		storeOp;
4220e5c31af7Sopenharmony_ci		m_clearValue,									//	VkClearValue			clearValue;
4221e5c31af7Sopenharmony_ci	};
4222e5c31af7Sopenharmony_ci#endif
4223e5c31af7Sopenharmony_ci
4224e5c31af7Sopenharmony_ci	for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; ++subpassNdx)
4225e5c31af7Sopenharmony_ci	{
4226e5c31af7Sopenharmony_ci		const auto			layerMask	= m_parameters.viewMasks[subpassNdx];
4227e5c31af7Sopenharmony_ci		Move<VkRenderPass>	renderPass;
4228e5c31af7Sopenharmony_ci		Move<VkFramebuffer>	frameBuffer;
4229e5c31af7Sopenharmony_ci
4230e5c31af7Sopenharmony_ci		// FrameBuffer & renderPass
4231e5c31af7Sopenharmony_ci		if (m_parameters.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
4232e5c31af7Sopenharmony_ci		{
4233e5c31af7Sopenharmony_ci			const std::vector<deUint32> layerMasks (1u, layerMask);
4234e5c31af7Sopenharmony_ci			renderPass	= makeRenderPass (*m_device, *m_logicalDevice, m_parameters.colorFormat, layerMasks, m_parameters.renderingType);
4235e5c31af7Sopenharmony_ci			frameBuffer	= makeFramebuffer(*m_device, *m_logicalDevice, *renderPass, m_colorImage->getImageView(), fbExtent.width, fbExtent.height);
4236e5c31af7Sopenharmony_ci		}
4237e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4238e5c31af7Sopenharmony_ci		const VkPipelineRenderingCreateInfo pipelineRenderingCreateInfo =
4239e5c31af7Sopenharmony_ci		{
4240e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,	//	VkStructureType	sType;
4241e5c31af7Sopenharmony_ci			nullptr,												//	const void*		pNext;
4242e5c31af7Sopenharmony_ci			layerMask,												//	uint32_t		viewMask;
4243e5c31af7Sopenharmony_ci			1u,														//	uint32_t		colorAttachmentCount;
4244e5c31af7Sopenharmony_ci			&m_parameters.colorFormat,								//	const VkFormat*	pColorAttachmentFormats;
4245e5c31af7Sopenharmony_ci			VK_FORMAT_UNDEFINED,									//	VkFormat		depthAttachmentFormat;
4246e5c31af7Sopenharmony_ci			VK_FORMAT_UNDEFINED,									//	VkFormat		stencilAttachmentFormat;
4247e5c31af7Sopenharmony_ci		};
4248e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4249e5c31af7Sopenharmony_ci		const std::vector<VkPipelineColorBlendAttachmentState> colorBlendStateVec (1u, colorBlendAttState);
4250e5c31af7Sopenharmony_ci
4251e5c31af7Sopenharmony_ci		const VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo =
4252e5c31af7Sopenharmony_ci		{
4253e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	//	VkStructureType								sType;
4254e5c31af7Sopenharmony_ci			nullptr,													//	const void*									pNext;
4255e5c31af7Sopenharmony_ci			0u,															//	VkPipelineColorBlendStateCreateFlags		flags;
4256e5c31af7Sopenharmony_ci			VK_FALSE,													//	VkBool32									logicOpEnable;
4257e5c31af7Sopenharmony_ci			VK_LOGIC_OP_CLEAR,											//	VkLogicOp									logicOp;
4258e5c31af7Sopenharmony_ci			de::sizeU32(colorBlendStateVec),							//	uint32_t									attachmentCount;
4259e5c31af7Sopenharmony_ci			de::dataOrNull(colorBlendStateVec),							//	const VkPipelineColorBlendAttachmentState*	pAttachments;
4260e5c31af7Sopenharmony_ci			{ 0.0f, 0.0f, 0.0f, 0.0f },									//	float										blendConstants[4];
4261e5c31af7Sopenharmony_ci		};
4262e5c31af7Sopenharmony_ci
4263e5c31af7Sopenharmony_ci		const auto pipeline = vk::makeGraphicsPipeline(*m_device, *m_logicalDevice, pipelineLayout.get(),
4264e5c31af7Sopenharmony_ci			vertexShaderModule, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, fragShaderModule,
4265e5c31af7Sopenharmony_ci			*renderPass, viewports, scissors, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0u, 0u,
4266e5c31af7Sopenharmony_ci			&vertexInputStateCreateInfo, nullptr, nullptr, nullptr, &colorBlendStateCreateInfo, nullptr,
4267e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4268e5c31af7Sopenharmony_ci			(*renderPass == 0) ? &pipelineRenderingCreateInfo : VK_NULL_HANDLE
4269e5c31af7Sopenharmony_ci#else
4270e5c31af7Sopenharmony_ci			VK_NULL_HANDLE
4271e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4272e5c31af7Sopenharmony_ci			);
4273e5c31af7Sopenharmony_ci
4274e5c31af7Sopenharmony_ci		CommandPoolWithBuffer cmd (*m_device, *m_logicalDevice, m_queueFamilyIndex);
4275e5c31af7Sopenharmony_ci		const auto cmdBuffer = cmd.cmdBuffer.get();
4276e5c31af7Sopenharmony_ci
4277e5c31af7Sopenharmony_ci		beginCommandBuffer(*m_device, cmdBuffer);
4278e5c31af7Sopenharmony_ci
4279e5c31af7Sopenharmony_ci		beforeRender(cmdBuffer);
4280e5c31af7Sopenharmony_ci
4281e5c31af7Sopenharmony_ci		if (!m_useDynamicRendering)
4282e5c31af7Sopenharmony_ci		{
4283e5c31af7Sopenharmony_ci			const VkRect2D				renderArea				= { { 0, 0 }, { fbExtent.width, fbExtent.height } };
4284e5c31af7Sopenharmony_ci			const VkRenderPassBeginInfo	renderPassBeginInfo
4285e5c31af7Sopenharmony_ci			{
4286e5c31af7Sopenharmony_ci				VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,	// VkStructureType		sType;
4287e5c31af7Sopenharmony_ci				DE_NULL,									// const void*			pNext;
4288e5c31af7Sopenharmony_ci				*renderPass,								// VkRenderPass			renderPass;
4289e5c31af7Sopenharmony_ci				*frameBuffer,								// VkFramebuffer		framebuffer;
4290e5c31af7Sopenharmony_ci				renderArea,									// VkRect2D				renderArea;
4291e5c31af7Sopenharmony_ci				1u,											// uint32_t				clearValueCount;
4292e5c31af7Sopenharmony_ci				&m_clearValue,								// const VkClearValue*	pClearValues;
4293e5c31af7Sopenharmony_ci			};
4294e5c31af7Sopenharmony_ci			cmdBeginRenderPass(*m_device, cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
4295e5c31af7Sopenharmony_ci		}
4296e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4297e5c31af7Sopenharmony_ci		else
4298e5c31af7Sopenharmony_ci		{
4299e5c31af7Sopenharmony_ci			const VkRenderingInfoKHR renderingInfo =
4300e5c31af7Sopenharmony_ci			{
4301e5c31af7Sopenharmony_ci				VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,				//	VkStructureType						sType;
4302e5c31af7Sopenharmony_ci				nullptr,											//	const void*							pNext;
4303e5c31af7Sopenharmony_ci				0,													//	VkRenderingFlags					flags;
4304e5c31af7Sopenharmony_ci				scissors.at(0u),									//	VkRect2D							renderArea;
4305e5c31af7Sopenharmony_ci				m_layerCount,										//	uint32_t							m_layerCount;
4306e5c31af7Sopenharmony_ci				layerMask,											//	uint32_t							viewMask;
4307e5c31af7Sopenharmony_ci				1u,													//	uint32_t							colorAttachmentCount;
4308e5c31af7Sopenharmony_ci				&renderingAttInfo,									//	const VkRenderingAttachmentInfo*	pColorAttachments;
4309e5c31af7Sopenharmony_ci				DE_NULL,											//	const VkRenderingAttachmentInfo*	pDepthAttachment;
4310e5c31af7Sopenharmony_ci				DE_NULL,											//	const VkRenderingAttachmentInfo*	pStencilAttachment;
4311e5c31af7Sopenharmony_ci			};
4312e5c31af7Sopenharmony_ci
4313e5c31af7Sopenharmony_ci			m_device->cmdBeginRendering(cmdBuffer, &renderingInfo);
4314e5c31af7Sopenharmony_ci		}
4315e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4316e5c31af7Sopenharmony_ci
4317e5c31af7Sopenharmony_ci		m_device->cmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.get());
4318e5c31af7Sopenharmony_ci
4319e5c31af7Sopenharmony_ci		m_device->cmdDraw(cmdBuffer, 3u, 1u, 0u, 0u);
4320e5c31af7Sopenharmony_ci
4321e5c31af7Sopenharmony_ci
4322e5c31af7Sopenharmony_ci		if (!m_useDynamicRendering)
4323e5c31af7Sopenharmony_ci			cmdEndRenderPass(*m_device, cmdBuffer, m_parameters.renderingType);
4324e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4325e5c31af7Sopenharmony_ci		else
4326e5c31af7Sopenharmony_ci			m_device->cmdEndRendering(cmdBuffer);
4327e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4328e5c31af7Sopenharmony_ci
4329e5c31af7Sopenharmony_ci		afterRender(cmdBuffer);
4330e5c31af7Sopenharmony_ci
4331e5c31af7Sopenharmony_ci		// Copy all image contents to their verification buffers
4332e5c31af7Sopenharmony_ci		const auto copyRegion = makeBufferImageCopy(fbExtent, colorSRL);
4333e5c31af7Sopenharmony_ci		m_device->cmdCopyImageToBuffer(cmdBuffer, m_colorImage->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_colorImage->getBuffer(), 1u, &copyRegion);
4334e5c31af7Sopenharmony_ci
4335e5c31af7Sopenharmony_ci		// Global barrier to synchronize verification buffers to host reads.
4336e5c31af7Sopenharmony_ci		{
4337e5c31af7Sopenharmony_ci			const auto transfer2HostBarrier = makeMemoryBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_HOST_READ_BIT);
4338e5c31af7Sopenharmony_ci			cmdPipelineMemoryBarrier(*m_device, cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, &transfer2HostBarrier);
4339e5c31af7Sopenharmony_ci		}
4340e5c31af7Sopenharmony_ci
4341e5c31af7Sopenharmony_ci		endCommandBuffer(*m_device, cmdBuffer);
4342e5c31af7Sopenharmony_ci		submitCommandsAndWait(*m_device, *m_logicalDevice, m_queue, cmdBuffer);
4343e5c31af7Sopenharmony_ci
4344e5c31af7Sopenharmony_ci		// Invalidate all allocations.
4345e5c31af7Sopenharmony_ci		invalidateAlloc(*m_device, *m_logicalDevice, m_colorImage->getBufferAllocation());
4346e5c31af7Sopenharmony_ci
4347e5c31af7Sopenharmony_ci		// Verify all layers in all images.
4348e5c31af7Sopenharmony_ci		const auto colorTcuFormat = mapVkFormat(m_parameters.colorFormat);
4349e5c31af7Sopenharmony_ci		const auto colorPixelSize = tcu::getPixelSize(colorTcuFormat);
4350e5c31af7Sopenharmony_ci		const auto colorLayerSize = static_cast<size_t>(m_dim.x() * m_dim.y() * m_dim.z() * colorPixelSize);
4351e5c31af7Sopenharmony_ci
4352e5c31af7Sopenharmony_ci		const tcu::UVec4	threshold	(0u, 0u, 0u, 0u); // We expect exact results.
4353e5c31af7Sopenharmony_ci		auto&				log			= m_context.getTestContext().getLog();
4354e5c31af7Sopenharmony_ci
4355e5c31af7Sopenharmony_ci		const auto	dataPtr		= reinterpret_cast<const char*>(m_colorImage->getBufferAllocation().getHostPtr());
4356e5c31af7Sopenharmony_ci
4357e5c31af7Sopenharmony_ci		for (uint32_t layerIdx = 0u; layerIdx < m_layerCount; ++layerIdx)
4358e5c31af7Sopenharmony_ci		{
4359e5c31af7Sopenharmony_ci			const bool							layerWritten	=	((layerMask & (1 << layerIdx)) != 0u);
4360e5c31af7Sopenharmony_ci			const auto							layerDataPtr	=	dataPtr + colorLayerSize * layerIdx;
4361e5c31af7Sopenharmony_ci			const tcu::ConstPixelBufferAccess	layerAccess			(colorTcuFormat, m_dim, layerDataPtr);
4362e5c31af7Sopenharmony_ci			const tcu::UVec4					expectedColor	=	(layerWritten
4363e5c31af7Sopenharmony_ci																	? tcu::UVec4(layerIdx, 255u, 0, 255u) // Needs to match frag shader.
4364e5c31af7Sopenharmony_ci																	: tcu::UVec4(0u, 0u, 0u, 0u));
4365e5c31af7Sopenharmony_ci			const std::string					logImgName		=	"ColorAttachment" + std::to_string(0) + "-Subpass" + std::to_string(subpassNdx) + "-Layer" + std::to_string(layerIdx);
4366e5c31af7Sopenharmony_ci			tcu::TextureLevel					refLevel			(colorTcuFormat, m_dim.x(), m_dim.y(), m_dim.z());
4367e5c31af7Sopenharmony_ci			tcu::PixelBufferAccess				refAccess		=	refLevel.getAccess();
4368e5c31af7Sopenharmony_ci
4369e5c31af7Sopenharmony_ci			tcu::clear(refAccess, expectedColor);
4370e5c31af7Sopenharmony_ci
4371e5c31af7Sopenharmony_ci			if (!tcu::intThresholdCompare(log, logImgName.c_str(), "", refAccess, layerAccess, threshold, tcu::COMPARE_LOG_ON_ERROR))
4372e5c31af7Sopenharmony_ci				failure = true;
4373e5c31af7Sopenharmony_ci		}
4374e5c31af7Sopenharmony_ci	}
4375e5c31af7Sopenharmony_ci
4376e5c31af7Sopenharmony_ci	if (failure)
4377e5c31af7Sopenharmony_ci		return tcu::TestStatus::fail("Invalid value found in verification buffers; check log for details");
4378e5c31af7Sopenharmony_ci
4379e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
4380e5c31af7Sopenharmony_ci}
4381e5c31af7Sopenharmony_ci
4382e5c31af7Sopenharmony_ciclass MultiViewRenderTestsCase : public vkt::TestCase
4383e5c31af7Sopenharmony_ci{
4384e5c31af7Sopenharmony_cipublic:
4385e5c31af7Sopenharmony_ci	MultiViewRenderTestsCase (tcu::TestContext &context, const char *name, const TestParameters& parameters)
4386e5c31af7Sopenharmony_ci		: TestCase			(context, name)
4387e5c31af7Sopenharmony_ci		, m_parameters		(parameters)
4388e5c31af7Sopenharmony_ci	{
4389e5c31af7Sopenharmony_ci		DE_ASSERT(m_parameters.extent.width == m_parameters.extent.height);
4390e5c31af7Sopenharmony_ci	}
4391e5c31af7Sopenharmony_ciprivate:
4392e5c31af7Sopenharmony_ci	const TestParameters	m_parameters;
4393e5c31af7Sopenharmony_ci
4394e5c31af7Sopenharmony_ci	vkt::TestInstance*	createInstance		(vkt::Context& context) const
4395e5c31af7Sopenharmony_ci	{
4396e5c31af7Sopenharmony_ci		if (TEST_TYPE_INPUT_ATTACHMENTS == m_parameters.viewIndex ||
4397e5c31af7Sopenharmony_ci			TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY == m_parameters.viewIndex)
4398e5c31af7Sopenharmony_ci			return new MultiViewAttachmentsTestInstance(context, m_parameters);
4399e5c31af7Sopenharmony_ci
4400e5c31af7Sopenharmony_ci		if (TEST_TYPE_INSTANCED_RENDERING == m_parameters.viewIndex)
4401e5c31af7Sopenharmony_ci			return new MultiViewInstancedTestInstance(context, m_parameters);
4402e5c31af7Sopenharmony_ci
4403e5c31af7Sopenharmony_ci		if (TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
4404e5c31af7Sopenharmony_ci			return new MultiViewInputRateInstanceTestInstance(context, m_parameters);
4405e5c31af7Sopenharmony_ci
4406e5c31af7Sopenharmony_ci		if (TEST_TYPE_DRAW_INDIRECT == m_parameters.viewIndex ||
4407e5c31af7Sopenharmony_ci			TEST_TYPE_DRAW_INDIRECT_INDEXED == m_parameters.viewIndex)
4408e5c31af7Sopenharmony_ci			return new MultiViewDrawIndirectTestInstance(context, m_parameters);
4409e5c31af7Sopenharmony_ci
4410e5c31af7Sopenharmony_ci		if (TEST_TYPE_CLEAR_ATTACHMENTS == m_parameters.viewIndex)
4411e5c31af7Sopenharmony_ci			return new MultiViewClearAttachmentsTestInstance(context, m_parameters);
4412e5c31af7Sopenharmony_ci
4413e5c31af7Sopenharmony_ci		if (TEST_TYPE_SECONDARY_CMD_BUFFER == m_parameters.viewIndex ||
4414e5c31af7Sopenharmony_ci			TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY == m_parameters.viewIndex)
4415e5c31af7Sopenharmony_ci			return new MultiViewSecondaryCommandBufferTestInstance(context, m_parameters);
4416e5c31af7Sopenharmony_ci
4417e5c31af7Sopenharmony_ci		if (TEST_TYPE_POINT_SIZE == m_parameters.viewIndex)
4418e5c31af7Sopenharmony_ci			return new MultiViewPointSizeTestInstance(context, m_parameters);
4419e5c31af7Sopenharmony_ci
4420e5c31af7Sopenharmony_ci		if (TEST_TYPE_MULTISAMPLE == m_parameters.viewIndex)
4421e5c31af7Sopenharmony_ci			return new MultiViewMultsampleTestInstance(context, m_parameters);
4422e5c31af7Sopenharmony_ci
4423e5c31af7Sopenharmony_ci		if (TEST_TYPE_QUERIES == m_parameters.viewIndex ||
4424e5c31af7Sopenharmony_ci			TEST_TYPE_NON_PRECISE_QUERIES == m_parameters.viewIndex ||
4425e5c31af7Sopenharmony_ci			TEST_TYPE_NON_PRECISE_QUERIES_WITH_AVAILABILITY == m_parameters.viewIndex)
4426e5c31af7Sopenharmony_ci			return new MultiViewQueriesTestInstance(context, m_parameters);
4427e5c31af7Sopenharmony_ci
4428e5c31af7Sopenharmony_ci		if (TEST_TYPE_VIEW_MASK == m_parameters.viewIndex ||
4429e5c31af7Sopenharmony_ci			TEST_TYPE_VIEW_INDEX_IN_VERTEX == m_parameters.viewIndex ||
4430e5c31af7Sopenharmony_ci			TEST_TYPE_VIEW_INDEX_IN_FRAGMENT == m_parameters.viewIndex ||
4431e5c31af7Sopenharmony_ci			TEST_TYPE_VIEW_INDEX_IN_GEOMETRY == m_parameters.viewIndex ||
4432e5c31af7Sopenharmony_ci			TEST_TYPE_VIEW_INDEX_IN_TESELLATION == m_parameters.viewIndex ||
4433e5c31af7Sopenharmony_ci			TEST_TYPE_DRAW_INDEXED == m_parameters.viewIndex)
4434e5c31af7Sopenharmony_ci			return new MultiViewRenderTestInstance(context, m_parameters);
4435e5c31af7Sopenharmony_ci		if (TEST_TYPE_VIEW_MASK_ITERATION == m_parameters.viewIndex)
4436e5c31af7Sopenharmony_ci			return new MultiViewMaskIterationTestInstance(context, m_parameters);
4437e5c31af7Sopenharmony_ci		if (TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR == m_parameters.viewIndex ||
4438e5c31af7Sopenharmony_ci			TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR == m_parameters.viewIndex)
4439e5c31af7Sopenharmony_ci			return new MultiViewReadbackTestInstance(context, m_parameters);
4440e5c31af7Sopenharmony_ci
4441e5c31af7Sopenharmony_ci		if (TEST_TYPE_DEPTH == m_parameters.viewIndex ||
4442e5c31af7Sopenharmony_ci			TEST_TYPE_DEPTH_DIFFERENT_RANGES == m_parameters.viewIndex ||
4443e5c31af7Sopenharmony_ci			TEST_TYPE_STENCIL == m_parameters.viewIndex)
4444e5c31af7Sopenharmony_ci			return new MultiViewDepthStencilTestInstance(context, m_parameters);
4445e5c31af7Sopenharmony_ci
4446e5c31af7Sopenharmony_ci		TCU_THROW(InternalError, "Unknown test type");
4447e5c31af7Sopenharmony_ci	}
4448e5c31af7Sopenharmony_ci
4449e5c31af7Sopenharmony_ci	virtual void		checkSupport		(Context& context) const
4450e5c31af7Sopenharmony_ci	{
4451e5c31af7Sopenharmony_ci		if (m_parameters.geometryShaderNeeded())
4452e5c31af7Sopenharmony_ci			context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_GEOMETRY_SHADER);
4453e5c31af7Sopenharmony_ci
4454e5c31af7Sopenharmony_ci		if (m_parameters.renderingType == RENDERING_TYPE_RENDERPASS2)
4455e5c31af7Sopenharmony_ci			context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
4456e5c31af7Sopenharmony_ci
4457e5c31af7Sopenharmony_ci		if (m_parameters.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
4458e5c31af7Sopenharmony_ci			context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
4459e5c31af7Sopenharmony_ci
4460e5c31af7Sopenharmony_ci		context.requireDeviceFunctionality("VK_KHR_multiview");
4461e5c31af7Sopenharmony_ci
4462e5c31af7Sopenharmony_ci		if (m_parameters.viewIndex == TEST_TYPE_DEPTH_DIFFERENT_RANGES)
4463e5c31af7Sopenharmony_ci			context.requireDeviceFunctionality("VK_EXT_depth_range_unrestricted");
4464e5c31af7Sopenharmony_ci		if (m_parameters.viewIndex == TEST_TYPE_QUERIES)
4465e5c31af7Sopenharmony_ci			context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_OCCLUSION_QUERY_PRECISE);
4466e5c31af7Sopenharmony_ci
4467e5c31af7Sopenharmony_ci#ifdef CTS_USES_VULKANSC
4468e5c31af7Sopenharmony_ci		const InstanceInterface&			instance			= context.getInstanceInterface();
4469e5c31af7Sopenharmony_ci		const VkPhysicalDevice				physicalDevice		= context.getPhysicalDevice();
4470e5c31af7Sopenharmony_ci		VkPhysicalDeviceMultiviewProperties	multiviewProperties =
4471e5c31af7Sopenharmony_ci		{
4472e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,		//VkStructureType	sType;
4473e5c31af7Sopenharmony_ci			DE_NULL,													//void*				pNext;
4474e5c31af7Sopenharmony_ci			0u,															//deUint32			maxMultiviewViewCount;
4475e5c31af7Sopenharmony_ci			0u															//deUint32			maxMultiviewInstanceIndex;
4476e5c31af7Sopenharmony_ci		};
4477e5c31af7Sopenharmony_ci
4478e5c31af7Sopenharmony_ci		VkPhysicalDeviceProperties2			propertiesDeviceProperties2;
4479e5c31af7Sopenharmony_ci		propertiesDeviceProperties2.sType						= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
4480e5c31af7Sopenharmony_ci		propertiesDeviceProperties2.pNext						= &multiviewProperties;
4481e5c31af7Sopenharmony_ci
4482e5c31af7Sopenharmony_ci		instance.getPhysicalDeviceProperties2(physicalDevice, &propertiesDeviceProperties2);
4483e5c31af7Sopenharmony_ci
4484e5c31af7Sopenharmony_ci		if (multiviewProperties.maxMultiviewViewCount < m_parameters.viewMasks.size())
4485e5c31af7Sopenharmony_ci			TCU_THROW(NotSupportedError, "maxMultiviewViewCount is less than required by test");
4486e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4487e5c31af7Sopenharmony_ci	}
4488e5c31af7Sopenharmony_ci
4489e5c31af7Sopenharmony_ci	void				initPrograms		(SourceCollections& programCollection) const
4490e5c31af7Sopenharmony_ci	{
4491e5c31af7Sopenharmony_ci		// Create vertex shader
4492e5c31af7Sopenharmony_ci		if (TEST_TYPE_INSTANCED_RENDERING == m_parameters.viewIndex)
4493e5c31af7Sopenharmony_ci		{
4494e5c31af7Sopenharmony_ci			std::ostringstream source;
4495e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4496e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4497e5c31af7Sopenharmony_ci					<< "layout(location = 0) in highp vec4 in_position;\n"
4498e5c31af7Sopenharmony_ci					<< "layout(location = 1) in vec4 in_color;\n"
4499e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4500e5c31af7Sopenharmony_ci					<< "void main (void)\n"
4501e5c31af7Sopenharmony_ci					<< "{\n"
4502e5c31af7Sopenharmony_ci					<< "	int modInstance = gl_InstanceIndex % 4;\n"
4503e5c31af7Sopenharmony_ci					<< "	int instance    = gl_InstanceIndex + 1;\n"
4504e5c31af7Sopenharmony_ci					<< "	gl_Position = in_position;\n"
4505e5c31af7Sopenharmony_ci					<< "	if (modInstance == 1)\n"
4506e5c31af7Sopenharmony_ci					<< "		gl_Position = in_position + vec4(0.0f, 1.0f, 0.0f, 0.0f);\n"
4507e5c31af7Sopenharmony_ci					<< "	if (modInstance == 2)\n"
4508e5c31af7Sopenharmony_ci					<< "		gl_Position = in_position + vec4(1.0f, 0.0f, 0.0f, 0.0f);\n"
4509e5c31af7Sopenharmony_ci					<< "	if (modInstance == 3)\n"
4510e5c31af7Sopenharmony_ci					<< "		gl_Position =  in_position + vec4(1.0f, 1.0f, 0.0f, 0.0f);\n"
4511e5c31af7Sopenharmony_ci					<< "	out_color = in_color + vec4(0.0f, gl_ViewIndex * 0.10f, instance * 0.10f, 0.0f);\n"
4512e5c31af7Sopenharmony_ci					<< "}\n";
4513e5c31af7Sopenharmony_ci			programCollection.glslSources.add("vertex") << glu::VertexSource(source.str());
4514e5c31af7Sopenharmony_ci		}
4515e5c31af7Sopenharmony_ci		else if (TEST_TYPE_INPUT_RATE_INSTANCE == m_parameters.viewIndex)
4516e5c31af7Sopenharmony_ci		{
4517e5c31af7Sopenharmony_ci			std::ostringstream source;
4518e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4519e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4520e5c31af7Sopenharmony_ci					<< "layout(location = 0) in highp vec4 in_position;\n"
4521e5c31af7Sopenharmony_ci					<< "layout(location = 1) in vec4 in_color;\n"
4522e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4523e5c31af7Sopenharmony_ci					<< "void main (void)\n"
4524e5c31af7Sopenharmony_ci					<< "{\n"
4525e5c31af7Sopenharmony_ci					<< "	int instance = gl_InstanceIndex + 1;\n"
4526e5c31af7Sopenharmony_ci					<< "	gl_Position = in_position;\n"
4527e5c31af7Sopenharmony_ci					<< "	if (gl_VertexIndex == 1)\n"
4528e5c31af7Sopenharmony_ci					<< "		gl_Position.y += 1.0f;\n"
4529e5c31af7Sopenharmony_ci					<< "	else if (gl_VertexIndex == 2)\n"
4530e5c31af7Sopenharmony_ci					<< "		gl_Position.x += 1.0f;\n"
4531e5c31af7Sopenharmony_ci					<< "	else if (gl_VertexIndex == 3)\n"
4532e5c31af7Sopenharmony_ci					<< "	{\n"
4533e5c31af7Sopenharmony_ci					<< "		gl_Position.x += 1.0f;\n"
4534e5c31af7Sopenharmony_ci					<< "		gl_Position.y += 1.0f;\n"
4535e5c31af7Sopenharmony_ci					<< "	}\n"
4536e5c31af7Sopenharmony_ci					<< "	out_color = in_color + vec4(0.0f, gl_ViewIndex * 0.10f, instance * 0.10f, 0.0f);\n"
4537e5c31af7Sopenharmony_ci					<< "}\n";
4538e5c31af7Sopenharmony_ci			programCollection.glslSources.add("vertex") << glu::VertexSource(source.str());
4539e5c31af7Sopenharmony_ci		}
4540e5c31af7Sopenharmony_ci		else if (TEST_TYPE_POINT_SIZE == m_parameters.viewIndex)
4541e5c31af7Sopenharmony_ci		{
4542e5c31af7Sopenharmony_ci			std::ostringstream source;
4543e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4544e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4545e5c31af7Sopenharmony_ci					<< "layout(location = 0) in highp vec4 in_position;\n"
4546e5c31af7Sopenharmony_ci					<< "layout(location = 1) in highp vec4 in_color;\n"
4547e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4548e5c31af7Sopenharmony_ci					<< "void main (void)\n"
4549e5c31af7Sopenharmony_ci					<< "{\n"
4550e5c31af7Sopenharmony_ci					<< "	gl_Position = in_position;\n"
4551e5c31af7Sopenharmony_ci					<< "	if (gl_ViewIndex == 0)\n"
4552e5c31af7Sopenharmony_ci					<< "		gl_PointSize = " << de::floatToString(static_cast<float>(TEST_POINT_SIZE_WIDE), 1) << "f;\n"
4553e5c31af7Sopenharmony_ci					<< "	else\n"
4554e5c31af7Sopenharmony_ci					<< "		gl_PointSize = " << de::floatToString(static_cast<float>(TEST_POINT_SIZE_SMALL), 1) << "f;\n"
4555e5c31af7Sopenharmony_ci					<< "	out_color = in_color;\n"
4556e5c31af7Sopenharmony_ci					<< "}\n";
4557e5c31af7Sopenharmony_ci			programCollection.glslSources.add("vertex") << glu::VertexSource(source.str());
4558e5c31af7Sopenharmony_ci		}
4559e5c31af7Sopenharmony_ci		else if (TEST_TYPE_VIEW_MASK_ITERATION == m_parameters.viewIndex)
4560e5c31af7Sopenharmony_ci		{
4561e5c31af7Sopenharmony_ci			std::ostringstream source;
4562e5c31af7Sopenharmony_ci			source
4563e5c31af7Sopenharmony_ci				<< "#version 460\n"
4564e5c31af7Sopenharmony_ci				<< "#extension GL_ARB_shader_viewport_layer_array : enable\n"
4565e5c31af7Sopenharmony_ci				<< "vec2 positions[3] = vec2[](\n"
4566e5c31af7Sopenharmony_ci				<< "    vec2(-1.0, -1.0),\n"
4567e5c31af7Sopenharmony_ci				<< "    vec2(-1.0,  3.0),\n"
4568e5c31af7Sopenharmony_ci				<< "    vec2( 3.0, -1.0)\n"
4569e5c31af7Sopenharmony_ci				<< ");\n"
4570e5c31af7Sopenharmony_ci				<< "void main() {\n"
4571e5c31af7Sopenharmony_ci				<< "    gl_Position = vec4(positions[gl_VertexIndex % 3], 1.0, 1.0);\n"
4572e5c31af7Sopenharmony_ci				<< "}\n"
4573e5c31af7Sopenharmony_ci				;
4574e5c31af7Sopenharmony_ci			{
4575e5c31af7Sopenharmony_ci				const auto						src			= source.str();
4576e5c31af7Sopenharmony_ci				const vk::ShaderBuildOptions	spv15Opts	(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_5, 0u, false);
4577e5c31af7Sopenharmony_ci
4578e5c31af7Sopenharmony_ci				programCollection.glslSources.add("vert-spv10") << glu::VertexSource(src);
4579e5c31af7Sopenharmony_ci				programCollection.glslSources.add("vert-spv15") << glu::VertexSource(src) << spv15Opts;
4580e5c31af7Sopenharmony_ci			}
4581e5c31af7Sopenharmony_ci		}
4582e5c31af7Sopenharmony_ci		else
4583e5c31af7Sopenharmony_ci		{
4584e5c31af7Sopenharmony_ci			const bool generateColor	=  (TEST_TYPE_VIEW_INDEX_IN_VERTEX == m_parameters.viewIndex)
4585e5c31af7Sopenharmony_ci										|| (TEST_TYPE_DRAW_INDIRECT == m_parameters.viewIndex)
4586e5c31af7Sopenharmony_ci										|| (TEST_TYPE_DRAW_INDIRECT_INDEXED == m_parameters.viewIndex)
4587e5c31af7Sopenharmony_ci										|| (TEST_TYPE_CLEAR_ATTACHMENTS == m_parameters.viewIndex);
4588e5c31af7Sopenharmony_ci			std::ostringstream source;
4589e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4590e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4591e5c31af7Sopenharmony_ci					<< "layout(location = 0) in highp vec4 in_position;\n"
4592e5c31af7Sopenharmony_ci					<< "layout(location = 1) in vec4 in_color;\n"
4593e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4594e5c31af7Sopenharmony_ci					<< "void main (void)\n"
4595e5c31af7Sopenharmony_ci					<< "{\n"
4596e5c31af7Sopenharmony_ci					<< "	gl_Position = in_position;\n";
4597e5c31af7Sopenharmony_ci				if (generateColor)
4598e5c31af7Sopenharmony_ci					source << "	out_color = in_color + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n";
4599e5c31af7Sopenharmony_ci				else
4600e5c31af7Sopenharmony_ci					source << "	out_color = in_color;\n";
4601e5c31af7Sopenharmony_ci			source	<< "}\n";
4602e5c31af7Sopenharmony_ci			programCollection.glslSources.add("vertex") << glu::VertexSource(source.str());
4603e5c31af7Sopenharmony_ci		}
4604e5c31af7Sopenharmony_ci
4605e5c31af7Sopenharmony_ci		if (TEST_TYPE_VIEW_INDEX_IN_TESELLATION == m_parameters.viewIndex)
4606e5c31af7Sopenharmony_ci		{// Tessellation control & evaluation
4607e5c31af7Sopenharmony_ci			std::ostringstream source_tc;
4608e5c31af7Sopenharmony_ci			source_tc	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
4609e5c31af7Sopenharmony_ci						<< "#extension GL_EXT_multiview : enable\n"
4610e5c31af7Sopenharmony_ci						<< "#extension GL_EXT_tessellation_shader : require\n"
4611e5c31af7Sopenharmony_ci						<< "layout(vertices = 4) out;\n"
4612e5c31af7Sopenharmony_ci						<< "layout(location = 0) in vec4 in_color[];\n"
4613e5c31af7Sopenharmony_ci						<< "layout(location = 0) out vec4 out_color[];\n"
4614e5c31af7Sopenharmony_ci						<< "\n"
4615e5c31af7Sopenharmony_ci						<< "void main (void)\n"
4616e5c31af7Sopenharmony_ci						<< "{\n"
4617e5c31af7Sopenharmony_ci						<< "	if ( gl_InvocationID == 0 )\n"
4618e5c31af7Sopenharmony_ci						<< "	{\n"
4619e5c31af7Sopenharmony_ci						<< "		gl_TessLevelInner[0] = 4.0f;\n"
4620e5c31af7Sopenharmony_ci						<< "		gl_TessLevelInner[1] = 4.0f;\n"
4621e5c31af7Sopenharmony_ci						<< "		gl_TessLevelOuter[0] = 4.0f;\n"
4622e5c31af7Sopenharmony_ci						<< "		gl_TessLevelOuter[1] = 4.0f;\n"
4623e5c31af7Sopenharmony_ci						<< "		gl_TessLevelOuter[2] = 4.0f;\n"
4624e5c31af7Sopenharmony_ci						<< "		gl_TessLevelOuter[3] = 4.0f;\n"
4625e5c31af7Sopenharmony_ci						<< "	}\n"
4626e5c31af7Sopenharmony_ci						<< "	out_color[gl_InvocationID] = in_color[gl_InvocationID];\n"
4627e5c31af7Sopenharmony_ci						<< "	gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
4628e5c31af7Sopenharmony_ci						<< "}\n";
4629e5c31af7Sopenharmony_ci			programCollection.glslSources.add("tessellation_control") << glu::TessellationControlSource(source_tc.str());
4630e5c31af7Sopenharmony_ci
4631e5c31af7Sopenharmony_ci			std::ostringstream source_te;
4632e5c31af7Sopenharmony_ci			source_te	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
4633e5c31af7Sopenharmony_ci						<< "#extension GL_EXT_multiview : enable\n"
4634e5c31af7Sopenharmony_ci						<< "#extension GL_EXT_tessellation_shader : require\n"
4635e5c31af7Sopenharmony_ci						<< "layout( quads, equal_spacing, ccw ) in;\n"
4636e5c31af7Sopenharmony_ci						<< "layout(location = 0) in vec4 in_color[];\n"
4637e5c31af7Sopenharmony_ci						<< "layout(location = 0) out vec4 out_color;\n"
4638e5c31af7Sopenharmony_ci						<< "void main (void)\n"
4639e5c31af7Sopenharmony_ci						<< "{\n"
4640e5c31af7Sopenharmony_ci						<< "	const float u = gl_TessCoord.x;\n"
4641e5c31af7Sopenharmony_ci						<< "	const float v = gl_TessCoord.y;\n"
4642e5c31af7Sopenharmony_ci						<< "	const float w = gl_TessCoord.z;\n"
4643e5c31af7Sopenharmony_ci						<< "	gl_Position = (1 - u) * (1 - v) * gl_in[0].gl_Position +(1 - u) * v * gl_in[1].gl_Position + u * (1 - v) * gl_in[2].gl_Position + u * v * gl_in[3].gl_Position;\n"
4644e5c31af7Sopenharmony_ci						<< "	out_color = in_color[0]+ vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n"
4645e5c31af7Sopenharmony_ci						<< "}\n";
4646e5c31af7Sopenharmony_ci			programCollection.glslSources.add("tessellation_evaluation") << glu::TessellationEvaluationSource(source_te.str());
4647e5c31af7Sopenharmony_ci		}
4648e5c31af7Sopenharmony_ci
4649e5c31af7Sopenharmony_ci		if (m_parameters.geometryShaderNeeded())
4650e5c31af7Sopenharmony_ci		{// Geometry Shader
4651e5c31af7Sopenharmony_ci			std::ostringstream	source;
4652e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4653e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4654e5c31af7Sopenharmony_ci					<< "layout(triangles) in;\n"
4655e5c31af7Sopenharmony_ci					<< "layout(triangle_strip, max_vertices = 16) out;\n"
4656e5c31af7Sopenharmony_ci					<< "layout(location = 0) in vec4 in_color[];\n"
4657e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4658e5c31af7Sopenharmony_ci					<< "void main (void)\n"
4659e5c31af7Sopenharmony_ci					<< "{\n"
4660e5c31af7Sopenharmony_ci					<< "	out_color = in_color[0] + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n"
4661e5c31af7Sopenharmony_ci					<< "	gl_Position = gl_in[0].gl_Position;\n"
4662e5c31af7Sopenharmony_ci					<< "	EmitVertex();\n"
4663e5c31af7Sopenharmony_ci					<< "	out_color = in_color[0] + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n"
4664e5c31af7Sopenharmony_ci					<< "	gl_Position = gl_in[1].gl_Position;\n"
4665e5c31af7Sopenharmony_ci					<< "	EmitVertex();\n"
4666e5c31af7Sopenharmony_ci					<< "	out_color = in_color[0] + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n"
4667e5c31af7Sopenharmony_ci					<< "	gl_Position = gl_in[2].gl_Position;\n"
4668e5c31af7Sopenharmony_ci					<< "	EmitVertex();\n"
4669e5c31af7Sopenharmony_ci					<< "	out_color = in_color[0] + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n"
4670e5c31af7Sopenharmony_ci					<< "	gl_Position = vec4(gl_in[2].gl_Position.x, gl_in[1].gl_Position.y, 1.0, 1.0);\n"
4671e5c31af7Sopenharmony_ci					<< "	EmitVertex();\n"
4672e5c31af7Sopenharmony_ci					<< "	EndPrimitive();\n"
4673e5c31af7Sopenharmony_ci					<< "}\n";
4674e5c31af7Sopenharmony_ci			programCollection.glslSources.add("geometry") << glu::GeometrySource(source.str());
4675e5c31af7Sopenharmony_ci		}
4676e5c31af7Sopenharmony_ci
4677e5c31af7Sopenharmony_ci		if (TEST_TYPE_INPUT_ATTACHMENTS == m_parameters.viewIndex)
4678e5c31af7Sopenharmony_ci		{// Create fragment shader read/write attachment
4679e5c31af7Sopenharmony_ci			std::ostringstream source;
4680e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4681e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4682e5c31af7Sopenharmony_ci					<< "layout(location = 0) in vec4 in_color;\n"
4683e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4684e5c31af7Sopenharmony_ci					<< "layout(input_attachment_index = 0, set=0, binding=0) uniform highp subpassInput in_color_attachment;\n"
4685e5c31af7Sopenharmony_ci					<< "void main()\n"
4686e5c31af7Sopenharmony_ci					<<"{\n"
4687e5c31af7Sopenharmony_ci					<< "	out_color = vec4(subpassLoad(in_color_attachment));\n"
4688e5c31af7Sopenharmony_ci					<< "}\n";
4689e5c31af7Sopenharmony_ci			programCollection.glslSources.add("fragment") << glu::FragmentSource(source.str());
4690e5c31af7Sopenharmony_ci		}
4691e5c31af7Sopenharmony_ci		else if (TEST_TYPE_VIEW_MASK_ITERATION == m_parameters.viewIndex)
4692e5c31af7Sopenharmony_ci		{
4693e5c31af7Sopenharmony_ci			std::ostringstream source;
4694e5c31af7Sopenharmony_ci			source	<< "#version 460\n"
4695e5c31af7Sopenharmony_ci					<< "#extension " << "GL_EXT_multiview" << " : enable\n"
4696e5c31af7Sopenharmony_ci					<< "layout (location=" << 0 << ") out uvec4 color;\n"
4697e5c31af7Sopenharmony_ci					<< "void main (void) {\n"
4698e5c31af7Sopenharmony_ci					<< "    const uint layerIndex = uint(gl_ViewIndex);\n"
4699e5c31af7Sopenharmony_ci					<< "    color = uvec4(layerIndex, 255, " << 0 << ", 255);\n"
4700e5c31af7Sopenharmony_ci					<< "}\n"
4701e5c31af7Sopenharmony_ci					;
4702e5c31af7Sopenharmony_ci			programCollection.glslSources.add("view_mask_iteration") << glu::FragmentSource(source.str());
4703e5c31af7Sopenharmony_ci		}
4704e5c31af7Sopenharmony_ci		else
4705e5c31af7Sopenharmony_ci		{// Create fragment shader
4706e5c31af7Sopenharmony_ci			std::ostringstream source;
4707e5c31af7Sopenharmony_ci			source	<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
4708e5c31af7Sopenharmony_ci					<< "#extension GL_EXT_multiview : enable\n"
4709e5c31af7Sopenharmony_ci					<< "layout(location = 0) in vec4 in_color;\n"
4710e5c31af7Sopenharmony_ci					<< "layout(location = 0) out vec4 out_color;\n"
4711e5c31af7Sopenharmony_ci					<< "void main()\n"
4712e5c31af7Sopenharmony_ci					<<"{\n";
4713e5c31af7Sopenharmony_ci				if (TEST_TYPE_VIEW_INDEX_IN_FRAGMENT == m_parameters.viewIndex ||
4714e5c31af7Sopenharmony_ci					TEST_TYPE_SECONDARY_CMD_BUFFER == m_parameters.viewIndex)
4715e5c31af7Sopenharmony_ci					source << "	out_color = in_color + vec4(0.0, gl_ViewIndex * 0.10f, 0.0, 0.0);\n";
4716e5c31af7Sopenharmony_ci				else
4717e5c31af7Sopenharmony_ci					source << "	out_color = in_color;\n";
4718e5c31af7Sopenharmony_ci			source	<< "}\n";
4719e5c31af7Sopenharmony_ci			programCollection.glslSources.add("fragment") << glu::FragmentSource(source.str());
4720e5c31af7Sopenharmony_ci		}
4721e5c31af7Sopenharmony_ci	}
4722e5c31af7Sopenharmony_ci};
4723e5c31af7Sopenharmony_ci} //anonymous
4724e5c31af7Sopenharmony_ci
4725e5c31af7Sopenharmony_cistatic std::string createViewMasksName(const std::vector<deUint32>& viewMasks)
4726e5c31af7Sopenharmony_ci{
4727e5c31af7Sopenharmony_ci	std::ostringstream		masks;
4728e5c31af7Sopenharmony_ci
4729e5c31af7Sopenharmony_ci	for (size_t ndx = 0u; ndx < viewMasks.size(); ++ndx)
4730e5c31af7Sopenharmony_ci	{
4731e5c31af7Sopenharmony_ci		masks << viewMasks[ndx];
4732e5c31af7Sopenharmony_ci		if (viewMasks.size() - 1 != ndx)
4733e5c31af7Sopenharmony_ci			masks << "_";
4734e5c31af7Sopenharmony_ci	}
4735e5c31af7Sopenharmony_ci
4736e5c31af7Sopenharmony_ci	return masks.str();
4737e5c31af7Sopenharmony_ci}
4738e5c31af7Sopenharmony_ci
4739e5c31af7Sopenharmony_cistatic std::vector<deUint32> tripleDepthStencilMasks(std::vector<deUint32>& baseMasks)
4740e5c31af7Sopenharmony_ci{
4741e5c31af7Sopenharmony_ci	std::vector<deUint32> tripledMasks(baseMasks);
4742e5c31af7Sopenharmony_ci	std::vector<deUint32> partBMasks;
4743e5c31af7Sopenharmony_ci
4744e5c31af7Sopenharmony_ci	// a,b,c,d  =>  b,c,d,a
4745e5c31af7Sopenharmony_ci	partBMasks.insert(partBMasks.end(), baseMasks.begin() + 1, baseMasks.end());
4746e5c31af7Sopenharmony_ci	partBMasks.push_back(baseMasks[0]);
4747e5c31af7Sopenharmony_ci
4748e5c31af7Sopenharmony_ci	tripledMasks.insert(tripledMasks.end(), partBMasks.begin(), partBMasks.end());
4749e5c31af7Sopenharmony_ci	tripledMasks.insert(tripledMasks.end(), partBMasks.begin(), partBMasks.end());
4750e5c31af7Sopenharmony_ci
4751e5c31af7Sopenharmony_ci	return tripledMasks;
4752e5c31af7Sopenharmony_ci}
4753e5c31af7Sopenharmony_ci
4754e5c31af7Sopenharmony_civoid multiViewRenderCreateTests (tcu::TestCaseGroup* group)
4755e5c31af7Sopenharmony_ci{
4756e5c31af7Sopenharmony_ci	const deUint32				testCaseCount				= 7u;
4757e5c31af7Sopenharmony_ci	const string				shaderName[TEST_TYPE_LAST]	=
4758e5c31af7Sopenharmony_ci	{
4759e5c31af7Sopenharmony_ci		"masks",
4760e5c31af7Sopenharmony_ci		"vertex_shader",
4761e5c31af7Sopenharmony_ci		"fragment_shader",
4762e5c31af7Sopenharmony_ci		"geometry_shader",
4763e5c31af7Sopenharmony_ci		"tessellation_shader",
4764e5c31af7Sopenharmony_ci		"input_attachments",
4765e5c31af7Sopenharmony_ci		"input_attachments_geometry",
4766e5c31af7Sopenharmony_ci		"instanced",
4767e5c31af7Sopenharmony_ci		"input_instance",
4768e5c31af7Sopenharmony_ci		"draw_indirect",
4769e5c31af7Sopenharmony_ci		"draw_indirect_indexed",
4770e5c31af7Sopenharmony_ci		"draw_indexed",
4771e5c31af7Sopenharmony_ci		"clear_attachments",
4772e5c31af7Sopenharmony_ci		"secondary_cmd_buffer",
4773e5c31af7Sopenharmony_ci		"secondary_cmd_buffer_geometry",
4774e5c31af7Sopenharmony_ci		"point_size",
4775e5c31af7Sopenharmony_ci		"multisample",
4776e5c31af7Sopenharmony_ci		"queries",
4777e5c31af7Sopenharmony_ci		"non_precise_queries",
4778e5c31af7Sopenharmony_ci		"non_precise_queries_with_availability",
4779e5c31af7Sopenharmony_ci		"readback_implicit_clear",
4780e5c31af7Sopenharmony_ci		"readback_explicit_clear",
4781e5c31af7Sopenharmony_ci		"depth",
4782e5c31af7Sopenharmony_ci		"depth_different_ranges",
4783e5c31af7Sopenharmony_ci		"stencil",
4784e5c31af7Sopenharmony_ci		"view_mask_iteration",
4785e5c31af7Sopenharmony_ci	};
4786e5c31af7Sopenharmony_ci	const VkExtent3D			extent3D[testCaseCount]		=
4787e5c31af7Sopenharmony_ci	{
4788e5c31af7Sopenharmony_ci		{16u,	16u,	4u},
4789e5c31af7Sopenharmony_ci		{64u,	64u,	8u},
4790e5c31af7Sopenharmony_ci		{128u,	128u,	4u},
4791e5c31af7Sopenharmony_ci		{32u,	32u,	5u},
4792e5c31af7Sopenharmony_ci		{64u,	64u,	6u},
4793e5c31af7Sopenharmony_ci		{32u,	32u,	4u},
4794e5c31af7Sopenharmony_ci		{16u,	16u,	10u},
4795e5c31af7Sopenharmony_ci	};
4796e5c31af7Sopenharmony_ci	vector<deUint32>			viewMasks[testCaseCount];
4797e5c31af7Sopenharmony_ci
4798e5c31af7Sopenharmony_ci	viewMasks[0].push_back(15u);	//1111
4799e5c31af7Sopenharmony_ci
4800e5c31af7Sopenharmony_ci	viewMasks[1].push_back(8u);		//1000
4801e5c31af7Sopenharmony_ci
4802e5c31af7Sopenharmony_ci	viewMasks[2].push_back(1u);		//0001
4803e5c31af7Sopenharmony_ci	viewMasks[2].push_back(2u);		//0010
4804e5c31af7Sopenharmony_ci	viewMasks[2].push_back(4u);		//0100
4805e5c31af7Sopenharmony_ci	viewMasks[2].push_back(8u);		//1000
4806e5c31af7Sopenharmony_ci
4807e5c31af7Sopenharmony_ci	viewMasks[3].push_back(15u);	//1111
4808e5c31af7Sopenharmony_ci	viewMasks[3].push_back(15u);	//1111
4809e5c31af7Sopenharmony_ci	viewMasks[3].push_back(15u);	//1111
4810e5c31af7Sopenharmony_ci	viewMasks[3].push_back(15u);	//1111
4811e5c31af7Sopenharmony_ci
4812e5c31af7Sopenharmony_ci	viewMasks[4].push_back(8u);		//1000
4813e5c31af7Sopenharmony_ci	viewMasks[4].push_back(1u);		//0001
4814e5c31af7Sopenharmony_ci	viewMasks[4].push_back(1u);		//0001
4815e5c31af7Sopenharmony_ci	viewMasks[4].push_back(8u);		//1000
4816e5c31af7Sopenharmony_ci
4817e5c31af7Sopenharmony_ci	viewMasks[5].push_back(5u);		//0101
4818e5c31af7Sopenharmony_ci	viewMasks[5].push_back(10u);	//1010
4819e5c31af7Sopenharmony_ci	viewMasks[5].push_back(5u);		//0101
4820e5c31af7Sopenharmony_ci	viewMasks[5].push_back(10u);	//1010
4821e5c31af7Sopenharmony_ci
4822e5c31af7Sopenharmony_ci	const deUint32 minSupportedMultiviewViewCount	= 6u;
4823e5c31af7Sopenharmony_ci	const deUint32 maxViewMask						= (1u << minSupportedMultiviewViewCount) - 1u;
4824e5c31af7Sopenharmony_ci
4825e5c31af7Sopenharmony_ci	for (deUint32 mask = 1u; mask <= maxViewMask; mask = mask << 1u)
4826e5c31af7Sopenharmony_ci		viewMasks[testCaseCount - 1].push_back(mask);
4827e5c31af7Sopenharmony_ci
4828e5c31af7Sopenharmony_ci	vector<deUint32>			depthStencilMasks;
4829e5c31af7Sopenharmony_ci
4830e5c31af7Sopenharmony_ci	depthStencilMasks.push_back(3u);	// 0011
4831e5c31af7Sopenharmony_ci	depthStencilMasks.push_back(6u);	// 0110
4832e5c31af7Sopenharmony_ci	depthStencilMasks.push_back(12u);	// 1100
4833e5c31af7Sopenharmony_ci	depthStencilMasks.push_back(9u);	// 1001
4834e5c31af7Sopenharmony_ci
4835e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
4836e5c31af7Sopenharmony_ci	int numberOfRenderingTypes = 3;
4837e5c31af7Sopenharmony_ci#else
4838e5c31af7Sopenharmony_ci	int numberOfRenderingTypes = 2;
4839e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC
4840e5c31af7Sopenharmony_ci
4841e5c31af7Sopenharmony_ci	for (int renderPassTypeNdx = 0; renderPassTypeNdx < numberOfRenderingTypes; ++renderPassTypeNdx)
4842e5c31af7Sopenharmony_ci	{
4843e5c31af7Sopenharmony_ci		RenderingType				renderPassType	(RENDERING_TYPE_RENDERPASS_LEGACY);
4844e5c31af7Sopenharmony_ci		MovePtr<tcu::TestCaseGroup>	targetGroup		(DE_NULL);
4845e5c31af7Sopenharmony_ci		tcu::TestCaseGroup*			targetGroupPtr	(group);
4846e5c31af7Sopenharmony_ci
4847e5c31af7Sopenharmony_ci		if (renderPassTypeNdx == 1)
4848e5c31af7Sopenharmony_ci		{
4849e5c31af7Sopenharmony_ci			renderPassType	= RENDERING_TYPE_RENDERPASS2;
4850e5c31af7Sopenharmony_ci			targetGroup		= MovePtr<tcu::TestCaseGroup>(new tcu::TestCaseGroup(group->getTestContext(), "renderpass2"));
4851e5c31af7Sopenharmony_ci			targetGroupPtr	= targetGroup.get();
4852e5c31af7Sopenharmony_ci		}
4853e5c31af7Sopenharmony_ci		else if (renderPassTypeNdx == 2)
4854e5c31af7Sopenharmony_ci		{
4855e5c31af7Sopenharmony_ci			renderPassType	= RENDERING_TYPE_DYNAMIC_RENDERING;
4856e5c31af7Sopenharmony_ci			targetGroup		= MovePtr<tcu::TestCaseGroup>(new tcu::TestCaseGroup(group->getTestContext(), "dynamic_rendering"));
4857e5c31af7Sopenharmony_ci			targetGroupPtr	= targetGroup.get();
4858e5c31af7Sopenharmony_ci		}
4859e5c31af7Sopenharmony_ci
4860e5c31af7Sopenharmony_ci		tcu::TestContext&			testCtx				(targetGroupPtr->getTestContext());
4861e5c31af7Sopenharmony_ci		// ViewIndex rendering tests.
4862e5c31af7Sopenharmony_ci		MovePtr<tcu::TestCaseGroup>	groupViewIndex		(new tcu::TestCaseGroup(testCtx, "index"));
4863e5c31af7Sopenharmony_ci
4864e5c31af7Sopenharmony_ci		for (int testTypeNdx = TEST_TYPE_VIEW_MASK; testTypeNdx < TEST_TYPE_LAST; ++testTypeNdx)
4865e5c31af7Sopenharmony_ci		{
4866e5c31af7Sopenharmony_ci			MovePtr<tcu::TestCaseGroup>	groupShader			(new tcu::TestCaseGroup(testCtx, shaderName[testTypeNdx].c_str()));
4867e5c31af7Sopenharmony_ci			const TestType				testType			= static_cast<TestType>(testTypeNdx);
4868e5c31af7Sopenharmony_ci			const VkSampleCountFlagBits	sampleCountFlags	= (testType == TEST_TYPE_MULTISAMPLE) ? VK_SAMPLE_COUNT_4_BIT : VK_SAMPLE_COUNT_1_BIT;
4869e5c31af7Sopenharmony_ci			VkFormat				colorFormat;
4870e5c31af7Sopenharmony_ci
4871e5c31af7Sopenharmony_ci			if (testType == TEST_TYPE_MULTISAMPLE)
4872e5c31af7Sopenharmony_ci				colorFormat = VK_FORMAT_R32G32B32A32_SFLOAT;
4873e5c31af7Sopenharmony_ci			else if (testType == TEST_TYPE_VIEW_MASK_ITERATION)
4874e5c31af7Sopenharmony_ci				colorFormat = VK_FORMAT_R8G8B8A8_UINT;
4875e5c31af7Sopenharmony_ci			else
4876e5c31af7Sopenharmony_ci				colorFormat = VK_FORMAT_R8G8B8A8_UNORM;
4877e5c31af7Sopenharmony_ci
4878e5c31af7Sopenharmony_ci			// subpassLoad can't be used with dynamic rendering
4879e5c31af7Sopenharmony_ci			if ((testTypeNdx == TEST_TYPE_INPUT_ATTACHMENTS) && (renderPassType == RENDERING_TYPE_DYNAMIC_RENDERING))
4880e5c31af7Sopenharmony_ci				continue;
4881e5c31af7Sopenharmony_ci
4882e5c31af7Sopenharmony_ci			if (testTypeNdx == TEST_TYPE_VIEW_MASK_ITERATION)
4883e5c31af7Sopenharmony_ci			{
4884e5c31af7Sopenharmony_ci				for (deUint32 testCaseNdx = 0u; testCaseNdx < testCaseCount; ++testCaseNdx)
4885e5c31af7Sopenharmony_ci				{
4886e5c31af7Sopenharmony_ci					const TestParameters	parameters	=	{ extent3D[testCaseNdx], viewMasks[testCaseNdx], testType, sampleCountFlags, colorFormat, QUERY_TYPE_GET_QUERY_POOL_RESULTS, renderPassType };
4887e5c31af7Sopenharmony_ci					const std::string		testName	=	createViewMasksName(parameters.viewMasks);
4888e5c31af7Sopenharmony_ci
4889e5c31af7Sopenharmony_ci					groupShader->addChild(new MultiViewRenderTestsCase(testCtx, testName.c_str(), parameters));
4890e5c31af7Sopenharmony_ci				}
4891e5c31af7Sopenharmony_ci			}
4892e5c31af7Sopenharmony_ci			else
4893e5c31af7Sopenharmony_ci			{
4894e5c31af7Sopenharmony_ci				for (int queryTypeNdx = 0; queryTypeNdx < 2; ++queryTypeNdx)
4895e5c31af7Sopenharmony_ci				{
4896e5c31af7Sopenharmony_ci					const std::string queryTestName = queryTypeNdx == 0 ? "get_query_pool_results" : "cmd_copy_query_pool_results";
4897e5c31af7Sopenharmony_ci					const auto queryType = queryTypeNdx == 0 ? QUERY_TYPE_GET_QUERY_POOL_RESULTS : QUERY_TYPE_CMD_COPY_QUERY_POOL_RESULTS;
4898e5c31af7Sopenharmony_ci					MovePtr<tcu::TestCaseGroup>	queryTypeGroup(new tcu::TestCaseGroup(testCtx, queryTestName.c_str()));
4899e5c31af7Sopenharmony_ci
4900e5c31af7Sopenharmony_ci					if (testTypeNdx == TEST_TYPE_DEPTH ||
4901e5c31af7Sopenharmony_ci						testTypeNdx == TEST_TYPE_DEPTH_DIFFERENT_RANGES ||
4902e5c31af7Sopenharmony_ci						testTypeNdx == TEST_TYPE_STENCIL)
4903e5c31af7Sopenharmony_ci					{
4904e5c31af7Sopenharmony_ci						const VkExtent3D		dsTestExtent3D	= { 64u, 64u, 4u };
4905e5c31af7Sopenharmony_ci						const TestParameters	parameters		= { dsTestExtent3D, tripleDepthStencilMasks(depthStencilMasks), testType, sampleCountFlags, colorFormat, queryType, renderPassType };
4906e5c31af7Sopenharmony_ci						const std::string		testName		= createViewMasksName(parameters.viewMasks);
4907e5c31af7Sopenharmony_ci
4908e5c31af7Sopenharmony_ci						queryTypeGroup->addChild(new MultiViewRenderTestsCase(testCtx, testName.c_str(), parameters));
4909e5c31af7Sopenharmony_ci					}
4910e5c31af7Sopenharmony_ci					else
4911e5c31af7Sopenharmony_ci					{
4912e5c31af7Sopenharmony_ci						for (deUint32 testCaseNdx = 0u; testCaseNdx < testCaseCount; ++testCaseNdx)
4913e5c31af7Sopenharmony_ci						{
4914e5c31af7Sopenharmony_ci							const TestParameters	parameters	=	{ extent3D[testCaseNdx], viewMasks[testCaseNdx], testType, sampleCountFlags, colorFormat, queryType, renderPassType };
4915e5c31af7Sopenharmony_ci							const std::string		testName	=	createViewMasksName(parameters.viewMasks);
4916e5c31af7Sopenharmony_ci
4917e5c31af7Sopenharmony_ci							queryTypeGroup->addChild(new MultiViewRenderTestsCase(testCtx, testName.c_str(), parameters));
4918e5c31af7Sopenharmony_ci						}
4919e5c31af7Sopenharmony_ci
4920e5c31af7Sopenharmony_ci						// maxMultiviewViewCount case
4921e5c31af7Sopenharmony_ci						{
4922e5c31af7Sopenharmony_ci							const VkExtent3D		incompleteExtent3D	= { 16u, 16u, 0u };
4923e5c31af7Sopenharmony_ci							const vector<deUint32>	unusedMasks;
4924e5c31af7Sopenharmony_ci							const TestParameters	parameters			= { incompleteExtent3D, unusedMasks, testType, sampleCountFlags, colorFormat, queryType, renderPassType };
4925e5c31af7Sopenharmony_ci
4926e5c31af7Sopenharmony_ci							queryTypeGroup->addChild(new MultiViewRenderTestsCase(testCtx, "max_multi_view_view_count", parameters));
4927e5c31af7Sopenharmony_ci						}
4928e5c31af7Sopenharmony_ci					}
4929e5c31af7Sopenharmony_ci					groupShader->addChild(queryTypeGroup.release());
4930e5c31af7Sopenharmony_ci				}
4931e5c31af7Sopenharmony_ci			}
4932e5c31af7Sopenharmony_ci
4933e5c31af7Sopenharmony_ci			switch (testType)
4934e5c31af7Sopenharmony_ci			{
4935e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_MASK:
4936e5c31af7Sopenharmony_ci				case TEST_TYPE_INPUT_ATTACHMENTS:
4937e5c31af7Sopenharmony_ci				case TEST_TYPE_INPUT_ATTACHMENTS_GEOMETRY:
4938e5c31af7Sopenharmony_ci				case TEST_TYPE_INSTANCED_RENDERING:
4939e5c31af7Sopenharmony_ci				case TEST_TYPE_INPUT_RATE_INSTANCE:
4940e5c31af7Sopenharmony_ci				case TEST_TYPE_DRAW_INDIRECT:
4941e5c31af7Sopenharmony_ci				case TEST_TYPE_DRAW_INDIRECT_INDEXED:
4942e5c31af7Sopenharmony_ci				case TEST_TYPE_DRAW_INDEXED:
4943e5c31af7Sopenharmony_ci				case TEST_TYPE_CLEAR_ATTACHMENTS:
4944e5c31af7Sopenharmony_ci				case TEST_TYPE_SECONDARY_CMD_BUFFER:
4945e5c31af7Sopenharmony_ci				case TEST_TYPE_SECONDARY_CMD_BUFFER_GEOMETRY:
4946e5c31af7Sopenharmony_ci				case TEST_TYPE_POINT_SIZE:
4947e5c31af7Sopenharmony_ci				case TEST_TYPE_MULTISAMPLE:
4948e5c31af7Sopenharmony_ci				case TEST_TYPE_QUERIES:
4949e5c31af7Sopenharmony_ci				case TEST_TYPE_NON_PRECISE_QUERIES:
4950e5c31af7Sopenharmony_ci				case TEST_TYPE_NON_PRECISE_QUERIES_WITH_AVAILABILITY:
4951e5c31af7Sopenharmony_ci				case TEST_TYPE_READBACK_WITH_IMPLICIT_CLEAR:
4952e5c31af7Sopenharmony_ci				case TEST_TYPE_READBACK_WITH_EXPLICIT_CLEAR:
4953e5c31af7Sopenharmony_ci				case TEST_TYPE_DEPTH:
4954e5c31af7Sopenharmony_ci				case TEST_TYPE_DEPTH_DIFFERENT_RANGES:
4955e5c31af7Sopenharmony_ci				case TEST_TYPE_STENCIL:
4956e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_MASK_ITERATION:
4957e5c31af7Sopenharmony_ci					targetGroupPtr->addChild(groupShader.release());
4958e5c31af7Sopenharmony_ci					break;
4959e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_INDEX_IN_VERTEX:
4960e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_INDEX_IN_FRAGMENT:
4961e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_INDEX_IN_GEOMETRY:
4962e5c31af7Sopenharmony_ci				case TEST_TYPE_VIEW_INDEX_IN_TESELLATION:
4963e5c31af7Sopenharmony_ci					groupViewIndex->addChild(groupShader.release());
4964e5c31af7Sopenharmony_ci					break;
4965e5c31af7Sopenharmony_ci				default:
4966e5c31af7Sopenharmony_ci					DE_ASSERT(0);
4967e5c31af7Sopenharmony_ci					break;
4968e5c31af7Sopenharmony_ci			}
4969e5c31af7Sopenharmony_ci		}
4970e5c31af7Sopenharmony_ci
4971e5c31af7Sopenharmony_ci		targetGroupPtr->addChild(groupViewIndex.release());
4972e5c31af7Sopenharmony_ci
4973e5c31af7Sopenharmony_ci		if (renderPassType != RENDERING_TYPE_RENDERPASS_LEGACY)
4974e5c31af7Sopenharmony_ci			group->addChild(targetGroup.release());
4975e5c31af7Sopenharmony_ci	}
4976e5c31af7Sopenharmony_ci}
4977e5c31af7Sopenharmony_ci
4978e5c31af7Sopenharmony_ci} //MultiView
4979e5c31af7Sopenharmony_ci} //vkt
4980