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 * Copyright (c) 2023 LunarG, Inc. 10 * Copyright (c) 2023 Nintendo 11 * 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 * 24 *//*! 25 * \file 26 * \brief Image sampling case 27 *//*--------------------------------------------------------------------*/ 28 29 #include "vkDefs.hpp" 30 31 #include "vktTestCase.hpp" 32 #include "vktTestCaseUtil.hpp" 33 #include "vktPipelineImageUtil.hpp" 34 #include "vktPipelineReferenceRenderer.hpp" 35 #include "vktPipelineVertexUtil.hpp" 36 #include "vkPipelineConstructionUtil.hpp" 37 #include "tcuVectorUtil.hpp" 38 #include "deSharedPtr.hpp" 39 40 namespace vkt 41 { 42 namespace pipeline 43 { 44 45 enum AllocationKind 46 { 47 ALLOCATION_KIND_SUBALLOCATED, 48 ALLOCATION_KIND_DEDICATED, 49 }; 50 51 struct ImageSamplingInstanceParams 52 { ImageSamplingInstanceParamsvkt::pipeline::ImageSamplingInstanceParams53 ImageSamplingInstanceParams (const vk::PipelineConstructionType pipelineConstructionType_, 54 const tcu::UVec2& renderSize_, 55 vk::VkImageViewType imageViewType_, 56 vk::VkFormat imageFormat_, 57 const tcu::IVec3& imageSize_, 58 int layerCount_, 59 const vk::VkComponentMapping& componentMapping_, 60 const vk::VkImageSubresourceRange& subresourceRange_, 61 const vk::VkSamplerCreateInfo& samplerParams_, 62 float samplerLod_, 63 const std::vector<Vertex4Tex4>& vertices_, 64 bool separateStencilUsage_ = false, 65 vk::VkDescriptorType samplingType_ = vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 66 int imageCount_ = 1, 67 AllocationKind allocationKind_ = ALLOCATION_KIND_SUBALLOCATED, 68 const vk::VkImageLayout imageLayout_ = vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 69 const vk::VkPipelineCreateFlags pipelineCreateFlags_ = 0u) 70 : pipelineConstructionType (pipelineConstructionType_) 71 , renderSize (renderSize_) 72 , imageViewType (imageViewType_) 73 , imageFormat (imageFormat_) 74 , imageSize (imageSize_) 75 , layerCount (layerCount_) 76 , componentMapping (componentMapping_) 77 , subresourceRange (subresourceRange_) 78 , samplerParams (samplerParams_) 79 , samplerLod (samplerLod_) 80 , vertices (vertices_) 81 , separateStencilUsage (separateStencilUsage_) 82 , samplingType (samplingType_) 83 , imageCount (imageCount_) 84 , allocationKind (allocationKind_) 85 , imageLayout (imageLayout_) 86 , pipelineCreateFlags (pipelineCreateFlags_) 87 {} 88 89 const vk::PipelineConstructionType pipelineConstructionType; 90 const tcu::UVec2 renderSize; 91 vk::VkImageViewType imageViewType; 92 vk::VkFormat imageFormat; 93 const tcu::IVec3 imageSize; 94 int layerCount; 95 const vk::VkComponentMapping componentMapping; 96 const vk::VkImageSubresourceRange subresourceRange; 97 const vk::VkSamplerCreateInfo samplerParams; 98 float samplerLod; 99 const std::vector<Vertex4Tex4> vertices; 100 bool separateStencilUsage; 101 vk::VkDescriptorType samplingType; 102 int imageCount; 103 AllocationKind allocationKind; 104 const vk::VkImageLayout imageLayout; 105 const vk::VkPipelineCreateFlags pipelineCreateFlags; 106 }; 107 108 void checkSupportImageSamplingInstance (Context& context, ImageSamplingInstanceParams params); 109 110 class ImageSamplingInstance : public vkt::TestInstance 111 { 112 public: 113 ImageSamplingInstance (Context& context, 114 ImageSamplingInstanceParams params); 115 116 virtual ~ImageSamplingInstance (void); 117 118 virtual tcu::TestStatus iterate (void); 119 120 protected: 121 virtual tcu::TestStatus verifyImage (void); 122 virtual void setup (void); 123 124 typedef vk::Unique<vk::VkImage> UniqueImage; 125 typedef vk::Unique<vk::VkImageView> UniqueImageView; 126 typedef de::UniquePtr<vk::Allocation> UniqueAlloc; 127 typedef de::SharedPtr<UniqueImage> SharedImagePtr; 128 typedef de::SharedPtr<UniqueImageView> SharedImageViewPtr; 129 typedef de::SharedPtr<UniqueAlloc> SharedAllocPtr; 130 131 const AllocationKind m_allocationKind; 132 const vk::VkDescriptorType m_samplingType; 133 const vk::VkImageViewType m_imageViewType; 134 const vk::VkFormat m_imageFormat; 135 const tcu::IVec3 m_imageSize; 136 const int m_layerCount; 137 const int m_imageCount; 138 139 const vk::VkComponentMapping m_componentMapping; 140 tcu::BVec4 m_componentMask; 141 const vk::VkImageSubresourceRange m_subresourceRange; 142 const vk::VkSamplerCreateInfo m_samplerParams; 143 const float m_samplerLod; 144 145 std::vector<SharedImagePtr> m_images; 146 std::vector<SharedAllocPtr> m_imageAllocs; 147 std::vector<SharedImageViewPtr> m_imageViews; 148 vk::Move<vk::VkSampler> m_sampler; 149 de::MovePtr<TestTexture> m_texture; 150 151 const tcu::UVec2 m_renderSize; 152 const vk::VkFormat m_colorFormat; 153 154 vk::Move<vk::VkDescriptorPool> m_descriptorPool; 155 vk::Move<vk::VkDescriptorSetLayout> m_descriptorSetLayout; 156 vk::Move<vk::VkDescriptorSet> m_descriptorSet; 157 158 std::vector<SharedImagePtr> m_colorImages; 159 std::vector<SharedAllocPtr> m_colorImageAllocs; 160 std::vector<SharedImageViewPtr> m_colorAttachmentViews; 161 vk::RenderPassWrapper m_renderPass; 162 163 vk::ShaderWrapper m_vertexShaderModule; 164 vk::ShaderWrapper m_fragmentShaderModule; 165 166 vk::Move<vk::VkBuffer> m_vertexBuffer; 167 std::vector<Vertex4Tex4> m_vertices; 168 de::MovePtr<vk::Allocation> m_vertexBufferAlloc; 169 170 vk::PipelineLayoutWrapper m_preRasterizationStatePipelineLayout; 171 vk::PipelineLayoutWrapper m_fragmentStatePipelineLayout; 172 vk::GraphicsPipelineWrapper m_graphicsPipeline; 173 const vk::PipelineConstructionType m_pipelineConstructionType; 174 175 vk::Move<vk::VkCommandPool> m_cmdPool; 176 vk::Move<vk::VkCommandBuffer> m_cmdBuffer; 177 178 const vk::VkImageLayout m_imageLayout; 179 }; 180 181 } // pipeline 182 } // vkt 183 184 #endif // _VKTPIPELINEIMAGESAMPLINGINSTANCE_HPP 185