• 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  *
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 Dynamic State Tests - Base Class
25  *//*--------------------------------------------------------------------*/
26 
27 #include "tcuDefs.hpp"
28 #include "vktTestCase.hpp"
29 
30 #include "vktDynamicStateTestCaseUtil.hpp"
31 #include "vktDrawImageObjectUtil.hpp"
32 #include "vktDrawBufferObjectUtil.hpp"
33 #include "vktDrawCreateInfoUtil.hpp"
34 
35 namespace vkt
36 {
37 namespace DynamicState
38 {
39 
40 class DynamicStateBaseClass : public TestInstance
41 {
42 public:
43 	DynamicStateBaseClass (Context& context, const char* vertexShaderName, const char* fragmentShaderName);
44 
45 protected:
46 	void					initialize						(void);
47 
48 	virtual void			initRenderPass					(const vk::VkDevice				device);
49 	virtual void			initFramebuffer					(const vk::VkDevice				device);
50 	virtual void			initPipeline					(const vk::VkDevice				device);
51 
52 	virtual tcu::TestStatus iterate							(void);
53 
54 	void					beginRenderPass					(void);
55 
56 	void					beginRenderPassWithClearColor	(const vk::VkClearColorValue&	clearColor,
57 															 const bool						skipBeginCmdBuffer	= false);
58 
59 	void					setDynamicViewportState			(const deUint32					width,
60 															const deUint32					height);
61 
62 	void					setDynamicViewportState			(deUint32						viewportCount,
63 															 const vk::VkViewport*			pViewports,
64 															 const vk::VkRect2D*			pScissors);
65 
66 	void					setDynamicRasterizationState	(const float					lineWidth = 1.0f,
67 															 const float					depthBiasConstantFactor = 0.0f,
68 															 const float					depthBiasClamp = 0.0f,
69 															 const float					depthBiasSlopeFactor = 0.0f);
70 
71 	void					setDynamicBlendState			(const float					const1 = 0.0f, const float const2 = 0.0f,
72 															 const float					const3 = 0.0f, const float const4 = 0.0f);
73 
74 	void					setDynamicDepthStencilState		(const float					minDepthBounds = -1.0f,
75 															 const float					maxDepthBounds = 1.0f,
76 															 const deUint32					stencilFrontCompareMask = 0xffffffffu,
77 															 const deUint32					stencilFrontWriteMask = 0xffffffffu,
78 															 const deUint32					stencilFrontReference = 0,
79 															 const deUint32					stencilBackCompareMask = 0xffffffffu,
80 															 const deUint32					stencilBackWriteMask = 0xffffffffu,
81 															 const deUint32					stencilBackReference = 0);
82 	enum
83 	{
84 		WIDTH       = 128,
85 		HEIGHT      = 128
86 	};
87 
88 	vk::VkFormat									m_colorAttachmentFormat;
89 
90 	vk::VkPrimitiveTopology							m_topology;
91 
92 	const vk::DeviceInterface&						m_vk;
93 
94 	vk::Move<vk::VkPipeline>						m_pipeline;
95 	vk::Move<vk::VkPipelineLayout>					m_pipelineLayout;
96 
97 	de::SharedPtr<Draw::Image>						m_colorTargetImage;
98 	vk::Move<vk::VkImageView>						m_colorTargetView;
99 
100 	Draw::PipelineCreateInfo::VertexInputState		m_vertexInputState;
101 	de::SharedPtr<Draw::Buffer>						m_vertexBuffer;
102 
103 	vk::Move<vk::VkCommandPool>						m_cmdPool;
104 	vk::Move<vk::VkCommandBuffer>					m_cmdBuffer;
105 
106 	vk::Move<vk::VkFramebuffer>						m_framebuffer;
107 	vk::Move<vk::VkRenderPass>						m_renderPass;
108 
109 	const std::string								m_vertexShaderName;
110 	const std::string								m_fragmentShaderName;
111 	std::vector<PositionColorVertex>				m_data;
112 };
113 
114 } // DynamicState
115 } // vkt
116 
117 #endif // _VKTDYNAMICSTATEBASECLASS_HPP
118