1 #ifndef _VKTPIPELINEIMAGESAMPLINGINSTANCE_HPP 2 #define _VKTPIPELINEIMAGESAMPLINGINSTANCE_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 The Khronos Group Inc. 8 * Copyright (c) 2015 Imagination Technologies Ltd. 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 Image sampling case 25 *//*--------------------------------------------------------------------*/ 26 27 #include "vkDefs.hpp" 28 29 #include "vktTestCase.hpp" 30 #include "vktTestCaseUtil.hpp" 31 #include "vktPipelineImageUtil.hpp" 32 #include "vktPipelineReferenceRenderer.hpp" 33 #include "vktPipelineVertexUtil.hpp" 34 #include "tcuVectorUtil.hpp" 35 #include "deSharedPtr.hpp" 36 37 namespace vkt 38 { 39 namespace pipeline 40 { 41 42 enum AllocationKind 43 { 44 ALLOCATION_KIND_SUBALLOCATED, 45 ALLOCATION_KIND_DEDICATED, 46 }; 47 48 struct ImageSamplingInstanceParams 49 { ImageSamplingInstanceParamsvkt::pipeline::ImageSamplingInstanceParams50 ImageSamplingInstanceParams (const tcu::UVec2& renderSize_, 51 vk::VkImageViewType imageViewType_, 52 vk::VkFormat imageFormat_, 53 const tcu::IVec3& imageSize_, 54 int layerCount_, 55 const vk::VkComponentMapping& componentMapping_, 56 const vk::VkImageSubresourceRange& subresourceRange_, 57 const vk::VkSamplerCreateInfo& samplerParams_, 58 float samplerLod_, 59 const std::vector<Vertex4Tex4>& vertices_, 60 bool separateStencilUsage_ = false, 61 vk::VkDescriptorType samplingType_ = vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 62 int imageCount_ = 1, 63 AllocationKind allocationKind_ = ALLOCATION_KIND_SUBALLOCATED) 64 : renderSize (renderSize_) 65 , imageViewType (imageViewType_) 66 , imageFormat (imageFormat_) 67 , imageSize (imageSize_) 68 , layerCount (layerCount_) 69 , componentMapping (componentMapping_) 70 , subresourceRange (subresourceRange_) 71 , samplerParams (samplerParams_) 72 , samplerLod (samplerLod_) 73 , vertices (vertices_) 74 , separateStencilUsage (separateStencilUsage_) 75 , samplingType (samplingType_) 76 , imageCount (imageCount_) 77 , allocationKind (allocationKind_) 78 {} 79 80 const tcu::UVec2 renderSize; 81 vk::VkImageViewType imageViewType; 82 vk::VkFormat imageFormat; 83 const tcu::IVec3 imageSize; 84 int layerCount; 85 const vk::VkComponentMapping componentMapping; 86 const vk::VkImageSubresourceRange subresourceRange; 87 const vk::VkSamplerCreateInfo samplerParams; 88 float samplerLod; 89 const std::vector<Vertex4Tex4> vertices; 90 bool separateStencilUsage; 91 vk::VkDescriptorType samplingType; 92 int imageCount; 93 AllocationKind allocationKind; 94 }; 95 96 void checkSupportImageSamplingInstance (Context& context, ImageSamplingInstanceParams params); 97 98 class ImageSamplingInstance : public vkt::TestInstance 99 { 100 public: 101 ImageSamplingInstance (Context& context, 102 ImageSamplingInstanceParams params); 103 104 virtual ~ImageSamplingInstance (void); 105 106 virtual tcu::TestStatus iterate (void); 107 108 protected: 109 tcu::TestStatus verifyImage (void); 110 111 private: 112 typedef vk::Unique<vk::VkImage> UniqueImage; 113 typedef vk::Unique<vk::VkImageView> UniqueImageView; 114 typedef de::UniquePtr<vk::Allocation> UniqueAlloc; 115 typedef de::SharedPtr<UniqueImage> SharedImagePtr; 116 typedef de::SharedPtr<UniqueImageView> SharedImageViewPtr; 117 typedef de::SharedPtr<UniqueAlloc> SharedAllocPtr; 118 119 const AllocationKind m_allocationKind; 120 const vk::VkDescriptorType m_samplingType; 121 const vk::VkImageViewType m_imageViewType; 122 const vk::VkFormat m_imageFormat; 123 const tcu::IVec3 m_imageSize; 124 const int m_layerCount; 125 const int m_imageCount; 126 127 const vk::VkComponentMapping m_componentMapping; 128 tcu::BVec4 m_componentMask; 129 const vk::VkImageSubresourceRange m_subresourceRange; 130 const vk::VkSamplerCreateInfo m_samplerParams; 131 const float m_samplerLod; 132 133 std::vector<SharedImagePtr> m_images; 134 std::vector<SharedAllocPtr> m_imageAllocs; 135 std::vector<SharedImageViewPtr> m_imageViews; 136 vk::Move<vk::VkSampler> m_sampler; 137 de::MovePtr<TestTexture> m_texture; 138 139 const tcu::UVec2 m_renderSize; 140 const vk::VkFormat m_colorFormat; 141 142 vk::Move<vk::VkDescriptorPool> m_descriptorPool; 143 vk::Move<vk::VkDescriptorSetLayout> m_descriptorSetLayout; 144 vk::Move<vk::VkDescriptorSet> m_descriptorSet; 145 146 std::vector<SharedImagePtr> m_colorImages; 147 std::vector<SharedAllocPtr> m_colorImageAllocs; 148 std::vector<SharedImageViewPtr> m_colorAttachmentViews; 149 vk::Move<vk::VkRenderPass> m_renderPass; 150 vk::Move<vk::VkFramebuffer> m_framebuffer; 151 152 vk::Move<vk::VkShaderModule> m_vertexShaderModule; 153 vk::Move<vk::VkShaderModule> m_fragmentShaderModule; 154 155 vk::Move<vk::VkBuffer> m_vertexBuffer; 156 std::vector<Vertex4Tex4> m_vertices; 157 de::MovePtr<vk::Allocation> m_vertexBufferAlloc; 158 159 vk::Move<vk::VkPipelineLayout> m_pipelineLayout; 160 vk::Move<vk::VkPipeline> m_graphicsPipeline; 161 162 vk::Move<vk::VkCommandPool> m_cmdPool; 163 vk::Move<vk::VkCommandBuffer> m_cmdBuffer; 164 }; 165 166 } // pipeline 167 } // vkt 168 169 #endif // _VKTPIPELINEIMAGESAMPLINGINSTANCE_HPP 170