• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTDYNAMICSTATEBASECLASS_HPP
2 #define _VKTDYNAMICSTATEBASECLASS_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
6 *
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Intel Corporation
9 * Copyright (c) 2023 LunarG, Inc.
10 * Copyright (c) 2023 Nintendo
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 *      http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 *//*!
25 * \file
26 * \brief Dynamic State Tests - Base Class
27 *//*--------------------------------------------------------------------*/
28 
29 #include "tcuDefs.hpp"
30 #include "vktTestCase.hpp"
31 
32 #include "vktDynamicStateTestCaseUtil.hpp"
33 #include "vktDrawImageObjectUtil.hpp"
34 #include "vktDrawBufferObjectUtil.hpp"
35 #include "vktDrawCreateInfoUtil.hpp"
36 #include "vkPipelineConstructionUtil.hpp"
37 
38 namespace vkt
39 {
40 namespace DynamicState
41 {
42 
43 class DynamicStateBaseClass : public TestInstance
44 {
45 public:
46 	DynamicStateBaseClass (Context& context,
47 						   vk::PipelineConstructionType pipelineConstructionType,
48 						   const char* vertexShaderName,
49 						   const char* fragmentShaderName,
50 						   const char* meshShaderName = nullptr);
51 
52 protected:
53 	void					initialize						(void);
54 
55 	virtual void			initRenderPass					(const vk::VkDevice				device);
56 	virtual void			initFramebuffer					(const vk::VkDevice				device);
57 	virtual void			initPipeline					(const vk::VkDevice				device);
58 
59 	virtual tcu::TestStatus iterate							(void);
60 
61 	void					beginRenderPass					(void);
62 
63 	void					beginRenderPassWithClearColor	(const vk::VkClearColorValue&	clearColor,
64 															 const bool						skipBeginCmdBuffer	= false,
65 															 const bool						previousTransfer = false);
66 
67 	void					setDynamicViewportState			(const deUint32					width,
68 															const deUint32					height);
69 
70 	void					setDynamicViewportState			(deUint32						viewportCount,
71 															 const vk::VkViewport*			pViewports,
72 															 const vk::VkRect2D*			pScissors);
73 
74 	void					setDynamicRasterizationState	(const float					lineWidth = 1.0f,
75 															 const float					depthBiasConstantFactor = 0.0f,
76 															 const float					depthBiasClamp = 0.0f,
77 															 const float					depthBiasSlopeFactor = 0.0f);
78 
79 	void					setDynamicBlendState			(const float					const1 = 0.0f, const float const2 = 0.0f,
80 															 const float					const3 = 0.0f, const float const4 = 0.0f);
81 
82 	void					setDynamicDepthStencilState		(const float					minDepthBounds = 0.0f,
83 															 const float					maxDepthBounds = 1.0f,
84 															 const deUint32					stencilFrontCompareMask = 0xffffffffu,
85 															 const deUint32					stencilFrontWriteMask = 0xffffffffu,
86 															 const deUint32					stencilFrontReference = 0,
87 															 const deUint32					stencilBackCompareMask = 0xffffffffu,
88 															 const deUint32					stencilBackWriteMask = 0xffffffffu,
89 															 const deUint32					stencilBackReference = 0);
90 
91 #ifndef CTS_USES_VULKANSC
92 	void					pushVertexOffset				(const uint32_t					vertexOffset,
93 															 const vk::VkPipelineLayout		pipelineLayout,
94 															 const vk::VkShaderStageFlags	stageFlags = vk::VK_SHADER_STAGE_MESH_BIT_EXT);
95 #endif // CTS_USES_VULKANSC
96 
97 	enum
98 	{
99 		WIDTH       = 128,
100 		HEIGHT      = 128
101 	};
102 
103 	vk::PipelineConstructionType							m_pipelineConstructionType;
104 	vk::VkFormat											m_colorAttachmentFormat;
105 
106 	vk::VkPrimitiveTopology									m_topology;
107 
108 	const vk::DeviceInterface&								m_vk;
109 
110 	vk::Move<vk::VkDescriptorPool>							m_descriptorPool;
111 	vk::Move<vk::VkDescriptorSetLayout>						m_meshSetLayout;
112 	vk::Move<vk::VkDescriptorSetLayout>						m_otherSetLayout;
113 	vk::PipelineLayoutWrapper								m_pipelineLayout;
114 	vk::Move<vk::VkDescriptorSet>							m_descriptorSet;
115 	vk::GraphicsPipelineWrapper								m_pipeline;
116 
117 	de::SharedPtr<Draw::Image>								m_colorTargetImage;
118 	vk::Move<vk::VkImageView>								m_colorTargetView;
119 
120 	Draw::PipelineCreateInfo::VertexInputState				m_vertexInputState;
121 	de::SharedPtr<Draw::Buffer>								m_vertexBuffer;
122 
123 	vk::Move<vk::VkCommandPool>								m_cmdPool;
124 	vk::Move<vk::VkCommandBuffer>							m_cmdBuffer;
125 
126 	vk::RenderPassWrapper									m_renderPass;
127 
128 	const std::string										m_vertexShaderName;
129 	const std::string										m_fragmentShaderName;
130 	const std::string										m_meshShaderName;
131 	std::vector<PositionColorVertex>						m_data;
132 	bool													m_isMesh;
133 
134 	Draw::PipelineCreateInfo::ColorBlendState::Attachment	m_attachmentState;
135 };
136 
137 } // DynamicState
138 } // vkt
139 
140 #endif // _VKTDYNAMICSTATEBASECLASS_HPP
141