Home | History | Annotate | Download | only in draw
      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 
     30 #include "tcuTestLog.hpp"
     31 #include "tcuResource.hpp"
     32 #include "tcuImageCompare.hpp"
     33 #include "tcuCommandLine.hpp"
     34 
     35 #include "vkRefUtil.hpp"
     36 #include "vkImageUtil.hpp"
     37 
     38 #include "deSharedPtr.hpp"
     39 
     40 #include "vkPrograms.hpp"
     41 
     42 #include "vktDrawCreateInfoUtil.hpp"
     43 #include "vktDrawImageObjectUtil.hpp"
     44 #include "vktDrawBufferObjectUtil.hpp"
     45 
     46 namespace vkt
     47 {
     48 namespace Draw
     49 {
     50 
     51 struct PositionColorVertex
     52 {
     53 				PositionColorVertex (tcu::Vec4 position_, tcu::Vec4 color_)
     54 					: position	(position_)
     55 					, color		(color_)
     56 				{}
     57 
     58 	tcu::Vec4	position;
     59 	tcu::Vec4	color;
     60 };
     61 
     62 struct VertexElementData : public PositionColorVertex
     63 {
     64 				VertexElementData (tcu::Vec4 position_, tcu::Vec4 color_, deUint32 refVertexIndex_)
     65 					: PositionColorVertex	(position_, color_)
     66 					, refVertexIndex		(refVertexIndex_)
     67 				{
     68 				}
     69 
     70 	deUint32	refVertexIndex;
     71 };
     72 
     73 struct ReferenceImageCoordinates
     74 {
     75 	ReferenceImageCoordinates (void)
     76 		: left		(-0.3)
     77 		, right		(0.3)
     78 		, top		(0.3)
     79 		, bottom	(-0.3)
     80 	{
     81 	}
     82 
     83 	double left;
     84 	double right;
     85 	double top;
     86 	double bottom;
     87 };
     88 
     89 struct ReferenceImageInstancedCoordinates
     90 {
     91 	ReferenceImageInstancedCoordinates (void)
     92 		: left		(-0.3)
     93 		, right		(0.6)
     94 		, top		(0.3)
     95 		, bottom	(-0.6)
     96 	{
     97 	}
     98 
     99 	double left;
    100 	double right;
    101 	double top;
    102 	double bottom;
    103 };
    104 
    105 class DrawTestsBaseClass : public TestInstance
    106 {
    107 public:
    108 								DrawTestsBaseClass	(Context& context, const char* vertexShaderName, const char* fragmentShaderName, vk::VkPrimitiveTopology topology = vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);
    109 
    110 protected:
    111 	void						initialize			(void);
    112 	virtual void				initPipeline		(const vk::VkDevice device);
    113 	void						beginRenderPass		(void);
    114 	virtual tcu::TestStatus		iterate				(void)						{ TCU_FAIL("Implement iterate() method!");	}
    115 
    116 	enum
    117 	{
    118 		WIDTH = 256,
    119 		HEIGHT = 256
    120 	};
    121 
    122 	vk::VkFormat									m_colorAttachmentFormat;
    123 
    124 	const vk::VkPrimitiveTopology					m_topology;
    125 
    126 	const vk::DeviceInterface&						m_vk;
    127 
    128 	vk::Move<vk::VkPipeline>						m_pipeline;
    129 	vk::Move<vk::VkPipelineLayout>					m_pipelineLayout;
    130 
    131 	de::SharedPtr<Image>							m_colorTargetImage;
    132 	vk::Move<vk::VkImageView>						m_colorTargetView;
    133 
    134 	// vertex buffer for vertex colors & position
    135 	de::SharedPtr<Buffer>							m_vertexBuffer;
    136 
    137 	// vertex buffer with reference data used in VS
    138 	de::SharedPtr<Buffer>							m_vertexRefDataBuffer;
    139 
    140 	PipelineCreateInfo::VertexInputState			m_vertexInputState;
    141 
    142 	vk::Move<vk::VkCommandPool>						m_cmdPool;
    143 	vk::Move<vk::VkCommandBuffer>					m_cmdBuffer;
    144 
    145 	vk::Move<vk::VkFramebuffer>						m_framebuffer;
    146 	vk::Move<vk::VkRenderPass>						m_renderPass;
    147 
    148 	const std::string								m_vertexShaderName;
    149 	const std::string								m_fragmentShaderName;
    150 
    151 	std::vector<VertexElementData>					m_data;
    152 };
    153 
    154 }	// Draw
    155 }	// vkt
    156 
    157 #endif // _VKTDRAWBASECLASS_HPP
    158