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 	tcu::Vec4 position;
     58 	tcu::Vec4 color;
     59 };
     60 
     61 struct ReferenceImageCoordinates
     62 {
     63 	ReferenceImageCoordinates (void)
     64 		: left		(-0.3)
     65 		, right		(0.3)
     66 		, top		(0.3)
     67 		, bottom	(-0.3)
     68 	{
     69 	}
     70 
     71 	double left;
     72 	double right;
     73 	double top;
     74 	double bottom;
     75 };
     76 
     77 struct ReferenceImageInstancedCoordinates
     78 {
     79 	ReferenceImageInstancedCoordinates (void)
     80 		: left		(-0.3)
     81 		, right		(0.6)
     82 		, top		(0.3)
     83 		, bottom	(-0.6)
     84 	{
     85 	}
     86 
     87 	double left;
     88 	double right;
     89 	double top;
     90 	double bottom;
     91 };
     92 
     93 class DrawTestsBaseClass : public TestInstance
     94 {
     95 public:
     96 								DrawTestsBaseClass	(Context& context, const char* vertexShaderName, const char* fragmentShaderName);
     97 
     98 protected:
     99 	void						initialize			(void);
    100 	virtual void				initPipeline		(const vk::VkDevice device);
    101 	void						beginRenderPass		(void);
    102 	virtual tcu::TestStatus		iterate				(void)						{ TCU_FAIL("Implement iterate() method!");	}
    103 
    104 	enum
    105 	{
    106 		WIDTH = 256,
    107 		HEIGHT = 256
    108 	};
    109 
    110 	vk::VkFormat									m_colorAttachmentFormat;
    111 
    112 	vk::VkPrimitiveTopology							m_topology;
    113 
    114 	const vk::DeviceInterface&						m_vk;
    115 
    116 	vk::Move<vk::VkPipeline>						m_pipeline;
    117 	vk::Move<vk::VkPipelineLayout>					m_pipelineLayout;
    118 
    119 	de::SharedPtr<Image>							m_colorTargetImage;
    120 	vk::Move<vk::VkImageView>						m_colorTargetView;
    121 
    122 	de::SharedPtr<Buffer>							m_vertexBuffer;
    123 	PipelineCreateInfo::VertexInputState			m_vertexInputState;
    124 
    125 	vk::Move<vk::VkCommandPool>						m_cmdPool;
    126 	vk::Move<vk::VkCommandBuffer>					m_cmdBuffer;
    127 
    128 	vk::Move<vk::VkFramebuffer>						m_framebuffer;
    129 	vk::Move<vk::VkRenderPass>						m_renderPass;
    130 
    131 	const std::string								m_vertexShaderName;
    132 	const std::string								m_fragmentShaderName;
    133 
    134 	std::vector<PositionColorVertex>				m_data;
    135 	std::vector<deUint32>							m_indexes;
    136 	de::SharedPtr<Buffer>							m_indexBuffer;
    137 };
    138 
    139 }	// Draw
    140 }	// vkt
    141 
    142 #endif // _VKTDRAWBASECLASS_HPP
    143