• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTCONDITIONALRENDERINGTESTUTIL_HPP
2 #define _VKTCONDITIONALRENDERINGTESTUTIL_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2018 The Khronos Group Inc.
8  * Copyright (c) 2018 Danylo Piliaiev <danylo.piliaiev@gmail.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  *//*!
23  * \file
24  * \brief Conditional Rendering Test Utils
25  *//*--------------------------------------------------------------------*/
26 
27 #include "vkDefs.hpp"
28 #include "vkObjUtil.hpp"
29 #include "vktDrawBufferObjectUtil.hpp"
30 #include "vktTestCase.hpp"
31 #include "deSharedPtr.hpp"
32 
33 namespace vkt
34 {
35 namespace conditional
36 {
37 
38 enum ConditionalBufferMemory { LOCAL, HOST };
39 
40 struct ConditionalData
41 {
42 	bool						conditionInPrimaryCommandBuffer;
43 	bool						conditionInSecondaryCommandBuffer;
44 	bool						conditionInverted;
45 	bool						conditionInherited;
46 	deUint32					conditionValue;
47 	bool						padConditionValue;
48 	bool						allocationOffset;	// Apply an offset to the condition variable buffer allocation.
49 	bool						clearInRenderPass;	// Clear the color attachment as part of beginning the render pass instead of outside.
50 
51 	bool						expectCommandExecution;
52 
53 	ConditionalBufferMemory		memoryType;
54 };
55 
56 static const ConditionalData s_testsData[] =
57 {
58 	//	CONDPRI	CONDSEC	INV		INH		V	PAD		ALLOCOFFSET	RP_CLEAR	RES		MEM
59 	{	true,	false,	false,	false,	1,	false,	false,		false,		true,	HOST	},
60 	{	true,	false,	false,	false,	0,	false,	false,		false,		false,	HOST	},
61 	{	true,	false,	true,	false,	0,	false,	false,		false,		true,	HOST	},
62 	{	true,	false,	true,	false,	1,	false,	false,		false,		false,	HOST	},
63 	{	true,	false,	false,	true,	1,	false,	false,		false,		true,	HOST	},
64 	{	true,	false,	false,	true,	0,	false,	false,		false,		false,	HOST	},
65 	{	true,	false,	true,	true,	0,	false,	false,		false,		true,	HOST	},
66 	{	true,	false,	true,	true,	1,	false,	false,		false,		false,	HOST	},
67 
68 	{	true,	false,	false,	false,	1,	false,	false,		false,		true,	LOCAL	},
69 	{	true,	false,	false,	false,	0,	false,	false,		false,		false,	LOCAL	},
70 	{	true,	false,	true,	false,	0,	false,	false,		false,		true,	LOCAL	},
71 	{	true,	false,	true,	false,	1,	false,	false,		false,		false,	LOCAL	},
72 	{	true,	false,	false,	true,	1,	false,	false,		false,		true,	LOCAL	},
73 	{	true,	false,	false,	true,	0,	false,	false,		false,		false,	LOCAL	},
74 	{	true,	false,	true,	true,	0,	false,	false,		false,		true,	LOCAL	},
75 	{	true,	false,	true,	true,	1,	false,	false,		false,		false,	LOCAL	},
76 
77 	{	false,	true,	false,	false,	1,	false,	false,		false,		true,	HOST	},
78 	{	false,	true,	false,	false,	0,	false,	false,		false,		false,	HOST	},
79 	{	false,	true,	true,	false,	0,	false,	false,		false,		true,	HOST	},
80 	{	false,	true,	true,	false,	1,	false,	false,		false,		false,	HOST	},
81 
82 	{	false,	true,	false,	false,	1,	false,	false,		false,		true,	LOCAL	},
83 	{	false,	true,	false,	false,	0,	false,	false,		false,		false,	LOCAL	},
84 	{	false,	true,	true,	false,	0,	false,	false,		false,		true,	LOCAL	},
85 	{	false,	true,	true,	false,	1,	false,	false,		false,		false,	LOCAL	},
86 
87 	// Test that inheritance does not affect outcome of secondary command buffer with conditional rendering or not.
88 	{	false,	false,	false,	true,	0,	false,	false,		false,		true,	HOST	},
89 	{	false,	false,	false,	true,	0,	false,	false,		false,		true,	LOCAL	},
90 
91 	{	false,	true,	false,	true,	1,	false,	false,		false,		true,	HOST	},
92 	{	false,	true,	false,	true,	0,	false,	false,		false,		false,	HOST	},
93 	{	false,	true,	true,	true,	1,	false,	false,		false,		false,	HOST	},
94 	{	false,	true,	true,	true,	0,	false,	false,		false,		true,	HOST	},
95 
96 	{	false,	true,	false,	true,	1,	false,	false,		false,		true,	LOCAL	},
97 	{	false,	true,	false,	true,	0,	false,	false,		false,		false,	LOCAL	},
98 	{	false,	true,	true,	true,	1,	false,	false,		false,		false,	LOCAL	},
99 	{	false,	true,	true,	true,	0,	false,	false,		false,		true,	LOCAL	},
100 
101 	// Test clearing the attachment when beginning the render pass.
102 	{	true,	false,	false,	false,	1,	false,	false,		true,		true,	HOST	},
103 	{	true,	false,	false,	false,	0,	false,	false,		true,		false,	HOST	},
104 	{	true,	false,	true,	false,	0,	false,	false,		true,		true,	HOST	},
105 	{	true,	false,	true,	false,	1,	false,	false,		true,		false,	HOST	},
106 };
107 
108 std::ostream&				operator<< (std::ostream& str, ConditionalData const& c);
109 
110 void						checkConditionalRenderingCapabilities	(vkt::Context& context, const ConditionalData& data);
111 de::SharedPtr<Draw::Buffer>	createConditionalRenderingBuffer		(vkt::Context& context, const ConditionalData& data);
112 void						beginConditionalRendering				(const vk::DeviceInterface& vk,
113 																	 vk::VkCommandBuffer cmdBuffer,
114 																	 Draw::Buffer& buffer,
115 																	 const ConditionalData& data);
116 
117 } // conditional
118 } // vkt
119 
120 #endif // _VKTCONDITIONALRENDERINGTESTUTIL_HPP
121