• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "vkPipelineConstructionUtil.hpp"
35 #include "tcuVectorUtil.hpp"
36 #include "deSharedPtr.hpp"
37 
38 namespace vkt
39 {
40 namespace pipeline
41 {
42 
43 enum AllocationKind
44 {
45 	ALLOCATION_KIND_SUBALLOCATED,
46 	ALLOCATION_KIND_DEDICATED,
47 };
48 
49 struct ImageSamplingInstanceParams
50 {
ImageSamplingInstanceParamsvkt::pipeline::ImageSamplingInstanceParams51 	ImageSamplingInstanceParams	(const vk::PipelineConstructionType		pipelineConstructionType_,
52 								 const tcu::UVec2&						renderSize_,
53 								 vk::VkImageViewType					imageViewType_,
54 								 vk::VkFormat							imageFormat_,
55 								 const tcu::IVec3&						imageSize_,
56 								 int									layerCount_,
57 								 const vk::VkComponentMapping&			componentMapping_,
58 								 const vk::VkImageSubresourceRange&		subresourceRange_,
59 								 const vk::VkSamplerCreateInfo&			samplerParams_,
60 								 float									samplerLod_,
61 								 const std::vector<Vertex4Tex4>&		vertices_,
62 								 bool									separateStencilUsage_ = false,
63 								 vk::VkDescriptorType					samplingType_ = vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
64 								 int									imageCount_ = 1,
65 								 AllocationKind							allocationKind_ = ALLOCATION_KIND_SUBALLOCATED,
66 								 const vk::VkImageLayout				imageLayout_ = vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
67 								 const vk::VkPipelineCreateFlags		pipelineCreateFlags_ = 0u)
68 	: pipelineConstructionType	(pipelineConstructionType_)
69 	, renderSize				(renderSize_)
70 	, imageViewType				(imageViewType_)
71 	, imageFormat				(imageFormat_)
72 	, imageSize					(imageSize_)
73 	, layerCount				(layerCount_)
74 	, componentMapping			(componentMapping_)
75 	, subresourceRange			(subresourceRange_)
76 	, samplerParams				(samplerParams_)
77 	, samplerLod				(samplerLod_)
78 	, vertices					(vertices_)
79 	, separateStencilUsage		(separateStencilUsage_)
80 	, samplingType				(samplingType_)
81 	, imageCount				(imageCount_)
82 	, allocationKind			(allocationKind_)
83 	, imageLayout				(imageLayout_)
84 	, pipelineCreateFlags		(pipelineCreateFlags_)
85 	{}
86 
87 	const vk::PipelineConstructionType	pipelineConstructionType;
88 	const tcu::UVec2					renderSize;
89 	vk::VkImageViewType					imageViewType;
90 	vk::VkFormat						imageFormat;
91 	const tcu::IVec3					imageSize;
92 	int									layerCount;
93 	const vk::VkComponentMapping		componentMapping;
94 	const vk::VkImageSubresourceRange	subresourceRange;
95 	const vk::VkSamplerCreateInfo		samplerParams;
96 	float								samplerLod;
97 	const std::vector<Vertex4Tex4>		vertices;
98 	bool								separateStencilUsage;
99 	vk::VkDescriptorType				samplingType;
100 	int									imageCount;
101 	AllocationKind						allocationKind;
102 	const vk::VkImageLayout				imageLayout;
103 	const vk::VkPipelineCreateFlags		pipelineCreateFlags;
104 };
105 
106 void checkSupportImageSamplingInstance (Context& context, ImageSamplingInstanceParams params);
107 
108 class ImageSamplingInstance : public vkt::TestInstance
109 {
110 public:
111 												ImageSamplingInstance	(Context&						context,
112 																		 ImageSamplingInstanceParams	params);
113 
114 	virtual										~ImageSamplingInstance	(void);
115 
116 	virtual tcu::TestStatus						iterate					(void);
117 
118 protected:
119 	virtual tcu::TestStatus						verifyImage				(void);
120 	virtual void								setup					(void);
121 
122 	typedef	vk::Unique<vk::VkImage>				UniqueImage;
123 	typedef	vk::Unique<vk::VkImageView>			UniqueImageView;
124 	typedef	de::UniquePtr<vk::Allocation>		UniqueAlloc;
125 	typedef	de::SharedPtr<UniqueImage>			SharedImagePtr;
126 	typedef	de::SharedPtr<UniqueImageView>		SharedImageViewPtr;
127 	typedef	de::SharedPtr<UniqueAlloc>			SharedAllocPtr;
128 
129 	const AllocationKind						m_allocationKind;
130 	const vk::VkDescriptorType					m_samplingType;
131 	const vk::VkImageViewType					m_imageViewType;
132 	const vk::VkFormat							m_imageFormat;
133 	const tcu::IVec3							m_imageSize;
134 	const int									m_layerCount;
135 	const int									m_imageCount;
136 
137 	const vk::VkComponentMapping				m_componentMapping;
138 	tcu::BVec4									m_componentMask;
139 	const vk::VkImageSubresourceRange			m_subresourceRange;
140 	const vk::VkSamplerCreateInfo				m_samplerParams;
141 	const float									m_samplerLod;
142 
143 	std::vector<SharedImagePtr>					m_images;
144 	std::vector<SharedAllocPtr>					m_imageAllocs;
145 	std::vector<SharedImageViewPtr>				m_imageViews;
146 	vk::Move<vk::VkSampler>						m_sampler;
147 	de::MovePtr<TestTexture>					m_texture;
148 
149 	const tcu::UVec2							m_renderSize;
150 	const vk::VkFormat							m_colorFormat;
151 
152 	vk::Move<vk::VkDescriptorPool>				m_descriptorPool;
153 	vk::Move<vk::VkDescriptorSetLayout>			m_descriptorSetLayout;
154 	vk::Move<vk::VkDescriptorSet>				m_descriptorSet;
155 
156 	std::vector<SharedImagePtr>					m_colorImages;
157 	std::vector<SharedAllocPtr>					m_colorImageAllocs;
158 	std::vector<SharedImageViewPtr>				m_colorAttachmentViews;
159 	vk::Move<vk::VkRenderPass>					m_renderPass;
160 	vk::Move<vk::VkFramebuffer>					m_framebuffer;
161 
162 	vk::Move<vk::VkShaderModule>				m_vertexShaderModule;
163 	vk::Move<vk::VkShaderModule>				m_fragmentShaderModule;
164 
165 	vk::Move<vk::VkBuffer>						m_vertexBuffer;
166 	std::vector<Vertex4Tex4>					m_vertices;
167 	de::MovePtr<vk::Allocation>					m_vertexBufferAlloc;
168 
169 	vk::Move<vk::VkPipelineLayout>				m_preRasterizationStatePipelineLayout;
170 	vk::Move<vk::VkPipelineLayout>				m_fragmentStatePipelineLayout;
171 	vk::GraphicsPipelineWrapper					m_graphicsPipeline;
172 	const vk::PipelineConstructionType			m_pipelineConstructionType;
173 
174 	vk::Move<vk::VkCommandPool>					m_cmdPool;
175 	vk::Move<vk::VkCommandBuffer>				m_cmdBuffer;
176 
177 	const vk::VkImageLayout						m_imageLayout;
178 };
179 
180 } // pipeline
181 } // vkt
182 
183 #endif // _VKTPIPELINEIMAGESAMPLINGINSTANCE_HPP
184