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 { PositionColorVertexvkt::Draw::PositionColorVertex53 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 { VertexElementDatavkt::Draw::VertexElementData64 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 { ReferenceImageCoordinatesvkt::Draw::ReferenceImageCoordinates75 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 { ReferenceImageInstancedCoordinatesvkt::Draw::ReferenceImageInstancedCoordinates91 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, bool useDynamicRendering, 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 beginRender (const vk::VkSubpassContents content = vk::VK_SUBPASS_CONTENTS_INLINE); 114 void endRender (void); iterate(void)115 virtual tcu::TestStatus iterate (void) { TCU_FAIL("Implement iterate() method!"); } 116 117 enum 118 { 119 WIDTH = 256, 120 HEIGHT = 256 121 }; 122 123 vk::VkFormat m_colorAttachmentFormat; 124 125 const bool m_useDynamicRendering; 126 const vk::VkPrimitiveTopology m_topology; 127 128 const vk::DeviceInterface& m_vk; 129 130 vk::Move<vk::VkPipeline> m_pipeline; 131 vk::Move<vk::VkPipelineLayout> m_pipelineLayout; 132 133 de::SharedPtr<Image> m_colorTargetImage; 134 vk::Move<vk::VkImageView> m_colorTargetView; 135 136 // vertex buffer for vertex colors & position 137 de::SharedPtr<Buffer> m_vertexBuffer; 138 139 // vertex buffer with reference data used in VS 140 de::SharedPtr<Buffer> m_vertexRefDataBuffer; 141 142 PipelineCreateInfo::VertexInputState m_vertexInputState; 143 144 vk::Move<vk::VkCommandPool> m_cmdPool; 145 vk::Move<vk::VkCommandBuffer> m_cmdBuffer; 146 147 vk::Move<vk::VkFramebuffer> m_framebuffer; 148 vk::Move<vk::VkRenderPass> m_renderPass; 149 150 const std::string m_vertexShaderName; 151 const std::string m_fragmentShaderName; 152 153 std::vector<VertexElementData> m_data; 154 }; 155 156 } // Draw 157 } // vkt 158 159 #endif // _VKTDRAWBASECLASS_HPP 160