1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2019 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Vulkan Decriptor Indexing Tests
22 *//*--------------------------------------------------------------------*/
32 #include "vktDescriptorSetsIndexingTests.hpp"
34 #include "vkBuilderUtil.hpp"
35 #include "vkCmdUtil.hpp"
37 #include "vkObjUtil.hpp"
38 #include "vkPlatform.hpp"
39 #include "vkPrograms.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkTypeUtil.hpp"
43 #include "tcuTestLog.hpp"
44 #include "tcuResource.hpp"
45 #include "tcuImageCompare.hpp"
46 #include "tcuCommandLine.hpp"
47 #include "tcuStringTemplate.hpp"
48 #include "tcuSurface.hpp"
49 #include "tcuVectorUtil.hpp"
51 #include "deRandom.hpp"
53 #include "deStringUtil.hpp"
57 namespace DescriptorIndexing
64 using tcu::TestStatus;
65 using tcu::PixelBufferAccess;
68 #define RESOLUTION_width 64
69 #define RESOLUTION_height 64
70 static const VkExtent3D RESOLUTION = { RESOLUTION_width, RESOLUTION_height, 1 };
72 #define MAX_DESCRIPTORS 4200
73 #define FUZZY_COMPARE DE_FALSE
74 #define CMP_THRESHOLD 0.02f
76 #define BINDING_Undefined 0
77 #define BINDING_UniformBuffer 1
78 #define BINDING_StorageBuffer 2
79 #define BINDING_UniformTexelBuffer 3
80 #define BINDING_StorageTexelBuffer 4
81 #define BINDING_Sampler 5
82 #define BINDING_SampledImage 6
83 #define BINDING_CombinedImageSampler 7
84 #define BINDING_UniformBufferDynamic 8
85 #define BINDING_StorageBufferDynamic 9
86 #define BINDING_InputAttachment 10
87 #define BINDING_StorageImage 11
88 #define BINDING_DescriptorEnumerator 12
90 static const VkExtent3D smallImageExtent = { 4, 4, 1 };
91 static const VkExtent3D bigImageExtent = { 32, 32, 1 };
93 #ifndef CTS_USES_VULKANSC
94 static const VkDescriptorType VK_DESCRIPTOR_TYPE_UNDEFINED = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT;
96 static const VkDescriptorType VK_DESCRIPTOR_TYPE_UNDEFINED = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
99 template<deUint32 BindingNumber>
102 static const deUint32 binding = BindingNumber;
105 struct BindingUniformBuffer : Binding<BINDING_UniformBuffer>
113 struct BindingStorageBuffer : Binding<BINDING_StorageBuffer>
122 struct TestCaseParams
124 VkDescriptorType descriptorType; // used only to distinguish test class instance
125 VkShaderStageFlags stageFlags; // used only to build a proper program
126 VkExtent3D frameResolution; // target frame buffer resolution
127 bool updateAfterBind; // whether a test will use update after bind feature
128 bool calculateInLoop; // perform calculation in a loop
129 bool usesMipMaps; // this makes a sense and affects in image test cases only
130 bool minNonUniform; // whether a test will use the minimum nonUniform decorations
131 deBool fuzzyComparison; // if true then a test will use fuzzy comparison, otherwise float threshold
132 float thresholdValue; // a threshold that will be used for both, float and fuzzy comparisons
137 VkShaderStageFlags stageFlags;
138 VkDescriptorType descriptorType;
139 deUint32 descriptorBinding;
140 VkDescriptorType additionalDescriptorType;
141 deUint32 additionalDescriptorBinding;
142 bool copyBuffersToImages;
143 bool allowVertexStoring;
144 VkExtent3D frameResolution;
145 bool updateAfterBind;
146 bool calculateInLoop;
149 deBool fuzzyComparison;
150 float thresholdValue;
152 TestParams (VkShaderStageFlags stageFlags_,
153 VkDescriptorType descriptorType_,
154 deUint32 descriptorBinding_,
155 VkDescriptorType additionalDescriptorType_,
156 deUint32 additionalDescriptorBinding_,
157 bool copyBuffersToImages_,
158 bool allowVertexStoring_,
159 const TestCaseParams& caseParams)
160 : stageFlags (stageFlags_)
161 , descriptorType (descriptorType_)
162 , descriptorBinding (descriptorBinding_)
163 , additionalDescriptorType (additionalDescriptorType_)
164 , additionalDescriptorBinding (additionalDescriptorBinding_)
165 , copyBuffersToImages (copyBuffersToImages_)
166 , allowVertexStoring (allowVertexStoring_)
167 , frameResolution (caseParams.frameResolution)
168 , updateAfterBind (caseParams.updateAfterBind)
169 , calculateInLoop (caseParams.calculateInLoop)
170 , usesMipMaps (caseParams.usesMipMaps)
171 , minNonUniform (caseParams.minNonUniform)
172 , fuzzyComparison (caseParams.fuzzyComparison ? true : false)
173 , thresholdValue (caseParams.thresholdValue)
178 struct DescriptorEnumerator
180 ut::BufferHandleAllocSp buffer;
181 ut::BufferViewSp bufferView;
182 VkDeviceSize bufferSize;
184 Move<VkDescriptorSetLayout> descriptorSetLayout;
185 Move<VkDescriptorPool> descriptorPool;
186 Move<VkDescriptorSet> descriptorSet;
188 void init(const vkt::Context& context, deUint32 vertexCount, deUint32 availableDescriptorCount);
189 void update(const vkt::Context& context);
192 struct IterateCommonVariables
194 // An amount of descriptors of a given type available on the platform
195 deUint32 availableDescriptorCount;
196 // An amount of valid descriptors that have connected a buffers to them
197 deUint32 validDescriptorCount;
198 // As the name suggests, sometimes it is used as invocationCount
199 deUint32 vertexCount;
201 VkDeviceSize dataAlignment;
205 DescriptorEnumerator descriptorEnumerator;
207 ut::BufferHandleAllocSp vertexAttributesBuffer;
208 ut::BufferHandleAllocSp descriptorsBuffer;
209 std::vector<VkDescriptorBufferInfo> descriptorsBufferInfos;
210 std::vector<ut::BufferViewSp> descriptorsBufferViews;
211 std::vector<ut::ImageViewSp> descriptorImageViews;
212 std::vector<ut::SamplerSp> descriptorSamplers;
213 std::vector<ut::ImageHandleAllocSp> descriptorsImages;
214 ut::FrameBufferSp frameBuffer;
216 Move<VkDescriptorSetLayout> descriptorSetLayout;
217 Move<VkDescriptorPool> descriptorPool;
218 Move<VkDescriptorSet> descriptorSet;
219 Move<VkPipelineLayout> pipelineLayout;
220 Move<VkRenderPass> renderPass;
221 Move<VkPipeline> pipeline;
222 Move<VkCommandBuffer> commandBuffer;
225 class CommonDescriptorInstance : public TestInstance
228 CommonDescriptorInstance (Context& context,
229 const TestParams& testParams);
231 deUint32 computeAvailableDescriptorCount (VkDescriptorType descriptorType,
232 bool reserveUniformTexelBuffer) const;
234 Move<VkDescriptorSetLayout> createDescriptorSetLayout (bool reserveUniformTexelBuffer,
235 deUint32& descriptorCount) const;
237 Move<VkDescriptorPool> createDescriptorPool (deUint32 descriptorCount) const;
239 Move<VkDescriptorSet> createDescriptorSet (VkDescriptorPool dsPool,
240 VkDescriptorSetLayout dsLayout) const;
244 typedef tcu::Vec4 vec4;
245 typedef tcu::Vec2 vec2;
246 typedef tcu::IVec4 ivec4;
250 attributes& operator()(const vec4& pos)
254 normalpos.x() = (pos.x() + 1.0f) / 2.0f;
255 normalpos.y() = (pos.y() + 1.0f) / 2.0f;
260 void createVertexAttributeBuffer (ut::BufferHandleAllocSp& buffer,
261 deUint32 availableDescriptorCount) const;
263 static std::string substBinding (deUint32 binding,
266 const char* name = DE_NULL);
268 static const char* getVertexShaderProlog (void);
270 static const char* getFragmentShaderProlog (void);
272 static const char* getShaderEpilog (void);
274 static bool performWritesInVertex (VkDescriptorType descriptorType);
276 static bool performWritesInVertex (VkDescriptorType descriptorType,
277 const Context& context);
279 static std::string getShaderAsm (VkShaderStageFlagBits shaderType,
280 const TestCaseParams& testCaseParams,
281 bool allowVertexStoring);
283 static std::string getShaderSource (VkShaderStageFlagBits shaderType,
284 const TestCaseParams& testCaseParams,
285 bool allowVertexStoring);
287 static std::string getColorAccess (VkDescriptorType descriptorType,
288 const char* indexVariableName,
291 static std::string getFragmentReturnSource (const std::string& colorAccess);
293 static std::string getFragmentLoopSource (const std::string& colorAccess1,
294 const std::string& colorAccess2);
296 virtual Move<VkRenderPass> createRenderPass (const IterateCommonVariables& variables);
303 VkPushConstantRange makePushConstantRange (void) const;
305 Move<VkPipelineLayout> createPipelineLayout (const std::vector<VkDescriptorSetLayout>& descriptorSetLayouts) const;
307 // Creates graphics or compute pipeline and appropriate shaders' modules according the testCaseParams.stageFlags
308 // In the case of compute pipeline renderPass parameter is ignored.
309 // Viewport will be created with a width and a height taken from testCaseParam.fragResolution.
310 Move<VkPipeline> createPipeline (VkPipelineLayout pipelineLayout,
311 VkRenderPass renderPass);
313 virtual void createFramebuffer (ut::FrameBufferSp& frameBuffer,
314 VkRenderPass renderPass,
315 const IterateCommonVariables& variables);
317 // Creates one big stagging buffer cutted out on chunks that can accomodate an element of elementSize size
318 VkDeviceSize createBuffers (std::vector<VkDescriptorBufferInfo>& bufferInfos,
319 ut::BufferHandleAllocSp& buffer,
320 deUint32 elementCount,
321 deUint32 elementSize,
322 VkDeviceSize alignment,
323 VkBufferUsageFlags bufferUsage);
325 // Creates and binds an imagesCount of images with given parameters.
326 // Additionally creates stagging buffer for their data and PixelBufferAccess for particular images.
327 VkDeviceSize createImages (std::vector<ut::ImageHandleAllocSp>& images,
328 std::vector<VkDescriptorBufferInfo>& bufferInfos,
329 ut::BufferHandleAllocSp& buffer,
330 VkBufferUsageFlags bufferUsage,
331 const VkExtent3D& imageExtent,
332 VkFormat imageFormat,
333 VkImageLayout imageLayout,
335 bool withMipMaps = false);
337 void createBuffersViews (std::vector<ut::BufferViewSp>& views,
338 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
341 void createImagesViews (std::vector<ut::ImageViewSp>& views,
342 const std::vector<ut::ImageHandleAllocSp>& images,
345 virtual void copyBuffersToImages (IterateCommonVariables& variables);
347 virtual void copyImagesToBuffers (IterateCommonVariables& variables);
349 PixelBufferAccess getPixelAccess (deUint32 imageIndex,
350 const VkExtent3D& imageExtent,
351 VkFormat imageFormat,
352 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
353 const ut::BufferHandleAllocSp& buffer,
354 deUint32 mipLevel = 0u) const;
356 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables) = 0;
358 virtual void updateDescriptors (IterateCommonVariables& variables);
360 virtual void iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
361 const IterateCommonVariables& variables,
364 void iterateCommandSetup (IterateCommonVariables& variables);
366 void iterateCommandBegin (IterateCommonVariables& variables,
367 bool firstPass = true);
369 void iterateCommandEnd (IterateCommonVariables& variables,
370 ut::UpdatablePixelBufferAccessPtr& programResult,
371 ut::UpdatablePixelBufferAccessPtr& referenceResult,
372 bool collectBeforeSubmit = true);
374 bool iterateVerifyResults (IterateCommonVariables& variables,
375 ut::UpdatablePixelBufferAccessPtr programResult,
376 ut::UpdatablePixelBufferAccessPtr referenceResult);
378 Move<VkCommandBuffer> createCmdBuffer (void);
380 void commandBindPipeline (VkCommandBuffer commandBuffer,
381 VkPipeline pipeline);
383 void commandBindVertexAttributes (VkCommandBuffer commandBuffer,
384 const ut::BufferHandleAllocSp& vertexAttributesBuffer);
386 void commandBindDescriptorSets (VkCommandBuffer commandBuffer,
387 VkPipelineLayout pipelineLayout,
388 VkDescriptorSet descriptorSet,
389 deUint32 descriptorSetIndex);
391 void commandReadFrameBuffer (ut::BufferHandleAllocSp& content,
392 VkCommandBuffer commandBuffer,
393 const ut::FrameBufferSp& frameBuffer);
394 ut::UpdatablePixelBufferAccessPtr
395 commandReadFrameBuffer (VkCommandBuffer commandBuffer,
396 const ut::FrameBufferSp& frameBuffer);
398 Move<VkFence> commandSubmit (VkCommandBuffer commandBuffer);
400 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
403 virtual tcu::TestStatus iterate (void);
406 const VkDevice m_vkd;
407 const DeviceInterface& m_vki;
408 Allocator& m_allocator;
409 const VkQueue m_queue;
410 const deUint32 m_queueFamilyIndex;
411 const Move<VkCommandPool> m_commandPool;
412 const VkFormat m_colorFormat;
413 const TestParams m_testParams;
414 static const tcu::Vec4 m_clearColor;
415 const std::vector<float> m_colorScheme;
416 const deUint32 m_schemeSize;
420 Move<VkPipeline> createGraphicsPipeline (VkPipelineLayout pipelineLayout,
421 VkRenderPass renderPass);
423 Move<VkPipeline> createComputePipeline (VkPipelineLayout pipelineLayout);
425 int constructShaderModules (void);
427 static std::vector<float> createColorScheme();
429 Move<VkShaderModule> m_vertexModule;
430 Move<VkShaderModule> m_fragmentModule;
431 Move<VkShaderModule> m_computeModule;
433 const tcu::Vec4 CommonDescriptorInstance::m_clearColor = tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
435 void DescriptorEnumerator::init (const vkt::Context& context, deUint32 vertexCount, deUint32 availableDescriptorCount)
437 const VkDevice device = context.getDevice();
438 const DeviceInterface& deviceInterface = context.getDeviceInterface();
440 const VkFormat imageFormat = VK_FORMAT_R32G32B32A32_SINT;
441 typedef ut::mapVkFormat2Type<imageFormat>::type pixelType;
442 const VkDeviceSize dataSize = vertexCount * sizeof(pixelType);
443 const std::vector<deUint32> primes = ut::generatePrimes(availableDescriptorCount);
444 const deUint32 primeCount = static_cast<deUint32>(primes.size());
446 std::vector<pixelType> data(vertexCount);
447 // e.g. 2,3,5,7,11,13,2,3,5,7,...
448 for (deUint32 idx = 0; idx < vertexCount; ++idx)
450 data[idx].x() = static_cast<pixelType::Element>(primes[idx % primeCount]);
451 data[idx].y() = static_cast<pixelType::Element>(idx);
454 bufferSize = ut::createBufferAndBind(buffer, context, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, dataSize);
455 deMemcpy(buffer->alloc->getHostPtr(), data.data(), static_cast<size_t>(dataSize));
457 const VkBufferViewCreateInfo bufferViewCreateInfo =
459 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // sType
462 *(buffer.get()->buffer), // buffer
463 imageFormat, // format
468 bufferView = ut::BufferViewSp(new Move<VkBufferView>(vk::createBufferView(deviceInterface, device, &bufferViewCreateInfo)));
470 const VkDescriptorSetLayoutBinding binding =
472 BINDING_DescriptorEnumerator, // binding
473 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, // descriptorType
474 1u, // descriptorCount
475 VK_SHADER_STAGE_ALL, // stageFlags
476 DE_NULL, // pImmutableSamplers
479 const VkDescriptorSetLayoutCreateInfo layoutCreateInfo =
481 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
485 &binding, // pBindings
488 descriptorSetLayout = vk::createDescriptorSetLayout(deviceInterface, device, &layoutCreateInfo);
489 descriptorPool = DescriptorPoolBuilder().addType(binding.descriptorType)
490 .build(deviceInterface, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u);
492 const VkDescriptorSetAllocateInfo dsAllocInfo =
494 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // sType
496 *descriptorPool, // descriptorPool
497 1u, // descriptorSetCount
498 &(*descriptorSetLayout) // pSetLayouts
501 descriptorSet = vk::allocateDescriptorSet(deviceInterface, device, &dsAllocInfo);
504 void DescriptorEnumerator::update (const vkt::Context& context)
506 const VkDescriptorBufferInfo bufferInfo =
508 *(buffer.get()->buffer), // buffer
513 const VkWriteDescriptorSet writeInfo =
515 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
517 *descriptorSet, // dstSet
518 BINDING_DescriptorEnumerator, // dstBinding
519 0u, // dstArrayElement
520 1u, // descriptorCount
521 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, // descriptorType
522 DE_NULL, // pImageInfo
523 &bufferInfo, // pBufferInfo
524 &(**bufferView), // pTexelBufferView
527 context.getDeviceInterface().updateDescriptorSets(context.getDevice(), 1u, &writeInfo, 0u, DE_NULL);
530 CommonDescriptorInstance::CommonDescriptorInstance (Context& context,
531 const TestParams& testParams)
532 : TestInstance (context)
533 , m_vkd (context.getDevice())
534 , m_vki (context.getDeviceInterface())
535 , m_allocator (context.getDefaultAllocator())
536 , m_queue (context.getUniversalQueue())
537 , m_queueFamilyIndex(context.getUniversalQueueFamilyIndex())
538 , m_commandPool (vk::createCommandPool(m_vki, m_vkd, (VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT), m_queueFamilyIndex))
539 , m_colorFormat (VK_FORMAT_R32G32B32A32_SFLOAT)
540 , m_testParams (testParams)
541 , m_colorScheme (createColorScheme())
542 , m_schemeSize (static_cast<deUint32>(m_colorScheme.size()))
546 deUint32 CommonDescriptorInstance::computeAvailableDescriptorCount (VkDescriptorType descriptorType,
547 bool reserveUniformTexelBuffer) const
549 DE_UNREF(descriptorType);
550 const deUint32 vertexCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
551 const deUint32 availableDescriptorsOnDevice = ut::DeviceProperties(m_context).computeMaxPerStageDescriptorCount(m_testParams.descriptorType, m_testParams.updateAfterBind, reserveUniformTexelBuffer);
552 return deMinu32(deMinu32(vertexCount, availableDescriptorsOnDevice), MAX_DESCRIPTORS);
555 Move<VkDescriptorSetLayout> CommonDescriptorInstance::createDescriptorSetLayout (bool reserveUniformTexelBuffer,
556 deUint32& descriptorCount) const
558 descriptorCount = computeAvailableDescriptorCount(m_testParams.descriptorType, reserveUniformTexelBuffer);
560 bool optional = (m_testParams.additionalDescriptorBinding != BINDING_Undefined) && (m_testParams.additionalDescriptorType != VK_DESCRIPTOR_TYPE_UNDEFINED);
562 const VkShaderStageFlags bindingStageFlags = (m_testParams.descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) ?
563 VkShaderStageFlags{VK_SHADER_STAGE_FRAGMENT_BIT} : m_testParams.stageFlags;
565 const VkDescriptorSetLayoutBinding bindings[] =
568 m_testParams.descriptorBinding, // binding
569 m_testParams.descriptorType, // descriptorType
570 descriptorCount, // descriptorCount
571 bindingStageFlags, // stageFlags
572 DE_NULL, // pImmutableSamplers
575 m_testParams.additionalDescriptorBinding, // binding
576 m_testParams.additionalDescriptorType, // descriptorType
577 1, // descriptorCount
578 bindingStageFlags, // stageFlags
579 DE_NULL, // pImmutableSamplers
583 const VkDescriptorBindingFlags bindingFlagUpdateAfterBind =
584 m_testParams.updateAfterBind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0;
586 const VkDescriptorBindingFlags bindingFlags[] =
588 VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | bindingFlagUpdateAfterBind,
589 VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | bindingFlagUpdateAfterBind
592 const VkDescriptorSetLayoutBindingFlagsCreateInfo bindingCreateInfo =
594 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
596 optional ? 2u : 1u, // bindingCount
597 bindingFlags, // pBindingFlags
600 const VkDescriptorSetLayoutCreateFlags layoutCreateFlags =
601 m_testParams.updateAfterBind ? VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT : 0;
603 const VkDescriptorSetLayoutCreateInfo layoutCreateInfo =
605 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
606 &bindingCreateInfo, // pNext
607 layoutCreateFlags, // flags
608 optional ? 2u : 1u, // bindingCount
609 bindings, // pBindings
612 return vk::createDescriptorSetLayout(m_vki, m_vkd, &layoutCreateInfo);
615 Move<VkDescriptorPool> CommonDescriptorInstance::createDescriptorPool (deUint32 descriptorCount) const
617 const VkDescriptorPoolCreateFlags pcf = m_testParams.updateAfterBind ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0;
619 DescriptorPoolBuilder builder;
621 builder.addType(m_testParams.descriptorType, descriptorCount);
623 if (m_testParams.additionalDescriptorType != VK_DESCRIPTOR_TYPE_UNDEFINED && m_testParams.additionalDescriptorBinding != BINDING_Undefined)
625 builder.addType(m_testParams.additionalDescriptorType, 1);
628 return builder.build(m_vki, m_vkd, (VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT | pcf), 1u);
631 Move<VkDescriptorSet> CommonDescriptorInstance::createDescriptorSet (VkDescriptorPool dsPool,
632 VkDescriptorSetLayout dsLayout) const
634 const VkDescriptorSetAllocateInfo dsAllocInfo =
636 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // sType;
638 dsPool, // descriptorPool;
639 1u, // descriptorSetCount
640 &dsLayout // pSetLayouts
643 return vk::allocateDescriptorSet(m_vki, m_vkd, &dsAllocInfo);
646 void CommonDescriptorInstance::createVertexAttributeBuffer (ut::BufferHandleAllocSp& buffer,
647 deUint32 availableDescriptorCount) const
652 const deUint32 invocationCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
653 const std::vector<Vec4> vertices = ut::createVertices(m_testParams.frameResolution.width, m_testParams.frameResolution.height, xSize, ySize);
654 const std::vector<deUint32> primes = ut::generatePrimes(availableDescriptorCount);
655 const deUint32 primeCount = static_cast<deUint32>(primes.size());
657 std::vector<attributes> data(vertices.size());
658 std::transform(vertices.begin(), vertices.end(), data.begin(), attributes());
660 for (deUint32 invIdx = 0; invIdx < invocationCount; ++invIdx)
662 // r: 2,3,5,7,11,13,2,3,5,7,...
663 data[invIdx].index.x() = primes[invIdx % primeCount];
665 // b: x index in texel coordinate
666 data[invIdx].index.z() = invIdx % m_testParams.frameResolution.width;
668 //a: y index in texel coordinate
669 data[invIdx].index.w() = invIdx / m_testParams.frameResolution.width;
672 // g: 0,0,2,3,0,5,0,7,0,0,0,11,0,13,...
673 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
675 const deUint32 prime = primes[primeIdx];
676 DE_ASSERT(prime < invocationCount);
677 data[prime].index.y() = prime;
680 const VkDeviceSize dataSize = data.size() * sizeof(attributes);
682 VkDeviceSize deviceSize = ut::createBufferAndBind(buffer, m_context, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, dataSize);
684 deMemcpy(buffer->alloc->getHostPtr(), data.data(), static_cast<size_t>(deviceSize));
686 vk::flushAlloc(m_vki, m_vkd, *buffer->alloc);
689 std::string CommonDescriptorInstance::substBinding (deUint32 binding,
694 std::map<std::string, std::string> vars;
695 vars["?"] = de::toString(binding);
696 vars["*"] = (0 == count) ? "" : de::toString(count);
697 vars["VAR"] = (DE_NULL == name) ? "data" : name;
698 return tcu::StringTemplate(str).specialize(vars);
701 const char* CommonDescriptorInstance::getVertexShaderProlog (void)
704 "layout(location = 0) in vec4 in_position; \n"
705 "layout(location = 1) in vec2 in_normalpos; \n"
706 "layout(location = 2) in ivec4 index; \n"
707 "layout(location = 0) out vec4 position; \n"
708 "layout(location = 1) out vec2 normalpos; \n"
709 "layout(location = 2) out int vIndex; \n"
710 "layout(location = 3) out int rIndex; \n"
711 "layout(location = 4) out int gIndex; \n"
712 "layout(location = 5) out int bIndex; \n"
713 "layout(location = 6) out int aIndex; \n"
716 " gl_PointSize = 0.2f; \n"
717 " position = in_position; \n"
718 " normalpos = in_normalpos; \n"
719 " gl_Position = position; \n"
720 " vIndex = gl_VertexIndex; \n"
721 " rIndex = index.x; \n"
722 " gIndex = index.y; \n"
723 " bIndex = index.z; \n"
724 " aIndex = index.w; \n";
727 const char* CommonDescriptorInstance::getFragmentShaderProlog (void)
730 "layout(location = 0) out vec4 FragColor; \n"
731 "layout(location = 0) in flat vec4 position; \n"
732 "layout(location = 1) in flat vec2 normalpos; \n"
733 "layout(location = 2) in flat int vIndex; \n"
734 "layout(location = 3) in flat int rIndex; \n"
735 "layout(location = 4) in flat int gIndex; \n"
736 "layout(location = 5) in flat int bIndex; \n"
737 "layout(location = 6) in flat int aIndex; \n"
742 const char* CommonDescriptorInstance::getShaderEpilog (void)
747 int CommonDescriptorInstance::constructShaderModules (void)
750 tcu::TestLog& log = m_context.getTestContext().getLog();
752 if (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
755 const std::string name = ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testParams.descriptorType, m_testParams.updateAfterBind, m_testParams.calculateInLoop, m_testParams.minNonUniform, false);
756 m_computeModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
758 if (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT)
761 const std::string name = ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testParams.descriptorType, m_testParams.updateAfterBind, m_testParams.calculateInLoop, m_testParams.minNonUniform, m_testParams.allowVertexStoring);
762 m_fragmentModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
763 log << tcu::TestLog::Message << "Finally used fragment shader: " << name << '\n' << tcu::TestLog::EndMessage;
765 if (m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT)
768 const std::string name = ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testParams.descriptorType, m_testParams.updateAfterBind, m_testParams.calculateInLoop, m_testParams.minNonUniform, m_testParams.allowVertexStoring);
769 m_vertexModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
770 log << tcu::TestLog::Message << "Finally used vertex shader: " << name << '\n' << tcu::TestLog::EndMessage;
773 DE_ASSERT(result > 0);
778 Move<VkRenderPass> CommonDescriptorInstance::createRenderPass (const IterateCommonVariables& variables)
781 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
783 // Use VK_ATTACHMENT_LOAD_OP_LOAD to make the utility function select initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
784 return vk::makeRenderPass(m_vki, m_vkd, m_colorFormat, VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD);
786 return Move<VkRenderPass>();
789 VkPushConstantRange CommonDescriptorInstance::makePushConstantRange (void) const
791 const VkPushConstantRange pcr =
793 m_testParams.stageFlags, // stageFlags
795 static_cast<deUint32>(sizeof(push_constant)) // size
800 Move<VkPipelineLayout> CommonDescriptorInstance::createPipelineLayout (const std::vector<VkDescriptorSetLayout>& descriptorSetLayouts) const
802 const VkPushConstantRange pcr = makePushConstantRange();
804 const VkPipelineLayoutCreateInfo createInfo =
806 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
808 (VkPipelineLayoutCreateFlags)0, // flags
809 static_cast<deUint32>(descriptorSetLayouts.size()), // setLayoutCount
810 descriptorSetLayouts.data(), // pSetLayouts;
811 m_testParams.calculateInLoop ? 1u : 0u, // pushConstantRangeCount
812 m_testParams.calculateInLoop ? &pcr : DE_NULL, // pPushConstantRanges
815 return vk::createPipelineLayout(m_vki, m_vkd, &createInfo);
818 void CommonDescriptorInstance::createFramebuffer (ut::FrameBufferSp& frameBuffer,
819 VkRenderPass renderPass,
820 const IterateCommonVariables& variables)
823 ut::createFrameBuffer(frameBuffer, m_context, m_testParams.frameResolution, m_colorFormat, renderPass);
826 Move<VkPipeline> CommonDescriptorInstance::createPipeline (VkPipelineLayout pipelineLayout,
827 VkRenderPass renderPass)
828 { DE_ASSERT(VK_SHADER_STAGE_ALL != m_testParams.stageFlags);
830 constructShaderModules();
832 return (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
833 ? createComputePipeline(pipelineLayout)
834 : createGraphicsPipeline(pipelineLayout, renderPass);
837 Move<VkPipeline> CommonDescriptorInstance::createComputePipeline (VkPipelineLayout pipelineLayout)
839 const VkPipelineShaderStageCreateInfo shaderStaegCreateInfo =
841 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
843 (VkPipelineShaderStageCreateFlags)0, // flags
844 VK_SHADER_STAGE_COMPUTE_BIT, // stage
845 *m_computeModule, // module
847 (VkSpecializationInfo*)DE_NULL // pSpecializationInfo
850 const VkComputePipelineCreateInfo pipelineCreateInfo =
852 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
855 shaderStaegCreateInfo, // stage
856 pipelineLayout, // layout
857 (VkPipeline)0, // basePipelineHandle
858 0u, // basePipelineIndex
860 return vk::createComputePipeline(m_vki, m_vkd, (VkPipelineCache)0u, &pipelineCreateInfo);
863 Move<VkPipeline> CommonDescriptorInstance::createGraphicsPipeline (VkPipelineLayout pipelineLayout,
864 VkRenderPass renderPass)
866 const VkVertexInputBindingDescription bindingDescriptions[] =
870 sizeof(attributes), // stride
871 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
875 const VkVertexInputAttributeDescription attributeDescriptions[] =
880 ut::mapType2vkFormat<attributes::vec4>::value, // format
886 ut::mapType2vkFormat<attributes::vec2>::value, // format
887 static_cast<deUint32>(sizeof(attributes::vec4)) // offset
892 ut::mapType2vkFormat<attributes::ivec4>::value, // format
893 static_cast<deUint32>(sizeof(attributes::vec2)
894 + sizeof(attributes::vec4)) // offset
898 const VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo =
900 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
902 (VkPipelineVertexInputStateCreateFlags)0, // flags
903 DE_LENGTH_OF_ARRAY(bindingDescriptions), // vertexBindingDescriptionCount
904 bindingDescriptions, // pVertexBindingDescriptions
905 DE_LENGTH_OF_ARRAY(attributeDescriptions), // vertexAttributeDescriptionCount
906 attributeDescriptions // pVertexAttributeDescriptions
909 const VkDynamicState dynamicStates[] =
911 VK_DYNAMIC_STATE_SCISSOR
914 const VkPipelineDynamicStateCreateInfo dynamicStateCreateInfo =
916 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // sType
919 DE_LENGTH_OF_ARRAY(dynamicStates), // dynamicStateCount
920 dynamicStates // pDynamicStates
923 const std::vector<VkViewport> viewports (1, makeViewport(m_testParams.frameResolution.width, m_testParams.frameResolution.height));
924 const std::vector<VkRect2D> scissors (1, makeRect2D(0u, 0u));
926 DE_ASSERT(m_vertexModule && m_fragmentModule);
928 return vk::makeGraphicsPipeline(
931 pipelineLayout, // pipelineLayout
932 *m_vertexModule, // vertexShaderModule
933 DE_NULL, // tessellationControlModule
934 DE_NULL, // tessellationEvalModule
935 DE_NULL, // geometryShaderModule
936 *m_fragmentModule, // fragmentShaderModule
937 renderPass, // renderPass
938 viewports, // viewports
939 scissors, // scissors
940 VK_PRIMITIVE_TOPOLOGY_POINT_LIST, // topology
942 0U, // patchControlPoints
943 &vertexInputStateCreateInfo, // vertexInputStateCreateInfo
944 nullptr, // rasterizationStateCreateInfo
945 nullptr, // multisampleStateCreateInfo
946 nullptr, // depthStencilStateCreateInfo
947 nullptr, // colorBlendStateCreateInfo
948 &dynamicStateCreateInfo); // dynamicStateCreateInfo
951 VkDeviceSize CommonDescriptorInstance::createBuffers (std::vector<VkDescriptorBufferInfo>& bufferInfos,
952 ut::BufferHandleAllocSp& buffer,
953 deUint32 elementCount,
954 deUint32 elementSize,
955 VkDeviceSize alignment,
956 VkBufferUsageFlags bufferUsage)
958 const VkDeviceSize roundedSize = deAlign64(elementSize, alignment);
959 VkDeviceSize bufferSize = ut::createBufferAndBind(buffer, m_context, bufferUsage, (roundedSize * elementCount));
961 for (deUint32 elementIdx = 0; elementIdx < elementCount; ++elementIdx)
963 const VkDescriptorBufferInfo bufferInfo =
965 *buffer.get()->buffer, //buffer;
966 elementIdx * roundedSize, //offset;
967 elementSize, // range;
970 bufferInfos.push_back(bufferInfo);
976 VkDeviceSize CommonDescriptorInstance::createImages (std::vector<ut::ImageHandleAllocSp>& images,
977 std::vector<VkDescriptorBufferInfo>& bufferInfos,
978 ut::BufferHandleAllocSp& buffer,
979 VkBufferUsageFlags bufferUsage,
980 const VkExtent3D& imageExtent,
981 VkFormat imageFormat,
982 VkImageLayout imageLayout,
987 const deUint32 imageSize = ut::computeImageSize(imageExtent, imageFormat, withMipMaps);
989 const VkDeviceSize bufferSize = createBuffers(bufferInfos, buffer, imageCount, imageSize, sizeof(tcu::Vec4), bufferUsage);
991 for (deUint32 imageIdx = 0; imageIdx < imageCount; ++imageIdx)
993 ut::ImageHandleAllocSp image;
994 ut::createImageAndBind(image, m_context, imageFormat, imageExtent, imageLayout, withMipMaps);
995 images.push_back(image);
1001 void CommonDescriptorInstance::createBuffersViews (std::vector<ut::BufferViewSp>& views,
1002 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
1005 const deUint32 infoCount = static_cast<deUint32>(bufferInfos.size());
1006 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1008 const VkDescriptorBufferInfo& bufferInfo = bufferInfos[infoIdx];
1009 const VkBufferViewCreateInfo bufferViewInfo =
1011 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // sType
1013 (VkBufferViewCreateFlags)0, // flags
1014 bufferInfo.buffer, // buffer
1016 bufferInfo.offset, // offset
1017 bufferInfo.range // range;
1019 views.push_back(ut::BufferViewSp(new Move<VkBufferView>(vk::createBufferView(m_vki, m_vkd, &bufferViewInfo))));
1023 void CommonDescriptorInstance::createImagesViews (std::vector<ut::ImageViewSp>& views,
1024 const std::vector<ut::ImageHandleAllocSp>& images,
1027 const deUint32 imageCount = static_cast<deUint32>(images.size());
1028 for (deUint32 imageIdx = 0; imageIdx < imageCount; ++imageIdx)
1030 const VkImageViewCreateInfo createInfo =
1032 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
1034 (VkImageViewCreateFlags)0, // flags
1035 *images[imageIdx]->image, // image
1036 VK_IMAGE_VIEW_TYPE_2D, // viewType
1038 vk::makeComponentMappingRGBA(), // components
1040 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
1041 (deUint32)0, // baseMipLevel
1042 images[imageIdx]->levels, // mipLevels
1043 (deUint32)0, // baseArrayLayer
1044 (deUint32)1u, // arraySize
1047 views.push_back(ut::ImageViewSp(new Move<VkImageView>(vk::createImageView(m_vki, m_vkd, &createInfo))));
1051 void CommonDescriptorInstance::copyBuffersToImages (IterateCommonVariables& variables)
1053 const deUint32 infoCount = static_cast<deUint32>(variables.descriptorsBufferInfos.size());
1054 DE_ASSERT(variables.descriptorsImages.size() == infoCount);
1055 const VkPipelineStageFlagBits dstStageMask = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
1056 ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
1057 : VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
1058 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1060 ut::recordCopyBufferToImage(
1061 *variables.commandBuffer, // commandBuffer
1063 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // srcStageMask
1064 dstStageMask, // dstStageMask
1065 variables.descriptorsBufferInfos[infoIdx], // bufferInfo
1066 *(variables.descriptorsImages[infoIdx]->image), // image
1067 variables.descriptorsImages[infoIdx]->extent, // imageExtent
1068 variables.descriptorsImages[infoIdx]->format, // imageFormat
1069 VK_IMAGE_LAYOUT_UNDEFINED, // oldImageLayout
1070 VK_IMAGE_LAYOUT_GENERAL, // newImageLayout
1071 variables.descriptorsImages[infoIdx]->levels); // mipLevelCount
1075 void CommonDescriptorInstance::copyImagesToBuffers (IterateCommonVariables& variables)
1077 const deUint32 infoCount = static_cast<deUint32>(variables.descriptorsBufferInfos.size());
1078 DE_ASSERT(variables.descriptorsImages.size() == infoCount);
1079 const VkPipelineStageFlagBits srcStageMask = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
1080 ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
1081 : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
1083 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1085 ut::recordCopyImageToBuffer(
1086 *variables.commandBuffer, // commandBuffer
1088 srcStageMask, // srcStageMask
1089 VK_PIPELINE_STAGE_HOST_BIT, // dstStageMask
1090 *(variables.descriptorsImages[infoIdx]->image), // image
1091 variables.descriptorsImages[infoIdx]->extent, // imageExtent
1092 variables.descriptorsImages[infoIdx]->format, // imageFormat
1093 VK_IMAGE_LAYOUT_GENERAL, // oldImageLayout
1094 VK_IMAGE_LAYOUT_GENERAL, // newImageLayout
1095 variables.descriptorsBufferInfos[infoIdx]); // bufferInfo
1099 PixelBufferAccess CommonDescriptorInstance::getPixelAccess (deUint32 imageIndex,
1100 const VkExtent3D& imageExtent,
1101 VkFormat imageFormat,
1102 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
1103 const ut::BufferHandleAllocSp& buffer,
1104 deUint32 mipLevel) const
1106 DE_ASSERT(bufferInfos[imageIndex].buffer == *buffer.get()->buffer);
1107 DE_ASSERT(ut::computeImageSize(imageExtent, imageFormat, true, (mipLevel ? ut::maxDeUint32 : 0)) <= bufferInfos[imageIndex].range);
1108 DE_ASSERT(imageExtent.width >> mipLevel);
1109 DE_ASSERT(imageExtent.height >> mipLevel);
1111 deUint32 mipOffset = 0;
1113 for (deUint32 level = 0; mipLevel && level < mipLevel; ++level)
1115 mipOffset += ut::computeImageSize(imageExtent, imageFormat, true, level);
1118 unsigned char* hostPtr = static_cast<unsigned char*>(buffer->alloc->getHostPtr());
1119 unsigned char* data = hostPtr + bufferInfos[imageIndex].offset + mipOffset;
1120 return tcu::PixelBufferAccess(vk::mapVkFormat(imageFormat), (imageExtent.width >> mipLevel), (imageExtent.height >> mipLevel), imageExtent.depth, data);
1123 void CommonDescriptorInstance::updateDescriptors (IterateCommonVariables& variables)
1125 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
1126 const deUint32 primeCount = static_cast<deUint32>(primes.size());
1128 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
1130 const VkDescriptorBufferInfo* pBufferInfo = DE_NULL;
1131 const VkDescriptorImageInfo* pImageInfo = DE_NULL;
1132 const VkBufferView* pTexelBufferView = DE_NULL;
1134 VkDescriptorImageInfo imageInfo =
1136 static_cast<VkSampler>(0),
1137 static_cast<VkImageView>(0),
1138 VK_IMAGE_LAYOUT_GENERAL
1141 switch (m_testParams.descriptorType)
1143 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1144 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1145 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1146 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
1147 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1148 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1150 pBufferInfo = &variables.descriptorsBufferInfos[primeIdx];
1151 switch (m_testParams.descriptorType)
1153 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1154 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1155 pTexelBufferView = &(**variables.descriptorsBufferViews[primeIdx]);
1163 case VK_DESCRIPTOR_TYPE_SAMPLER:
1164 imageInfo.sampler = **variables.descriptorSamplers[primeIdx];
1165 pImageInfo = &imageInfo;
1168 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
1169 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
1170 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
1171 imageInfo.imageView = **variables.descriptorImageViews[primeIdx];
1172 pImageInfo = &imageInfo;
1178 const VkWriteDescriptorSet writeInfo =
1180 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
1182 *variables.descriptorSet, // descriptorSet
1183 m_testParams.descriptorBinding, // descriptorBinding;
1184 primes[primeIdx], // elementIndex
1185 1u, // descriptorCount
1186 m_testParams.descriptorType, // descriptorType
1187 pImageInfo, // pImageInfo
1188 pBufferInfo, // pBufferInfo
1189 pTexelBufferView // pTexelBufferView
1192 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
1196 void CommonDescriptorInstance::iterateCommandSetup (IterateCommonVariables& variables)
1198 variables.dataAlignment = 0;
1200 variables.renderArea.offset.x = 0;
1201 variables.renderArea.offset.y = 0;
1202 variables.renderArea.extent.width = m_testParams.frameResolution.width;
1203 variables.renderArea.extent.height = m_testParams.frameResolution.height;
1205 variables.vertexCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
1207 variables.lowerBound = 0;
1208 variables.upperBound = variables.vertexCount;
1210 variables.descriptorSetLayout = createDescriptorSetLayout(m_testParams.calculateInLoop, variables.availableDescriptorCount);
1211 variables.validDescriptorCount = ut::computePrimeCount(variables.availableDescriptorCount);
1212 variables.descriptorPool = createDescriptorPool(variables.availableDescriptorCount);
1213 variables.descriptorSet = createDescriptorSet(*variables.descriptorPool, *variables.descriptorSetLayout);
1215 std::vector<VkDescriptorSetLayout> descriptorSetLayouts;
1216 descriptorSetLayouts.push_back(*variables.descriptorSetLayout);
1217 if (m_testParams.calculateInLoop)
1219 variables.descriptorEnumerator.init(m_context, variables.vertexCount, variables.availableDescriptorCount);
1220 descriptorSetLayouts.push_back(*variables.descriptorEnumerator.descriptorSetLayout);
1223 variables.pipelineLayout = createPipelineLayout(descriptorSetLayouts);
1225 createAndPopulateDescriptors (variables);
1227 variables.renderPass = createRenderPass(variables);
1228 variables.pipeline = createPipeline(*variables.pipelineLayout, *variables.renderPass);
1230 variables.commandBuffer = createCmdBuffer();
1232 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1234 createVertexAttributeBuffer (variables.vertexAttributesBuffer, variables.availableDescriptorCount);
1235 createFramebuffer (variables.frameBuffer, *variables.renderPass, variables);
1238 if (m_testParams.calculateInLoop)
1240 variables.descriptorEnumerator.update(m_context);
1243 if (!m_testParams.updateAfterBind)
1245 updateDescriptors (variables);
1250 void CommonDescriptorInstance::iterateCommandBegin (IterateCommonVariables& variables, bool firstPass)
1252 vk::beginCommandBuffer (m_vki, *variables.commandBuffer);
1254 // Clear color attachment, and transition it to VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
1255 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1259 const VkImageMemoryBarrier preImageBarrier =
1261 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType
1262 DE_NULL, // const void* pNext
1263 0u, // VkAccessFlags srcAccessMask
1264 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1265 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout
1266 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout
1267 VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
1268 VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
1269 *variables.frameBuffer->image->image, // VkImage image
1271 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask
1272 0u, // uint32_t baseMipLevel
1273 VK_REMAINING_MIP_LEVELS, // uint32_t mipLevels,
1274 0u, // uint32_t baseArray
1275 VK_REMAINING_ARRAY_LAYERS, // uint32_t arraySize
1279 m_vki.cmdPipelineBarrier(*variables.commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
1280 (VkDependencyFlags)0,
1281 0, (const VkMemoryBarrier*)DE_NULL,
1282 0, (const VkBufferMemoryBarrier*)DE_NULL,
1283 1, &preImageBarrier);
1285 const VkClearColorValue clearColorValue = makeClearValueColor(m_clearColor).color;
1287 m_vki.cmdClearColorImage(*variables.commandBuffer, *variables.frameBuffer->image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColorValue, 1, &preImageBarrier.subresourceRange);
1289 const VkImageMemoryBarrier postImageBarrier =
1291 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType
1292 DE_NULL, // const void* pNext
1293 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1294 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask
1295 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout
1296 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout
1297 VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
1298 VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
1299 *variables.frameBuffer->image->image, // VkImage image
1301 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask
1302 0u, // uint32_t baseMipLevel
1303 VK_REMAINING_MIP_LEVELS, // uint32_t mipLevels,
1304 0u, // uint32_t baseArray
1305 VK_REMAINING_ARRAY_LAYERS, // uint32_t arraySize
1309 m_vki.cmdPipelineBarrier(*variables.commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
1310 (VkDependencyFlags)0,
1311 0, (const VkMemoryBarrier*)DE_NULL,
1312 0, (const VkBufferMemoryBarrier*)DE_NULL,
1313 1, &postImageBarrier);
1318 if (m_testParams.calculateInLoop)
1321 deRandom_init(&rnd, static_cast<deUint32>(m_testParams.descriptorType));
1322 const deUint32 quarter = variables.vertexCount / 4;
1324 variables.lowerBound = deRandom_getUint32(&rnd) % quarter;
1325 variables.upperBound = (deRandom_getUint32(&rnd) % quarter) + (3 * quarter);
1327 const push_constant pc =
1329 static_cast<deInt32>(variables.lowerBound),
1330 static_cast<deInt32>(variables.upperBound)
1333 m_vki.cmdPushConstants(*variables.commandBuffer, *variables.pipelineLayout, m_testParams.stageFlags, 0u, static_cast<deUint32>(sizeof(pc)), &pc);
1336 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1338 commandBindVertexAttributes (*variables.commandBuffer, variables.vertexAttributesBuffer);
1341 if (m_testParams.calculateInLoop)
1343 commandBindDescriptorSets(*variables.commandBuffer, *variables.pipelineLayout, *variables.descriptorEnumerator.descriptorSet, 1);
1346 if (!ut::isDynamicDescriptor(m_testParams.descriptorType))
1348 commandBindDescriptorSets (*variables.commandBuffer, *variables.pipelineLayout, *variables.descriptorSet, 0);
1351 commandBindPipeline (*variables.commandBuffer, *variables.pipeline);
1354 tcu::TestStatus CommonDescriptorInstance::iterate (void)
1356 IterateCommonVariables v;
1357 ut::UpdatablePixelBufferAccessPtr programResult;
1358 ut::UpdatablePixelBufferAccessPtr referenceResult;
1360 bool firstPass = true;
1362 iterateCommandSetup (v);
1364 v.renderArea.extent.width = m_testParams.frameResolution.width/4;
1365 v.renderArea.extent.height = m_testParams.frameResolution.height/4;
1367 for (int x = 0; x < 4; x++)
1368 for (int y= 0; y < 4; y++)
1370 iterateCommandBegin (v, firstPass);
1372 if (true == firstPass && true == m_testParams.copyBuffersToImages)
1374 copyBuffersToImages (v);
1379 if (true == m_testParams.updateAfterBind)
1381 updateDescriptors (v);
1384 v.renderArea.offset.x = x * m_testParams.frameResolution.width/4;
1385 v.renderArea.offset.y = y * m_testParams.frameResolution.height/4;
1387 vk::VkRect2D scissor = makeRect2D(v.renderArea.offset.x, v.renderArea.offset.y, v.renderArea.extent.width, v.renderArea.extent.height);
1388 m_vki.cmdSetScissor(*v.commandBuffer, 0u, 1u, &scissor);
1390 vk::beginRenderPass (m_vki, *v.commandBuffer, *v.renderPass, *v.frameBuffer->buffer, v.renderArea, m_clearColor);
1391 m_vki.cmdDraw (*v.commandBuffer, v.vertexCount, 1u, 0u, 0u);
1392 vk::endRenderPass (m_vki, *v.commandBuffer);
1394 iterateCommandEnd(v, programResult, referenceResult);
1395 programResult->invalidate();
1398 return ( iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
1401 std::vector<float> CommonDescriptorInstance::createColorScheme (void)
1403 std::vector<float> cs;
1405 for (int i = 0; i < 10; ++i)
1407 cs.push_back(1.0f / float(divider));
1413 void CommonDescriptorInstance::iterateCommandEnd (IterateCommonVariables& variables,
1414 ut::UpdatablePixelBufferAccessPtr& programResult,
1415 ut::UpdatablePixelBufferAccessPtr& referenceResult,
1416 bool collectBeforeSubmit)
1418 if (collectBeforeSubmit)
1420 iterateCollectResults(programResult, variables, true);
1421 iterateCollectResults(referenceResult, variables, false);
1424 VK_CHECK(m_vki.endCommandBuffer(*variables.commandBuffer));
1425 Move<VkFence> fence = commandSubmit(*variables.commandBuffer);
1426 m_vki.waitForFences(m_vkd, 1, &(*fence), DE_TRUE, ~0ull);
1428 if (false == collectBeforeSubmit)
1430 iterateCollectResults(programResult, variables, true);
1431 iterateCollectResults(referenceResult, variables, false);
1435 bool CommonDescriptorInstance::iterateVerifyResults (IterateCommonVariables& variables,
1436 ut::UpdatablePixelBufferAccessPtr programResult,
1437 ut::UpdatablePixelBufferAccessPtr referenceResult)
1439 bool result = false;
1440 if (m_testParams.fuzzyComparison)
1442 result = tcu::fuzzyCompare(m_context.getTestContext().getLog(),
1443 "Fuzzy Compare", "Comparison result", *referenceResult.get(), *programResult.get(), 0.02f, tcu::COMPARE_LOG_EVERYTHING);
1447 result = tcu::floatThresholdCompare(m_context.getTestContext().getLog(),
1448 "Float Threshold Compare", "Comparison result", *referenceResult.get(), *programResult.get(), tcu::Vec4(0.02f, 0.02f, 0.02f, 0.02f), tcu::COMPARE_LOG_EVERYTHING);
1451 if (m_testParams.allowVertexStoring)
1453 result = verifyVertexWriteResults(variables);
1459 void CommonDescriptorInstance::iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
1460 const IterateCommonVariables& variables,
1465 result = commandReadFrameBuffer(*variables.commandBuffer, variables.frameBuffer);
1469 result = ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessAllocation(vk::mapVkFormat(m_colorFormat), m_testParams.frameResolution));
1471 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
1473 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
1475 const float component = m_colorScheme[(pixelNum % variables.validDescriptorCount) % m_schemeSize];
1476 result->setPixel(tcu::Vec4(component, component, component, 1.0f), x, y);
1482 Move<VkCommandBuffer> CommonDescriptorInstance::createCmdBuffer (void)
1484 return vk::allocateCommandBuffer(m_vki, m_vkd, *m_commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
1487 Move<VkFence> CommonDescriptorInstance::commandSubmit (VkCommandBuffer cmd)
1489 Move<VkFence> fence(vk::createFence(m_vki, m_vkd));
1491 const VkSubmitInfo submitInfo =
1493 VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
1495 0u, // waitSemaphoreCount
1496 static_cast<VkSemaphore*>(DE_NULL), // pWaitSemaphores
1497 static_cast<const VkPipelineStageFlags*>(DE_NULL), // pWaitDstStageMask
1498 1u, // commandBufferCount
1499 &cmd, // pCommandBuffers
1500 0u, // signalSemaphoreCount
1501 static_cast<VkSemaphore*>(DE_NULL) // pSignalSemaphores
1504 VK_CHECK(m_vki.queueSubmit(m_queue, 1u, &submitInfo, *fence));
1509 bool CommonDescriptorInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
1511 DE_UNREF(variables);
1515 void CommonDescriptorInstance::commandBindPipeline (VkCommandBuffer commandBuffer,
1516 VkPipeline pipeline)
1518 const VkPipelineBindPoint pipelineBindingPoint = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS;
1519 m_vki.cmdBindPipeline(commandBuffer, pipelineBindingPoint, pipeline);
1522 void CommonDescriptorInstance::commandBindVertexAttributes (VkCommandBuffer commandBuffer,
1523 const ut::BufferHandleAllocSp& vertexAttributesBuffer)
1525 const VkDeviceSize offsets[] = { 0u };
1526 const VkBuffer buffers[] = { *vertexAttributesBuffer->buffer };
1527 m_vki.cmdBindVertexBuffers(commandBuffer, 0u, 1u, buffers, offsets);
1530 void CommonDescriptorInstance::commandBindDescriptorSets (VkCommandBuffer commandBuffer,
1531 VkPipelineLayout pipelineLayout,
1532 VkDescriptorSet descriptorSet,
1533 deUint32 descriptorSetIndex)
1535 const VkPipelineBindPoint pipelineBindingPoint = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS;
1536 m_vki.cmdBindDescriptorSets(commandBuffer, pipelineBindingPoint, pipelineLayout, descriptorSetIndex, 1u, &descriptorSet, 0u, static_cast<deUint32*>(DE_NULL));
1539 ut::UpdatablePixelBufferAccessPtr
1540 CommonDescriptorInstance::commandReadFrameBuffer (VkCommandBuffer commandBuffer,
1541 const ut::FrameBufferSp& frameBuffer)
1543 ut::BufferHandleAllocSp frameBufferContent;
1544 commandReadFrameBuffer(frameBufferContent, commandBuffer, frameBuffer);
1545 return ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessBuffer(
1546 m_vkd, m_vki, vk::mapVkFormat(m_colorFormat), m_testParams.frameResolution,
1547 de::SharedPtr< Move<VkBuffer> >(new Move<VkBuffer>(frameBufferContent->buffer)),
1548 de::SharedPtr< de::MovePtr<Allocation> >(new de::MovePtr<Allocation>(frameBufferContent->alloc))));
1551 void CommonDescriptorInstance::commandReadFrameBuffer (ut::BufferHandleAllocSp& content,
1552 VkCommandBuffer commandBuffer,
1553 const ut::FrameBufferSp& frameBuffer)
1555 Move<VkBuffer> buffer;
1556 de::MovePtr<Allocation> allocation;
1558 const VkDeviceSize bufferSize = ut::computeImageSize(frameBuffer->image);
1560 // create a buffer and an host allocation for it
1562 const VkBufferCreateInfo bufferCreateInfo =
1564 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
1568 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
1569 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
1570 1u, // queueFamilyIndexCoun
1571 &m_queueFamilyIndex // pQueueFamilyIndices
1574 buffer = vk::createBuffer(m_vki, m_vkd, &bufferCreateInfo);
1575 const VkMemoryRequirements memRequirements(vk::getBufferMemoryRequirements(m_vki, m_vkd, *buffer));
1576 allocation = m_allocator.allocate(memRequirements, MemoryRequirement::HostVisible);
1578 VK_CHECK(m_vki.bindBufferMemory(m_vkd, *buffer, allocation->getMemory(), allocation->getOffset()));
1581 const VkImage& image = *frameBuffer->image->image;
1583 VkImageSubresourceRange subresourceRange =
1585 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
1588 0u, // baseArrayLayer
1592 const VkImageMemoryBarrier barrierBefore =
1594 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
1596 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask;
1597 VK_ACCESS_TRANSFER_READ_BIT, // dstAccessMask;
1598 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
1599 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout;
1600 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1601 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1603 subresourceRange // subresourceRange;
1606 const VkBufferImageCopy copyRegion =
1609 frameBuffer->image->extent.width, // bufferRowLength
1610 frameBuffer->image->extent.height, // bufferImageHeight
1611 { // VkImageSubresourceLayers
1612 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
1614 0u, // baseArrayLayer
1617 { 0, 0, 0 }, // imageOffset
1618 frameBuffer->image->extent // imageExtent
1621 const VkBufferMemoryBarrier bufferBarrier =
1623 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType;
1625 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask;
1626 VK_ACCESS_HOST_READ_BIT, // dstAccessMask;
1627 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1628 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1634 const VkImageMemoryBarrier barrierAfter =
1636 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
1638 VK_ACCESS_TRANSFER_READ_BIT, // srcAccessMask;
1639 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // dstAccessMask;
1640 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // oldLayout;
1641 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout;
1642 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1643 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1645 subresourceRange // subresourceRange
1649 m_vki.cmdPipelineBarrier(commandBuffer, // commandBuffer
1650 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, // srcStageMask, dstStageMask
1651 (VkDependencyFlags)0, // dependencyFlags
1652 0u, DE_NULL, // memoryBarrierCount, pMemoryBarriers
1653 0u, DE_NULL, // bufferBarrierCount, pBufferBarriers
1654 1u, &barrierBefore); // imageBarrierCount, pImageBarriers
1656 m_vki.cmdCopyImageToBuffer(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, ©Region);
1658 m_vki.cmdPipelineBarrier(commandBuffer,
1659 VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
1660 (VkDependencyFlags)0,
1665 content = ut::BufferHandleAllocSp(new ut::BufferHandleAlloc(buffer, allocation));
1668 std::string CommonDescriptorInstance::getColorAccess (VkDescriptorType descriptorType,
1669 const char* indexVariableName,
1673 std::map<std::string, std::string> vars;
1674 vars["INDEX"] = indexVariableName;
1676 switch (descriptorType)
1678 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1679 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
1680 text = "data[nonuniformEXT(${INDEX})].c";
1682 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1683 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1684 text = "data[nonuniformEXT(${INDEX})].cold";
1686 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
1687 text = "subpassLoad(data[nonuniformEXT(${INDEX})]).rgba";
1689 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1690 text = "texelFetch(data[nonuniformEXT(${INDEX})], 0)";
1692 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1693 text = "imageLoad(data[nonuniformEXT(${INDEX})], 0)";
1695 case VK_DESCRIPTOR_TYPE_SAMPLER:
1697 ? "textureLod(nonuniformEXT(sampler2D(tex[0], data[${INDEX}])), normalpos, 1)"
1698 : "texture( nonuniformEXT(sampler2D(tex[0], data[${INDEX}])), normalpos )";
1700 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
1702 ? "textureLod( nonuniformEXT(sampler2D(data[${INDEX}], samp[0])), vec2(0,0), textureQueryLevels(nonuniformEXT(sampler2D(data[${INDEX}], samp[0])))-1)"
1703 : "texture( nonuniformEXT(sampler2D(data[${INDEX}], samp[0])), vec2(0,0) )";
1705 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
1707 ? "textureLod( data[nonuniformEXT(${INDEX})], uvec2(0,0), textureQueryLevels(data[nonuniformEXT(${INDEX})])-1)"
1708 : "texture( data[nonuniformEXT(${INDEX})], uvec2(0,0) )";
1711 TCU_THROW(InternalError, "Not implemented descriptor type");
1714 return tcu::StringTemplate(text).specialize(vars);
1717 std::string CommonDescriptorInstance::getFragmentReturnSource (const std::string& colorAccess)
1719 return " FragColor = " + colorAccess + ";\n";
1722 std::string CommonDescriptorInstance::getFragmentLoopSource (const std::string& colorAccess1,
1723 const std::string& colorAccess2)
1725 std::map < std::string, std::string > vars;
1726 vars["COLOR_ACCESS_1"] = colorAccess1;
1727 vars["COLOR_ACCESS_2"] = colorAccess2;
1730 " vec4 sumClr1 = vec4(0,0,0,0); \n"
1731 " vec4 sumClr2 = vec4(0,0,0,0); \n"
1732 " for (int i = pc.lowerBound; i < pc.upperBound; ++i) \n"
1734 " int loopIdx = texelFetch(iter, i).x; \n"
1735 " sumClr1 += ${COLOR_ACCESS_2} + ${COLOR_ACCESS_1}; \n"
1736 " sumClr2 += ${COLOR_ACCESS_2}; \n"
1738 " FragColor = vec4(((sumClr1 - sumClr2) / float(pc.upperBound - pc.lowerBound)).rgb, 1); \n";
1740 return tcu::StringTemplate(s).specialize(vars);
1743 bool CommonDescriptorInstance::performWritesInVertex (VkDescriptorType descriptorType)
1745 bool result = false;
1747 switch (descriptorType)
1749 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1750 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1751 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1762 bool CommonDescriptorInstance::performWritesInVertex (VkDescriptorType descriptorType,
1763 const Context& context)
1765 bool result = false;
1767 ut::DeviceProperties dp (context);
1768 const VkPhysicalDeviceFeatures& feats = dp.physicalDeviceFeatures();
1770 if (feats.vertexPipelineStoresAndAtomics != DE_FALSE)
1772 result = CommonDescriptorInstance::performWritesInVertex(descriptorType);
1778 std::string CommonDescriptorInstance::getShaderAsm (VkShaderStageFlagBits shaderType,
1779 const TestCaseParams& testCaseParams,
1780 bool allowVertexStoring)
1782 std::stringstream s;
1785 case VK_SHADER_STAGE_VERTEX_BIT:
1786 switch (testCaseParams.descriptorType)
1788 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1789 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1790 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
1791 s << " OpCapability Shader\n";
1792 s << " OpCapability SampledBuffer\n";
1793 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
1794 s << " OpMemoryModel Logical GLSL450\n";
1795 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex\n";
1796 s << " OpSource GLSL 450\n";
1797 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
1798 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
1799 s << " OpName %main \"main\"\n";
1800 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
1801 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
1802 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
1803 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
1804 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
1805 s << " OpName %_ \"\"\n";
1806 s << " OpName %position \"position\"\n";
1807 s << " OpName %in_position \"in_position\"\n";
1808 s << " OpName %normalpos \"normalpos\"\n";
1809 s << " OpName %in_normalpos \"in_normalpos\"\n";
1810 s << " OpName %vIndex \"vIndex\"\n";
1811 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
1812 s << " OpName %rIndex \"rIndex\"\n";
1813 s << " OpName %index \"index\"\n";
1814 s << " OpName %gIndex \"gIndex\"\n";
1815 s << " OpName %bIndex \"bIndex\"\n";
1816 s << " OpName %aIndex \"aIndex\"\n";
1817 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
1818 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
1819 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
1820 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
1821 s << " OpDecorate %gl_PerVertex Block\n";
1822 s << " OpDecorate %position Location 0\n";
1823 s << " OpDecorate %in_position Location 0\n";
1824 s << " OpDecorate %normalpos Location 1\n";
1825 s << " OpDecorate %in_normalpos Location 1\n";
1826 s << " OpDecorate %vIndex Location 2\n";
1827 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
1828 s << " OpDecorate %rIndex Location 3\n";
1829 s << " OpDecorate %index Location 2\n";
1830 s << " OpDecorate %gIndex Location 4\n";
1831 s << " OpDecorate %bIndex Location 5\n";
1832 s << " OpDecorate %aIndex Location 6\n";
1833 s << " %void = OpTypeVoid\n";
1834 s << " %3 = OpTypeFunction %void\n";
1835 s << " %float = OpTypeFloat 32\n";
1836 s << " %v4float = OpTypeVector %float 4\n";
1837 s << " %uint = OpTypeInt 32 0\n";
1838 s << " %uint_1 = OpConstant %uint 1\n";
1839 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
1840 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
1841 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
1842 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
1843 s << " %int = OpTypeInt 32 1\n";
1844 s << " %int_1 = OpConstant %int 1\n";
1845 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
1846 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
1847 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
1848 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
1849 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
1850 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
1851 s << " %v2float = OpTypeVector %float 2\n";
1852 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
1853 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
1854 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
1855 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
1856 s << " %int_0 = OpConstant %int 0\n";
1857 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
1858 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
1859 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
1860 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
1861 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
1862 s << " %v4int = OpTypeVector %int 4\n";
1863 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
1864 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
1865 s << " %uint_0 = OpConstant %uint 0\n";
1866 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
1867 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
1868 s << " %uint_2 = OpConstant %uint 2\n";
1869 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
1870 s << " %uint_3 = OpConstant %uint 3\n";
1871 s << " %main = OpFunction %void None %3\n";
1872 s << " %5 = OpLabel\n";
1873 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
1874 s << " OpStore %18 %float_0_200000003\n";
1875 s << " %23 = OpLoad %v4float %in_position\n";
1876 s << " OpStore %position %23\n";
1877 s << " %29 = OpLoad %v2float %in_normalpos\n";
1878 s << " OpStore %normalpos %29\n";
1879 s << " %31 = OpLoad %v4float %position\n";
1880 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
1881 s << " OpStore %32 %31\n";
1882 s << " %37 = OpLoad %int %gl_VertexIndex\n";
1883 s << " OpStore %vIndex %37\n";
1884 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
1885 s << " %44 = OpLoad %int %43\n";
1886 s << " OpStore %rIndex %44\n";
1887 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
1888 s << " %47 = OpLoad %int %46\n";
1889 s << " OpStore %gIndex %47\n";
1890 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
1891 s << " %51 = OpLoad %int %50\n";
1892 s << " OpStore %bIndex %51\n";
1893 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
1894 s << " %55 = OpLoad %int %54\n";
1895 s << " OpStore %aIndex %55\n";
1897 s << " OpFunctionEnd\n";
1899 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1900 s << " OpCapability Shader\n";
1901 s << " OpCapability ImageBuffer\n";
1902 if (allowVertexStoring)
1904 s << " OpCapability ShaderNonUniform\n";
1905 s << " OpCapability RuntimeDescriptorArray\n";
1906 s << " OpCapability StorageTexelBufferArrayNonUniformIndexing\n";
1907 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
1909 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
1910 s << " OpMemoryModel Logical GLSL450\n";
1911 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex %data\n";
1912 s << " OpSource GLSL 450\n";
1913 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
1914 s << " OpName %main \"main\"\n";
1915 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
1916 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
1917 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
1918 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
1919 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
1920 s << " OpName %_ \"\"\n";
1921 s << " OpName %position \"position\"\n";
1922 s << " OpName %in_position \"in_position\"\n";
1923 s << " OpName %normalpos \"normalpos\"\n";
1924 s << " OpName %in_normalpos \"in_normalpos\"\n";
1925 s << " OpName %vIndex \"vIndex\"\n";
1926 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
1927 s << " OpName %rIndex \"rIndex\"\n";
1928 s << " OpName %index \"index\"\n";
1929 s << " OpName %gIndex \"gIndex\"\n";
1930 s << " OpName %bIndex \"bIndex\"\n";
1931 s << " OpName %aIndex \"aIndex\"\n";
1932 s << " OpName %data \"data\"\n";
1933 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
1934 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
1935 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
1936 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
1937 s << " OpDecorate %gl_PerVertex Block\n";
1938 s << " OpDecorate %position Location 0\n";
1939 s << " OpDecorate %in_position Location 0\n";
1940 s << " OpDecorate %normalpos Location 1\n";
1941 s << " OpDecorate %in_normalpos Location 1\n";
1942 s << " OpDecorate %vIndex Location 2\n";
1943 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
1944 s << " OpDecorate %rIndex Location 3\n";
1945 s << " OpDecorate %index Location 2\n";
1946 s << " OpDecorate %gIndex Location 4\n";
1947 s << " OpDecorate %bIndex Location 5\n";
1948 s << " OpDecorate %aIndex Location 6\n";
1949 s << " OpDecorate %data DescriptorSet 0\n";
1950 s << " OpDecorate %data Binding 4\n";
1951 if (allowVertexStoring)
1953 // s << " OpDecorate %66 NonUniform\n";
1954 // s << " OpDecorate %68 NonUniform\n";
1955 s << " OpDecorate %69 NonUniform\n";
1956 // s << " OpDecorate %71 NonUniform\n";
1957 // s << " OpDecorate %72 NonUniform\n";
1958 s << " OpDecorate %73 NonUniform\n";
1960 s << " %void = OpTypeVoid\n";
1961 s << " %3 = OpTypeFunction %void\n";
1962 s << " %float = OpTypeFloat 32\n";
1963 s << " %v4float = OpTypeVector %float 4\n";
1964 s << " %uint = OpTypeInt 32 0\n";
1965 s << " %uint_1 = OpConstant %uint 1\n";
1966 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
1967 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
1968 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
1969 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
1970 s << " %int = OpTypeInt 32 1\n";
1971 s << " %int_1 = OpConstant %int 1\n";
1972 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
1973 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
1974 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
1975 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
1976 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
1977 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
1978 s << " %v2float = OpTypeVector %float 2\n";
1979 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
1980 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
1981 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
1982 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
1983 s << " %int_0 = OpConstant %int 0\n";
1984 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
1985 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
1986 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
1987 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
1988 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
1989 s << " %v4int = OpTypeVector %int 4\n";
1990 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
1991 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
1992 s << " %uint_0 = OpConstant %uint 0\n";
1993 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
1994 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
1995 s << " %uint_2 = OpConstant %uint 2\n";
1996 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
1997 s << " %uint_3 = OpConstant %uint 3\n";
1998 if (allowVertexStoring)
2000 s << " %bool = OpTypeBool\n";
2001 s << " %61 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
2002 s << " %_runtimearr_61 = OpTypeRuntimeArray %61\n";
2003 s << " %_ptr_UniformConstant__runtimearr_61 = OpTypePointer UniformConstant %_runtimearr_61\n";
2004 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_61 UniformConstant\n";
2005 s << " %_ptr_UniformConstant_61 = OpTypePointer UniformConstant %61\n";
2009 s << " %56 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
2010 s << "%_arr_56_uint_1 = OpTypeArray %56 %uint_1\n";
2011 s << "%_ptr_UniformConstant__arr_56_uint_1 = OpTypePointer UniformConstant %_arr_56_uint_1\n";
2012 s << " %data = OpVariable %_ptr_UniformConstant__arr_56_uint_1 UniformConstant\n";
2014 s << " %main = OpFunction %void None %3\n";
2015 s << " %5 = OpLabel\n";
2016 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
2017 s << " OpStore %18 %float_0_200000003\n";
2018 s << " %23 = OpLoad %v4float %in_position\n";
2019 s << " OpStore %position %23\n";
2020 s << " %29 = OpLoad %v2float %in_normalpos\n";
2021 s << " OpStore %normalpos %29\n";
2022 s << " %31 = OpLoad %v4float %position\n";
2023 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
2024 s << " OpStore %32 %31\n";
2025 s << " %37 = OpLoad %int %gl_VertexIndex\n";
2026 s << " OpStore %vIndex %37\n";
2027 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
2028 s << " %44 = OpLoad %int %43\n";
2029 s << " OpStore %rIndex %44\n";
2030 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
2031 s << " %47 = OpLoad %int %46\n";
2032 s << " OpStore %gIndex %47\n";
2033 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
2034 s << " %51 = OpLoad %int %50\n";
2035 s << " OpStore %bIndex %51\n";
2036 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
2037 s << " %55 = OpLoad %int %54\n";
2038 s << " OpStore %aIndex %55\n";
2039 if (allowVertexStoring)
2041 s << " %56 = OpLoad %int %gIndex\n";
2042 s << " %58 = OpINotEqual %bool %56 %int_0\n";
2043 s << " OpSelectionMerge %60 None\n";
2044 s << " OpBranchConditional %58 %59 %60\n";
2045 s << " %59 = OpLabel\n";
2046 s << " %65 = OpLoad %int %gIndex\n";
2047 s << " %66 = OpCopyObject %int %65\n";
2048 s << " %68 = OpAccessChain %_ptr_UniformConstant_61 %data %66\n";
2049 s << " %69 = OpLoad %61 %68\n";
2050 s << " %70 = OpLoad %int %rIndex\n";
2051 s << " %71 = OpCopyObject %int %70\n";
2052 s << " %72 = OpAccessChain %_ptr_UniformConstant_61 %data %71\n";
2053 s << " %73 = OpLoad %61 %72\n";
2054 s << " %74 = OpImageRead %v4float %73 %int_0\n";
2055 s << " OpImageWrite %69 %int_1 %74\n";
2056 s << " OpBranch %60\n";
2057 s << " %60 = OpLabel\n";
2060 s << " OpFunctionEnd\n";
2062 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2063 s << " OpCapability Shader\n";
2064 if (allowVertexStoring)
2066 s << " OpCapability ShaderNonUniform\n";
2067 s << " OpCapability RuntimeDescriptorArray\n";
2068 s << " OpCapability StorageBufferArrayNonUniformIndexing\n";
2069 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2071 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2072 s << " OpMemoryModel Logical GLSL450\n";
2073 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex %data\n";
2074 s << " OpSource GLSL 450\n";
2075 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2076 s << " OpName %main \"main\"\n";
2077 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
2078 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
2079 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
2080 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
2081 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
2082 s << " OpName %_ \"\"\n";
2083 s << " OpName %position \"position\"\n";
2084 s << " OpName %in_position \"in_position\"\n";
2085 s << " OpName %normalpos \"normalpos\"\n";
2086 s << " OpName %in_normalpos \"in_normalpos\"\n";
2087 s << " OpName %vIndex \"vIndex\"\n";
2088 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
2089 s << " OpName %rIndex \"rIndex\"\n";
2090 s << " OpName %index \"index\"\n";
2091 s << " OpName %gIndex \"gIndex\"\n";
2092 s << " OpName %bIndex \"bIndex\"\n";
2093 s << " OpName %aIndex \"aIndex\"\n";
2094 s << " OpName %Data \"Data\"\n";
2095 s << " OpMemberName %Data 0 \"cnew\"\n";
2096 s << " OpMemberName %Data 1 \"cold\"\n";
2097 s << " OpName %data \"data\"\n";
2098 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
2099 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
2100 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
2101 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
2102 s << " OpDecorate %gl_PerVertex Block\n";
2103 s << " OpDecorate %position Location 0\n";
2104 s << " OpDecorate %in_position Location 0\n";
2105 s << " OpDecorate %normalpos Location 1\n";
2106 s << " OpDecorate %in_normalpos Location 1\n";
2107 s << " OpDecorate %vIndex Location 2\n";
2108 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
2109 s << " OpDecorate %rIndex Location 3\n";
2110 s << " OpDecorate %index Location 2\n";
2111 s << " OpDecorate %gIndex Location 4\n";
2112 s << " OpDecorate %bIndex Location 5\n";
2113 s << " OpDecorate %aIndex Location 6\n";
2114 s << " OpMemberDecorate %Data 0 Offset 0\n";
2115 s << " OpMemberDecorate %Data 1 Offset 16\n";
2116 s << " OpDecorate %Data Block\n";
2117 s << " OpDecorate %data DescriptorSet 0\n";
2118 s << " OpDecorate %data Binding 2\n";
2119 if (allowVertexStoring)
2121 // s << " OpDecorate %66 NonUniform\n";
2122 // s << " OpDecorate %68 NonUniform\n";
2123 s << " OpDecorate %70 NonUniform\n";
2124 // s << " OpDecorate %71 NonUniform\n";
2125 s << " OpDecorate %72 NonUniform\n";
2127 s << " %void = OpTypeVoid\n";
2128 s << " %3 = OpTypeFunction %void\n";
2129 s << " %float = OpTypeFloat 32\n";
2130 s << " %v4float = OpTypeVector %float 4\n";
2131 s << " %uint = OpTypeInt 32 0\n";
2132 s << " %uint_1 = OpConstant %uint 1\n";
2133 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
2134 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
2135 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
2136 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
2137 s << " %int = OpTypeInt 32 1\n";
2138 s << " %int_1 = OpConstant %int 1\n";
2139 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
2140 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
2141 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2142 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
2143 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2144 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
2145 s << " %v2float = OpTypeVector %float 2\n";
2146 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
2147 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
2148 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2149 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
2150 s << " %int_0 = OpConstant %int 0\n";
2151 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
2152 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
2153 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2154 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
2155 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
2156 s << " %v4int = OpTypeVector %int 4\n";
2157 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
2158 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
2159 s << " %uint_0 = OpConstant %uint 0\n";
2160 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
2161 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
2162 s << " %uint_2 = OpConstant %uint 2\n";
2163 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
2164 s << " %uint_3 = OpConstant %uint 3\n";
2165 s << " %Data = OpTypeStruct %v4float %v4float\n";
2166 if (allowVertexStoring)
2168 s << " %bool = OpTypeBool\n";
2169 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2170 s << "%_ptr_StorageBuffer__runtimearr_Data = OpTypePointer StorageBuffer %_runtimearr_Data\n";
2171 s << " %data = OpVariable %_ptr_StorageBuffer__runtimearr_Data StorageBuffer\n";
2172 s << "%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float\n";
2176 s << "%_arr_Data_uint_1 = OpTypeArray %Data %uint_1\n";
2177 s << "%_ptr_StorageBuffer__arr_Data_uint_1 = OpTypePointer StorageBuffer %_arr_Data_uint_1\n";
2178 s << " %data = OpVariable %_ptr_StorageBuffer__arr_Data_uint_1 StorageBuffer\n";
2180 s << " %main = OpFunction %void None %3\n";
2181 s << " %5 = OpLabel\n";
2182 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
2183 s << " OpStore %18 %float_0_200000003\n";
2184 s << " %23 = OpLoad %v4float %in_position\n";
2185 s << " OpStore %position %23\n";
2186 s << " %29 = OpLoad %v2float %in_normalpos\n";
2187 s << " OpStore %normalpos %29\n";
2188 s << " %31 = OpLoad %v4float %position\n";
2189 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
2190 s << " OpStore %32 %31\n";
2191 s << " %37 = OpLoad %int %gl_VertexIndex\n";
2192 s << " OpStore %vIndex %37\n";
2193 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
2194 s << " %44 = OpLoad %int %43\n";
2195 s << " OpStore %rIndex %44\n";
2196 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
2197 s << " %47 = OpLoad %int %46\n";
2198 s << " OpStore %gIndex %47\n";
2199 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
2200 s << " %51 = OpLoad %int %50\n";
2201 s << " OpStore %bIndex %51\n";
2202 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
2203 s << " %55 = OpLoad %int %54\n";
2204 s << " OpStore %aIndex %55\n";
2205 if (allowVertexStoring)
2207 s << " %56 = OpLoad %int %gIndex\n";
2208 s << " %58 = OpINotEqual %bool %56 %int_0\n";
2209 s << " OpSelectionMerge %60 None\n";
2210 s << " OpBranchConditional %58 %59 %60\n";
2211 s << " %59 = OpLabel\n";
2212 s << " %65 = OpLoad %int %gIndex\n";
2213 s << " %66 = OpCopyObject %int %65\n";
2214 s << " %67 = OpLoad %int %rIndex\n";
2215 s << " %68 = OpCopyObject %int %67\n";
2216 s << " %70 = OpAccessChain %_ptr_StorageBuffer_v4float %data %68 %int_1\n";
2217 s << " %71 = OpLoad %v4float %70\n";
2218 s << " %72 = OpAccessChain %_ptr_StorageBuffer_v4float %data %66 %int_0\n";
2219 s << " OpStore %72 %71\n";
2220 s << " OpBranch %60\n";
2221 s << " %60 = OpLabel\n";
2224 s << " OpFunctionEnd\n";
2227 TCU_THROW(InternalError, "Unexpected descriptor type");
2230 case VK_SHADER_STAGE_FRAGMENT_BIT:
2231 switch (testCaseParams.descriptorType)
2233 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2234 s << " OpCapability Shader\n";
2235 if (testCaseParams.usesMipMaps)
2237 s << " OpCapability ImageQuery\n";
2239 s << " OpCapability ShaderNonUniform\n";
2240 s << " OpCapability RuntimeDescriptorArray\n";
2241 s << " OpCapability SampledImageArrayNonUniformIndexing\n";
2242 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2243 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2244 s << " OpMemoryModel Logical GLSL450\n";
2245 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2246 s << " OpExecutionMode %main OriginUpperLeft\n";
2247 s << " OpSource GLSL 450\n";
2248 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2249 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
2250 s << " OpName %main \"main\"\n";
2251 s << " OpName %FragColor \"FragColor\"\n";
2252 s << " OpName %data \"data\"\n";
2253 s << " OpName %rIndex \"rIndex\"\n";
2254 s << " OpName %position \"position\"\n";
2255 s << " OpName %normalpos \"normalpos\"\n";
2256 s << " OpName %vIndex \"vIndex\"\n";
2257 s << " OpName %gIndex \"gIndex\"\n";
2258 s << " OpName %bIndex \"bIndex\"\n";
2259 s << " OpName %aIndex \"aIndex\"\n";
2260 s << " OpDecorate %FragColor Location 0\n";
2261 s << " OpDecorate %data DescriptorSet 0\n";
2262 s << " OpDecorate %data Binding 7\n";
2263 s << " OpDecorate %rIndex Flat\n";
2264 s << " OpDecorate %rIndex Location 3\n";
2265 // s << " OpDecorate %19 NonUniform\n";
2266 // s << " OpDecorate %21 NonUniform\n";
2267 s << " OpDecorate %22 NonUniform\n";
2268 if (testCaseParams.usesMipMaps)
2270 // s << " OpDecorate %27 NonUniform\n";
2271 // s << " OpDecorate %28 NonUniform\n";
2272 // s << " OpDecorate %29 NonUniform\n";
2273 s << " OpDecorate %30 NonUniform\n";
2275 s << " OpDecorate %position Flat\n";
2276 s << " OpDecorate %position Location 0\n";
2277 s << " OpDecorate %normalpos Flat\n";
2278 s << " OpDecorate %normalpos Location 1\n";
2279 s << " OpDecorate %vIndex Flat\n";
2280 s << " OpDecorate %vIndex Location 2\n";
2281 s << " OpDecorate %gIndex Flat\n";
2282 s << " OpDecorate %gIndex Location 4\n";
2283 s << " OpDecorate %bIndex Flat\n";
2284 s << " OpDecorate %bIndex Location 5\n";
2285 s << " OpDecorate %aIndex Flat\n";
2286 s << " OpDecorate %aIndex Location 6\n";
2287 s << " %void = OpTypeVoid\n";
2288 s << " %3 = OpTypeFunction %void\n";
2289 s << " %float = OpTypeFloat 32\n";
2290 s << " %v4float = OpTypeVector %float 4\n";
2291 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2292 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2293 s << " %10 = OpTypeImage %float 2D 0 0 0 1 Unknown\n";
2294 s << " %11 = OpTypeSampledImage %10\n";
2295 s << "%_runtimearr_11 = OpTypeRuntimeArray %11\n";
2296 s << "%_ptr_UniformConstant__runtimearr_11 = OpTypePointer UniformConstant %_runtimearr_11\n";
2297 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_11 UniformConstant\n";
2298 s << " %int = OpTypeInt 32 1\n";
2299 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2300 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2301 s << "%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11\n";
2302 s << " %v2float = OpTypeVector %float 2\n";
2303 s << " %float_0 = OpConstant %float 0\n";
2304 s << " %int_1 = OpConstant %int 1\n";
2305 s << " %25 = OpConstantComposite %v2float %float_0 %float_0\n";
2306 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2307 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2308 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2309 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2310 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2311 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2312 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2313 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2314 s << " %main = OpFunction %void None %3\n";
2315 s << " %5 = OpLabel\n";
2316 s << " %18 = OpLoad %int %rIndex\n";
2317 s << " %19 = OpCopyObject %int %18\n";
2318 s << " %21 = OpAccessChain %_ptr_UniformConstant_11 %data %19\n";
2319 s << " %22 = OpLoad %11 %21\n";
2320 if (testCaseParams.usesMipMaps)
2322 s << " %26 = OpLoad %int %rIndex\n";
2323 s << " %27 = OpCopyObject %int %26\n";
2324 s << " %28 = OpAccessChain %_ptr_UniformConstant_11 %data %27\n";
2325 s << " %29 = OpLoad %11 %28\n";
2326 s << " %30 = OpImage %10 %29\n";
2327 s << " %31 = OpImageQueryLevels %int %30\n";
2328 s << " %33 = OpISub %int %31 %int_1\n";
2329 s << " %34 = OpConvertSToF %float %33\n";
2330 s << " %35 = OpImageSampleExplicitLod %v4float %22 %25 Lod %34\n";
2331 s << " OpStore %FragColor %35\n";
2335 s << " %26 = OpImageSampleImplicitLod %v4float %22 %25\n";
2336 s << " OpStore %FragColor %26\n";
2339 s << " OpFunctionEnd\n";
2341 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2342 s << " OpCapability Shader\n";
2343 s << " OpCapability SampledBuffer\n";
2344 s << " OpCapability ShaderNonUniform\n";
2345 s << " OpCapability RuntimeDescriptorArray\n";
2346 s << " OpCapability UniformTexelBufferArrayNonUniformIndexing\n";
2347 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2348 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2349 s << " OpMemoryModel Logical GLSL450\n";
2350 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2351 s << " OpExecutionMode %main OriginUpperLeft\n";
2352 s << " OpSource GLSL 450\n";
2353 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2354 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
2355 s << " OpName %main \"main\"\n";
2356 s << " OpName %FragColor \"FragColor\"\n";
2357 s << " OpName %data \"data\"\n";
2358 s << " OpName %rIndex \"rIndex\"\n";
2359 s << " OpName %position \"position\"\n";
2360 s << " OpName %normalpos \"normalpos\"\n";
2361 s << " OpName %vIndex \"vIndex\"\n";
2362 s << " OpName %gIndex \"gIndex\"\n";
2363 s << " OpName %bIndex \"bIndex\"\n";
2364 s << " OpName %aIndex \"aIndex\"\n";
2365 s << " OpDecorate %FragColor Location 0\n";
2366 s << " OpDecorate %data DescriptorSet 0\n";
2367 s << " OpDecorate %data Binding 3\n";
2368 s << " OpDecorate %rIndex Flat\n";
2369 s << " OpDecorate %rIndex Location 3\n";
2370 // s << " OpDecorate %19 NonUniform\n";
2371 // s << " OpDecorate %21 NonUniform\n";
2372 // s << " OpDecorate %22 NonUniform\n";
2373 s << " OpDecorate %24 NonUniform\n";
2374 s << " OpDecorate %position Flat\n";
2375 s << " OpDecorate %position Location 0\n";
2376 s << " OpDecorate %normalpos Flat\n";
2377 s << " OpDecorate %normalpos Location 1\n";
2378 s << " OpDecorate %vIndex Flat\n";
2379 s << " OpDecorate %vIndex Location 2\n";
2380 s << " OpDecorate %gIndex Flat\n";
2381 s << " OpDecorate %gIndex Location 4\n";
2382 s << " OpDecorate %bIndex Flat\n";
2383 s << " OpDecorate %bIndex Location 5\n";
2384 s << " OpDecorate %aIndex Flat\n";
2385 s << " OpDecorate %aIndex Location 6\n";
2386 s << " %void = OpTypeVoid\n";
2387 s << " %3 = OpTypeFunction %void\n";
2388 s << " %float = OpTypeFloat 32\n";
2389 s << " %v4float = OpTypeVector %float 4\n";
2390 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2391 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2392 s << " %10 = OpTypeImage %float Buffer 0 0 0 1 Unknown\n";
2393 s << " %11 = OpTypeSampledImage %10\n";
2394 s << "%_runtimearr_11 = OpTypeRuntimeArray %11\n";
2395 s << "%_ptr_UniformConstant__runtimearr_11 = OpTypePointer UniformConstant %_runtimearr_11\n";
2396 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_11 UniformConstant\n";
2397 s << " %int = OpTypeInt 32 1\n";
2398 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2399 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2400 s << "%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11\n";
2401 s << " %int_0 = OpConstant %int 0\n";
2402 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2403 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2404 s << " %v2float = OpTypeVector %float 2\n";
2405 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2406 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2407 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2408 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2409 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2410 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2411 s << " %main = OpFunction %void None %3\n";
2412 s << " %5 = OpLabel\n";
2413 s << " %18 = OpLoad %int %rIndex\n";
2414 s << " %19 = OpCopyObject %int %18\n";
2415 s << " %21 = OpAccessChain %_ptr_UniformConstant_11 %data %19\n";
2416 s << " %22 = OpLoad %11 %21\n";
2417 s << " %24 = OpImage %10 %22\n";
2418 s << " %25 = OpImageFetch %v4float %24 %int_0\n";
2419 s << " OpStore %FragColor %25\n";
2421 s << " OpFunctionEnd\n";
2423 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2424 s << " OpCapability Shader\n";
2425 s << " OpCapability ImageBuffer\n";
2426 s << " OpCapability ShaderNonUniform\n";
2427 s << " OpCapability RuntimeDescriptorArray\n";
2428 s << " OpCapability StorageTexelBufferArrayNonUniformIndexing\n";
2429 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2430 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2431 s << " OpMemoryModel Logical GLSL450\n";
2432 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2433 s << " OpExecutionMode %main OriginUpperLeft\n";
2434 s << " OpSource GLSL 450\n";
2435 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2436 s << " OpName %main \"main\"\n";
2437 s << " OpName %FragColor \"FragColor\"\n";
2438 s << " OpName %data \"data\"\n";
2439 s << " OpName %rIndex \"rIndex\"\n";
2440 s << " OpName %position \"position\"\n";
2441 s << " OpName %normalpos \"normalpos\"\n";
2442 s << " OpName %vIndex \"vIndex\"\n";
2443 s << " OpName %gIndex \"gIndex\"\n";
2444 s << " OpName %bIndex \"bIndex\"\n";
2445 s << " OpName %aIndex \"aIndex\"\n";
2446 s << " OpDecorate %FragColor Location 0\n";
2447 s << " OpDecorate %data DescriptorSet 0\n";
2448 s << " OpDecorate %data Binding 4\n";
2449 s << " OpDecorate %rIndex Flat\n";
2450 s << " OpDecorate %rIndex Location 3\n";
2451 // s << " OpDecorate %18 NonUniform\n";
2452 // s << " OpDecorate %20 NonUniform\n";
2453 s << " OpDecorate %21 NonUniform\n";
2454 s << " OpDecorate %position Flat\n";
2455 s << " OpDecorate %position Location 0\n";
2456 s << " OpDecorate %normalpos Flat\n";
2457 s << " OpDecorate %normalpos Location 1\n";
2458 s << " OpDecorate %vIndex Flat\n";
2459 s << " OpDecorate %vIndex Location 2\n";
2460 s << " OpDecorate %gIndex Flat\n";
2461 s << " OpDecorate %gIndex Location 4\n";
2462 s << " OpDecorate %bIndex Flat\n";
2463 s << " OpDecorate %bIndex Location 5\n";
2464 s << " OpDecorate %aIndex Flat\n";
2465 s << " OpDecorate %aIndex Location 6\n";
2466 s << " %void = OpTypeVoid\n";
2467 s << " %3 = OpTypeFunction %void\n";
2468 s << " %float = OpTypeFloat 32\n";
2469 s << " %v4float = OpTypeVector %float 4\n";
2470 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2471 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2472 s << " %10 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
2473 s << "%_runtimearr_10 = OpTypeRuntimeArray %10\n";
2474 s << "%_ptr_UniformConstant__runtimearr_10 = OpTypePointer UniformConstant %_runtimearr_10\n";
2475 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_10 UniformConstant\n";
2476 s << " %int = OpTypeInt 32 1\n";
2477 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2478 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2479 s << "%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10\n";
2480 s << " %int_0 = OpConstant %int 0\n";
2481 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2482 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2483 s << " %v2float = OpTypeVector %float 2\n";
2484 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2485 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2486 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2487 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2488 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2489 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2490 s << " %main = OpFunction %void None %3\n";
2491 s << " %5 = OpLabel\n";
2492 s << " %17 = OpLoad %int %rIndex\n";
2493 s << " %18 = OpCopyObject %int %17\n";
2494 s << " %20 = OpAccessChain %_ptr_UniformConstant_10 %data %18\n";
2495 s << " %21 = OpLoad %10 %20\n";
2496 s << " %23 = OpImageRead %v4float %21 %int_0\n";
2497 s << " OpStore %FragColor %23\n";
2499 s << " OpFunctionEnd\n";
2501 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2502 s << " OpCapability Shader\n";
2503 s << " OpCapability ShaderNonUniform\n";
2504 s << " OpCapability RuntimeDescriptorArray\n";
2505 s << " OpCapability StorageBufferArrayNonUniformIndexing\n";
2506 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2507 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2508 s << " OpMemoryModel Logical GLSL450\n";
2509 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2510 s << " OpExecutionMode %main OriginUpperLeft\n";
2511 s << " OpSource GLSL 450\n";
2512 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2513 s << " OpName %main \"main\"\n";
2514 s << " OpName %FragColor \"FragColor\"\n";
2515 s << " OpName %Data \"Data\"\n";
2516 s << " OpMemberName %Data 0 \"cnew\"\n";
2517 s << " OpMemberName %Data 1 \"cold\"\n";
2518 s << " OpName %data \"data\"\n";
2519 s << " OpName %rIndex \"rIndex\"\n";
2520 s << " OpName %position \"position\"\n";
2521 s << " OpName %normalpos \"normalpos\"\n";
2522 s << " OpName %vIndex \"vIndex\"\n";
2523 s << " OpName %gIndex \"gIndex\"\n";
2524 s << " OpName %bIndex \"bIndex\"\n";
2525 s << " OpName %aIndex \"aIndex\"\n";
2526 s << " OpDecorate %FragColor Location 0\n";
2527 s << " OpMemberDecorate %Data 0 Offset 0\n";
2528 s << " OpMemberDecorate %Data 1 Offset 16\n";
2529 s << " OpDecorate %Data Block\n";
2530 s << " OpDecorate %data DescriptorSet 0\n";
2531 s << " OpDecorate %data Binding 2\n";
2532 s << " OpDecorate %rIndex Flat\n";
2533 s << " OpDecorate %rIndex Location 3\n";
2534 // s << " OpDecorate %18 NonUniform\n";
2535 s << " OpDecorate %21 NonUniform\n";
2536 // s << " OpDecorate %22 NonUniform\n";
2537 s << " OpDecorate %position Flat\n";
2538 s << " OpDecorate %position Location 0\n";
2539 s << " OpDecorate %normalpos Flat OpDecorate %normalpos Location 1\n";
2540 s << " OpDecorate %vIndex Flat\n";
2541 s << " OpDecorate %vIndex Location 2\n";
2542 s << " OpDecorate %gIndex Flat\n";
2543 s << " OpDecorate %gIndex Location 4\n";
2544 s << " OpDecorate %bIndex Flat\n";
2545 s << " OpDecorate %bIndex Location 5\n";
2546 s << " OpDecorate %aIndex Flat\n";
2547 s << " OpDecorate %aIndex Location 6\n";
2548 s << " %void = OpTypeVoid\n";
2549 s << " %3 = OpTypeFunction %void\n";
2550 s << " %float = OpTypeFloat 32\n";
2551 s << " %v4float = OpTypeVector %float 4\n";
2552 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2553 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2554 s << " %Data = OpTypeStruct %v4float %v4float\n";
2555 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2556 s << "%_ptr_StorageBuffer__runtimearr_Data = OpTypePointer StorageBuffer %_runtimearr_Data\n";
2557 s << " %data = OpVariable %_ptr_StorageBuffer__runtimearr_Data StorageBuffer\n";
2558 s << " %int = OpTypeInt 32 1\n";
2559 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2560 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2561 s << " %int_1 = OpConstant %int 1\n";
2562 s << "%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float\n";
2563 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2564 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2565 s << " %v2float = OpTypeVector %float 2\n";
2566 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2567 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2568 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2569 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2570 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2571 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2572 s << " %main = OpFunction %void None %3\n";
2573 s << " %5 = OpLabel\n";
2574 s << " %17 = OpLoad %int %rIndex\n";
2575 s << " %18 = OpCopyObject %int %17\n";
2576 s << " %21 = OpAccessChain %_ptr_StorageBuffer_v4float %data %18 %int_1\n";
2577 s << " %22 = OpLoad %v4float %21\n";
2578 s << " OpStore %FragColor %22\n";
2580 s << " OpFunctionEnd\n";
2582 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2583 s << " OpCapability Shader\n";
2584 s << " OpCapability ShaderNonUniform\n";
2585 s << " OpCapability RuntimeDescriptorArray\n";
2586 s << " OpCapability UniformBufferArrayNonUniformIndexing\n";
2587 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2588 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2589 s << " OpMemoryModel Logical GLSL450\n";
2590 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2591 s << " OpExecutionMode %main OriginUpperLeft\n";
2592 s << " OpSource GLSL 450\n";
2593 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2594 s << " OpName %main \"main\"\n";
2595 s << " OpName %FragColor \"FragColor\"\n";
2596 s << " OpName %Data \"Data\"\n";
2597 s << " OpMemberName %Data 0 \"c\"\n";
2598 s << " OpName %data \"data\"\n";
2599 s << " OpName %rIndex \"rIndex\"\n";
2600 s << " OpName %position \"position\"\n";
2601 s << " OpName %normalpos \"normalpos\"\n";
2602 s << " OpName %vIndex \"vIndex\"\n";
2603 s << " OpName %gIndex \"gIndex\"\n";
2604 s << " OpName %bIndex \"bIndex\"\n";
2605 s << " OpName %aIndex \"aIndex\"\n";
2606 s << " OpDecorate %FragColor Location 0\n";
2607 s << " OpMemberDecorate %Data 0 Offset 0\n";
2608 s << " OpDecorate %Data Block\n";
2609 s << " OpDecorate %data DescriptorSet 0\n";
2610 s << " OpDecorate %data Binding 1\n";
2611 s << " OpDecorate %rIndex Flat\n";
2612 s << " OpDecorate %rIndex Location 3\n";
2613 // s << " OpDecorate %18 NonUniform\n";
2614 s << " OpDecorate %21 NonUniform\n";
2615 // s << " OpDecorate %22 NonUniform\n";
2616 s << " OpDecorate %position Flat\n";
2617 s << " OpDecorate %position Location 0\n";
2618 s << " OpDecorate %normalpos Flat\n";
2619 s << " OpDecorate %normalpos Location 1\n";
2620 s << " OpDecorate %vIndex Flat\n";
2621 s << " OpDecorate %vIndex Location 2\n";
2622 s << " OpDecorate %gIndex Flat\n";
2623 s << " OpDecorate %gIndex Location 4\n";
2624 s << " OpDecorate %bIndex Flat\n";
2625 s << " OpDecorate %bIndex Location 5\n";
2626 s << " OpDecorate %aIndex Flat\n";
2627 s << " OpDecorate %aIndex Location 6\n";
2628 s << " %void = OpTypeVoid\n";
2629 s << " %3 = OpTypeFunction %void\n";
2630 s << " %float = OpTypeFloat 32\n";
2631 s << " %v4float = OpTypeVector %float 4\n";
2632 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2633 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2634 s << " %Data = OpTypeStruct %v4float\n";
2635 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2636 s << "%_ptr_Uniform__runtimearr_Data = OpTypePointer Uniform %_runtimearr_Data\n";
2637 s << " %data = OpVariable %_ptr_Uniform__runtimearr_Data Uniform\n";
2638 s << " %int = OpTypeInt 32 1\n";
2639 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2640 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2641 s << " %int_0 = OpConstant %int 0\n";
2642 s << "%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float\n";
2643 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2644 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2645 s << " %v2float = OpTypeVector %float 2\n";
2646 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2647 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2648 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2649 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2650 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2651 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2652 s << " %main = OpFunction %void None %3\n";
2653 s << " %5 = OpLabel\n";
2654 s << " %17 = OpLoad %int %rIndex\n";
2655 s << " %18 = OpCopyObject %int %17\n";
2656 s << " %21 = OpAccessChain %_ptr_Uniform_v4float %data %18 %int_0\n";
2657 s << " %22 = OpLoad %v4float %21\n";
2658 s << " OpStore %FragColor %22\n";
2660 s << " OpFunctionEnd\n";
2663 TCU_THROW(InternalError, "Unexpected descriptor type");
2666 case VK_SHADER_STAGE_COMPUTE_BIT:
2667 switch (testCaseParams.descriptorType)
2669 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
2670 s << " OpCapability Shader\n";
2671 s << " OpCapability ShaderNonUniform\n";
2672 s << " OpCapability RuntimeDescriptorArray\n";
2673 s << " OpCapability StorageImageArrayNonUniformIndexing\n";
2674 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2675 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2676 s << " OpMemoryModel Logical GLSL450\n";
2677 s << " OpEntryPoint GLCompute %main \"main\" %idxs %gl_WorkGroupID %data\n";
2678 s << " OpExecutionMode %main LocalSize 1 1 1\n";
2679 s << " OpSource GLSL 450\n";
2680 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2681 s << " OpName %main \"main\"\n";
2682 s << " OpName %c \"c\"\n";
2683 s << " OpName %idxs \"idxs\"\n";
2684 s << " OpName %gl_WorkGroupID \"gl_WorkGroupID\"\n";
2685 s << " OpName %data \"data\"\n";
2686 s << " OpDecorate %idxs DescriptorSet 0\n";
2687 s << " OpDecorate %idxs Binding 12\n";
2688 s << " OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId\n";
2689 s << " OpDecorate %data DescriptorSet 0\n";
2690 s << " OpDecorate %data Binding 11\n";
2691 // s << " OpDecorate %36 NonUniform\n";
2692 // s << " OpDecorate %37 NonUniform\n";
2693 s << " OpDecorate %41 NonUniform\n";
2694 s << " OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize\n";
2695 s << " %void = OpTypeVoid\n";
2696 s << " %3 = OpTypeFunction %void\n";
2697 s << " %uint = OpTypeInt 32 0\n";
2698 s << " %v4uint = OpTypeVector %uint 4\n";
2699 s << "%_ptr_Function_v4uint = OpTypePointer Function %v4uint\n";
2700 s << " %10 = OpTypeImage %uint 2D 0 0 0 2 R32ui\n";
2701 s << "%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10\n";
2702 s << " %idxs = OpVariable %_ptr_UniformConstant_10 UniformConstant\n";
2703 s << " %v3uint = OpTypeVector %uint 3\n";
2704 s << "%_ptr_Input_v3uint = OpTypePointer Input %v3uint\n";
2705 s << "%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input\n";
2706 s << " %uint_0 = OpConstant %uint 0\n";
2707 s << "%_ptr_Input_uint = OpTypePointer Input %uint\n";
2708 s << " %int = OpTypeInt 32 1\n";
2709 s << " %uint_1 = OpConstant %uint 1\n";
2710 s << " %v2int = OpTypeVector %int 2\n";
2711 s << "%_runtimearr_10 = OpTypeRuntimeArray %10\n";
2712 s << "%_ptr_UniformConstant__runtimearr_10 = OpTypePointer UniformConstant %_runtimearr_10\n";
2713 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_10 UniformConstant\n";
2714 s << "%_ptr_Function_uint = OpTypePointer Function %uint\n";
2715 s << " %int_0 = OpConstant %int 0\n";
2716 s << " %39 = OpConstantComposite %v2int %int_0 %int_0\n";
2717 s << "%_ptr_Image_uint = OpTypePointer Image %uint\n";
2718 s << "%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1\n";
2719 s << " %main = OpFunction %void None %3\n";
2720 s << " %5 = OpLabel\n";
2721 s << " %c = OpVariable %_ptr_Function_v4uint Function\n";
2722 s << " %13 = OpLoad %10 %idxs\n";
2723 s << " %19 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0\n";
2724 s << " %20 = OpLoad %uint %19\n";
2725 s << " %22 = OpBitcast %int %20\n";
2726 s << " %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_1\n";
2727 s << " %25 = OpLoad %uint %24\n";
2728 s << " %26 = OpBitcast %int %25\n";
2729 s << " %28 = OpCompositeConstruct %v2int %22 %26\n";
2730 s << " %29 = OpImageRead %v4uint %13 %28 ZeroExtend\n";
2731 s << " OpStore %c %29\n";
2732 s << " %34 = OpAccessChain %_ptr_Function_uint %c %uint_0\n";
2733 s << " %35 = OpLoad %uint %34\n";
2734 s << " %36 = OpCopyObject %uint %35\n";
2735 s << " %37 = OpAccessChain %_ptr_UniformConstant_10 %data %36\n";
2736 s << " %41 = OpImageTexelPointer %_ptr_Image_uint %37 %39 %uint_0\n";
2737 s << " %42 = OpAtomicIAdd %uint %41 %uint_1 %uint_0 %uint_1\n";
2739 s << " OpFunctionEnd\n";
2742 TCU_THROW(InternalError, "Unexpected descriptor type");
2746 TCU_THROW(InternalError, "Unexpected stage");
2752 std::string CommonDescriptorInstance::getShaderSource (VkShaderStageFlagBits shaderType,
2753 const TestCaseParams& testCaseParams,
2754 bool allowVertexStoring)
2756 std::stringstream s;
2758 s << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << '\n';
2759 s << "#extension GL_EXT_nonuniform_qualifier : require \n";
2761 if (testCaseParams.calculateInLoop)
2763 s << "layout(push_constant) uniform Block { int lowerBound, upperBound; } pc;\n";
2764 s << substBinding(BINDING_DescriptorEnumerator,
2765 "layout(set=1,binding=${?}) uniform isamplerBuffer iter; \n");
2768 switch (testCaseParams.descriptorType)
2770 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2771 s << substBinding(BINDING_StorageBuffer,
2772 "layout(set=0,binding=${?}) buffer Data { vec4 cnew, cold; } data[]; \n");
2774 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2775 s << substBinding(BINDING_StorageBufferDynamic,
2776 "layout(set=0,binding=${?}) buffer Data { vec4 cnew, cold; } data[]; \n");
2778 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2779 s << substBinding(BINDING_UniformBuffer,
2780 "layout(set=0,binding=${?}) uniform Data { vec4 c; } data[]; \n");
2782 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2783 s << substBinding(BINDING_UniformBufferDynamic,
2784 "layout(set=0,binding=${?}) uniform Data { vec4 c; } data[]; \n");
2786 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2787 s << substBinding(BINDING_StorageTexelBuffer,
2788 "layout(set=0,binding=${?},rgba32f) uniform imageBuffer data[];\n");
2790 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2791 s << "#extension GL_EXT_texture_buffer : require \n";
2792 s << substBinding(BINDING_UniformTexelBuffer,
2793 "layout(set=0,binding=${?}) uniform samplerBuffer data[];\n");
2795 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2796 // Left for the consistent of code.
2797 // Header is set one swicth below
2799 case VK_DESCRIPTOR_TYPE_SAMPLER:
2800 s << "#extension GL_EXT_texture_buffer : require \n";
2801 s << substBinding(BINDING_SampledImage,
2802 "layout(set=0,binding=${?}) uniform texture2D ${VAR}[${*}];\n", 1, "tex");
2803 s << substBinding(BINDING_Sampler,
2804 "layout(set=0,binding=${?}) uniform sampler ${VAR}[${*}];\n");
2806 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2807 s << "#extension GL_EXT_texture_buffer : require \n";
2808 s << substBinding(BINDING_Sampler,
2809 "layout(set=0,binding=${?}) uniform sampler ${VAR}[${*}];\n", 1, "samp");
2810 s << substBinding(BINDING_SampledImage,
2811 "layout(set=0,binding=${?}) uniform texture2D ${VAR}[${*}];\n");
2813 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2814 s << "#extension GL_EXT_texture_buffer : require \n";
2815 s << substBinding(BINDING_CombinedImageSampler,
2816 "layout(set=0,binding=${?}) uniform sampler2D data[];\n");
2818 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
2819 s << "layout(local_size_x=1,local_size_y=1,local_size_z=1) in; \n";
2820 s << substBinding(BINDING_StorageImage + 1,
2821 "layout(r32ui,set=0,binding=${?}) uniform uimage2D idxs; \n");
2822 s << substBinding(BINDING_StorageImage,
2823 "layout(r32ui,set=0,binding=${?}) uniform uimage2D data[]; \n");
2826 TCU_THROW(InternalError, "Not implemented descriptor type");
2831 case VK_SHADER_STAGE_VERTEX_BIT: s << getVertexShaderProlog(); break;
2832 case VK_SHADER_STAGE_FRAGMENT_BIT:
2834 if (testCaseParams.descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)
2836 s << substBinding(BINDING_InputAttachment,
2837 "layout(input_attachment_index=1,set=0,binding=${?}) uniform subpassInput data[]; \n");
2839 s << getFragmentShaderProlog();
2842 case VK_SHADER_STAGE_COMPUTE_BIT:
2845 TCU_THROW(InternalError, "Not implemented shader stage");
2850 case VK_SHADER_STAGE_VERTEX_BIT:
2852 switch (testCaseParams.descriptorType)
2854 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2855 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2856 if (allowVertexStoring)
2857 s << " if (gIndex != 0) data[nonuniformEXT(gIndex)].cnew = data[nonuniformEXT(rIndex)].cold; \n";
2859 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2860 if (allowVertexStoring)
2861 s << " if (gIndex != 0) imageStore(data[nonuniformEXT(gIndex)], 1, imageLoad(data[nonuniformEXT(rIndex)], 0)); \n";
2863 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2864 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2865 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2866 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2867 case VK_DESCRIPTOR_TYPE_SAMPLER:
2868 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2869 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2873 TCU_THROW(InternalError, "Not implemented descriptor type");
2878 case VK_SHADER_STAGE_FRAGMENT_BIT:
2880 switch (testCaseParams.descriptorType)
2882 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2883 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2884 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2886 if (testCaseParams.calculateInLoop)
2887 s << getFragmentLoopSource(
2888 getColorAccess(testCaseParams.descriptorType, "rIndex", false),
2889 getColorAccess(testCaseParams.descriptorType, "loopIdx", false));
2891 s << getFragmentReturnSource(getColorAccess(testCaseParams.descriptorType, "rIndex", false));
2894 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2895 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2896 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2897 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2898 case VK_DESCRIPTOR_TYPE_SAMPLER:
2899 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2900 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2901 if (testCaseParams.calculateInLoop)
2902 s << getFragmentLoopSource(
2903 getColorAccess(testCaseParams.descriptorType, "rIndex", testCaseParams.usesMipMaps),
2904 getColorAccess(testCaseParams.descriptorType, "loopIdx", testCaseParams.usesMipMaps));
2906 s << getFragmentReturnSource(getColorAccess(testCaseParams.descriptorType, "rIndex", testCaseParams.usesMipMaps));
2908 default: TCU_THROW(InternalError, "Not implemented descriptor type");
2913 case VK_SHADER_STAGE_COMPUTE_BIT: // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
2914 s << "void main(void)\n{\n";
2915 if (testCaseParams.calculateInLoop)
2916 s << " for (int i = pc.lowerBound; i < pc.upperBound; ++i) \n"
2917 " imageAtomicAdd(data[nonuniformEXT(texelFetch(iter, i).x)], ivec2(0, 0), 1); \n";
2919 s << " uvec4 c = imageLoad(idxs, ivec2(gl_WorkGroupID.x, gl_WorkGroupID.y)); \n"
2920 " imageAtomicAdd( data[nonuniformEXT(c.r)], ivec2(0, 0), 1); \n";
2923 default: TCU_THROW(InternalError, "Not implemented shader stage");
2926 s << getShaderEpilog();
2931 class StorageBufferInstance : virtual public CommonDescriptorInstance
2934 StorageBufferInstance (Context& context,
2935 const TestCaseParams& testCaseParams);
2937 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
2939 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
2942 StorageBufferInstance::StorageBufferInstance (Context& context,
2943 const TestCaseParams& testCaseParams)
2944 : CommonDescriptorInstance(context,
2945 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
2946 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2947 BINDING_StorageBuffer,
2948 VK_DESCRIPTOR_TYPE_UNDEFINED,
2951 performWritesInVertex(testCaseParams.descriptorType, context),
2956 void StorageBufferInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
2958 BindingStorageBuffer::Data data;
2960 bool vertexStores = false;
2962 ut::DeviceProperties dp(m_context);
2963 vertexStores = dp.physicalDeviceFeatures().vertexPipelineStoresAndAtomics != DE_FALSE;
2965 const deUint32 alignment = static_cast<deUint32>(ut::DeviceProperties(m_context).physicalDeviceProperties().limits.minStorageBufferOffsetAlignment);
2966 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, sizeof(data), alignment, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
2968 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
2969 for (deUint32 infoIdx = 0; infoIdx < variables.validDescriptorCount; ++infoIdx)
2971 const float component = m_colorScheme[infoIdx % m_schemeSize];
2972 const tcu::Vec4 color (component, component, component, 1.0f);
2973 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[infoIdx];
2974 data.cnew = vertexStores ? m_clearColor : color;
2977 deMemcpy(buffer + info.offset, &data, sizeof(data));
2979 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
2981 variables.dataAlignment = deAlign64(sizeof(data), alignment);
2984 bool StorageBufferInstance::verifyVertexWriteResults (IterateCommonVariables& variables)
2986 const tcu::Vec4 threshold (0.002f, 0.002f, 0.002f, 0.002f);
2987 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
2989 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
2990 BindingStorageBuffer::Data data;
2991 for (deUint32 primeIdx = 0; primeIdx < variables.validDescriptorCount; ++primeIdx)
2993 const deUint32 prime = primes[primeIdx];
2994 const float component = m_colorScheme[(prime % variables.validDescriptorCount) % m_schemeSize];
2995 const tcu::Vec4 referenceValue(component, component, component, 1.0f);
2997 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[primeIdx];
2998 deMemcpy(&data, buffer + info.offset, sizeof(data));
2999 const tcu::Vec4 realValue = data.cnew;
3001 const tcu::Vec4 diff = tcu::absDiff(referenceValue, realValue);
3002 if (!tcu::boolAll(tcu::lessThanEqual(diff, threshold)))
3008 class UniformBufferInstance : virtual public CommonDescriptorInstance
3011 UniformBufferInstance (Context& context,
3012 const TestCaseParams& testCaseParams);
3014 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3017 UniformBufferInstance::UniformBufferInstance (Context& context,
3018 const TestCaseParams& testCaseParams)
3019 : CommonDescriptorInstance(context,
3020 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3021 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
3022 BINDING_UniformBuffer,
3023 VK_DESCRIPTOR_TYPE_UNDEFINED,
3026 performWritesInVertex(testCaseParams.descriptorType, context),
3031 void UniformBufferInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3033 BindingUniformBuffer::Data data;
3035 const deUint32 alignment = static_cast<deUint32>(ut::DeviceProperties(m_context).physicalDeviceProperties().limits.minUniformBufferOffsetAlignment);
3036 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, sizeof(data), alignment, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
3038 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
3039 for (deUint32 infoIdx = 0; infoIdx < variables.validDescriptorCount; ++infoIdx)
3041 const float component = m_colorScheme[infoIdx % m_schemeSize];
3042 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[infoIdx];
3043 data.c = tcu::Vec4(component, component, component, 1.0f);
3044 deMemcpy(buffer + info.offset, &data, sizeof(data));
3046 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3048 variables.dataAlignment = deAlign64(sizeof(data), alignment);
3051 class StorageTexelInstance : public CommonDescriptorInstance
3054 StorageTexelInstance (Context& context,
3055 const TestCaseParams& testCaseParams);
3057 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3059 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
3062 StorageTexelInstance::StorageTexelInstance (Context& context,
3063 const TestCaseParams& testCaseParams)
3064 : CommonDescriptorInstance(context,
3065 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3066 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
3067 BINDING_StorageTexelBuffer,
3068 VK_DESCRIPTOR_TYPE_UNDEFINED,
3071 performWritesInVertex(testCaseParams.descriptorType, context),
3076 void StorageTexelInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3078 const VkExtent3D imageExtent = { 4, 4, 1 };
3079 const deUint32 imageSize = ut::computeImageSize(imageExtent, m_colorFormat);
3081 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, imageSize, sizeof(tcu::Vec4), VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT);
3082 createBuffersViews(variables.descriptorsBufferViews, variables.descriptorsBufferInfos, m_colorFormat);
3084 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3086 const float component = m_colorScheme[imageIdx % m_schemeSize];
3087 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3089 tcu::clear(pa, m_clearColor);
3090 pa.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3092 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3095 bool StorageTexelInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
3097 const VkExtent3D imageExtent = { 4, 4, 1 };
3098 const tcu::Vec4 threshold (0.002f, 0.002f, 0.002f, 0.002f);
3099 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3101 for (deUint32 primeIdx = 0; primeIdx < variables.validDescriptorCount; ++primeIdx)
3103 const deUint32 prime = primes[primeIdx];
3104 const float component = m_colorScheme[( prime % variables.validDescriptorCount ) % m_schemeSize];
3105 const tcu::Vec4 referenceValue(component, component, component, 1.0f);
3107 const PixelBufferAccess pa = getPixelAccess(primeIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3108 const tcu::Vec4 realValue = pa.getPixel(1, 0);
3110 const tcu::Vec4 diff = tcu::absDiff(referenceValue, realValue);
3111 if (!tcu::boolAll(tcu::lessThanEqual(diff, threshold)))
3117 class UniformTexelInstance : public CommonDescriptorInstance
3120 UniformTexelInstance (Context& context,
3121 const TestCaseParams& testCaseParams);
3123 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3126 UniformTexelInstance::UniformTexelInstance (Context& context,
3127 const TestCaseParams& testCaseParams)
3128 : CommonDescriptorInstance(context,
3129 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3130 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
3131 BINDING_UniformTexelBuffer,
3132 VK_DESCRIPTOR_TYPE_UNDEFINED,
3135 performWritesInVertex(testCaseParams.descriptorType, context),
3140 void UniformTexelInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3142 const VkExtent3D imageExtent = { 4, 4, 1 };
3143 const deUint32 imageSize = ut::computeImageSize(imageExtent, m_colorFormat);
3145 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, imageSize, sizeof(tcu::Vec4), VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT);
3146 createBuffersViews(variables.descriptorsBufferViews, variables.descriptorsBufferInfos, m_colorFormat);
3148 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3150 const float component = m_colorScheme[imageIdx % m_schemeSize];
3151 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3153 tcu::clear(pa, tcu::Vec4(component, component, component, 1.0f));
3155 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3158 class DynamicBuffersInstance : virtual public CommonDescriptorInstance
3161 DynamicBuffersInstance (Context& context,
3162 const TestParams& testParams)
3163 : CommonDescriptorInstance(context, testParams) {}
3166 virtual tcu::TestStatus iterate (void);
3167 virtual void updateDescriptors (IterateCommonVariables& variables);
3170 void DynamicBuffersInstance::updateDescriptors (IterateCommonVariables& variables)
3172 DE_ASSERT(variables.dataAlignment);
3174 VkDescriptorBufferInfo bufferInfo =
3176 *variables.descriptorsBuffer.get()->buffer,
3177 0, // always 0, it will be taken from pDynamicOffsets
3178 variables.dataAlignment
3181 VkWriteDescriptorSet updateInfo =
3183 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3185 *variables.descriptorSet, // descriptorSet
3186 m_testParams.descriptorBinding, // descriptorBinding;
3187 0, // to be set in below loop // dstArrayElement
3188 1u, // descriptorCount
3189 m_testParams.descriptorType, // descriptorType
3190 DE_NULL, // pImageInfo
3191 &bufferInfo, // pBufferInfo
3192 DE_NULL // pTexelBufferView
3195 deUint32 descIdx = 0;
3196 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3197 for (deUint32 validIdx = 0; validIdx < variables.validDescriptorCount; ++validIdx)
3199 for (; descIdx < primes[validIdx]; ++descIdx)
3201 updateInfo.dstArrayElement = descIdx;
3202 m_vki.updateDescriptorSets (m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3205 updateInfo.dstArrayElement = primes[validIdx];
3206 m_vki.updateDescriptorSets (m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3210 for (; descIdx < variables.availableDescriptorCount; ++descIdx)
3212 updateInfo.dstArrayElement = descIdx;
3213 m_vki.updateDescriptorSets(m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3217 tcu::TestStatus DynamicBuffersInstance::iterate (void)
3219 IterateCommonVariables v;
3220 iterateCommandSetup (v);
3222 ut::UpdatablePixelBufferAccessPtr programResult;
3223 ut::UpdatablePixelBufferAccessPtr referenceResult;
3224 bool firstPass = true;
3226 DE_ASSERT(v.dataAlignment);
3228 std::vector<deUint32> dynamicOffsets;
3230 deUint32 descIdx = 0;
3231 const std::vector<deUint32> primes = ut::generatePrimes(v.availableDescriptorCount);
3232 for (deUint32 validIdx = 0; validIdx < v.validDescriptorCount; ++validIdx)
3234 for (; descIdx < primes[validIdx]; ++descIdx)
3236 dynamicOffsets.push_back(0);
3239 dynamicOffsets.push_back(static_cast<deUint32>(validIdx * v.dataAlignment));
3243 for (; descIdx < v.availableDescriptorCount; ++descIdx)
3245 dynamicOffsets.push_back(0);
3248 // Unfortunatelly not lees and not more, only exactly
3249 DE_ASSERT(dynamicOffsets.size() == v.availableDescriptorCount);
3251 const VkDescriptorSet descriptorSets[] = { *v.descriptorSet };
3253 v.renderArea.extent.width = m_testParams.frameResolution.width/4;
3254 v.renderArea.extent.height = m_testParams.frameResolution.height/4;
3256 for (int x = 0; x < 4; x++)
3257 for (int y= 0; y < 4; y++)
3260 v.renderArea.offset.x = x * m_testParams.frameResolution.width/4;
3261 v.renderArea.offset.y = y * m_testParams.frameResolution.height/4;
3263 iterateCommandBegin (v, firstPass);
3266 m_vki.cmdBindDescriptorSets(
3267 *v.commandBuffer, // commandBuffer
3268 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
3269 *v.pipelineLayout, // layout
3271 DE_LENGTH_OF_ARRAY(descriptorSets), // descriptorSetCount
3272 descriptorSets, // pDescriptorSets
3273 v.availableDescriptorCount, // dynamicOffsetCount
3274 dynamicOffsets.data()); // pDynamicOffsets
3276 vk::VkRect2D scissor = makeRect2D(v.renderArea.offset.x, v.renderArea.offset.y, v.renderArea.extent.width, v.renderArea.extent.height);
3277 m_vki.cmdSetScissor(*v.commandBuffer, 0u, 1u, &scissor);
3279 vk::beginRenderPass (m_vki, *v.commandBuffer, *v.renderPass, *v.frameBuffer->buffer, v.renderArea, m_clearColor);
3280 m_vki.cmdDraw (*v.commandBuffer, v.vertexCount, 1u, 0u, 0u);
3281 vk::endRenderPass (m_vki, *v.commandBuffer);
3283 iterateCommandEnd(v, programResult, referenceResult);
3284 programResult->invalidate();
3287 return (iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
3290 class DynamicStorageBufferInstance : public DynamicBuffersInstance, public StorageBufferInstance
3293 DynamicStorageBufferInstance (Context& context,
3294 const TestCaseParams& testCaseParams);
3295 tcu::TestStatus iterate (void);
3296 void createAndPopulateDescriptors (IterateCommonVariables& variables);
3297 void updateDescriptors (IterateCommonVariables& variables);
3298 bool verifyVertexWriteResults (IterateCommonVariables& variables);
3301 DynamicStorageBufferInstance::DynamicStorageBufferInstance (Context& context,
3302 const TestCaseParams& testCaseParams)
3303 : CommonDescriptorInstance(context,
3304 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3305 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
3306 BINDING_StorageBufferDynamic,
3307 VK_DESCRIPTOR_TYPE_UNDEFINED,
3310 performWritesInVertex(testCaseParams.descriptorType, context),
3312 DynamicBuffersInstance(context, m_testParams), StorageBufferInstance(context, testCaseParams)
3316 tcu::TestStatus DynamicStorageBufferInstance::iterate(void)
3318 return DynamicBuffersInstance::iterate();
3321 void DynamicStorageBufferInstance::createAndPopulateDescriptors(IterateCommonVariables& variables)
3323 StorageBufferInstance::createAndPopulateDescriptors(variables);
3326 void DynamicStorageBufferInstance::updateDescriptors(IterateCommonVariables& variables)
3328 DynamicBuffersInstance::updateDescriptors(variables);
3331 bool DynamicStorageBufferInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
3333 return StorageBufferInstance::verifyVertexWriteResults(variables);
3336 class DynamicUniformBufferInstance : public DynamicBuffersInstance, public UniformBufferInstance
3339 DynamicUniformBufferInstance (Context& context,
3340 const TestCaseParams& testCaseParams);
3341 tcu::TestStatus iterate(void);
3342 void createAndPopulateDescriptors(IterateCommonVariables& variables);
3343 void updateDescriptors(IterateCommonVariables& variables);
3346 DynamicUniformBufferInstance::DynamicUniformBufferInstance (Context& context,
3347 const TestCaseParams& testCaseParams)
3348 : CommonDescriptorInstance(context,
3349 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3350 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
3351 BINDING_UniformBufferDynamic,
3352 VK_DESCRIPTOR_TYPE_UNDEFINED,
3355 performWritesInVertex(testCaseParams.descriptorType, context),
3357 DynamicBuffersInstance(context, m_testParams), UniformBufferInstance(context, testCaseParams)
3361 tcu::TestStatus DynamicUniformBufferInstance::iterate(void)
3363 return DynamicBuffersInstance::iterate();
3366 void DynamicUniformBufferInstance::createAndPopulateDescriptors(IterateCommonVariables& variables)
3368 UniformBufferInstance::createAndPopulateDescriptors(variables);
3371 void DynamicUniformBufferInstance::updateDescriptors(IterateCommonVariables& variables)
3373 DynamicBuffersInstance::updateDescriptors(variables);
3376 class InputAttachmentInstance : public CommonDescriptorInstance
3379 InputAttachmentInstance (Context& context,
3380 const TestCaseParams& testCaseParams);
3382 virtual Move<VkRenderPass> createRenderPass (const IterateCommonVariables& variables);
3383 virtual void createFramebuffer (ut::FrameBufferSp& frameBuffer,
3384 VkRenderPass renderPass,
3385 const IterateCommonVariables& variables);
3386 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3389 InputAttachmentInstance::InputAttachmentInstance (Context& context,
3390 const TestCaseParams& testCaseParams)
3391 : CommonDescriptorInstance(context,
3392 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3393 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
3394 BINDING_InputAttachment,
3395 VK_DESCRIPTOR_TYPE_UNDEFINED,
3398 performWritesInVertex(testCaseParams.descriptorType, context),
3403 void InputAttachmentInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3405 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3406 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, m_testParams.frameResolution, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount);
3407 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3409 for (deUint32 descriptorIdx = 0; descriptorIdx < variables.validDescriptorCount; ++descriptorIdx)
3411 const float component = m_colorScheme[descriptorIdx % m_schemeSize];
3412 const tcu::PixelBufferAccess pa = getPixelAccess(descriptorIdx, m_testParams.frameResolution, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3413 tcu::clear(pa, tcu::Vec4(component, component, component, 1.0f));
3415 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3418 Move<VkRenderPass> InputAttachmentInstance::createRenderPass (const IterateCommonVariables& variables)
3420 std::vector<VkAttachmentDescription> attachmentDescriptions;
3421 std::vector<VkAttachmentReference> inputAttachmentRefs;
3423 const VkAttachmentDescription colorAttachmentDescription =
3425 (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags;
3426 m_colorFormat, // VkFormat format;
3427 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
3428 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
3429 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
3430 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
3431 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
3432 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
3433 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout finalLayout;
3435 const VkAttachmentReference colorAttachmentRef =
3437 0u, // deUint32 attachment;
3438 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
3440 attachmentDescriptions.push_back(colorAttachmentDescription);
3442 // build input atachments
3444 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3445 const deUint32 inputCount = static_cast<deUint32>(variables.descriptorImageViews.size());
3446 for (deUint32 inputIdx = 0; inputIdx < inputCount; ++inputIdx)
3448 // primes holds the indices of input attachments for shader binding 10 which has input_attachment_index=1
3449 deUint32 nextInputAttachmentIndex = primes[inputIdx] + 1;
3451 // Fill up the subpass description's input attachments with unused attachments forming gaps to the next referenced attachment
3452 for (deUint32 unusedIdx = static_cast<deUint32>(inputAttachmentRefs.size()); unusedIdx < nextInputAttachmentIndex; ++unusedIdx)
3454 const VkAttachmentReference inputAttachmentRef =
3456 VK_ATTACHMENT_UNUSED, // deUint32 attachment;
3457 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout layout;
3460 inputAttachmentRefs.push_back(inputAttachmentRef);
3463 const VkAttachmentDescription inputAttachmentDescription =
3465 VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT, // VkAttachmentDescriptionFlags flags;
3466 variables.descriptorsImages[inputIdx]->format, // VkFormat format;
3467 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
3468 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
3469 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
3470 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
3471 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
3472 VK_IMAGE_LAYOUT_GENERAL, // VkImageLayout initialLayout;
3473 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout finalLayout;
3476 const VkAttachmentReference inputAttachmentRef =
3478 inputIdx + 1, // deUint32 attachment;
3479 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout layout;
3482 inputAttachmentRefs.push_back(inputAttachmentRef);
3483 attachmentDescriptions.push_back(inputAttachmentDescription);
3487 const VkSubpassDescription subpassDescription =
3489 (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags;
3490 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
3491 static_cast<deUint32>(inputAttachmentRefs.size()), // deUint32 inputAttachmentCount;
3492 inputAttachmentRefs.data(), // const VkAttachmentReference* pInputAttachments;
3493 1u, // deUint32 colorAttachmentCount;
3494 &colorAttachmentRef, // const VkAttachmentReference* pColorAttachments;
3495 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
3496 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
3497 0u, // deUint32 preserveAttachmentCount;
3498 DE_NULL // const deUint32* pPreserveAttachments;
3501 const VkRenderPassCreateInfo renderPassInfo =
3503 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
3504 DE_NULL, // const void* pNext;
3505 (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags;
3506 static_cast<deUint32>(attachmentDescriptions.size()), // deUint32 attachmentCount;
3507 attachmentDescriptions.data(), // const VkAttachmentDescription* pAttachments;
3508 1u, // deUint32 subpassCount;
3509 &subpassDescription, // const VkSubpassDescription* pSubpasses;
3510 0u, // deUint32 dependencyCount;
3511 DE_NULL // const VkSubpassDependency* pDependencies;
3514 return vk::createRenderPass(m_vki, m_vkd, &renderPassInfo);
3517 void InputAttachmentInstance::createFramebuffer (ut::FrameBufferSp& frameBuffer,
3518 VkRenderPass renderPass,
3519 const IterateCommonVariables& variables)
3521 std::vector<VkImageView> inputAttachments;
3522 const deUint32 viewCount = static_cast<deUint32>(variables.descriptorImageViews.size());
3523 inputAttachments.resize(viewCount);
3524 for (deUint32 viewIdx = 0; viewIdx < viewCount; ++viewIdx)
3526 inputAttachments[viewIdx] = **variables.descriptorImageViews[viewIdx];
3528 ut::createFrameBuffer(frameBuffer, m_context, m_testParams.frameResolution, m_colorFormat, renderPass, viewCount, inputAttachments.data());
3531 class SamplerInstance : public CommonDescriptorInstance
3534 SamplerInstance (Context& context,
3535 const TestCaseParams& testCaseParams);
3537 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3538 virtual void updateDescriptors (IterateCommonVariables& variables);
3541 SamplerInstance::SamplerInstance (Context& context,
3542 const TestCaseParams& testCaseParams)
3543 : CommonDescriptorInstance(context,
3544 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3545 VK_DESCRIPTOR_TYPE_SAMPLER,
3547 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
3548 BINDING_SampledImage,
3550 performWritesInVertex(testCaseParams.descriptorType, context),
3555 void SamplerInstance::updateDescriptors (IterateCommonVariables& variables)
3557 DE_ASSERT(variables.descriptorsImages.size() == 1);
3558 DE_ASSERT(variables.descriptorImageViews.size() == 1);
3559 DE_ASSERT(variables.descriptorsBufferInfos.size() == 1);
3560 DE_ASSERT(m_testParams.additionalDescriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
3561 DE_ASSERT(variables.descriptorSamplers.size() == variables.validDescriptorCount);
3565 const VkDescriptorImageInfo imageInfo =
3567 static_cast<VkSampler>(0),
3568 **variables.descriptorImageViews[0],
3569 VK_IMAGE_LAYOUT_GENERAL
3572 const VkWriteDescriptorSet writeInfo =
3574 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3576 *variables.descriptorSet, // descriptorSet
3577 BINDING_SampledImage, // descriptorBinding;
3579 1u, // descriptorCount
3580 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, // descriptorType
3581 &imageInfo, // pImageInfo
3582 DE_NULL, // pBufferInfo
3583 DE_NULL // pTexelBufferView
3586 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3590 CommonDescriptorInstance::updateDescriptors(variables);
3593 void SamplerInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3595 DE_ASSERT(variables.descriptorsImages.size() == 0);
3596 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3597 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3598 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3600 // create and populate an image
3602 VkExtent3D imageExtent = m_testParams.frameResolution;
3603 if (m_testParams.usesMipMaps)
3605 imageExtent.width *= 2;
3606 imageExtent.height *= 2;
3609 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3610 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, 1, m_testParams.usesMipMaps);
3611 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3613 PixelBufferAccess pa = getPixelAccess(0, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, m_testParams.usesMipMaps ? 1 : 0);
3615 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
3617 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
3619 const float component = m_colorScheme[(pixelNum % variables.validDescriptorCount) % m_schemeSize];
3620 pa.setPixel(tcu::Vec4(component, component, component, 1.0f), x, y);
3624 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3627 const tcu::Sampler sampler(
3628 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3629 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3630 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3631 m_testParams.usesMipMaps ? tcu::Sampler::LINEAR_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3632 m_testParams.usesMipMaps ? tcu::Sampler::LINEAR_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3633 0.0f, // lodTreshold
3634 true); // normalizeCoords
3635 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3636 variables.descriptorSamplers.resize(variables.validDescriptorCount);
3638 for (deUint32 samplerIdx = 0; samplerIdx < variables.validDescriptorCount; ++samplerIdx)
3640 variables.descriptorSamplers[samplerIdx] = ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo)));
3644 class SampledImageInstance : public CommonDescriptorInstance
3647 SampledImageInstance (Context& context,
3648 const TestCaseParams& testCaseParams);
3650 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3651 virtual void updateDescriptors (IterateCommonVariables& variables);
3654 SampledImageInstance::SampledImageInstance (Context& context,
3655 const TestCaseParams& testCaseParams)
3656 : CommonDescriptorInstance(context,
3657 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3658 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
3659 BINDING_SampledImage,
3660 VK_DESCRIPTOR_TYPE_SAMPLER,
3663 performWritesInVertex(testCaseParams.descriptorType, context),
3668 void SampledImageInstance::updateDescriptors (IterateCommonVariables& variables)
3670 DE_ASSERT(variables.descriptorSamplers.size() == 1);
3671 DE_ASSERT(variables.descriptorsImages.size() == variables.validDescriptorCount);
3672 DE_ASSERT(variables.descriptorImageViews.size() == variables.validDescriptorCount);
3673 DE_ASSERT(variables.descriptorsBufferInfos.size() == variables.validDescriptorCount);
3677 const VkDescriptorImageInfo samplerInfo =
3679 **variables.descriptorSamplers[0],
3680 static_cast<VkImageView>(0),
3681 static_cast<VkImageLayout>(0)
3684 const VkWriteDescriptorSet writeInfo =
3686 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3688 *variables.descriptorSet, // descriptorSet
3689 BINDING_Sampler, // descriptorBinding;
3691 1u, // descriptorCount
3692 VK_DESCRIPTOR_TYPE_SAMPLER, // descriptorType
3693 &samplerInfo, // pImageInfo
3694 DE_NULL, // pBufferInfo
3695 DE_NULL // pTexelBufferView
3698 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3702 CommonDescriptorInstance::updateDescriptors(variables);
3705 void SampledImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3707 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3708 DE_ASSERT(variables.descriptorsImages.size() == 0);
3709 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3710 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3712 // create an only one sampler for all images
3714 const tcu::Sampler sampler(
3715 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3716 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3717 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3718 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3719 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3720 0.0f, // lodTreshold
3721 true); // normalizeCoords
3722 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3723 variables.descriptorSamplers.push_back(ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo))));
3726 const VkExtent3D& imageExtent = m_testParams.usesMipMaps ? bigImageExtent : smallImageExtent;
3728 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3729 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount, m_testParams.usesMipMaps);
3730 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3732 PixelBufferAccess pixelAccess;
3733 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3735 const float component = m_colorScheme[imageIdx % m_schemeSize];
3737 if (m_testParams.usesMipMaps)
3739 const deUint32 mipCount = ut::computeMipMapCount(imageExtent);
3740 DE_ASSERT(mipCount >= 2);
3741 for (deUint32 mipIdx = 0; mipIdx < mipCount; ++mipIdx)
3743 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipIdx);
3744 tcu::clear(pixelAccess, m_clearColor);
3747 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipCount-1);
3748 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3752 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, 0);
3753 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3756 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3759 class CombinedImageInstance : public CommonDescriptorInstance
3762 CombinedImageInstance (Context& context,
3763 const TestCaseParams& testCaseParams);
3765 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3766 virtual void updateDescriptors (IterateCommonVariables& variables);
3769 CombinedImageInstance::CombinedImageInstance (Context& context,
3770 const TestCaseParams& testCaseParams)
3771 : CommonDescriptorInstance(context,
3772 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3773 testCaseParams.descriptorType,
3774 BINDING_CombinedImageSampler,
3775 VK_DESCRIPTOR_TYPE_UNDEFINED,
3778 performWritesInVertex(testCaseParams.descriptorType),
3783 void CombinedImageInstance::updateDescriptors (IterateCommonVariables& variables)
3785 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3786 const deUint32 primeCount = static_cast<deUint32>(primes.size());
3788 DE_ASSERT(variables.descriptorSamplers.size() == 1);
3789 DE_ASSERT(variables.descriptorsImages.size() == primeCount);
3790 DE_ASSERT(variables.descriptorImageViews.size() == primeCount);
3791 DE_ASSERT(variables.descriptorsBufferInfos.size() == primeCount);
3793 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
3795 const VkDescriptorImageInfo imageInfo =
3797 **variables.descriptorSamplers[0],
3798 **variables.descriptorImageViews[primeIdx],
3799 VK_IMAGE_LAYOUT_GENERAL
3802 const VkWriteDescriptorSet writeInfo =
3804 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3806 *variables.descriptorSet, // descriptorSet
3807 BINDING_CombinedImageSampler, // descriptorBinding;
3808 primes[primeIdx], // elementIndex
3809 1u, // descriptorCount
3810 m_testParams.descriptorType, // descriptorType
3811 &imageInfo, // pImageInfo
3812 DE_NULL, // pBufferInfo
3813 DE_NULL // pTexelBufferView
3816 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3820 void CombinedImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3822 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3823 DE_ASSERT(variables.descriptorsImages.size() == 0);
3824 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3825 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3826 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3828 const tcu::Sampler sampler(
3829 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3830 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3831 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3832 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3833 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3834 0.0f, // lodTreshold
3835 true); // normalizeCoords
3836 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3837 variables.descriptorSamplers.push_back(ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo))));
3839 const VkExtent3D& imageExtent = m_testParams.usesMipMaps ? bigImageExtent : smallImageExtent;
3840 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
3841 imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount, m_testParams.usesMipMaps);
3842 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3844 PixelBufferAccess pixelAccess;
3845 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3847 const float component = m_colorScheme[imageIdx % m_schemeSize];
3849 if (m_testParams.usesMipMaps)
3851 const deUint32 mipCount = ut::computeMipMapCount(imageExtent);
3852 DE_ASSERT(mipCount >= 2);
3853 for (deUint32 mipIdx = 0; mipIdx < mipCount; ++mipIdx)
3855 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipIdx);
3856 tcu::clear(pixelAccess, m_clearColor);
3859 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipCount-1);
3860 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3864 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, 0);
3865 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3869 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3872 class StorageImageInstance : public CommonDescriptorInstance
3875 StorageImageInstance (Context& context,
3876 const TestCaseParams& testCaseParams);
3878 virtual tcu::TestStatus iterate (void);
3879 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3880 virtual void updateDescriptors (IterateCommonVariables& variables);
3881 virtual void iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
3882 const IterateCommonVariables& variables,
3884 ut::BufferHandleAllocSp m_buffer;
3885 const deUint32 m_fillColor;
3886 typedef deUint32 m_imageFormat_t;
3889 StorageImageInstance::StorageImageInstance (Context& context,
3890 const TestCaseParams& testCaseParams)
3891 : CommonDescriptorInstance(context,
3892 TestParams (VK_SHADER_STAGE_COMPUTE_BIT,
3893 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
3894 BINDING_StorageImage,
3895 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
3896 (BINDING_StorageImage + 1),
3898 performWritesInVertex(testCaseParams.descriptorType, context),
3905 void StorageImageInstance::updateDescriptors (IterateCommonVariables& variables)
3907 // update image at last index
3909 VkDescriptorImageInfo imageInfo =
3911 static_cast<VkSampler>(0),
3912 **variables.descriptorImageViews[variables.validDescriptorCount],
3913 VK_IMAGE_LAYOUT_GENERAL
3916 const VkWriteDescriptorSet writeInfo =
3918 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3920 *variables.descriptorSet, // descriptorSet
3921 m_testParams.additionalDescriptorBinding, // descriptorBinding;
3923 1u, // descriptorCount
3924 m_testParams.additionalDescriptorType, // descriptorType
3925 &imageInfo, // pImageInfo
3926 DE_NULL, // pBufferInfo
3927 DE_NULL // pTexelBufferView
3930 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3933 // update rest images
3934 CommonDescriptorInstance::updateDescriptors(variables);
3937 void StorageImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3939 const VkFormat imageFormat = ut::mapType2vkFormat<m_imageFormat_t>::value;
3940 const VkBufferUsageFlags bufferUsage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
3942 // create descriptor buffer, images and views
3944 const VkExtent3D imageExtent = { 4, 4, 1 };
3946 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3947 bufferUsage, imageExtent, imageFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount);
3949 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3951 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, imageFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3952 tcu::clear(pa, tcu::UVec4(m_fillColor));
3954 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3957 // create additional image that will be used as index container
3959 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, m_buffer,
3960 bufferUsage, m_testParams.frameResolution, imageFormat, VK_IMAGE_LAYOUT_UNDEFINED, 1);
3963 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3964 const PixelBufferAccess pa = getPixelAccess(variables.validDescriptorCount, m_testParams.frameResolution, imageFormat, variables.descriptorsBufferInfos, m_buffer);
3965 for (deUint32 y = 0, pixel = 0; y < m_testParams.frameResolution.height; ++y)
3967 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixel)
3969 const deUint32 component = primes[pixel % variables.validDescriptorCount];
3970 pa.setPixel(tcu::UVec4(component), x, y);
3975 vk::flushAlloc(m_vki, m_vkd, *m_buffer->alloc);
3978 // create views for all previously created images
3979 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, imageFormat);
3982 tcu::TestStatus StorageImageInstance::iterate (void)
3984 IterateCommonVariables v;
3985 iterateCommandSetup (v);
3986 iterateCommandBegin (v);
3988 ut::UpdatablePixelBufferAccessPtr programResult;
3989 ut::UpdatablePixelBufferAccessPtr referenceResult;
3991 if (m_testParams.updateAfterBind)
3993 updateDescriptors (v);
3996 copyBuffersToImages (v);
3998 m_vki.cmdDispatch (*v.commandBuffer,
3999 m_testParams.calculateInLoop ? 1 : v.renderArea.extent.width,
4000 m_testParams.calculateInLoop ? 1 : v.renderArea.extent.height,
4003 copyImagesToBuffers (v);
4005 iterateCommandEnd(v, programResult, referenceResult, false);
4007 return ( iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
4010 void StorageImageInstance::iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
4011 const IterateCommonVariables& variables,
4014 result = ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessAllocation(
4015 vk::mapVkFormat(ut::mapType2vkFormat<m_imageFormat_t>::value), m_testParams.frameResolution));
4016 const PixelBufferAccess& dst = *result.get();
4020 vk::invalidateAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
4021 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
4023 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
4025 const deUint32 imageIdx = pixelNum % variables.validDescriptorCount;
4026 const PixelBufferAccess src = getPixelAccess(imageIdx,
4027 variables.descriptorsImages[imageIdx]->extent, variables.descriptorsImages[imageIdx]->format,
4028 variables.descriptorsBufferInfos, variables.descriptorsBuffer);
4029 dst.setPixel(tcu::Vector<m_imageFormat_t, 4>(src.getPixelT<m_imageFormat_t>(0, 0).x()), x, y);
4035 std::vector<m_imageFormat_t> inc(variables.validDescriptorCount, m_fillColor);
4037 for (deUint32 invIdx = variables.lowerBound; invIdx < variables.upperBound; ++invIdx)
4039 ++inc[invIdx % variables.validDescriptorCount];
4042 for (deUint32 invIdx = 0; invIdx < variables.vertexCount; ++invIdx)
4044 const deUint32 row = invIdx / m_testParams.frameResolution.width;
4045 const deUint32 col = invIdx % m_testParams.frameResolution.width;
4046 const m_imageFormat_t color = inc[invIdx % variables.validDescriptorCount];
4047 dst.setPixel(tcu::Vector<m_imageFormat_t, 4>(color), col, row);
4052 class DescriptorIndexingTestCase : public TestCase
4054 const TestCaseParams m_testCaseParams;
4056 DescriptorIndexingTestCase (tcu::TestContext &context, const char *name, const char *description, const TestCaseParams& testCaseParams)
4057 : TestCase(context, name, description)
4058 , m_testCaseParams(testCaseParams)
4062 vkt::TestInstance* createInstance (vkt::Context& context) const // override
4064 switch (m_testCaseParams.descriptorType)
4066 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
4067 return new StorageBufferInstance (context, m_testCaseParams);
4068 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
4069 return new UniformBufferInstance (context, m_testCaseParams);
4070 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
4071 return new StorageTexelInstance (context, m_testCaseParams);
4072 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
4073 return new UniformTexelInstance (context, m_testCaseParams);
4074 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4075 return new DynamicStorageBufferInstance (context, m_testCaseParams);
4076 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4077 return new DynamicUniformBufferInstance (context, m_testCaseParams);
4078 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
4079 return new InputAttachmentInstance (context, m_testCaseParams);
4080 case VK_DESCRIPTOR_TYPE_SAMPLER:
4081 return new SamplerInstance (context, m_testCaseParams);
4082 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
4083 return new SampledImageInstance (context, m_testCaseParams);
4084 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
4085 return new CombinedImageInstance (context, m_testCaseParams);
4086 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
4087 return new StorageImageInstance (context, m_testCaseParams);
4089 TCU_THROW(InternalError, "Unknown Descriptor Type");
4094 virtual void checkSupport (vkt::Context& context) const
4096 context.requireDeviceFunctionality("VK_EXT_descriptor_indexing");
4098 const vk::VkPhysicalDeviceDescriptorIndexingFeatures& feats = context.getDescriptorIndexingFeatures();
4100 switch (m_testCaseParams.descriptorType)
4102 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
4103 if (!(feats.shaderStorageBufferArrayNonUniformIndexing))
4104 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage buffer descriptor arrays is not supported.");
4106 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageBufferUpdateAfterBind)
4107 TCU_THROW(NotSupportedError, "Update after bind for storage buffer descriptors is not supported.");
4109 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
4110 if (!(feats.shaderUniformBufferArrayNonUniformIndexing))
4111 TCU_THROW(NotSupportedError, "Non-uniform indexing for uniform buffer descriptor arrays is not supported.");
4113 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingUniformBufferUpdateAfterBind)
4114 TCU_THROW(NotSupportedError, "Update after bind for uniform buffer descriptors is not supported.");
4116 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
4117 if (!(feats.shaderStorageTexelBufferArrayNonUniformIndexing))
4118 TCU_THROW(NotSupportedError, "Non-uniform indexing for storage texel buffer descriptor arrays is not supported.");
4120 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageTexelBufferUpdateAfterBind)
4121 TCU_THROW(NotSupportedError, "Update after bind for storage texel buffer descriptors is not supported.");
4123 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
4124 if (!(feats.shaderUniformTexelBufferArrayNonUniformIndexing))
4125 TCU_THROW(NotSupportedError, "Non-uniform indexing for uniform texel buffer descriptor arrays is not supported.");
4127 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingUniformTexelBufferUpdateAfterBind)
4128 TCU_THROW(NotSupportedError, "Update after bind for uniform texel buffer descriptors is not supported.");
4130 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4131 if (!(feats.shaderStorageBufferArrayNonUniformIndexing))
4132 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage buffer dynamic descriptor arrays is not supported.");
4134 if (m_testCaseParams.updateAfterBind)
4135 TCU_THROW(NotSupportedError, "Update after bind for storage buffer dynamic descriptors is not supported.");
4137 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4138 if (!(feats.shaderUniformBufferArrayNonUniformIndexing))
4139 TCU_THROW(NotSupportedError, "Non-uniform indexing over uniform buffer dynamic descriptor arrays is not supported.");
4141 if (m_testCaseParams.updateAfterBind)
4142 TCU_THROW(NotSupportedError, "Update after bind for uniform buffer dynamic descriptors is not supported.");
4144 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
4145 if (!(feats.shaderInputAttachmentArrayNonUniformIndexing))
4146 TCU_THROW(NotSupportedError, "Non-uniform indexing over input attachment descriptor arrays is not supported.");
4148 if (m_testCaseParams.updateAfterBind)
4149 TCU_THROW(NotSupportedError, "Update after bind for input attachment descriptors is not supported.");
4151 case VK_DESCRIPTOR_TYPE_SAMPLER:
4152 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4153 TCU_THROW(NotSupportedError, "Non-uniform indexing over sampler descriptor arrays is not supported.");
4155 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4156 TCU_THROW(NotSupportedError, "Update after bind for sampler descriptors is not supported.");
4158 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
4159 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4160 TCU_THROW(NotSupportedError, "Non-uniform indexing over sampled image descriptor arrays is not supported.");
4162 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4163 TCU_THROW(NotSupportedError, "Update after bind for sampled image descriptors is not supported.");
4165 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
4166 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4167 TCU_THROW(NotSupportedError, "Non-uniform indexing over combined image sampler descriptor arrays is not supported.");
4169 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4170 TCU_THROW(NotSupportedError, "Update after bind for combined image sampler descriptors is not supported.");
4172 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
4173 if (!(feats.shaderStorageImageArrayNonUniformIndexing))
4174 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage image descriptor arrays is not supported.");
4176 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageImageUpdateAfterBind)
4177 TCU_THROW(NotSupportedError, "Update after bind for storage image descriptors is not supported.");
4180 DE_FATAL("Unknown Descriptor Type");
4185 void initAsmPrograms(SourceCollections& programCollection) const
4188 std::string(*genShaderSource)(VkShaderStageFlagBits, const TestCaseParams&, bool) = &CommonDescriptorInstance::getShaderAsm;
4190 deUint32 vulkan_version = VK_MAKE_API_VERSION(0, 1, 2, 0);
4191 vk::SpirvVersion spirv_version = vk::SPIRV_VERSION_1_4;
4192 vk::SpirVAsmBuildOptions asm_options(vulkan_version, spirv_version);
4194 if (VK_SHADER_STAGE_VERTEX_BIT & m_testCaseParams.stageFlags)
4196 programCollection.spirvAsmSources.add(
4197 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4198 << (*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, false);
4200 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4202 programCollection.spirvAsmSources.add(
4203 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true), &asm_options)
4204 << (*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, true);
4207 if (VK_SHADER_STAGE_FRAGMENT_BIT & m_testCaseParams.stageFlags)
4209 programCollection.spirvAsmSources.add(
4210 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4211 << (*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, false);
4213 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4215 programCollection.spirvAsmSources.add(
4216 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true), &asm_options)
4217 << (*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, true);
4220 if (VK_SHADER_STAGE_COMPUTE_BIT & m_testCaseParams.stageFlags)
4222 programCollection.spirvAsmSources.add(
4223 ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4224 << (*genShaderSource)(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams, false);
4228 virtual void initPrograms (SourceCollections& programCollection) const
4230 if (m_testCaseParams.minNonUniform) {
4231 initAsmPrograms(programCollection);
4235 std::string(*genShaderSource)(VkShaderStageFlagBits, const TestCaseParams&, bool) = &CommonDescriptorInstance::getShaderSource;
4237 if (VK_SHADER_STAGE_VERTEX_BIT & m_testCaseParams.stageFlags)
4239 programCollection.glslSources.add(
4240 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4241 << glu::VertexSource((*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, false));
4243 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4245 programCollection.glslSources.add(
4246 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true))
4247 << glu::VertexSource((*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, true));
4250 if (VK_SHADER_STAGE_FRAGMENT_BIT & m_testCaseParams.stageFlags)
4252 programCollection.glslSources.add(
4253 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4254 << glu::FragmentSource((*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, false));
4256 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4258 programCollection.glslSources.add(
4259 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true))
4260 << glu::FragmentSource((*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, true));
4263 if (VK_SHADER_STAGE_COMPUTE_BIT & m_testCaseParams.stageFlags)
4265 programCollection.glslSources.add(
4266 ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4267 << glu::ComputeSource((*genShaderSource)(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams, false));
4272 } // - unnamed namespace
4274 void descriptorIndexingDescriptorSetsCreateTests (tcu::TestCaseGroup* group)
4279 const char* description;
4280 TestCaseParams params;
4283 tcu::TestContext& context(group->getTestContext());
4285 TestCaseInfo casesAfterBindAndLoop[] =
4288 "storage_buffer", "Regular Storage Buffer Descriptors",
4290 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4291 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4293 false, // updateAfterBind
4294 false, // calculateInLoop
4295 false, // useMipMaps
4296 false, // minNonUniform
4297 FUZZY_COMPARE, CMP_THRESHOLD
4301 "storage_texel_buffer", "Storage Texel Buffer Descriptors",
4303 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4304 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4306 false, // updateAfterBind
4307 false, // calculateInLoop
4308 false, // useMipMaps
4309 false, // minNonUniform
4310 FUZZY_COMPARE, CMP_THRESHOLD
4314 "uniform_texel_buffer", "Uniform Texel Buffer Descriptors",
4316 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4317 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4319 false, // updateAfterBind,
4320 false, // calculateInLoop
4321 false, // usesMipMaps
4322 false, // minNonUniform
4323 FUZZY_COMPARE, CMP_THRESHOLD
4327 "storage_image", "Storage Image Descriptors",
4329 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4330 VK_SHADER_STAGE_COMPUTE_BIT,
4332 false, // updateAfterBind
4333 false, // calculateInLoop
4334 false, // useMipMaps
4335 false, // minNonUniform
4336 FUZZY_COMPARE, CMP_THRESHOLD
4341 for (int updateAfterBind = 0; updateAfterBind < 2; ++updateAfterBind)
4343 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4345 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesAfterBindAndLoop); ++caseIdx)
4347 TestCaseInfo& info (casesAfterBindAndLoop[caseIdx]);
4348 std::string caseName (info.name);
4349 std::string caseDescription (info.description);
4350 TestCaseParams params (info.params);
4352 caseName += (updateAfterBind ? "_after_bind" : "");
4353 caseName += (calculateInLoop ? "_in_loop" : "");
4355 caseDescription += (updateAfterBind ? " After Bind" : "");
4356 caseDescription += (calculateInLoop ? " In Loop" : "");
4358 params.updateAfterBind = updateAfterBind ? true : false;
4359 params.calculateInLoop = calculateInLoop ? true : false;
4361 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4366 TestCaseInfo casesAfterBindAndLoopAndLOD[] =
4369 "sampler", "Sampler Descriptors",
4371 VK_DESCRIPTOR_TYPE_SAMPLER,
4372 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4374 false, // updateAfterBind
4375 false, // calculateInLoop
4376 false, // usesMipMaps
4377 false, // minNonUniform
4378 FUZZY_COMPARE, CMP_THRESHOLD
4382 "sampled_image", "Sampled Image Descriptors",
4384 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4385 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4387 false, // updateAfterBind
4388 false, // calculateInLoop
4389 false, // usesMipMaps
4390 false, // minNonUniform
4391 FUZZY_COMPARE, CMP_THRESHOLD
4395 "combined_image_sampler", "Combined Image Sampler Descriptors",
4397 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4398 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4400 false, // updateAfterBind
4401 false, // calculateInLoop
4402 false, // usesMipMaps
4403 false, // minNonUniform
4404 FUZZY_COMPARE, CMP_THRESHOLD
4409 for (int updateAfterBind = 0; updateAfterBind < 2; ++updateAfterBind)
4411 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4413 for (int usesMipMaps = 0; usesMipMaps < 2; ++usesMipMaps)
4415 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesAfterBindAndLoopAndLOD); ++caseIdx)
4417 TestCaseInfo& info (casesAfterBindAndLoopAndLOD[caseIdx]);
4418 std::string caseName (info.name);
4419 std::string caseDescription (info.description);
4420 TestCaseParams params (info.params);
4422 caseName += (updateAfterBind ? "_after_bind" : "");
4423 caseName += (calculateInLoop ? "_in_loop" : "");
4424 caseName += (usesMipMaps ? "_with_lod" : "");
4426 caseDescription += (updateAfterBind ? " After Bind" : "");
4427 caseDescription += (calculateInLoop ? " In Loop" : "");
4428 caseDescription += (usesMipMaps ? " Use LOD" : "");
4430 params.updateAfterBind = updateAfterBind ? true : false;
4431 params.calculateInLoop = calculateInLoop ? true : false;
4432 params.usesMipMaps = usesMipMaps ? true : false;
4434 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4440 TestCaseInfo casesNonAfterBindAndLoop[] =
4443 "uniform_buffer", "Regular Uniform Buffer Descriptors",
4445 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4446 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4448 false, // updateAfterBind
4449 false, // calculateInLoop
4450 false, // usesMipMaps
4451 false, // minNonUniform
4452 FUZZY_COMPARE, CMP_THRESHOLD
4456 "storage_buffer_dynamic", "Dynamic Storage Buffer Descriptors",
4458 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4459 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4461 false, // updateAfterBind
4462 false, // calculateInLoop
4463 false, // useMipMaps
4464 false, // minNonUniform
4465 FUZZY_COMPARE, CMP_THRESHOLD
4469 "uniform_buffer_dynamic", "Dynamic Uniform Buffer Descriptors",
4471 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4472 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4474 false, // updateAfterBind
4475 false, // calculateInLoop
4476 false, // useMipMaps
4477 false, // minNonUniform
4478 FUZZY_COMPARE, CMP_THRESHOLD
4482 "input_attachment", "Input Attachment Descriptors",
4484 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4485 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4487 false, // updateAfterBind
4488 false, // calculateInLoop
4489 false, // useMipMaps
4490 false, // minNonUniform
4491 FUZZY_COMPARE, CMP_THRESHOLD
4496 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4498 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesNonAfterBindAndLoop); ++caseIdx)
4500 TestCaseInfo& info(casesNonAfterBindAndLoop[caseIdx]);
4501 std::string caseName(info.name);
4502 std::string caseDescription(info.description);
4503 TestCaseParams params(info.params);
4505 caseName += (calculateInLoop ? "_in_loop" : "");
4507 caseDescription += (calculateInLoop ? " In Loop" : "");
4509 params.calculateInLoop = calculateInLoop ? true : false;
4511 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4516 // Tests that have the minimum necessary NonUniform decorations.
4517 // sampler and sampled_image GLSL already have minimum NonUniform decorations.
4519 TestCaseInfo casesMinNonUniform[] =
4522 "storage_buffer", "Regular Storage Buffer Descriptors",
4524 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4525 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4527 false, // updateAfterBind
4528 false, // calculateInLoop
4529 false, // useMipMaps
4530 true, // minNonUniform
4531 FUZZY_COMPARE, CMP_THRESHOLD
4535 "storage_texel_buffer", "Storage Texel Buffer Descriptors",
4537 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4538 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4540 false, // updateAfterBind
4541 false, // calculateInLoop
4542 false, // useMipMaps
4543 true, // minNonUniform
4544 FUZZY_COMPARE, CMP_THRESHOLD
4548 "uniform_texel_buffer", "Uniform Texel Buffer Descriptors",
4550 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4551 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4553 false, // updateAfterBind,
4554 false, // calculateInLoop
4555 false, // usesMipMaps
4556 true, // minNonUniform
4557 FUZZY_COMPARE, CMP_THRESHOLD
4561 "uniform_buffer", "Regular Uniform Buffer Descriptors",
4563 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4564 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4566 false, // updateAfterBind
4567 false, // calculateInLoop
4568 false, // usesMipMaps
4569 true, // minNonUniform
4570 FUZZY_COMPARE, CMP_THRESHOLD
4574 "combined_image_sampler", "Combined Image Sampler Descriptors",
4576 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4577 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4579 false, // updateAfterBind
4580 false, // calculateInLoop
4581 false, // usesMipMaps
4582 true, // minNonUniform
4583 FUZZY_COMPARE, CMP_THRESHOLD
4587 "combined_image_sampler", "Combined Image Sampler Descriptors",
4589 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4590 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4592 false, // updateAfterBind
4593 false, // calculateInLoop
4594 true, // usesMipMaps
4595 true, // minNonUniform
4596 FUZZY_COMPARE, CMP_THRESHOLD
4600 "storage_image", "Storage Image Descriptors",
4602 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4603 VK_SHADER_STAGE_COMPUTE_BIT,
4605 false, // updateAfterBind
4606 false, // calculateInLoop
4607 false, // useMipMaps
4608 true, // minNonUniform
4609 FUZZY_COMPARE, CMP_THRESHOLD
4614 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesMinNonUniform); ++caseIdx)
4616 TestCaseInfo& info(casesMinNonUniform[caseIdx]);
4617 std::string caseName(info.name);
4618 std::string caseDescription(info.description);
4619 TestCaseParams params(info.params);
4621 if (params.usesMipMaps) {
4622 caseName += "_with_lod";
4624 caseName += "_minNonUniform";
4626 caseDescription += " With Minimum NonUniform Decorations";
4628 TestCase* tc = new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params);
4629 group->addChild(tc);
4630 // group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4634 } // - DescriptorIndexing