Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / draw / vktDrawBaseClass.hpp
1 #ifndef _VKTDRAWBASECLASS_HPP
2 #define _VKTDRAWBASECLASS_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2015 The Khronos Group Inc.
8  * Copyright (c) 2015 Intel Corporation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  *//*!
23  * \file
24  * \brief Command draw Tests - Base Class
25  *//*--------------------------------------------------------------------*/
26
27 #include "vkDefs.hpp"
28 #include "vktTestCase.hpp"
29 #include "vktDrawGroupParams.hpp"
30
31 #include "tcuTestLog.hpp"
32 #include "tcuResource.hpp"
33 #include "tcuImageCompare.hpp"
34 #include "tcuCommandLine.hpp"
35
36 #include "vkRefUtil.hpp"
37 #include "vkImageUtil.hpp"
38
39 #include "deSharedPtr.hpp"
40
41 #include "vkPrograms.hpp"
42
43 #include "vktDrawCreateInfoUtil.hpp"
44 #include "vktDrawImageObjectUtil.hpp"
45 #include "vktDrawBufferObjectUtil.hpp"
46
47 namespace vkt
48 {
49 namespace Draw
50 {
51
52 struct PositionColorVertex
53 {
54                                 PositionColorVertex (tcu::Vec4 position_, tcu::Vec4 color_)
55                                         : position      (position_)
56                                         , color         (color_)
57                                 {}
58
59         tcu::Vec4       position;
60         tcu::Vec4       color;
61 };
62
63 struct VertexElementData : public PositionColorVertex
64 {
65                                 VertexElementData (tcu::Vec4 position_, tcu::Vec4 color_, deUint32 refVertexIndex_)
66                                         : PositionColorVertex   (position_, color_)
67                                         , refVertexIndex                (refVertexIndex_)
68                                 {
69                                 }
70
71         deUint32        refVertexIndex;
72 };
73
74 struct ReferenceImageCoordinates
75 {
76         ReferenceImageCoordinates (void)
77                 : left          (-0.3)
78                 , right         (0.3)
79                 , top           (0.3)
80                 , bottom        (-0.3)
81         {
82         }
83
84         double left;
85         double right;
86         double top;
87         double bottom;
88 };
89
90 struct ReferenceImageInstancedCoordinates
91 {
92         ReferenceImageInstancedCoordinates (void)
93                 : left          (-0.3)
94                 , right         (0.6)
95                 , top           (0.3)
96                 , bottom        (-0.6)
97         {
98         }
99
100         double left;
101         double right;
102         double top;
103         double bottom;
104 };
105
106 class DrawTestsBaseClass : public TestInstance
107 {
108 public:
109                                                                 DrawTestsBaseClass      (Context& context, const char* vertexShaderName, const char* fragmentShaderName, const SharedGroupParams groupParams, vk::VkPrimitiveTopology topology = vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);
110
111 protected:
112         void                                            initialize                              (void);
113         virtual void                            initPipeline                    (const vk::VkDevice device);
114         void                                            preRenderBarriers               (void);
115         void                                            beginLegacyRender               (vk::VkCommandBuffer cmdBuffer, const vk::VkSubpassContents content = vk::VK_SUBPASS_CONTENTS_INLINE);
116         void                                            endLegacyRender                 (vk::VkCommandBuffer cmdBuffer);
117         virtual tcu::TestStatus         iterate                                 (void)                                          { TCU_FAIL("Implement iterate() method!");      }
118
119 #ifndef CTS_USES_VULKANSC
120         void                                            beginSecondaryCmdBuffer (const vk::DeviceInterface& vk, const vk::VkRenderingFlagsKHR renderingFlags = 0u);
121         void                                            beginDynamicRender              (vk::VkCommandBuffer cmdBuffer, const vk::VkRenderingFlagsKHR renderingFlags = 0u);
122         void                                            endDynamicRender                (vk::VkCommandBuffer cmdBuffer);
123 #endif // CTS_USES_VULKANSC
124
125         enum
126         {
127                 WIDTH = 256,
128                 HEIGHT = 256
129         };
130
131         vk::VkFormat                                                                    m_colorAttachmentFormat;
132
133         const SharedGroupParams                                                 m_groupParams;
134         const vk::VkPrimitiveTopology                                   m_topology;
135
136         const vk::DeviceInterface&                                              m_vk;
137
138         vk::Move<vk::VkPipeline>                                                m_pipeline;
139         vk::Move<vk::VkPipelineLayout>                                  m_pipelineLayout;
140
141         de::SharedPtr<Image>                                                    m_colorTargetImage;
142         vk::Move<vk::VkImageView>                                               m_colorTargetView;
143
144         // vertex buffer for vertex colors & position
145         de::SharedPtr<Buffer>                                                   m_vertexBuffer;
146
147         // vertex buffer with reference data used in VS
148         de::SharedPtr<Buffer>                                                   m_vertexRefDataBuffer;
149
150         PipelineCreateInfo::VertexInputState                    m_vertexInputState;
151
152         vk::Move<vk::VkCommandPool>                                             m_cmdPool;
153         vk::Move<vk::VkCommandBuffer>                                   m_cmdBuffer;
154         vk::Move<vk::VkCommandBuffer>                                   m_secCmdBuffer;
155
156         vk::Move<vk::VkFramebuffer>                                             m_framebuffer;
157         vk::Move<vk::VkRenderPass>                                              m_renderPass;
158
159         const std::string                                                               m_vertexShaderName;
160         const std::string                                                               m_fragmentShaderName;
161
162         std::vector<VertexElementData>                                  m_data;
163 };
164
165 }       // Draw
166 }       // vkt
167
168 #endif // _VKTDRAWBASECLASS_HPP