1 #ifndef _VKTSPARSERESOURCESSHADERINTRINSICSBASE_HPP
2 #define _VKTSPARSERESOURCESSHADERINTRINSICSBASE_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
22 * \file vktSparseResourcesShaderIntrinsicsBase.hpp
23 * \brief Sparse Resources Shader Intrinsics Base Classes
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "vktTestCase.hpp"
28 #include "vktTestCaseUtil.hpp"
29 #include "vktSparseResourcesBase.hpp"
30 #include "vktSparseResourcesTestsUtil.hpp"
34 #include "vkRefUtil.hpp"
35 #include "vkPlatform.hpp"
36 #include "vkPrograms.hpp"
37 #include "vkRefUtil.hpp"
38 #include "vkMemUtil.hpp"
39 #include "vkQueryUtil.hpp"
40 #include "vkBuilderUtil.hpp"
41 #include "vkTypeUtil.hpp"
42 #include "vkDebugReportUtil.hpp"
43 #include "tcuTextureUtil.hpp"
45 #include "deStringUtil.hpp"
46 #include "deUniquePtr.hpp"
47 #include "deSharedPtr.hpp"
61 MEMORY_BLOCK_BOUND = 0u,
62 MEMORY_BLOCK_NOT_BOUND = 1u,
63 MEMORY_BLOCK_TYPE_COUNT = 2u
68 MEMORY_BLOCK_BOUND_VALUE = 1u,
69 MEMORY_BLOCK_NOT_BOUND_VALUE = 2u
74 BINDING_IMAGE_SPARSE = 0u,
75 BINDING_IMAGE_TEXELS = 1u,
76 BINDING_IMAGE_RESIDENCY = 2u
83 SPARSE_SAMPLE_EXPLICIT_LOD,
84 SPARSE_SAMPLE_IMPLICIT_LOD,
86 SPARSE_SPIRV_FUNCTION_TYPE_LAST
89 std::string getOpTypeImageComponent (const tcu::TextureFormat& format);
90 std::string getImageComponentTypeName (const tcu::TextureFormat& format);
91 std::string getImageComponentVec4TypeName (const tcu::TextureFormat& format);
93 std::string getOpTypeImageSparse (const ImageType imageType,
94 const tcu::TextureFormat& format,
95 const std::string& componentType,
96 const bool requiresSampler);
98 std::string getOpTypeImageResidency (const ImageType imageType);
100 class SparseShaderIntrinsicsCaseBase : public TestCase
103 SparseShaderIntrinsicsCaseBase (tcu::TestContext& testCtx,
104 const std::string& name,
105 const SpirVFunction function,
106 const ImageType imageType,
107 const tcu::UVec3& imageSize,
108 const tcu::TextureFormat& format)
109 : TestCase(testCtx, name, "")
110 , m_function(function)
111 , m_imageType(imageType)
112 , m_imageSize(imageSize)
118 const SpirVFunction m_function;
119 const ImageType m_imageType;
120 const tcu::UVec3 m_imageSize;
121 const tcu::TextureFormat m_format;
124 class SparseShaderIntrinsicsInstanceBase : public SparseResourcesBaseInstance
127 SparseShaderIntrinsicsInstanceBase (Context& context,
128 const SpirVFunction function,
129 const ImageType imageType,
130 const tcu::UVec3& imageSize,
131 const tcu::TextureFormat& format)
132 : SparseResourcesBaseInstance(context)
133 , m_function(function)
134 , m_imageType(imageType)
135 , m_imageSize(imageSize)
137 , m_residencyFormat(tcu::TextureFormat::R, tcu::TextureFormat::UNSIGNED_INT32)
141 tcu::TestStatus iterate (void);
143 virtual vk::VkImageUsageFlags imageSparseUsageFlags (void) const = 0;
144 virtual vk::VkImageUsageFlags imageOutputUsageFlags (void) const = 0;
146 virtual vk::VkQueueFlags getQueueFlags (void) const = 0;
148 virtual void recordCommands (vk::Allocator& allocator,
149 const vk::VkCommandBuffer commandBuffer,
150 const vk::VkImageCreateInfo& imageSparseInfo,
151 const vk::VkImage imageSparse,
152 const vk::VkImage imageTexels,
153 const vk::VkImage imageResidency) = 0;
155 const SpirVFunction m_function;
156 const ImageType m_imageType;
157 const tcu::UVec3 m_imageSize;
158 const tcu::TextureFormat m_format;
159 const tcu::TextureFormat m_residencyFormat;
161 typedef de::SharedPtr< vk::Unique<vk::VkPipeline> > SharedVkPipeline;
162 std::vector<SharedVkPipeline> pipelines;
164 typedef de::SharedPtr< vk::Unique<vk::VkImageView> > SharedVkImageView;
165 std::vector<SharedVkImageView> imageSparseViews;
166 std::vector<SharedVkImageView> imageTexelsViews;
167 std::vector<SharedVkImageView> imageResidencyViews;
169 vk::Move<vk::VkDescriptorPool> descriptorPool;
171 typedef de::SharedPtr< vk::Unique<vk::VkDescriptorSet> > SharedVkDescriptorSet;
172 std::vector<SharedVkDescriptorSet> descriptorSets;
178 #endif // _VKTSPARSERESOURCESSHADERINTRINSICSBASE_HPP