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 };
92 static const VkDescriptorType VK_DESCRIPTOR_TYPE_UNDEFINED = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT;
94 template<deUint32 BindingNumber>
97 static const deUint32 binding = BindingNumber;
100 struct BindingUniformBuffer : Binding<BINDING_UniformBuffer>
108 struct BindingStorageBuffer : Binding<BINDING_StorageBuffer>
117 struct TestCaseParams
119 VkDescriptorType descriptorType; // used only to distinguish test class instance
120 VkShaderStageFlags stageFlags; // used only to build a proper program
121 VkExtent3D frameResolution; // target frame buffer resolution
122 bool updateAfterBind; // whether a test will use update after bind feature
123 bool calculateInLoop; // perform calculation in a loop
124 bool usesMipMaps; // this makes a sense and affects in image test cases only
125 bool minNonUniform; // whether a test will use the minimum nonUniform decorations
126 deBool fuzzyComparison; // if true then a test will use fuzzy comparison, otherwise float threshold
127 float thresholdValue; // a threshold that will be used for both, float and fuzzy comparisons
132 VkShaderStageFlags stageFlags;
133 VkDescriptorType descriptorType;
134 deUint32 descriptorBinding;
135 VkDescriptorType additionalDescriptorType;
136 deUint32 additionalDescriptorBinding;
137 bool copyBuffersToImages;
138 bool allowVertexStoring;
139 VkExtent3D frameResolution;
140 bool updateAfterBind;
141 bool calculateInLoop;
144 deBool fuzzyComparison;
145 float thresholdValue;
147 TestParams (VkShaderStageFlags stageFlags_,
148 VkDescriptorType descriptorType_,
149 deUint32 descriptorBinding_,
150 VkDescriptorType additionalDescriptorType_,
151 deUint32 additionalDescriptorBinding_,
152 bool copyBuffersToImages_,
153 bool allowVertexStoring_,
154 const TestCaseParams& caseParams)
155 : stageFlags (stageFlags_)
156 , descriptorType (descriptorType_)
157 , descriptorBinding (descriptorBinding_)
158 , additionalDescriptorType (additionalDescriptorType_)
159 , additionalDescriptorBinding (additionalDescriptorBinding_)
160 , copyBuffersToImages (copyBuffersToImages_)
161 , allowVertexStoring (allowVertexStoring_)
162 , frameResolution (caseParams.frameResolution)
163 , updateAfterBind (caseParams.updateAfterBind)
164 , calculateInLoop (caseParams.calculateInLoop)
165 , usesMipMaps (caseParams.usesMipMaps)
166 , minNonUniform (caseParams.minNonUniform)
167 , fuzzyComparison (caseParams.fuzzyComparison ? true : false)
168 , thresholdValue (caseParams.thresholdValue)
173 struct DescriptorEnumerator
175 ut::BufferHandleAllocSp buffer;
176 ut::BufferViewSp bufferView;
177 VkDeviceSize bufferSize;
179 Move<VkDescriptorSetLayout> descriptorSetLayout;
180 Move<VkDescriptorPool> descriptorPool;
181 Move<VkDescriptorSet> descriptorSet;
183 void init(const vkt::Context& context, deUint32 vertexCount, deUint32 availableDescriptorCount);
184 void update(const vkt::Context& context);
187 struct IterateCommonVariables
189 // An amount of descriptors of a given type available on the platform
190 deUint32 availableDescriptorCount;
191 // An amount of valid descriptors that have connected a buffers to them
192 deUint32 validDescriptorCount;
193 // As the name suggests, sometimes it is used as invocationCount
194 deUint32 vertexCount;
196 VkDeviceSize dataAlignment;
200 DescriptorEnumerator descriptorEnumerator;
202 ut::BufferHandleAllocSp vertexAttributesBuffer;
203 ut::BufferHandleAllocSp descriptorsBuffer;
204 std::vector<VkDescriptorBufferInfo> descriptorsBufferInfos;
205 std::vector<ut::BufferViewSp> descriptorsBufferViews;
206 std::vector<ut::ImageViewSp> descriptorImageViews;
207 std::vector<ut::SamplerSp> descriptorSamplers;
208 std::vector<ut::ImageHandleAllocSp> descriptorsImages;
209 ut::FrameBufferSp frameBuffer;
211 Move<VkDescriptorSetLayout> descriptorSetLayout;
212 Move<VkDescriptorPool> descriptorPool;
213 Move<VkDescriptorSet> descriptorSet;
214 Move<VkPipelineLayout> pipelineLayout;
215 Move<VkRenderPass> renderPass;
216 Move<VkPipeline> pipeline;
217 Move<VkCommandBuffer> commandBuffer;
220 class CommonDescriptorInstance : public TestInstance
223 CommonDescriptorInstance (Context& context,
224 const TestParams& testParams);
226 deUint32 computeAvailableDescriptorCount (VkDescriptorType descriptorType,
227 bool reserveUniformTexelBuffer) const;
229 Move<VkDescriptorSetLayout> createDescriptorSetLayout (bool reserveUniformTexelBuffer,
230 deUint32& descriptorCount) const;
232 Move<VkDescriptorPool> createDescriptorPool (deUint32 descriptorCount) const;
234 Move<VkDescriptorSet> createDescriptorSet (VkDescriptorPool dsPool,
235 VkDescriptorSetLayout dsLayout) const;
239 typedef tcu::Vec4 vec4;
240 typedef tcu::Vec2 vec2;
241 typedef tcu::IVec4 ivec4;
245 attributes& operator()(const vec4& pos)
249 normalpos.x() = (pos.x() + 1.0f) / 2.0f;
250 normalpos.y() = (pos.y() + 1.0f) / 2.0f;
255 void createVertexAttributeBuffer (ut::BufferHandleAllocSp& buffer,
256 deUint32 availableDescriptorCount) const;
258 static std::string substBinding (deUint32 binding,
261 const char* name = DE_NULL);
263 static const char* getVertexShaderProlog (void);
265 static const char* getFragmentShaderProlog (void);
267 static const char* getShaderEpilog (void);
269 static bool performWritesInVertex (VkDescriptorType descriptorType);
271 static bool performWritesInVertex (VkDescriptorType descriptorType,
272 const Context& context);
274 static std::string getShaderAsm (VkShaderStageFlagBits shaderType,
275 const TestCaseParams& testCaseParams,
276 bool allowVertexStoring);
278 static std::string getShaderSource (VkShaderStageFlagBits shaderType,
279 const TestCaseParams& testCaseParams,
280 bool allowVertexStoring);
282 static std::string getColorAccess (VkDescriptorType descriptorType,
283 const char* indexVariableName,
286 static std::string getFragmentReturnSource (const std::string& colorAccess);
288 static std::string getFragmentLoopSource (const std::string& colorAccess1,
289 const std::string& colorAccess2);
291 virtual Move<VkRenderPass> createRenderPass (const IterateCommonVariables& variables);
298 VkPushConstantRange makePushConstantRange (void) const;
300 Move<VkPipelineLayout> createPipelineLayout (const std::vector<VkDescriptorSetLayout>& descriptorSetLayouts) const;
302 // Creates graphics or compute pipeline and appropriate shaders' modules according the testCaseParams.stageFlags
303 // In the case of compute pipeline renderPass parameter is ignored.
304 // Viewport will be created with a width and a height taken from testCaseParam.fragResolution.
305 Move<VkPipeline> createPipeline (VkPipelineLayout pipelineLayout,
306 VkRenderPass renderPass);
308 virtual void createFramebuffer (ut::FrameBufferSp& frameBuffer,
309 VkRenderPass renderPass,
310 const IterateCommonVariables& variables);
312 // Creates one big stagging buffer cutted out on chunks that can accomodate an element of elementSize size
313 VkDeviceSize createBuffers (std::vector<VkDescriptorBufferInfo>& bufferInfos,
314 ut::BufferHandleAllocSp& buffer,
315 deUint32 elementCount,
316 deUint32 elementSize,
317 VkDeviceSize alignment,
318 VkBufferUsageFlags bufferUsage);
320 // Creates and binds an imagesCount of images with given parameters.
321 // Additionally creates stagging buffer for their data and PixelBufferAccess for particular images.
322 VkDeviceSize createImages (std::vector<ut::ImageHandleAllocSp>& images,
323 std::vector<VkDescriptorBufferInfo>& bufferInfos,
324 ut::BufferHandleAllocSp& buffer,
325 VkBufferUsageFlags bufferUsage,
326 const VkExtent3D& imageExtent,
327 VkFormat imageFormat,
328 VkImageLayout imageLayout,
330 bool withMipMaps = false);
332 void createBuffersViews (std::vector<ut::BufferViewSp>& views,
333 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
336 void createImagesViews (std::vector<ut::ImageViewSp>& views,
337 const std::vector<ut::ImageHandleAllocSp>& images,
340 virtual void copyBuffersToImages (IterateCommonVariables& variables);
342 virtual void copyImagesToBuffers (IterateCommonVariables& variables);
344 PixelBufferAccess getPixelAccess (deUint32 imageIndex,
345 const VkExtent3D& imageExtent,
346 VkFormat imageFormat,
347 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
348 const ut::BufferHandleAllocSp& buffer,
349 deUint32 mipLevel = 0u) const;
351 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables) = 0;
353 virtual void updateDescriptors (IterateCommonVariables& variables);
355 virtual void iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
356 const IterateCommonVariables& variables,
359 void iterateCommandSetup (IterateCommonVariables& variables);
361 void iterateCommandBegin (IterateCommonVariables& variables,
362 bool firstPass = true);
364 void iterateCommandEnd (IterateCommonVariables& variables,
365 ut::UpdatablePixelBufferAccessPtr& programResult,
366 ut::UpdatablePixelBufferAccessPtr& referenceResult,
367 bool collectBeforeSubmit = true);
369 bool iterateVerifyResults (IterateCommonVariables& variables,
370 ut::UpdatablePixelBufferAccessPtr programResult,
371 ut::UpdatablePixelBufferAccessPtr referenceResult);
373 Move<VkCommandBuffer> createCmdBuffer (void);
375 void commandBindPipeline (VkCommandBuffer commandBuffer,
376 VkPipeline pipeline);
378 void commandBindVertexAttributes (VkCommandBuffer commandBuffer,
379 const ut::BufferHandleAllocSp& vertexAttributesBuffer);
381 void commandBindDescriptorSets (VkCommandBuffer commandBuffer,
382 VkPipelineLayout pipelineLayout,
383 VkDescriptorSet descriptorSet,
384 deUint32 descriptorSetIndex);
386 void commandReadFrameBuffer (ut::BufferHandleAllocSp& content,
387 VkCommandBuffer commandBuffer,
388 const ut::FrameBufferSp& frameBuffer);
389 ut::UpdatablePixelBufferAccessPtr
390 commandReadFrameBuffer (VkCommandBuffer commandBuffer,
391 const ut::FrameBufferSp& frameBuffer);
393 Move<VkFence> commandSubmit (VkCommandBuffer commandBuffer);
395 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
398 virtual tcu::TestStatus iterate (void);
401 const VkDevice m_vkd;
402 const DeviceInterface& m_vki;
403 Allocator& m_allocator;
404 const VkQueue m_queue;
405 const deUint32 m_queueFamilyIndex;
406 const Move<VkCommandPool> m_commandPool;
407 const VkFormat m_colorFormat;
408 const TestParams m_testParams;
409 static const tcu::Vec4 m_clearColor;
410 const std::vector<float> m_colorScheme;
411 const deUint32 m_schemeSize;
415 Move<VkPipeline> createGraphicsPipeline (VkPipelineLayout pipelineLayout,
416 VkRenderPass renderPass);
418 Move<VkPipeline> createComputePipeline (VkPipelineLayout pipelineLayout);
420 int constructShaderModules (void);
422 static std::vector<float> createColorScheme();
424 Move<VkShaderModule> m_vertexModule;
425 Move<VkShaderModule> m_fragmentModule;
426 Move<VkShaderModule> m_computeModule;
428 const tcu::Vec4 CommonDescriptorInstance::m_clearColor = tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
430 void DescriptorEnumerator::init (const vkt::Context& context, deUint32 vertexCount, deUint32 availableDescriptorCount)
432 const VkDevice device = context.getDevice();
433 const DeviceInterface& deviceInterface = context.getDeviceInterface();
435 const VkFormat imageFormat = VK_FORMAT_R32G32B32A32_SINT;
436 typedef ut::mapVkFormat2Type<imageFormat>::type pixelType;
437 const VkDeviceSize dataSize = vertexCount * sizeof(pixelType);
438 const std::vector<deUint32> primes = ut::generatePrimes(availableDescriptorCount);
439 const deUint32 primeCount = static_cast<deUint32>(primes.size());
441 std::vector<pixelType> data(vertexCount);
442 // e.g. 2,3,5,7,11,13,2,3,5,7,...
443 for (deUint32 idx = 0; idx < vertexCount; ++idx)
445 data[idx].x() = static_cast<pixelType::Element>(primes[idx % primeCount]);
446 data[idx].y() = static_cast<pixelType::Element>(idx);
449 bufferSize = ut::createBufferAndBind(buffer, context, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, dataSize);
450 deMemcpy(buffer->alloc->getHostPtr(), data.data(), static_cast<size_t>(dataSize));
452 const VkBufferViewCreateInfo bufferViewCreateInfo =
454 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // sType
457 *(buffer.get()->buffer), // buffer
458 imageFormat, // format
463 bufferView = ut::BufferViewSp(new Move<VkBufferView>(vk::createBufferView(deviceInterface, device, &bufferViewCreateInfo)));
465 const VkDescriptorSetLayoutBinding binding =
467 BINDING_DescriptorEnumerator, // binding
468 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, // descriptorType
469 1u, // descriptorCount
470 VK_SHADER_STAGE_ALL, // stageFlags
471 DE_NULL, // pImmutableSamplers
474 const VkDescriptorSetLayoutCreateInfo layoutCreateInfo =
476 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
480 &binding, // pBindings
483 descriptorSetLayout = vk::createDescriptorSetLayout(deviceInterface, device, &layoutCreateInfo);
484 descriptorPool = DescriptorPoolBuilder().addType(binding.descriptorType)
485 .build(deviceInterface, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u);
487 const VkDescriptorSetAllocateInfo dsAllocInfo =
489 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // sType
491 *descriptorPool, // descriptorPool
492 1u, // descriptorSetCount
493 &(*descriptorSetLayout) // pSetLayouts
496 descriptorSet = vk::allocateDescriptorSet(deviceInterface, device, &dsAllocInfo);
499 void DescriptorEnumerator::update (const vkt::Context& context)
501 const VkDescriptorBufferInfo bufferInfo =
503 *(buffer.get()->buffer), // buffer
508 const VkWriteDescriptorSet writeInfo =
510 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
512 *descriptorSet, // dstSet
513 BINDING_DescriptorEnumerator, // dstBinding
514 0u, // dstArrayElement
515 1u, // descriptorCount
516 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, // descriptorType
517 DE_NULL, // pImageInfo
518 &bufferInfo, // pBufferInfo
519 &(**bufferView), // pTexelBufferView
522 context.getDeviceInterface().updateDescriptorSets(context.getDevice(), 1u, &writeInfo, 0u, DE_NULL);
525 CommonDescriptorInstance::CommonDescriptorInstance (Context& context,
526 const TestParams& testParams)
527 : TestInstance (context)
528 , m_vkd (context.getDevice())
529 , m_vki (context.getDeviceInterface())
530 , m_allocator (context.getDefaultAllocator())
531 , m_queue (context.getUniversalQueue())
532 , m_queueFamilyIndex(context.getUniversalQueueFamilyIndex())
533 , m_commandPool (vk::createCommandPool(m_vki, m_vkd, (VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT), m_queueFamilyIndex))
534 , m_colorFormat (VK_FORMAT_R32G32B32A32_SFLOAT)
535 , m_testParams (testParams)
536 , m_colorScheme (createColorScheme())
537 , m_schemeSize (static_cast<deUint32>(m_colorScheme.size()))
541 deUint32 CommonDescriptorInstance::computeAvailableDescriptorCount (VkDescriptorType descriptorType,
542 bool reserveUniformTexelBuffer) const
544 DE_UNREF(descriptorType);
545 const deUint32 vertexCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
546 const deUint32 availableDescriptorsOnDevice = ut::DeviceProperties(m_context).computeMaxPerStageDescriptorCount(m_testParams.descriptorType, m_testParams.updateAfterBind, reserveUniformTexelBuffer);
547 return deMinu32(deMinu32(vertexCount, availableDescriptorsOnDevice), MAX_DESCRIPTORS);
550 Move<VkDescriptorSetLayout> CommonDescriptorInstance::createDescriptorSetLayout (bool reserveUniformTexelBuffer,
551 deUint32& descriptorCount) const
553 descriptorCount = computeAvailableDescriptorCount(m_testParams.descriptorType, reserveUniformTexelBuffer);
555 bool optional = (m_testParams.additionalDescriptorBinding != BINDING_Undefined) && (m_testParams.additionalDescriptorType != VK_DESCRIPTOR_TYPE_UNDEFINED);
557 const VkShaderStageFlags bindingStageFlags = (m_testParams.descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) ?
558 VkShaderStageFlags{VK_SHADER_STAGE_FRAGMENT_BIT} : m_testParams.stageFlags;
560 const VkDescriptorSetLayoutBinding bindings[] =
563 m_testParams.descriptorBinding, // binding
564 m_testParams.descriptorType, // descriptorType
565 descriptorCount, // descriptorCount
566 bindingStageFlags, // stageFlags
567 DE_NULL, // pImmutableSamplers
570 m_testParams.additionalDescriptorBinding, // binding
571 m_testParams.additionalDescriptorType, // descriptorType
572 1, // descriptorCount
573 bindingStageFlags, // stageFlags
574 DE_NULL, // pImmutableSamplers
578 const VkDescriptorBindingFlags bindingFlagUpdateAfterBind =
579 m_testParams.updateAfterBind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0;
581 const VkDescriptorBindingFlags bindingFlags[] =
583 VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | bindingFlagUpdateAfterBind,
584 VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | bindingFlagUpdateAfterBind
587 const VkDescriptorSetLayoutBindingFlagsCreateInfo bindingCreateInfo =
589 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
591 optional ? 2u : 1u, // bindingCount
592 bindingFlags, // pBindingFlags
595 const VkDescriptorSetLayoutCreateFlags layoutCreateFlags =
596 m_testParams.updateAfterBind ? VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT : 0;
598 const VkDescriptorSetLayoutCreateInfo layoutCreateInfo =
600 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
601 &bindingCreateInfo, // pNext
602 layoutCreateFlags, // flags
603 optional ? 2u : 1u, // bindingCount
604 bindings, // pBindings
607 return vk::createDescriptorSetLayout(m_vki, m_vkd, &layoutCreateInfo);
610 Move<VkDescriptorPool> CommonDescriptorInstance::createDescriptorPool (deUint32 descriptorCount) const
612 const VkDescriptorPoolCreateFlags pcf = m_testParams.updateAfterBind ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0;
614 DescriptorPoolBuilder builder;
616 builder.addType(m_testParams.descriptorType, descriptorCount);
618 if (m_testParams.additionalDescriptorType != VK_DESCRIPTOR_TYPE_UNDEFINED && m_testParams.additionalDescriptorBinding != BINDING_Undefined)
620 builder.addType(m_testParams.additionalDescriptorType, 1);
623 return builder.build(m_vki, m_vkd, (VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT | pcf), 1u);
626 Move<VkDescriptorSet> CommonDescriptorInstance::createDescriptorSet (VkDescriptorPool dsPool,
627 VkDescriptorSetLayout dsLayout) const
629 const VkDescriptorSetAllocateInfo dsAllocInfo =
631 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // sType;
633 dsPool, // descriptorPool;
634 1u, // descriptorSetCount
635 &dsLayout // pSetLayouts
638 return vk::allocateDescriptorSet(m_vki, m_vkd, &dsAllocInfo);
641 void CommonDescriptorInstance::createVertexAttributeBuffer (ut::BufferHandleAllocSp& buffer,
642 deUint32 availableDescriptorCount) const
647 const deUint32 invocationCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
648 const std::vector<Vec4> vertices = ut::createVertices(m_testParams.frameResolution.width, m_testParams.frameResolution.height, xSize, ySize);
649 const std::vector<deUint32> primes = ut::generatePrimes(availableDescriptorCount);
650 const deUint32 primeCount = static_cast<deUint32>(primes.size());
652 std::vector<attributes> data(vertices.size());
653 std::transform(vertices.begin(), vertices.end(), data.begin(), attributes());
655 for (deUint32 invIdx = 0; invIdx < invocationCount; ++invIdx)
657 // r: 2,3,5,7,11,13,2,3,5,7,...
658 data[invIdx].index.x() = primes[invIdx % primeCount];
660 // b: x index in texel coordinate
661 data[invIdx].index.z() = invIdx % m_testParams.frameResolution.width;
663 //a: y index in texel coordinate
664 data[invIdx].index.w() = invIdx / m_testParams.frameResolution.width;
667 // g: 0,0,2,3,0,5,0,7,0,0,0,11,0,13,...
668 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
670 const deUint32 prime = primes[primeIdx];
671 DE_ASSERT(prime < invocationCount);
672 data[prime].index.y() = prime;
675 const VkDeviceSize dataSize = data.size() * sizeof(attributes);
677 VkDeviceSize deviceSize = ut::createBufferAndBind(buffer, m_context, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, dataSize);
679 deMemcpy(buffer->alloc->getHostPtr(), data.data(), static_cast<size_t>(deviceSize));
681 vk::flushAlloc(m_vki, m_vkd, *buffer->alloc);
684 std::string CommonDescriptorInstance::substBinding (deUint32 binding,
689 std::map<std::string, std::string> vars;
690 vars["?"] = de::toString(binding);
691 vars["*"] = (0 == count) ? "" : de::toString(count);
692 vars["VAR"] = (DE_NULL == name) ? "data" : name;
693 return tcu::StringTemplate(str).specialize(vars);
696 const char* CommonDescriptorInstance::getVertexShaderProlog (void)
699 "layout(location = 0) in vec4 in_position; \n"
700 "layout(location = 1) in vec2 in_normalpos; \n"
701 "layout(location = 2) in ivec4 index; \n"
702 "layout(location = 0) out vec4 position; \n"
703 "layout(location = 1) out vec2 normalpos; \n"
704 "layout(location = 2) out int vIndex; \n"
705 "layout(location = 3) out int rIndex; \n"
706 "layout(location = 4) out int gIndex; \n"
707 "layout(location = 5) out int bIndex; \n"
708 "layout(location = 6) out int aIndex; \n"
711 " gl_PointSize = 0.2f; \n"
712 " position = in_position; \n"
713 " normalpos = in_normalpos; \n"
714 " gl_Position = position; \n"
715 " vIndex = gl_VertexIndex; \n"
716 " rIndex = index.x; \n"
717 " gIndex = index.y; \n"
718 " bIndex = index.z; \n"
719 " aIndex = index.w; \n";
722 const char* CommonDescriptorInstance::getFragmentShaderProlog (void)
725 "layout(location = 0) out vec4 FragColor; \n"
726 "layout(location = 0) in flat vec4 position; \n"
727 "layout(location = 1) in flat vec2 normalpos; \n"
728 "layout(location = 2) in flat int vIndex; \n"
729 "layout(location = 3) in flat int rIndex; \n"
730 "layout(location = 4) in flat int gIndex; \n"
731 "layout(location = 5) in flat int bIndex; \n"
732 "layout(location = 6) in flat int aIndex; \n"
737 const char* CommonDescriptorInstance::getShaderEpilog (void)
742 int CommonDescriptorInstance::constructShaderModules (void)
745 tcu::TestLog& log = m_context.getTestContext().getLog();
747 if (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
750 const std::string name = ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testParams.descriptorType, m_testParams.updateAfterBind, m_testParams.calculateInLoop, m_testParams.minNonUniform, false);
751 m_computeModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
753 if (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT)
756 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);
757 m_fragmentModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
758 log << tcu::TestLog::Message << "Finally used fragment shader: " << name << '\n' << tcu::TestLog::EndMessage;
760 if (m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT)
763 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);
764 m_vertexModule = vk::createShaderModule(m_vki, m_vkd, m_context.getBinaryCollection().get(name), (VkShaderModuleCreateFlags)0);
765 log << tcu::TestLog::Message << "Finally used vertex shader: " << name << '\n' << tcu::TestLog::EndMessage;
768 DE_ASSERT(result > 0);
773 Move<VkRenderPass> CommonDescriptorInstance::createRenderPass (const IterateCommonVariables& variables)
776 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
778 // Use VK_ATTACHMENT_LOAD_OP_LOAD to make the utility function select initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
779 return vk::makeRenderPass(m_vki, m_vkd, m_colorFormat, VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD);
781 return Move<VkRenderPass>();
784 VkPushConstantRange CommonDescriptorInstance::makePushConstantRange (void) const
786 const VkPushConstantRange pcr =
788 m_testParams.stageFlags, // stageFlags
790 static_cast<deUint32>(sizeof(push_constant)) // size
795 Move<VkPipelineLayout> CommonDescriptorInstance::createPipelineLayout (const std::vector<VkDescriptorSetLayout>& descriptorSetLayouts) const
797 const VkPushConstantRange pcr = makePushConstantRange();
799 const VkPipelineLayoutCreateInfo createInfo =
801 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType
803 (VkPipelineLayoutCreateFlags)0, // flags
804 static_cast<deUint32>(descriptorSetLayouts.size()), // setLayoutCount
805 descriptorSetLayouts.data(), // pSetLayouts;
806 m_testParams.calculateInLoop ? 1u : 0u, // pushConstantRangeCount
807 m_testParams.calculateInLoop ? &pcr : DE_NULL, // pPushConstantRanges
810 return vk::createPipelineLayout(m_vki, m_vkd, &createInfo);
813 void CommonDescriptorInstance::createFramebuffer (ut::FrameBufferSp& frameBuffer,
814 VkRenderPass renderPass,
815 const IterateCommonVariables& variables)
818 ut::createFrameBuffer(frameBuffer, m_context, m_testParams.frameResolution, m_colorFormat, renderPass);
821 Move<VkPipeline> CommonDescriptorInstance::createPipeline (VkPipelineLayout pipelineLayout,
822 VkRenderPass renderPass)
823 { DE_ASSERT(VK_SHADER_STAGE_ALL != m_testParams.stageFlags);
825 constructShaderModules();
827 return (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
828 ? createComputePipeline(pipelineLayout)
829 : createGraphicsPipeline(pipelineLayout, renderPass);
832 Move<VkPipeline> CommonDescriptorInstance::createComputePipeline (VkPipelineLayout pipelineLayout)
834 const VkPipelineShaderStageCreateInfo shaderStaegCreateInfo =
836 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
838 (VkPipelineShaderStageCreateFlags)0, // flags
839 VK_SHADER_STAGE_COMPUTE_BIT, // stage
840 *m_computeModule, // module
842 (VkSpecializationInfo*)DE_NULL // pSpecializationInfo
845 const VkComputePipelineCreateInfo pipelineCreateInfo =
847 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
850 shaderStaegCreateInfo, // stage
851 pipelineLayout, // layout
852 (VkPipeline)0, // basePipelineHandle
853 0u, // basePipelineIndex
855 return vk::createComputePipeline(m_vki, m_vkd, (VkPipelineCache)0u, &pipelineCreateInfo);
858 Move<VkPipeline> CommonDescriptorInstance::createGraphicsPipeline (VkPipelineLayout pipelineLayout,
859 VkRenderPass renderPass)
861 const VkVertexInputBindingDescription bindingDescriptions[] =
865 sizeof(attributes), // stride
866 VK_VERTEX_INPUT_RATE_VERTEX, // inputRate
870 const VkVertexInputAttributeDescription attributeDescriptions[] =
875 ut::mapType2vkFormat<attributes::vec4>::value, // format
881 ut::mapType2vkFormat<attributes::vec2>::value, // format
882 static_cast<deUint32>(sizeof(attributes::vec4)) // offset
887 ut::mapType2vkFormat<attributes::ivec4>::value, // format
888 static_cast<deUint32>(sizeof(attributes::vec2)
889 + sizeof(attributes::vec4)) // offset
893 const VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo =
895 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
897 (VkPipelineVertexInputStateCreateFlags)0, // flags
898 DE_LENGTH_OF_ARRAY(bindingDescriptions), // vertexBindingDescriptionCount
899 bindingDescriptions, // pVertexBindingDescriptions
900 DE_LENGTH_OF_ARRAY(attributeDescriptions), // vertexAttributeDescriptionCount
901 attributeDescriptions // pVertexAttributeDescriptions
904 const VkDynamicState dynamicStates[] =
906 VK_DYNAMIC_STATE_SCISSOR
909 const VkPipelineDynamicStateCreateInfo dynamicStateCreateInfo =
911 VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // sType
914 DE_LENGTH_OF_ARRAY(dynamicStates), // dynamicStateCount
915 dynamicStates // pDynamicStates
918 const std::vector<VkViewport> viewports (1, makeViewport(m_testParams.frameResolution.width, m_testParams.frameResolution.height));
919 const std::vector<VkRect2D> scissors (1, makeRect2D(0u, 0u));
921 DE_ASSERT(m_vertexModule && m_fragmentModule);
923 return vk::makeGraphicsPipeline(
926 pipelineLayout, // pipelineLayout
927 *m_vertexModule, // vertexShaderModule
928 DE_NULL, // tessellationControlModule
929 DE_NULL, // tessellationEvalModule
930 DE_NULL, // geometryShaderModule
931 *m_fragmentModule, // fragmentShaderModule
932 renderPass, // renderPass
933 viewports, // viewports
934 scissors, // scissors
935 VK_PRIMITIVE_TOPOLOGY_POINT_LIST, // topology
937 0U, // patchControlPoints
938 &vertexInputStateCreateInfo, // vertexInputStateCreateInfo
939 nullptr, // rasterizationStateCreateInfo
940 nullptr, // multisampleStateCreateInfo
941 nullptr, // depthStencilStateCreateInfo
942 nullptr, // colorBlendStateCreateInfo
943 &dynamicStateCreateInfo); // dynamicStateCreateInfo
946 VkDeviceSize CommonDescriptorInstance::createBuffers (std::vector<VkDescriptorBufferInfo>& bufferInfos,
947 ut::BufferHandleAllocSp& buffer,
948 deUint32 elementCount,
949 deUint32 elementSize,
950 VkDeviceSize alignment,
951 VkBufferUsageFlags bufferUsage)
953 const VkDeviceSize roundedSize = deAlign64(elementSize, alignment);
954 VkDeviceSize bufferSize = ut::createBufferAndBind(buffer, m_context, bufferUsage, (roundedSize * elementCount));
956 for (deUint32 elementIdx = 0; elementIdx < elementCount; ++elementIdx)
958 const VkDescriptorBufferInfo bufferInfo =
960 *buffer.get()->buffer, //buffer;
961 elementIdx * roundedSize, //offset;
962 elementSize, // range;
965 bufferInfos.push_back(bufferInfo);
971 VkDeviceSize CommonDescriptorInstance::createImages (std::vector<ut::ImageHandleAllocSp>& images,
972 std::vector<VkDescriptorBufferInfo>& bufferInfos,
973 ut::BufferHandleAllocSp& buffer,
974 VkBufferUsageFlags bufferUsage,
975 const VkExtent3D& imageExtent,
976 VkFormat imageFormat,
977 VkImageLayout imageLayout,
982 const deUint32 imageSize = ut::computeImageSize(imageExtent, imageFormat, withMipMaps);
984 const VkDeviceSize bufferSize = createBuffers(bufferInfos, buffer, imageCount, imageSize, sizeof(tcu::Vec4), bufferUsage);
986 for (deUint32 imageIdx = 0; imageIdx < imageCount; ++imageIdx)
988 ut::ImageHandleAllocSp image;
989 ut::createImageAndBind(image, m_context, imageFormat, imageExtent, imageLayout, withMipMaps);
990 images.push_back(image);
996 void CommonDescriptorInstance::createBuffersViews (std::vector<ut::BufferViewSp>& views,
997 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
1000 const deUint32 infoCount = static_cast<deUint32>(bufferInfos.size());
1001 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1003 const VkDescriptorBufferInfo& bufferInfo = bufferInfos[infoIdx];
1004 const VkBufferViewCreateInfo bufferViewInfo =
1006 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // sType
1008 (VkBufferViewCreateFlags)0, // flags
1009 bufferInfo.buffer, // buffer
1011 bufferInfo.offset, // offset
1012 bufferInfo.range // range;
1014 views.push_back(ut::BufferViewSp(new Move<VkBufferView>(vk::createBufferView(m_vki, m_vkd, &bufferViewInfo))));
1018 void CommonDescriptorInstance::createImagesViews (std::vector<ut::ImageViewSp>& views,
1019 const std::vector<ut::ImageHandleAllocSp>& images,
1022 const deUint32 imageCount = static_cast<deUint32>(images.size());
1023 for (deUint32 imageIdx = 0; imageIdx < imageCount; ++imageIdx)
1025 const VkImageViewCreateInfo createInfo =
1027 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
1029 (VkImageViewCreateFlags)0, // flags
1030 *images[imageIdx]->image, // image
1031 VK_IMAGE_VIEW_TYPE_2D, // viewType
1033 vk::makeComponentMappingRGBA(), // components
1035 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
1036 (deUint32)0, // baseMipLevel
1037 images[imageIdx]->levels, // mipLevels
1038 (deUint32)0, // baseArrayLayer
1039 (deUint32)1u, // arraySize
1042 views.push_back(ut::ImageViewSp(new Move<VkImageView>(vk::createImageView(m_vki, m_vkd, &createInfo))));
1046 void CommonDescriptorInstance::copyBuffersToImages (IterateCommonVariables& variables)
1048 const deUint32 infoCount = static_cast<deUint32>(variables.descriptorsBufferInfos.size());
1049 DE_ASSERT(variables.descriptorsImages.size() == infoCount);
1050 const VkPipelineStageFlagBits dstStageMask = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
1051 ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
1052 : VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
1053 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1055 ut::recordCopyBufferToImage(
1056 *variables.commandBuffer, // commandBuffer
1058 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // srcStageMask
1059 dstStageMask, // dstStageMask
1060 variables.descriptorsBufferInfos[infoIdx], // bufferInfo
1061 *(variables.descriptorsImages[infoIdx]->image), // image
1062 variables.descriptorsImages[infoIdx]->extent, // imageExtent
1063 variables.descriptorsImages[infoIdx]->format, // imageFormat
1064 VK_IMAGE_LAYOUT_UNDEFINED, // oldImageLayout
1065 VK_IMAGE_LAYOUT_GENERAL, // newImageLayout
1066 variables.descriptorsImages[infoIdx]->levels); // mipLevelCount
1070 void CommonDescriptorInstance::copyImagesToBuffers (IterateCommonVariables& variables)
1072 const deUint32 infoCount = static_cast<deUint32>(variables.descriptorsBufferInfos.size());
1073 DE_ASSERT(variables.descriptorsImages.size() == infoCount);
1074 const VkPipelineStageFlagBits srcStageMask = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT)
1075 ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
1076 : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
1078 for (deUint32 infoIdx = 0; infoIdx < infoCount; ++infoIdx)
1080 ut::recordCopyImageToBuffer(
1081 *variables.commandBuffer, // commandBuffer
1083 srcStageMask, // srcStageMask
1084 VK_PIPELINE_STAGE_HOST_BIT, // dstStageMask
1085 *(variables.descriptorsImages[infoIdx]->image), // image
1086 variables.descriptorsImages[infoIdx]->extent, // imageExtent
1087 variables.descriptorsImages[infoIdx]->format, // imageFormat
1088 VK_IMAGE_LAYOUT_GENERAL, // oldImageLayout
1089 VK_IMAGE_LAYOUT_GENERAL, // newImageLayout
1090 variables.descriptorsBufferInfos[infoIdx]); // bufferInfo
1094 PixelBufferAccess CommonDescriptorInstance::getPixelAccess (deUint32 imageIndex,
1095 const VkExtent3D& imageExtent,
1096 VkFormat imageFormat,
1097 const std::vector<VkDescriptorBufferInfo>& bufferInfos,
1098 const ut::BufferHandleAllocSp& buffer,
1099 deUint32 mipLevel) const
1101 DE_ASSERT(bufferInfos[imageIndex].buffer == *buffer.get()->buffer);
1102 DE_ASSERT(ut::computeImageSize(imageExtent, imageFormat, true, (mipLevel ? ut::maxDeUint32 : 0)) <= bufferInfos[imageIndex].range);
1103 DE_ASSERT(imageExtent.width >> mipLevel);
1104 DE_ASSERT(imageExtent.height >> mipLevel);
1106 deUint32 mipOffset = 0;
1108 for (deUint32 level = 0; mipLevel && level < mipLevel; ++level)
1110 mipOffset += ut::computeImageSize(imageExtent, imageFormat, true, level);
1113 unsigned char* hostPtr = static_cast<unsigned char*>(buffer->alloc->getHostPtr());
1114 unsigned char* data = hostPtr + bufferInfos[imageIndex].offset + mipOffset;
1115 return tcu::PixelBufferAccess(vk::mapVkFormat(imageFormat), (imageExtent.width >> mipLevel), (imageExtent.height >> mipLevel), imageExtent.depth, data);
1118 void CommonDescriptorInstance::updateDescriptors (IterateCommonVariables& variables)
1120 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
1121 const deUint32 primeCount = static_cast<deUint32>(primes.size());
1123 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
1125 const VkDescriptorBufferInfo* pBufferInfo = DE_NULL;
1126 const VkDescriptorImageInfo* pImageInfo = DE_NULL;
1127 const VkBufferView* pTexelBufferView = DE_NULL;
1129 VkDescriptorImageInfo imageInfo =
1131 static_cast<VkSampler>(0),
1132 static_cast<VkImageView>(0),
1133 VK_IMAGE_LAYOUT_GENERAL
1136 switch (m_testParams.descriptorType)
1138 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1139 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1140 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1141 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
1142 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1143 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1145 pBufferInfo = &variables.descriptorsBufferInfos[primeIdx];
1146 switch (m_testParams.descriptorType)
1148 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1149 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1150 pTexelBufferView = &(**variables.descriptorsBufferViews[primeIdx]);
1158 case VK_DESCRIPTOR_TYPE_SAMPLER:
1159 imageInfo.sampler = **variables.descriptorSamplers[primeIdx];
1160 pImageInfo = &imageInfo;
1163 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
1164 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
1165 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
1166 imageInfo.imageView = **variables.descriptorImageViews[primeIdx];
1167 pImageInfo = &imageInfo;
1173 const VkWriteDescriptorSet writeInfo =
1175 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
1177 *variables.descriptorSet, // descriptorSet
1178 m_testParams.descriptorBinding, // descriptorBinding;
1179 primes[primeIdx], // elementIndex
1180 1u, // descriptorCount
1181 m_testParams.descriptorType, // descriptorType
1182 pImageInfo, // pImageInfo
1183 pBufferInfo, // pBufferInfo
1184 pTexelBufferView // pTexelBufferView
1187 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
1191 void CommonDescriptorInstance::iterateCommandSetup (IterateCommonVariables& variables)
1193 variables.dataAlignment = 0;
1195 variables.renderArea.offset.x = 0;
1196 variables.renderArea.offset.y = 0;
1197 variables.renderArea.extent.width = m_testParams.frameResolution.width;
1198 variables.renderArea.extent.height = m_testParams.frameResolution.height;
1200 variables.vertexCount = m_testParams.frameResolution.width * m_testParams.frameResolution.height;
1202 variables.lowerBound = 0;
1203 variables.upperBound = variables.vertexCount;
1205 variables.descriptorSetLayout = createDescriptorSetLayout(m_testParams.calculateInLoop, variables.availableDescriptorCount);
1206 variables.validDescriptorCount = ut::computePrimeCount(variables.availableDescriptorCount);
1207 variables.descriptorPool = createDescriptorPool(variables.availableDescriptorCount);
1208 variables.descriptorSet = createDescriptorSet(*variables.descriptorPool, *variables.descriptorSetLayout);
1210 std::vector<VkDescriptorSetLayout> descriptorSetLayouts;
1211 descriptorSetLayouts.push_back(*variables.descriptorSetLayout);
1212 if (m_testParams.calculateInLoop)
1214 variables.descriptorEnumerator.init(m_context, variables.vertexCount, variables.availableDescriptorCount);
1215 descriptorSetLayouts.push_back(*variables.descriptorEnumerator.descriptorSetLayout);
1218 variables.pipelineLayout = createPipelineLayout(descriptorSetLayouts);
1220 createAndPopulateDescriptors (variables);
1222 variables.renderPass = createRenderPass(variables);
1223 variables.pipeline = createPipeline(*variables.pipelineLayout, *variables.renderPass);
1225 variables.commandBuffer = createCmdBuffer();
1227 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1229 createVertexAttributeBuffer (variables.vertexAttributesBuffer, variables.availableDescriptorCount);
1230 createFramebuffer (variables.frameBuffer, *variables.renderPass, variables);
1233 if (m_testParams.calculateInLoop)
1235 variables.descriptorEnumerator.update(m_context);
1238 if (!m_testParams.updateAfterBind)
1240 updateDescriptors (variables);
1245 void CommonDescriptorInstance::iterateCommandBegin (IterateCommonVariables& variables, bool firstPass)
1247 vk::beginCommandBuffer (m_vki, *variables.commandBuffer);
1249 // Clear color attachment, and transition it to VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
1250 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1254 const VkImageMemoryBarrier preImageBarrier =
1256 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType
1257 DE_NULL, // const void* pNext
1258 0u, // VkAccessFlags srcAccessMask
1259 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1260 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout
1261 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout
1262 VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
1263 VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
1264 *variables.frameBuffer->image->image, // VkImage image
1266 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask
1267 0u, // uint32_t baseMipLevel
1268 VK_REMAINING_MIP_LEVELS, // uint32_t mipLevels,
1269 0u, // uint32_t baseArray
1270 VK_REMAINING_ARRAY_LAYERS, // uint32_t arraySize
1274 m_vki.cmdPipelineBarrier(*variables.commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
1275 (VkDependencyFlags)0,
1276 0, (const VkMemoryBarrier*)DE_NULL,
1277 0, (const VkBufferMemoryBarrier*)DE_NULL,
1278 1, &preImageBarrier);
1280 const VkClearColorValue clearColorValue = makeClearValueColor(m_clearColor).color;
1282 m_vki.cmdClearColorImage(*variables.commandBuffer, *variables.frameBuffer->image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColorValue, 1, &preImageBarrier.subresourceRange);
1284 const VkImageMemoryBarrier postImageBarrier =
1286 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType
1287 DE_NULL, // const void* pNext
1288 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1289 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask
1290 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout
1291 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout
1292 VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
1293 VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
1294 *variables.frameBuffer->image->image, // VkImage image
1296 VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask
1297 0u, // uint32_t baseMipLevel
1298 VK_REMAINING_MIP_LEVELS, // uint32_t mipLevels,
1299 0u, // uint32_t baseArray
1300 VK_REMAINING_ARRAY_LAYERS, // uint32_t arraySize
1304 m_vki.cmdPipelineBarrier(*variables.commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
1305 (VkDependencyFlags)0,
1306 0, (const VkMemoryBarrier*)DE_NULL,
1307 0, (const VkBufferMemoryBarrier*)DE_NULL,
1308 1, &postImageBarrier);
1313 if (m_testParams.calculateInLoop)
1316 deRandom_init(&rnd, static_cast<deUint32>(m_testParams.descriptorType));
1317 const deUint32 quarter = variables.vertexCount / 4;
1319 variables.lowerBound = deRandom_getUint32(&rnd) % quarter;
1320 variables.upperBound = (deRandom_getUint32(&rnd) % quarter) + (3 * quarter);
1322 const push_constant pc =
1324 static_cast<deInt32>(variables.lowerBound),
1325 static_cast<deInt32>(variables.upperBound)
1328 m_vki.cmdPushConstants(*variables.commandBuffer, *variables.pipelineLayout, m_testParams.stageFlags, 0u, static_cast<deUint32>(sizeof(pc)), &pc);
1331 if ((m_testParams.stageFlags & VK_SHADER_STAGE_VERTEX_BIT) || (m_testParams.stageFlags & VK_SHADER_STAGE_FRAGMENT_BIT))
1333 commandBindVertexAttributes (*variables.commandBuffer, variables.vertexAttributesBuffer);
1336 if (m_testParams.calculateInLoop)
1338 commandBindDescriptorSets(*variables.commandBuffer, *variables.pipelineLayout, *variables.descriptorEnumerator.descriptorSet, 1);
1341 if (!ut::isDynamicDescriptor(m_testParams.descriptorType))
1343 commandBindDescriptorSets (*variables.commandBuffer, *variables.pipelineLayout, *variables.descriptorSet, 0);
1346 commandBindPipeline (*variables.commandBuffer, *variables.pipeline);
1349 tcu::TestStatus CommonDescriptorInstance::iterate (void)
1351 IterateCommonVariables v;
1352 ut::UpdatablePixelBufferAccessPtr programResult;
1353 ut::UpdatablePixelBufferAccessPtr referenceResult;
1355 bool firstPass = true;
1357 iterateCommandSetup (v);
1359 v.renderArea.extent.width = m_testParams.frameResolution.width/4;
1360 v.renderArea.extent.height = m_testParams.frameResolution.height/4;
1362 for (int x = 0; x < 4; x++)
1363 for (int y= 0; y < 4; y++)
1365 iterateCommandBegin (v, firstPass);
1367 if (true == firstPass && true == m_testParams.copyBuffersToImages)
1369 copyBuffersToImages (v);
1374 if (true == m_testParams.updateAfterBind)
1376 updateDescriptors (v);
1379 v.renderArea.offset.x = x * m_testParams.frameResolution.width/4;
1380 v.renderArea.offset.y = y * m_testParams.frameResolution.height/4;
1382 vk::VkRect2D scissor = makeRect2D(v.renderArea.offset.x, v.renderArea.offset.y, v.renderArea.extent.width, v.renderArea.extent.height);
1383 m_vki.cmdSetScissor(*v.commandBuffer, 0u, 1u, &scissor);
1385 vk::beginRenderPass (m_vki, *v.commandBuffer, *v.renderPass, *v.frameBuffer->buffer, v.renderArea, m_clearColor);
1386 m_vki.cmdDraw (*v.commandBuffer, v.vertexCount, 1u, 0u, 0u);
1387 vk::endRenderPass (m_vki, *v.commandBuffer);
1389 iterateCommandEnd(v, programResult, referenceResult);
1390 programResult->invalidate();
1393 return ( iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
1396 std::vector<float> CommonDescriptorInstance::createColorScheme (void)
1398 std::vector<float> cs;
1400 for (int i = 0; i < 10; ++i)
1402 cs.push_back(1.0f / float(divider));
1408 void CommonDescriptorInstance::iterateCommandEnd (IterateCommonVariables& variables,
1409 ut::UpdatablePixelBufferAccessPtr& programResult,
1410 ut::UpdatablePixelBufferAccessPtr& referenceResult,
1411 bool collectBeforeSubmit)
1413 if (collectBeforeSubmit)
1415 iterateCollectResults(programResult, variables, true);
1416 iterateCollectResults(referenceResult, variables, false);
1419 VK_CHECK(m_vki.endCommandBuffer(*variables.commandBuffer));
1420 Move<VkFence> fence = commandSubmit(*variables.commandBuffer);
1421 m_vki.waitForFences(m_vkd, 1, &(*fence), DE_TRUE, ~0ull);
1423 if (false == collectBeforeSubmit)
1425 iterateCollectResults(programResult, variables, true);
1426 iterateCollectResults(referenceResult, variables, false);
1430 bool CommonDescriptorInstance::iterateVerifyResults (IterateCommonVariables& variables,
1431 ut::UpdatablePixelBufferAccessPtr programResult,
1432 ut::UpdatablePixelBufferAccessPtr referenceResult)
1434 bool result = false;
1435 if (m_testParams.fuzzyComparison)
1437 result = tcu::fuzzyCompare(m_context.getTestContext().getLog(),
1438 "Fuzzy Compare", "Comparison result", *referenceResult.get(), *programResult.get(), 0.02f, tcu::COMPARE_LOG_EVERYTHING);
1442 result = tcu::floatThresholdCompare(m_context.getTestContext().getLog(),
1443 "Float Threshold Compare", "Comparison result", *referenceResult.get(), *programResult.get(), tcu::Vec4(0.02f, 0.02f, 0.02f, 0.02f), tcu::COMPARE_LOG_EVERYTHING);
1446 if (m_testParams.allowVertexStoring)
1448 result = verifyVertexWriteResults(variables);
1454 void CommonDescriptorInstance::iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
1455 const IterateCommonVariables& variables,
1460 result = commandReadFrameBuffer(*variables.commandBuffer, variables.frameBuffer);
1464 result = ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessAllocation(vk::mapVkFormat(m_colorFormat), m_testParams.frameResolution));
1466 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
1468 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
1470 const float component = m_colorScheme[(pixelNum % variables.validDescriptorCount) % m_schemeSize];
1471 result->setPixel(tcu::Vec4(component, component, component, 1.0f), x, y);
1477 Move<VkCommandBuffer> CommonDescriptorInstance::createCmdBuffer (void)
1479 return vk::allocateCommandBuffer(m_vki, m_vkd, *m_commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
1482 Move<VkFence> CommonDescriptorInstance::commandSubmit (VkCommandBuffer cmd)
1484 Move<VkFence> fence(vk::createFence(m_vki, m_vkd));
1486 const VkSubmitInfo submitInfo =
1488 VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
1490 0u, // waitSemaphoreCount
1491 static_cast<VkSemaphore*>(DE_NULL), // pWaitSemaphores
1492 static_cast<const VkPipelineStageFlags*>(DE_NULL), // pWaitDstStageMask
1493 1u, // commandBufferCount
1494 &cmd, // pCommandBuffers
1495 0u, // signalSemaphoreCount
1496 static_cast<VkSemaphore*>(DE_NULL) // pSignalSemaphores
1499 VK_CHECK(m_vki.queueSubmit(m_queue, 1u, &submitInfo, *fence));
1504 bool CommonDescriptorInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
1506 DE_UNREF(variables);
1510 void CommonDescriptorInstance::commandBindPipeline (VkCommandBuffer commandBuffer,
1511 VkPipeline pipeline)
1513 const VkPipelineBindPoint pipelineBindingPoint = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS;
1514 m_vki.cmdBindPipeline(commandBuffer, pipelineBindingPoint, pipeline);
1517 void CommonDescriptorInstance::commandBindVertexAttributes (VkCommandBuffer commandBuffer,
1518 const ut::BufferHandleAllocSp& vertexAttributesBuffer)
1520 const VkDeviceSize offsets[] = { 0u };
1521 const VkBuffer buffers[] = { *vertexAttributesBuffer->buffer };
1522 m_vki.cmdBindVertexBuffers(commandBuffer, 0u, 1u, buffers, offsets);
1525 void CommonDescriptorInstance::commandBindDescriptorSets (VkCommandBuffer commandBuffer,
1526 VkPipelineLayout pipelineLayout,
1527 VkDescriptorSet descriptorSet,
1528 deUint32 descriptorSetIndex)
1530 const VkPipelineBindPoint pipelineBindingPoint = (m_testParams.stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS;
1531 m_vki.cmdBindDescriptorSets(commandBuffer, pipelineBindingPoint, pipelineLayout, descriptorSetIndex, 1u, &descriptorSet, 0u, static_cast<deUint32*>(DE_NULL));
1534 ut::UpdatablePixelBufferAccessPtr
1535 CommonDescriptorInstance::commandReadFrameBuffer (VkCommandBuffer commandBuffer,
1536 const ut::FrameBufferSp& frameBuffer)
1538 ut::BufferHandleAllocSp frameBufferContent;
1539 commandReadFrameBuffer(frameBufferContent, commandBuffer, frameBuffer);
1540 return ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessBuffer(
1541 m_vkd, m_vki, vk::mapVkFormat(m_colorFormat), m_testParams.frameResolution,
1542 de::SharedPtr< Move<VkBuffer> >(new Move<VkBuffer>(frameBufferContent->buffer)),
1543 de::SharedPtr< de::MovePtr<Allocation> >(new de::MovePtr<Allocation>(frameBufferContent->alloc))));
1546 void CommonDescriptorInstance::commandReadFrameBuffer (ut::BufferHandleAllocSp& content,
1547 VkCommandBuffer commandBuffer,
1548 const ut::FrameBufferSp& frameBuffer)
1550 Move<VkBuffer> buffer;
1551 de::MovePtr<Allocation> allocation;
1553 const VkDeviceSize bufferSize = ut::computeImageSize(frameBuffer->image);
1555 // create a buffer and an host allocation for it
1557 const VkBufferCreateInfo bufferCreateInfo =
1559 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType
1563 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // usage
1564 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
1565 1u, // queueFamilyIndexCoun
1566 &m_queueFamilyIndex // pQueueFamilyIndices
1569 buffer = vk::createBuffer(m_vki, m_vkd, &bufferCreateInfo);
1570 const VkMemoryRequirements memRequirements(vk::getBufferMemoryRequirements(m_vki, m_vkd, *buffer));
1571 allocation = m_allocator.allocate(memRequirements, MemoryRequirement::HostVisible);
1573 VK_CHECK(m_vki.bindBufferMemory(m_vkd, *buffer, allocation->getMemory(), allocation->getOffset()));
1576 const VkImage& image = *frameBuffer->image->image;
1578 VkImageSubresourceRange subresourceRange =
1580 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask
1583 0u, // baseArrayLayer
1587 const VkImageMemoryBarrier barrierBefore =
1589 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
1591 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask;
1592 VK_ACCESS_TRANSFER_READ_BIT, // dstAccessMask;
1593 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // oldLayout
1594 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout;
1595 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1596 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1598 subresourceRange // subresourceRange;
1601 const VkBufferImageCopy copyRegion =
1604 frameBuffer->image->extent.width, // bufferRowLength
1605 frameBuffer->image->extent.height, // bufferImageHeight
1606 { // VkImageSubresourceLayers
1607 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
1609 0u, // baseArrayLayer
1612 { 0, 0, 0 }, // imageOffset
1613 frameBuffer->image->extent // imageExtent
1616 const VkBufferMemoryBarrier bufferBarrier =
1618 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType;
1620 VK_ACCESS_TRANSFER_WRITE_BIT, // srcAccessMask;
1621 VK_ACCESS_HOST_READ_BIT, // dstAccessMask;
1622 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1623 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1629 const VkImageMemoryBarrier barrierAfter =
1631 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
1633 VK_ACCESS_TRANSFER_READ_BIT, // srcAccessMask;
1634 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // dstAccessMask;
1635 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // oldLayout;
1636 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // newLayout;
1637 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
1638 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex;
1640 subresourceRange // subresourceRange
1644 m_vki.cmdPipelineBarrier(commandBuffer, // commandBuffer
1645 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, // srcStageMask, dstStageMask
1646 (VkDependencyFlags)0, // dependencyFlags
1647 0u, DE_NULL, // memoryBarrierCount, pMemoryBarriers
1648 0u, DE_NULL, // bufferBarrierCount, pBufferBarriers
1649 1u, &barrierBefore); // imageBarrierCount, pImageBarriers
1651 m_vki.cmdCopyImageToBuffer(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, ©Region);
1653 m_vki.cmdPipelineBarrier(commandBuffer,
1654 VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
1655 (VkDependencyFlags)0,
1660 content = ut::BufferHandleAllocSp(new ut::BufferHandleAlloc(buffer, allocation));
1663 std::string CommonDescriptorInstance::getColorAccess (VkDescriptorType descriptorType,
1664 const char* indexVariableName,
1668 std::map<std::string, std::string> vars;
1669 vars["INDEX"] = indexVariableName;
1671 switch (descriptorType)
1673 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1674 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
1675 text = "data[nonuniformEXT(${INDEX})].c";
1677 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1678 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1679 text = "data[nonuniformEXT(${INDEX})].cold";
1681 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
1682 text = "subpassLoad(data[nonuniformEXT(${INDEX})]).rgba";
1684 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1685 text = "texelFetch(data[nonuniformEXT(${INDEX})], 0)";
1687 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1688 text = "imageLoad(data[nonuniformEXT(${INDEX})], 0)";
1690 case VK_DESCRIPTOR_TYPE_SAMPLER:
1692 ? "textureLod(nonuniformEXT(sampler2D(tex[0], data[${INDEX}])), normalpos, 1)"
1693 : "texture( nonuniformEXT(sampler2D(tex[0], data[${INDEX}])), normalpos )";
1695 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
1697 ? "textureLod( nonuniformEXT(sampler2D(data[${INDEX}], samp[0])), vec2(0,0), textureQueryLevels(nonuniformEXT(sampler2D(data[${INDEX}], samp[0])))-1)"
1698 : "texture( nonuniformEXT(sampler2D(data[${INDEX}], samp[0])), vec2(0,0) )";
1700 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
1702 ? "textureLod( data[nonuniformEXT(${INDEX})], uvec2(0,0), textureQueryLevels(data[nonuniformEXT(${INDEX})])-1)"
1703 : "texture( data[nonuniformEXT(${INDEX})], uvec2(0,0) )";
1706 TCU_THROW(InternalError, "Not implemented descriptor type");
1709 return tcu::StringTemplate(text).specialize(vars);
1712 std::string CommonDescriptorInstance::getFragmentReturnSource (const std::string& colorAccess)
1714 return " FragColor = " + colorAccess + ";\n";
1717 std::string CommonDescriptorInstance::getFragmentLoopSource (const std::string& colorAccess1,
1718 const std::string& colorAccess2)
1720 std::map < std::string, std::string > vars;
1721 vars["COLOR_ACCESS_1"] = colorAccess1;
1722 vars["COLOR_ACCESS_2"] = colorAccess2;
1725 " vec4 sumClr1 = vec4(0,0,0,0); \n"
1726 " vec4 sumClr2 = vec4(0,0,0,0); \n"
1727 " for (int i = pc.lowerBound; i < pc.upperBound; ++i) \n"
1729 " int loopIdx = texelFetch(iter, i).x; \n"
1730 " sumClr1 += ${COLOR_ACCESS_2} + ${COLOR_ACCESS_1}; \n"
1731 " sumClr2 += ${COLOR_ACCESS_2}; \n"
1733 " FragColor = vec4(((sumClr1 - sumClr2) / float(pc.upperBound - pc.lowerBound)).rgb, 1); \n";
1735 return tcu::StringTemplate(s).specialize(vars);
1738 bool CommonDescriptorInstance::performWritesInVertex (VkDescriptorType descriptorType)
1740 bool result = false;
1742 switch (descriptorType)
1744 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1745 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
1746 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1757 bool CommonDescriptorInstance::performWritesInVertex (VkDescriptorType descriptorType,
1758 const Context& context)
1760 bool result = false;
1762 ut::DeviceProperties dp (context);
1763 const VkPhysicalDeviceFeatures& feats = dp.physicalDeviceFeatures();
1765 if (feats.vertexPipelineStoresAndAtomics != DE_FALSE)
1767 result = CommonDescriptorInstance::performWritesInVertex(descriptorType);
1773 std::string CommonDescriptorInstance::getShaderAsm (VkShaderStageFlagBits shaderType,
1774 const TestCaseParams& testCaseParams,
1775 bool allowVertexStoring)
1777 std::stringstream s;
1780 case VK_SHADER_STAGE_VERTEX_BIT:
1781 switch (testCaseParams.descriptorType)
1783 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1784 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1785 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
1786 s << " OpCapability Shader\n";
1787 s << " OpCapability SampledBuffer\n";
1788 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
1789 s << " OpMemoryModel Logical GLSL450\n";
1790 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex\n";
1791 s << " OpSource GLSL 450\n";
1792 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
1793 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
1794 s << " OpName %main \"main\"\n";
1795 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
1796 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
1797 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
1798 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
1799 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
1800 s << " OpName %_ \"\"\n";
1801 s << " OpName %position \"position\"\n";
1802 s << " OpName %in_position \"in_position\"\n";
1803 s << " OpName %normalpos \"normalpos\"\n";
1804 s << " OpName %in_normalpos \"in_normalpos\"\n";
1805 s << " OpName %vIndex \"vIndex\"\n";
1806 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
1807 s << " OpName %rIndex \"rIndex\"\n";
1808 s << " OpName %index \"index\"\n";
1809 s << " OpName %gIndex \"gIndex\"\n";
1810 s << " OpName %bIndex \"bIndex\"\n";
1811 s << " OpName %aIndex \"aIndex\"\n";
1812 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
1813 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
1814 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
1815 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
1816 s << " OpDecorate %gl_PerVertex Block\n";
1817 s << " OpDecorate %position Location 0\n";
1818 s << " OpDecorate %in_position Location 0\n";
1819 s << " OpDecorate %normalpos Location 1\n";
1820 s << " OpDecorate %in_normalpos Location 1\n";
1821 s << " OpDecorate %vIndex Location 2\n";
1822 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
1823 s << " OpDecorate %rIndex Location 3\n";
1824 s << " OpDecorate %index Location 2\n";
1825 s << " OpDecorate %gIndex Location 4\n";
1826 s << " OpDecorate %bIndex Location 5\n";
1827 s << " OpDecorate %aIndex Location 6\n";
1828 s << " %void = OpTypeVoid\n";
1829 s << " %3 = OpTypeFunction %void\n";
1830 s << " %float = OpTypeFloat 32\n";
1831 s << " %v4float = OpTypeVector %float 4\n";
1832 s << " %uint = OpTypeInt 32 0\n";
1833 s << " %uint_1 = OpConstant %uint 1\n";
1834 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
1835 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
1836 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
1837 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
1838 s << " %int = OpTypeInt 32 1\n";
1839 s << " %int_1 = OpConstant %int 1\n";
1840 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
1841 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
1842 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
1843 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
1844 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
1845 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
1846 s << " %v2float = OpTypeVector %float 2\n";
1847 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
1848 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
1849 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
1850 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
1851 s << " %int_0 = OpConstant %int 0\n";
1852 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
1853 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
1854 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
1855 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
1856 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
1857 s << " %v4int = OpTypeVector %int 4\n";
1858 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
1859 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
1860 s << " %uint_0 = OpConstant %uint 0\n";
1861 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
1862 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
1863 s << " %uint_2 = OpConstant %uint 2\n";
1864 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
1865 s << " %uint_3 = OpConstant %uint 3\n";
1866 s << " %main = OpFunction %void None %3\n";
1867 s << " %5 = OpLabel\n";
1868 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
1869 s << " OpStore %18 %float_0_200000003\n";
1870 s << " %23 = OpLoad %v4float %in_position\n";
1871 s << " OpStore %position %23\n";
1872 s << " %29 = OpLoad %v2float %in_normalpos\n";
1873 s << " OpStore %normalpos %29\n";
1874 s << " %31 = OpLoad %v4float %position\n";
1875 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
1876 s << " OpStore %32 %31\n";
1877 s << " %37 = OpLoad %int %gl_VertexIndex\n";
1878 s << " OpStore %vIndex %37\n";
1879 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
1880 s << " %44 = OpLoad %int %43\n";
1881 s << " OpStore %rIndex %44\n";
1882 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
1883 s << " %47 = OpLoad %int %46\n";
1884 s << " OpStore %gIndex %47\n";
1885 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
1886 s << " %51 = OpLoad %int %50\n";
1887 s << " OpStore %bIndex %51\n";
1888 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
1889 s << " %55 = OpLoad %int %54\n";
1890 s << " OpStore %aIndex %55\n";
1892 s << " OpFunctionEnd\n";
1894 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1895 s << " OpCapability Shader\n";
1896 s << " OpCapability ImageBuffer\n";
1897 if (allowVertexStoring)
1899 s << " OpCapability ShaderNonUniform\n";
1900 s << " OpCapability RuntimeDescriptorArray\n";
1901 s << " OpCapability StorageTexelBufferArrayNonUniformIndexing\n";
1902 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
1904 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
1905 s << " OpMemoryModel Logical GLSL450\n";
1906 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex %data\n";
1907 s << " OpSource GLSL 450\n";
1908 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
1909 s << " OpName %main \"main\"\n";
1910 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
1911 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
1912 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
1913 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
1914 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
1915 s << " OpName %_ \"\"\n";
1916 s << " OpName %position \"position\"\n";
1917 s << " OpName %in_position \"in_position\"\n";
1918 s << " OpName %normalpos \"normalpos\"\n";
1919 s << " OpName %in_normalpos \"in_normalpos\"\n";
1920 s << " OpName %vIndex \"vIndex\"\n";
1921 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
1922 s << " OpName %rIndex \"rIndex\"\n";
1923 s << " OpName %index \"index\"\n";
1924 s << " OpName %gIndex \"gIndex\"\n";
1925 s << " OpName %bIndex \"bIndex\"\n";
1926 s << " OpName %aIndex \"aIndex\"\n";
1927 s << " OpName %data \"data\"\n";
1928 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
1929 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
1930 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
1931 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
1932 s << " OpDecorate %gl_PerVertex Block\n";
1933 s << " OpDecorate %position Location 0\n";
1934 s << " OpDecorate %in_position Location 0\n";
1935 s << " OpDecorate %normalpos Location 1\n";
1936 s << " OpDecorate %in_normalpos Location 1\n";
1937 s << " OpDecorate %vIndex Location 2\n";
1938 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
1939 s << " OpDecorate %rIndex Location 3\n";
1940 s << " OpDecorate %index Location 2\n";
1941 s << " OpDecorate %gIndex Location 4\n";
1942 s << " OpDecorate %bIndex Location 5\n";
1943 s << " OpDecorate %aIndex Location 6\n";
1944 s << " OpDecorate %data DescriptorSet 0\n";
1945 s << " OpDecorate %data Binding 4\n";
1946 if (allowVertexStoring)
1948 // s << " OpDecorate %66 NonUniform\n";
1949 // s << " OpDecorate %68 NonUniform\n";
1950 s << " OpDecorate %69 NonUniform\n";
1951 // s << " OpDecorate %71 NonUniform\n";
1952 // s << " OpDecorate %72 NonUniform\n";
1953 s << " OpDecorate %73 NonUniform\n";
1955 s << " %void = OpTypeVoid\n";
1956 s << " %3 = OpTypeFunction %void\n";
1957 s << " %float = OpTypeFloat 32\n";
1958 s << " %v4float = OpTypeVector %float 4\n";
1959 s << " %uint = OpTypeInt 32 0\n";
1960 s << " %uint_1 = OpConstant %uint 1\n";
1961 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
1962 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
1963 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
1964 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
1965 s << " %int = OpTypeInt 32 1\n";
1966 s << " %int_1 = OpConstant %int 1\n";
1967 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
1968 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
1969 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
1970 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
1971 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
1972 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
1973 s << " %v2float = OpTypeVector %float 2\n";
1974 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
1975 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
1976 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
1977 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
1978 s << " %int_0 = OpConstant %int 0\n";
1979 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
1980 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
1981 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
1982 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
1983 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
1984 s << " %v4int = OpTypeVector %int 4\n";
1985 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
1986 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
1987 s << " %uint_0 = OpConstant %uint 0\n";
1988 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
1989 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
1990 s << " %uint_2 = OpConstant %uint 2\n";
1991 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
1992 s << " %uint_3 = OpConstant %uint 3\n";
1993 if (allowVertexStoring)
1995 s << " %bool = OpTypeBool\n";
1996 s << " %61 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
1997 s << " %_runtimearr_61 = OpTypeRuntimeArray %61\n";
1998 s << " %_ptr_UniformConstant__runtimearr_61 = OpTypePointer UniformConstant %_runtimearr_61\n";
1999 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_61 UniformConstant\n";
2000 s << " %_ptr_UniformConstant_61 = OpTypePointer UniformConstant %61\n";
2004 s << " %56 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
2005 s << "%_arr_56_uint_1 = OpTypeArray %56 %uint_1\n";
2006 s << "%_ptr_UniformConstant__arr_56_uint_1 = OpTypePointer UniformConstant %_arr_56_uint_1\n";
2007 s << " %data = OpVariable %_ptr_UniformConstant__arr_56_uint_1 UniformConstant\n";
2009 s << " %main = OpFunction %void None %3\n";
2010 s << " %5 = OpLabel\n";
2011 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
2012 s << " OpStore %18 %float_0_200000003\n";
2013 s << " %23 = OpLoad %v4float %in_position\n";
2014 s << " OpStore %position %23\n";
2015 s << " %29 = OpLoad %v2float %in_normalpos\n";
2016 s << " OpStore %normalpos %29\n";
2017 s << " %31 = OpLoad %v4float %position\n";
2018 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
2019 s << " OpStore %32 %31\n";
2020 s << " %37 = OpLoad %int %gl_VertexIndex\n";
2021 s << " OpStore %vIndex %37\n";
2022 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
2023 s << " %44 = OpLoad %int %43\n";
2024 s << " OpStore %rIndex %44\n";
2025 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
2026 s << " %47 = OpLoad %int %46\n";
2027 s << " OpStore %gIndex %47\n";
2028 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
2029 s << " %51 = OpLoad %int %50\n";
2030 s << " OpStore %bIndex %51\n";
2031 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
2032 s << " %55 = OpLoad %int %54\n";
2033 s << " OpStore %aIndex %55\n";
2034 if (allowVertexStoring)
2036 s << " %56 = OpLoad %int %gIndex\n";
2037 s << " %58 = OpINotEqual %bool %56 %int_0\n";
2038 s << " OpSelectionMerge %60 None\n";
2039 s << " OpBranchConditional %58 %59 %60\n";
2040 s << " %59 = OpLabel\n";
2041 s << " %65 = OpLoad %int %gIndex\n";
2042 s << " %66 = OpCopyObject %int %65\n";
2043 s << " %68 = OpAccessChain %_ptr_UniformConstant_61 %data %66\n";
2044 s << " %69 = OpLoad %61 %68\n";
2045 s << " %70 = OpLoad %int %rIndex\n";
2046 s << " %71 = OpCopyObject %int %70\n";
2047 s << " %72 = OpAccessChain %_ptr_UniformConstant_61 %data %71\n";
2048 s << " %73 = OpLoad %61 %72\n";
2049 s << " %74 = OpImageRead %v4float %73 %int_0\n";
2050 s << " OpImageWrite %69 %int_1 %74\n";
2051 s << " OpBranch %60\n";
2052 s << " %60 = OpLabel\n";
2055 s << " OpFunctionEnd\n";
2057 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2058 s << " OpCapability Shader\n";
2059 if (allowVertexStoring)
2061 s << " OpCapability ShaderNonUniform\n";
2062 s << " OpCapability RuntimeDescriptorArray\n";
2063 s << " OpCapability StorageBufferArrayNonUniformIndexing\n";
2064 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2066 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2067 s << " OpMemoryModel Logical GLSL450\n";
2068 s << " OpEntryPoint Vertex %main \"main\" %_ %position %in_position %normalpos %in_normalpos %vIndex %gl_VertexIndex %rIndex %index %gIndex %bIndex %aIndex %data\n";
2069 s << " OpSource GLSL 450\n";
2070 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2071 s << " OpName %main \"main\"\n";
2072 s << " OpName %gl_PerVertex \"gl_PerVertex\"\n";
2073 s << " OpMemberName %gl_PerVertex 0 \"gl_Position\"\n";
2074 s << " OpMemberName %gl_PerVertex 1 \"gl_PointSize\"\n";
2075 s << " OpMemberName %gl_PerVertex 2 \"gl_ClipDistance\"\n";
2076 s << " OpMemberName %gl_PerVertex 3 \"gl_CullDistance\"\n";
2077 s << " OpName %_ \"\"\n";
2078 s << " OpName %position \"position\"\n";
2079 s << " OpName %in_position \"in_position\"\n";
2080 s << " OpName %normalpos \"normalpos\"\n";
2081 s << " OpName %in_normalpos \"in_normalpos\"\n";
2082 s << " OpName %vIndex \"vIndex\"\n";
2083 s << " OpName %gl_VertexIndex \"gl_VertexIndex\"\n";
2084 s << " OpName %rIndex \"rIndex\"\n";
2085 s << " OpName %index \"index\"\n";
2086 s << " OpName %gIndex \"gIndex\"\n";
2087 s << " OpName %bIndex \"bIndex\"\n";
2088 s << " OpName %aIndex \"aIndex\"\n";
2089 s << " OpName %Data \"Data\"\n";
2090 s << " OpMemberName %Data 0 \"cnew\"\n";
2091 s << " OpMemberName %Data 1 \"cold\"\n";
2092 s << " OpName %data \"data\"\n";
2093 s << " OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n";
2094 s << " OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n";
2095 s << " OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n";
2096 s << " OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n";
2097 s << " OpDecorate %gl_PerVertex Block\n";
2098 s << " OpDecorate %position Location 0\n";
2099 s << " OpDecorate %in_position Location 0\n";
2100 s << " OpDecorate %normalpos Location 1\n";
2101 s << " OpDecorate %in_normalpos Location 1\n";
2102 s << " OpDecorate %vIndex Location 2\n";
2103 s << " OpDecorate %gl_VertexIndex BuiltIn VertexIndex\n";
2104 s << " OpDecorate %rIndex Location 3\n";
2105 s << " OpDecorate %index Location 2\n";
2106 s << " OpDecorate %gIndex Location 4\n";
2107 s << " OpDecorate %bIndex Location 5\n";
2108 s << " OpDecorate %aIndex Location 6\n";
2109 s << " OpMemberDecorate %Data 0 Offset 0\n";
2110 s << " OpMemberDecorate %Data 1 Offset 16\n";
2111 s << " OpDecorate %Data Block\n";
2112 s << " OpDecorate %data DescriptorSet 0\n";
2113 s << " OpDecorate %data Binding 2\n";
2114 if (allowVertexStoring)
2116 // s << " OpDecorate %66 NonUniform\n";
2117 // s << " OpDecorate %68 NonUniform\n";
2118 s << " OpDecorate %70 NonUniform\n";
2119 // s << " OpDecorate %71 NonUniform\n";
2120 s << " OpDecorate %72 NonUniform\n";
2122 s << " %void = OpTypeVoid\n";
2123 s << " %3 = OpTypeFunction %void\n";
2124 s << " %float = OpTypeFloat 32\n";
2125 s << " %v4float = OpTypeVector %float 4\n";
2126 s << " %uint = OpTypeInt 32 0\n";
2127 s << " %uint_1 = OpConstant %uint 1\n";
2128 s << "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n";
2129 s << "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1\n";
2130 s << "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n";
2131 s << " %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n";
2132 s << " %int = OpTypeInt 32 1\n";
2133 s << " %int_1 = OpConstant %int 1\n";
2134 s << "%float_0_200000003 = OpConstant %float 0.200000003\n";
2135 s << "%_ptr_Output_float = OpTypePointer Output %float\n";
2136 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2137 s << " %position = OpVariable %_ptr_Output_v4float Output\n";
2138 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2139 s << "%in_position = OpVariable %_ptr_Input_v4float Input\n";
2140 s << " %v2float = OpTypeVector %float 2\n";
2141 s << "%_ptr_Output_v2float = OpTypePointer Output %v2float\n";
2142 s << " %normalpos = OpVariable %_ptr_Output_v2float Output\n";
2143 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2144 s << "%in_normalpos = OpVariable %_ptr_Input_v2float Input\n";
2145 s << " %int_0 = OpConstant %int 0\n";
2146 s << "%_ptr_Output_int = OpTypePointer Output %int\n";
2147 s << " %vIndex = OpVariable %_ptr_Output_int Output\n";
2148 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2149 s << "%gl_VertexIndex = OpVariable %_ptr_Input_int Input\n";
2150 s << " %rIndex = OpVariable %_ptr_Output_int Output\n";
2151 s << " %v4int = OpTypeVector %int 4\n";
2152 s << "%_ptr_Input_v4int = OpTypePointer Input %v4int\n";
2153 s << " %index = OpVariable %_ptr_Input_v4int Input\n";
2154 s << " %uint_0 = OpConstant %uint 0\n";
2155 s << " %gIndex = OpVariable %_ptr_Output_int Output\n";
2156 s << " %bIndex = OpVariable %_ptr_Output_int Output\n";
2157 s << " %uint_2 = OpConstant %uint 2\n";
2158 s << " %aIndex = OpVariable %_ptr_Output_int Output\n";
2159 s << " %uint_3 = OpConstant %uint 3\n";
2160 s << " %Data = OpTypeStruct %v4float %v4float\n";
2161 if (allowVertexStoring)
2163 s << " %bool = OpTypeBool\n";
2164 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2165 s << "%_ptr_StorageBuffer__runtimearr_Data = OpTypePointer StorageBuffer %_runtimearr_Data\n";
2166 s << " %data = OpVariable %_ptr_StorageBuffer__runtimearr_Data StorageBuffer\n";
2167 s << "%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float\n";
2171 s << "%_arr_Data_uint_1 = OpTypeArray %Data %uint_1\n";
2172 s << "%_ptr_StorageBuffer__arr_Data_uint_1 = OpTypePointer StorageBuffer %_arr_Data_uint_1\n";
2173 s << " %data = OpVariable %_ptr_StorageBuffer__arr_Data_uint_1 StorageBuffer\n";
2175 s << " %main = OpFunction %void None %3\n";
2176 s << " %5 = OpLabel\n";
2177 s << " %18 = OpAccessChain %_ptr_Output_float %_ %int_1\n";
2178 s << " OpStore %18 %float_0_200000003\n";
2179 s << " %23 = OpLoad %v4float %in_position\n";
2180 s << " OpStore %position %23\n";
2181 s << " %29 = OpLoad %v2float %in_normalpos\n";
2182 s << " OpStore %normalpos %29\n";
2183 s << " %31 = OpLoad %v4float %position\n";
2184 s << " %32 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n";
2185 s << " OpStore %32 %31\n";
2186 s << " %37 = OpLoad %int %gl_VertexIndex\n";
2187 s << " OpStore %vIndex %37\n";
2188 s << " %43 = OpAccessChain %_ptr_Input_int %index %uint_0\n";
2189 s << " %44 = OpLoad %int %43\n";
2190 s << " OpStore %rIndex %44\n";
2191 s << " %46 = OpAccessChain %_ptr_Input_int %index %uint_1\n";
2192 s << " %47 = OpLoad %int %46\n";
2193 s << " OpStore %gIndex %47\n";
2194 s << " %50 = OpAccessChain %_ptr_Input_int %index %uint_2\n";
2195 s << " %51 = OpLoad %int %50\n";
2196 s << " OpStore %bIndex %51\n";
2197 s << " %54 = OpAccessChain %_ptr_Input_int %index %uint_3\n";
2198 s << " %55 = OpLoad %int %54\n";
2199 s << " OpStore %aIndex %55\n";
2200 if (allowVertexStoring)
2202 s << " %56 = OpLoad %int %gIndex\n";
2203 s << " %58 = OpINotEqual %bool %56 %int_0\n";
2204 s << " OpSelectionMerge %60 None\n";
2205 s << " OpBranchConditional %58 %59 %60\n";
2206 s << " %59 = OpLabel\n";
2207 s << " %65 = OpLoad %int %gIndex\n";
2208 s << " %66 = OpCopyObject %int %65\n";
2209 s << " %67 = OpLoad %int %rIndex\n";
2210 s << " %68 = OpCopyObject %int %67\n";
2211 s << " %70 = OpAccessChain %_ptr_StorageBuffer_v4float %data %68 %int_1\n";
2212 s << " %71 = OpLoad %v4float %70\n";
2213 s << " %72 = OpAccessChain %_ptr_StorageBuffer_v4float %data %66 %int_0\n";
2214 s << " OpStore %72 %71\n";
2215 s << " OpBranch %60\n";
2216 s << " %60 = OpLabel\n";
2219 s << " OpFunctionEnd\n";
2222 TCU_THROW(InternalError, "Unexpected descriptor type");
2225 case VK_SHADER_STAGE_FRAGMENT_BIT:
2226 switch (testCaseParams.descriptorType)
2228 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2229 s << " OpCapability Shader\n";
2230 if (testCaseParams.usesMipMaps)
2232 s << " OpCapability ImageQuery\n";
2234 s << " OpCapability ShaderNonUniform\n";
2235 s << " OpCapability RuntimeDescriptorArray\n";
2236 s << " OpCapability SampledImageArrayNonUniformIndexing\n";
2237 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2238 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2239 s << " OpMemoryModel Logical GLSL450\n";
2240 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2241 s << " OpExecutionMode %main OriginUpperLeft\n";
2242 s << " OpSource GLSL 450\n";
2243 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2244 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
2245 s << " OpName %main \"main\"\n";
2246 s << " OpName %FragColor \"FragColor\"\n";
2247 s << " OpName %data \"data\"\n";
2248 s << " OpName %rIndex \"rIndex\"\n";
2249 s << " OpName %position \"position\"\n";
2250 s << " OpName %normalpos \"normalpos\"\n";
2251 s << " OpName %vIndex \"vIndex\"\n";
2252 s << " OpName %gIndex \"gIndex\"\n";
2253 s << " OpName %bIndex \"bIndex\"\n";
2254 s << " OpName %aIndex \"aIndex\"\n";
2255 s << " OpDecorate %FragColor Location 0\n";
2256 s << " OpDecorate %data DescriptorSet 0\n";
2257 s << " OpDecorate %data Binding 7\n";
2258 s << " OpDecorate %rIndex Flat\n";
2259 s << " OpDecorate %rIndex Location 3\n";
2260 // s << " OpDecorate %19 NonUniform\n";
2261 // s << " OpDecorate %21 NonUniform\n";
2262 s << " OpDecorate %22 NonUniform\n";
2263 if (testCaseParams.usesMipMaps)
2265 // s << " OpDecorate %27 NonUniform\n";
2266 // s << " OpDecorate %28 NonUniform\n";
2267 // s << " OpDecorate %29 NonUniform\n";
2268 s << " OpDecorate %30 NonUniform\n";
2270 s << " OpDecorate %position Flat\n";
2271 s << " OpDecorate %position Location 0\n";
2272 s << " OpDecorate %normalpos Flat\n";
2273 s << " OpDecorate %normalpos Location 1\n";
2274 s << " OpDecorate %vIndex Flat\n";
2275 s << " OpDecorate %vIndex Location 2\n";
2276 s << " OpDecorate %gIndex Flat\n";
2277 s << " OpDecorate %gIndex Location 4\n";
2278 s << " OpDecorate %bIndex Flat\n";
2279 s << " OpDecorate %bIndex Location 5\n";
2280 s << " OpDecorate %aIndex Flat\n";
2281 s << " OpDecorate %aIndex Location 6\n";
2282 s << " %void = OpTypeVoid\n";
2283 s << " %3 = OpTypeFunction %void\n";
2284 s << " %float = OpTypeFloat 32\n";
2285 s << " %v4float = OpTypeVector %float 4\n";
2286 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2287 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2288 s << " %10 = OpTypeImage %float 2D 0 0 0 1 Unknown\n";
2289 s << " %11 = OpTypeSampledImage %10\n";
2290 s << "%_runtimearr_11 = OpTypeRuntimeArray %11\n";
2291 s << "%_ptr_UniformConstant__runtimearr_11 = OpTypePointer UniformConstant %_runtimearr_11\n";
2292 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_11 UniformConstant\n";
2293 s << " %int = OpTypeInt 32 1\n";
2294 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2295 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2296 s << "%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11\n";
2297 s << " %v2float = OpTypeVector %float 2\n";
2298 s << " %float_0 = OpConstant %float 0\n";
2299 s << " %int_1 = OpConstant %int 1\n";
2300 s << " %25 = OpConstantComposite %v2float %float_0 %float_0\n";
2301 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2302 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2303 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2304 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2305 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2306 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2307 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2308 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2309 s << " %main = OpFunction %void None %3\n";
2310 s << " %5 = OpLabel\n";
2311 s << " %18 = OpLoad %int %rIndex\n";
2312 s << " %19 = OpCopyObject %int %18\n";
2313 s << " %21 = OpAccessChain %_ptr_UniformConstant_11 %data %19\n";
2314 s << " %22 = OpLoad %11 %21\n";
2315 if (testCaseParams.usesMipMaps)
2317 s << " %26 = OpLoad %int %rIndex\n";
2318 s << " %27 = OpCopyObject %int %26\n";
2319 s << " %28 = OpAccessChain %_ptr_UniformConstant_11 %data %27\n";
2320 s << " %29 = OpLoad %11 %28\n";
2321 s << " %30 = OpImage %10 %29\n";
2322 s << " %31 = OpImageQueryLevels %int %30\n";
2323 s << " %33 = OpISub %int %31 %int_1\n";
2324 s << " %34 = OpConvertSToF %float %33\n";
2325 s << " %35 = OpImageSampleExplicitLod %v4float %22 %25 Lod %34\n";
2326 s << " OpStore %FragColor %35\n";
2330 s << " %26 = OpImageSampleImplicitLod %v4float %22 %25\n";
2331 s << " OpStore %FragColor %26\n";
2334 s << " OpFunctionEnd\n";
2336 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2337 s << " OpCapability Shader\n";
2338 s << " OpCapability SampledBuffer\n";
2339 s << " OpCapability ShaderNonUniform\n";
2340 s << " OpCapability RuntimeDescriptorArray\n";
2341 s << " OpCapability UniformTexelBufferArrayNonUniformIndexing\n";
2342 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2343 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2344 s << " OpMemoryModel Logical GLSL450\n";
2345 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2346 s << " OpExecutionMode %main OriginUpperLeft\n";
2347 s << " OpSource GLSL 450\n";
2348 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2349 s << " OpSourceExtension \"GL_EXT_texture_buffer\"\n";
2350 s << " OpName %main \"main\"\n";
2351 s << " OpName %FragColor \"FragColor\"\n";
2352 s << " OpName %data \"data\"\n";
2353 s << " OpName %rIndex \"rIndex\"\n";
2354 s << " OpName %position \"position\"\n";
2355 s << " OpName %normalpos \"normalpos\"\n";
2356 s << " OpName %vIndex \"vIndex\"\n";
2357 s << " OpName %gIndex \"gIndex\"\n";
2358 s << " OpName %bIndex \"bIndex\"\n";
2359 s << " OpName %aIndex \"aIndex\"\n";
2360 s << " OpDecorate %FragColor Location 0\n";
2361 s << " OpDecorate %data DescriptorSet 0\n";
2362 s << " OpDecorate %data Binding 3\n";
2363 s << " OpDecorate %rIndex Flat\n";
2364 s << " OpDecorate %rIndex Location 3\n";
2365 // s << " OpDecorate %19 NonUniform\n";
2366 // s << " OpDecorate %21 NonUniform\n";
2367 // s << " OpDecorate %22 NonUniform\n";
2368 s << " OpDecorate %24 NonUniform\n";
2369 s << " OpDecorate %position Flat\n";
2370 s << " OpDecorate %position Location 0\n";
2371 s << " OpDecorate %normalpos Flat\n";
2372 s << " OpDecorate %normalpos Location 1\n";
2373 s << " OpDecorate %vIndex Flat\n";
2374 s << " OpDecorate %vIndex Location 2\n";
2375 s << " OpDecorate %gIndex Flat\n";
2376 s << " OpDecorate %gIndex Location 4\n";
2377 s << " OpDecorate %bIndex Flat\n";
2378 s << " OpDecorate %bIndex Location 5\n";
2379 s << " OpDecorate %aIndex Flat\n";
2380 s << " OpDecorate %aIndex Location 6\n";
2381 s << " %void = OpTypeVoid\n";
2382 s << " %3 = OpTypeFunction %void\n";
2383 s << " %float = OpTypeFloat 32\n";
2384 s << " %v4float = OpTypeVector %float 4\n";
2385 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2386 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2387 s << " %10 = OpTypeImage %float Buffer 0 0 0 1 Unknown\n";
2388 s << " %11 = OpTypeSampledImage %10\n";
2389 s << "%_runtimearr_11 = OpTypeRuntimeArray %11\n";
2390 s << "%_ptr_UniformConstant__runtimearr_11 = OpTypePointer UniformConstant %_runtimearr_11\n";
2391 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_11 UniformConstant\n";
2392 s << " %int = OpTypeInt 32 1\n";
2393 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2394 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2395 s << "%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11\n";
2396 s << " %int_0 = OpConstant %int 0\n";
2397 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2398 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2399 s << " %v2float = OpTypeVector %float 2\n";
2400 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2401 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2402 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2403 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2404 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2405 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2406 s << " %main = OpFunction %void None %3\n";
2407 s << " %5 = OpLabel\n";
2408 s << " %18 = OpLoad %int %rIndex\n";
2409 s << " %19 = OpCopyObject %int %18\n";
2410 s << " %21 = OpAccessChain %_ptr_UniformConstant_11 %data %19\n";
2411 s << " %22 = OpLoad %11 %21\n";
2412 s << " %24 = OpImage %10 %22\n";
2413 s << " %25 = OpImageFetch %v4float %24 %int_0\n";
2414 s << " OpStore %FragColor %25\n";
2416 s << " OpFunctionEnd\n";
2418 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2419 s << " OpCapability Shader\n";
2420 s << " OpCapability ImageBuffer\n";
2421 s << " OpCapability ShaderNonUniform\n";
2422 s << " OpCapability RuntimeDescriptorArray\n";
2423 s << " OpCapability StorageTexelBufferArrayNonUniformIndexing\n";
2424 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2425 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2426 s << " OpMemoryModel Logical GLSL450\n";
2427 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2428 s << " OpExecutionMode %main OriginUpperLeft\n";
2429 s << " OpSource GLSL 450\n";
2430 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2431 s << " OpName %main \"main\"\n";
2432 s << " OpName %FragColor \"FragColor\"\n";
2433 s << " OpName %data \"data\"\n";
2434 s << " OpName %rIndex \"rIndex\"\n";
2435 s << " OpName %position \"position\"\n";
2436 s << " OpName %normalpos \"normalpos\"\n";
2437 s << " OpName %vIndex \"vIndex\"\n";
2438 s << " OpName %gIndex \"gIndex\"\n";
2439 s << " OpName %bIndex \"bIndex\"\n";
2440 s << " OpName %aIndex \"aIndex\"\n";
2441 s << " OpDecorate %FragColor Location 0\n";
2442 s << " OpDecorate %data DescriptorSet 0\n";
2443 s << " OpDecorate %data Binding 4\n";
2444 s << " OpDecorate %rIndex Flat\n";
2445 s << " OpDecorate %rIndex Location 3\n";
2446 // s << " OpDecorate %18 NonUniform\n";
2447 // s << " OpDecorate %20 NonUniform\n";
2448 s << " OpDecorate %21 NonUniform\n";
2449 s << " OpDecorate %position Flat\n";
2450 s << " OpDecorate %position Location 0\n";
2451 s << " OpDecorate %normalpos Flat\n";
2452 s << " OpDecorate %normalpos Location 1\n";
2453 s << " OpDecorate %vIndex Flat\n";
2454 s << " OpDecorate %vIndex Location 2\n";
2455 s << " OpDecorate %gIndex Flat\n";
2456 s << " OpDecorate %gIndex Location 4\n";
2457 s << " OpDecorate %bIndex Flat\n";
2458 s << " OpDecorate %bIndex Location 5\n";
2459 s << " OpDecorate %aIndex Flat\n";
2460 s << " OpDecorate %aIndex Location 6\n";
2461 s << " %void = OpTypeVoid\n";
2462 s << " %3 = OpTypeFunction %void\n";
2463 s << " %float = OpTypeFloat 32\n";
2464 s << " %v4float = OpTypeVector %float 4\n";
2465 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2466 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2467 s << " %10 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f\n";
2468 s << "%_runtimearr_10 = OpTypeRuntimeArray %10\n";
2469 s << "%_ptr_UniformConstant__runtimearr_10 = OpTypePointer UniformConstant %_runtimearr_10\n";
2470 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_10 UniformConstant\n";
2471 s << " %int = OpTypeInt 32 1\n";
2472 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2473 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2474 s << "%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10\n";
2475 s << " %int_0 = OpConstant %int 0\n";
2476 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2477 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2478 s << " %v2float = OpTypeVector %float 2\n";
2479 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2480 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2481 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2482 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2483 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2484 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2485 s << " %main = OpFunction %void None %3\n";
2486 s << " %5 = OpLabel\n";
2487 s << " %17 = OpLoad %int %rIndex\n";
2488 s << " %18 = OpCopyObject %int %17\n";
2489 s << " %20 = OpAccessChain %_ptr_UniformConstant_10 %data %18\n";
2490 s << " %21 = OpLoad %10 %20\n";
2491 s << " %23 = OpImageRead %v4float %21 %int_0\n";
2492 s << " OpStore %FragColor %23\n";
2494 s << " OpFunctionEnd\n";
2496 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2497 s << " OpCapability Shader\n";
2498 s << " OpCapability ShaderNonUniform\n";
2499 s << " OpCapability RuntimeDescriptorArray\n";
2500 s << " OpCapability StorageBufferArrayNonUniformIndexing\n";
2501 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2502 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2503 s << " OpMemoryModel Logical GLSL450\n";
2504 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2505 s << " OpExecutionMode %main OriginUpperLeft\n";
2506 s << " OpSource GLSL 450\n";
2507 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2508 s << " OpName %main \"main\"\n";
2509 s << " OpName %FragColor \"FragColor\"\n";
2510 s << " OpName %Data \"Data\"\n";
2511 s << " OpMemberName %Data 0 \"cnew\"\n";
2512 s << " OpMemberName %Data 1 \"cold\"\n";
2513 s << " OpName %data \"data\"\n";
2514 s << " OpName %rIndex \"rIndex\"\n";
2515 s << " OpName %position \"position\"\n";
2516 s << " OpName %normalpos \"normalpos\"\n";
2517 s << " OpName %vIndex \"vIndex\"\n";
2518 s << " OpName %gIndex \"gIndex\"\n";
2519 s << " OpName %bIndex \"bIndex\"\n";
2520 s << " OpName %aIndex \"aIndex\"\n";
2521 s << " OpDecorate %FragColor Location 0\n";
2522 s << " OpMemberDecorate %Data 0 Offset 0\n";
2523 s << " OpMemberDecorate %Data 1 Offset 16\n";
2524 s << " OpDecorate %Data Block\n";
2525 s << " OpDecorate %data DescriptorSet 0\n";
2526 s << " OpDecorate %data Binding 2\n";
2527 s << " OpDecorate %rIndex Flat\n";
2528 s << " OpDecorate %rIndex Location 3\n";
2529 // s << " OpDecorate %18 NonUniform\n";
2530 s << " OpDecorate %21 NonUniform\n";
2531 // s << " OpDecorate %22 NonUniform\n";
2532 s << " OpDecorate %position Flat\n";
2533 s << " OpDecorate %position Location 0\n";
2534 s << " OpDecorate %normalpos Flat OpDecorate %normalpos Location 1\n";
2535 s << " OpDecorate %vIndex Flat\n";
2536 s << " OpDecorate %vIndex Location 2\n";
2537 s << " OpDecorate %gIndex Flat\n";
2538 s << " OpDecorate %gIndex Location 4\n";
2539 s << " OpDecorate %bIndex Flat\n";
2540 s << " OpDecorate %bIndex Location 5\n";
2541 s << " OpDecorate %aIndex Flat\n";
2542 s << " OpDecorate %aIndex Location 6\n";
2543 s << " %void = OpTypeVoid\n";
2544 s << " %3 = OpTypeFunction %void\n";
2545 s << " %float = OpTypeFloat 32\n";
2546 s << " %v4float = OpTypeVector %float 4\n";
2547 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2548 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2549 s << " %Data = OpTypeStruct %v4float %v4float\n";
2550 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2551 s << "%_ptr_StorageBuffer__runtimearr_Data = OpTypePointer StorageBuffer %_runtimearr_Data\n";
2552 s << " %data = OpVariable %_ptr_StorageBuffer__runtimearr_Data StorageBuffer\n";
2553 s << " %int = OpTypeInt 32 1\n";
2554 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2555 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2556 s << " %int_1 = OpConstant %int 1\n";
2557 s << "%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float\n";
2558 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2559 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2560 s << " %v2float = OpTypeVector %float 2\n";
2561 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2562 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2563 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2564 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2565 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2566 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2567 s << " %main = OpFunction %void None %3\n";
2568 s << " %5 = OpLabel\n";
2569 s << " %17 = OpLoad %int %rIndex\n";
2570 s << " %18 = OpCopyObject %int %17\n";
2571 s << " %21 = OpAccessChain %_ptr_StorageBuffer_v4float %data %18 %int_1\n";
2572 s << " %22 = OpLoad %v4float %21\n";
2573 s << " OpStore %FragColor %22\n";
2575 s << " OpFunctionEnd\n";
2577 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2578 s << " OpCapability Shader\n";
2579 s << " OpCapability ShaderNonUniform\n";
2580 s << " OpCapability RuntimeDescriptorArray\n";
2581 s << " OpCapability UniformBufferArrayNonUniformIndexing\n";
2582 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2583 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2584 s << " OpMemoryModel Logical GLSL450\n";
2585 s << " OpEntryPoint Fragment %main \"main\" %FragColor %data %rIndex %position %normalpos %vIndex %gIndex %bIndex %aIndex\n";
2586 s << " OpExecutionMode %main OriginUpperLeft\n";
2587 s << " OpSource GLSL 450\n";
2588 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2589 s << " OpName %main \"main\"\n";
2590 s << " OpName %FragColor \"FragColor\"\n";
2591 s << " OpName %Data \"Data\"\n";
2592 s << " OpMemberName %Data 0 \"c\"\n";
2593 s << " OpName %data \"data\"\n";
2594 s << " OpName %rIndex \"rIndex\"\n";
2595 s << " OpName %position \"position\"\n";
2596 s << " OpName %normalpos \"normalpos\"\n";
2597 s << " OpName %vIndex \"vIndex\"\n";
2598 s << " OpName %gIndex \"gIndex\"\n";
2599 s << " OpName %bIndex \"bIndex\"\n";
2600 s << " OpName %aIndex \"aIndex\"\n";
2601 s << " OpDecorate %FragColor Location 0\n";
2602 s << " OpMemberDecorate %Data 0 Offset 0\n";
2603 s << " OpDecorate %Data Block\n";
2604 s << " OpDecorate %data DescriptorSet 0\n";
2605 s << " OpDecorate %data Binding 1\n";
2606 s << " OpDecorate %rIndex Flat\n";
2607 s << " OpDecorate %rIndex Location 3\n";
2608 // s << " OpDecorate %18 NonUniform\n";
2609 s << " OpDecorate %21 NonUniform\n";
2610 // s << " OpDecorate %22 NonUniform\n";
2611 s << " OpDecorate %position Flat\n";
2612 s << " OpDecorate %position Location 0\n";
2613 s << " OpDecorate %normalpos Flat\n";
2614 s << " OpDecorate %normalpos Location 1\n";
2615 s << " OpDecorate %vIndex Flat\n";
2616 s << " OpDecorate %vIndex Location 2\n";
2617 s << " OpDecorate %gIndex Flat\n";
2618 s << " OpDecorate %gIndex Location 4\n";
2619 s << " OpDecorate %bIndex Flat\n";
2620 s << " OpDecorate %bIndex Location 5\n";
2621 s << " OpDecorate %aIndex Flat\n";
2622 s << " OpDecorate %aIndex Location 6\n";
2623 s << " %void = OpTypeVoid\n";
2624 s << " %3 = OpTypeFunction %void\n";
2625 s << " %float = OpTypeFloat 32\n";
2626 s << " %v4float = OpTypeVector %float 4\n";
2627 s << "%_ptr_Output_v4float = OpTypePointer Output %v4float\n";
2628 s << " %FragColor = OpVariable %_ptr_Output_v4float Output\n";
2629 s << " %Data = OpTypeStruct %v4float\n";
2630 s << "%_runtimearr_Data = OpTypeRuntimeArray %Data\n";
2631 s << "%_ptr_Uniform__runtimearr_Data = OpTypePointer Uniform %_runtimearr_Data\n";
2632 s << " %data = OpVariable %_ptr_Uniform__runtimearr_Data Uniform\n";
2633 s << " %int = OpTypeInt 32 1\n";
2634 s << "%_ptr_Input_int = OpTypePointer Input %int\n";
2635 s << " %rIndex = OpVariable %_ptr_Input_int Input\n";
2636 s << " %int_0 = OpConstant %int 0\n";
2637 s << "%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float\n";
2638 s << "%_ptr_Input_v4float = OpTypePointer Input %v4float\n";
2639 s << " %position = OpVariable %_ptr_Input_v4float Input\n";
2640 s << " %v2float = OpTypeVector %float 2\n";
2641 s << "%_ptr_Input_v2float = OpTypePointer Input %v2float\n";
2642 s << " %normalpos = OpVariable %_ptr_Input_v2float Input\n";
2643 s << " %vIndex = OpVariable %_ptr_Input_int Input\n";
2644 s << " %gIndex = OpVariable %_ptr_Input_int Input\n";
2645 s << " %bIndex = OpVariable %_ptr_Input_int Input\n";
2646 s << " %aIndex = OpVariable %_ptr_Input_int Input\n";
2647 s << " %main = OpFunction %void None %3\n";
2648 s << " %5 = OpLabel\n";
2649 s << " %17 = OpLoad %int %rIndex\n";
2650 s << " %18 = OpCopyObject %int %17\n";
2651 s << " %21 = OpAccessChain %_ptr_Uniform_v4float %data %18 %int_0\n";
2652 s << " %22 = OpLoad %v4float %21\n";
2653 s << " OpStore %FragColor %22\n";
2655 s << " OpFunctionEnd\n";
2658 TCU_THROW(InternalError, "Unexpected descriptor type");
2661 case VK_SHADER_STAGE_COMPUTE_BIT:
2662 switch (testCaseParams.descriptorType)
2664 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
2665 s << " OpCapability Shader\n";
2666 s << " OpCapability ShaderNonUniform\n";
2667 s << " OpCapability RuntimeDescriptorArray\n";
2668 s << " OpCapability StorageImageArrayNonUniformIndexing\n";
2669 s << " OpExtension \"SPV_EXT_descriptor_indexing\"\n";
2670 s << " %1 = OpExtInstImport \"GLSL.std.450\"\n";
2671 s << " OpMemoryModel Logical GLSL450\n";
2672 s << " OpEntryPoint GLCompute %main \"main\" %idxs %gl_WorkGroupID %data\n";
2673 s << " OpExecutionMode %main LocalSize 1 1 1\n";
2674 s << " OpSource GLSL 450\n";
2675 s << " OpSourceExtension \"GL_EXT_nonuniform_qualifier\"\n";
2676 s << " OpName %main \"main\"\n";
2677 s << " OpName %c \"c\"\n";
2678 s << " OpName %idxs \"idxs\"\n";
2679 s << " OpName %gl_WorkGroupID \"gl_WorkGroupID\"\n";
2680 s << " OpName %data \"data\"\n";
2681 s << " OpDecorate %idxs DescriptorSet 0\n";
2682 s << " OpDecorate %idxs Binding 12\n";
2683 s << " OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId\n";
2684 s << " OpDecorate %data DescriptorSet 0\n";
2685 s << " OpDecorate %data Binding 11\n";
2686 // s << " OpDecorate %36 NonUniform\n";
2687 // s << " OpDecorate %37 NonUniform\n";
2688 s << " OpDecorate %41 NonUniform\n";
2689 s << " OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize\n";
2690 s << " %void = OpTypeVoid\n";
2691 s << " %3 = OpTypeFunction %void\n";
2692 s << " %uint = OpTypeInt 32 0\n";
2693 s << " %v4uint = OpTypeVector %uint 4\n";
2694 s << "%_ptr_Function_v4uint = OpTypePointer Function %v4uint\n";
2695 s << " %10 = OpTypeImage %uint 2D 0 0 0 2 R32ui\n";
2696 s << "%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10\n";
2697 s << " %idxs = OpVariable %_ptr_UniformConstant_10 UniformConstant\n";
2698 s << " %v3uint = OpTypeVector %uint 3\n";
2699 s << "%_ptr_Input_v3uint = OpTypePointer Input %v3uint\n";
2700 s << "%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input\n";
2701 s << " %uint_0 = OpConstant %uint 0\n";
2702 s << "%_ptr_Input_uint = OpTypePointer Input %uint\n";
2703 s << " %int = OpTypeInt 32 1\n";
2704 s << " %uint_1 = OpConstant %uint 1\n";
2705 s << " %v2int = OpTypeVector %int 2\n";
2706 s << "%_runtimearr_10 = OpTypeRuntimeArray %10\n";
2707 s << "%_ptr_UniformConstant__runtimearr_10 = OpTypePointer UniformConstant %_runtimearr_10\n";
2708 s << " %data = OpVariable %_ptr_UniformConstant__runtimearr_10 UniformConstant\n";
2709 s << "%_ptr_Function_uint = OpTypePointer Function %uint\n";
2710 s << " %int_0 = OpConstant %int 0\n";
2711 s << " %39 = OpConstantComposite %v2int %int_0 %int_0\n";
2712 s << "%_ptr_Image_uint = OpTypePointer Image %uint\n";
2713 s << "%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1\n";
2714 s << " %main = OpFunction %void None %3\n";
2715 s << " %5 = OpLabel\n";
2716 s << " %c = OpVariable %_ptr_Function_v4uint Function\n";
2717 s << " %13 = OpLoad %10 %idxs\n";
2718 s << " %19 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0\n";
2719 s << " %20 = OpLoad %uint %19\n";
2720 s << " %22 = OpBitcast %int %20\n";
2721 s << " %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_1\n";
2722 s << " %25 = OpLoad %uint %24\n";
2723 s << " %26 = OpBitcast %int %25\n";
2724 s << " %28 = OpCompositeConstruct %v2int %22 %26\n";
2725 s << " %29 = OpImageRead %v4uint %13 %28 ZeroExtend\n";
2726 s << " OpStore %c %29\n";
2727 s << " %34 = OpAccessChain %_ptr_Function_uint %c %uint_0\n";
2728 s << " %35 = OpLoad %uint %34\n";
2729 s << " %36 = OpCopyObject %uint %35\n";
2730 s << " %37 = OpAccessChain %_ptr_UniformConstant_10 %data %36\n";
2731 s << " %41 = OpImageTexelPointer %_ptr_Image_uint %37 %39 %uint_0\n";
2732 s << " %42 = OpAtomicIAdd %uint %41 %uint_1 %uint_0 %uint_1\n";
2734 s << " OpFunctionEnd\n";
2737 TCU_THROW(InternalError, "Unexpected descriptor type");
2741 TCU_THROW(InternalError, "Unexpected stage");
2747 std::string CommonDescriptorInstance::getShaderSource (VkShaderStageFlagBits shaderType,
2748 const TestCaseParams& testCaseParams,
2749 bool allowVertexStoring)
2751 std::stringstream s;
2753 s << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << '\n';
2754 s << "#extension GL_EXT_nonuniform_qualifier : require \n";
2756 if (testCaseParams.calculateInLoop)
2758 s << "layout(push_constant) uniform Block { int lowerBound, upperBound; } pc;\n";
2759 s << substBinding(BINDING_DescriptorEnumerator,
2760 "layout(set=1,binding=${?}) uniform isamplerBuffer iter; \n");
2763 switch (testCaseParams.descriptorType)
2765 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2766 s << substBinding(BINDING_StorageBuffer,
2767 "layout(set=0,binding=${?}) buffer Data { vec4 cnew, cold; } data[]; \n");
2769 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2770 s << substBinding(BINDING_StorageBufferDynamic,
2771 "layout(set=0,binding=${?}) buffer Data { vec4 cnew, cold; } data[]; \n");
2773 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2774 s << substBinding(BINDING_UniformBuffer,
2775 "layout(set=0,binding=${?}) uniform Data { vec4 c; } data[]; \n");
2777 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2778 s << substBinding(BINDING_UniformBufferDynamic,
2779 "layout(set=0,binding=${?}) uniform Data { vec4 c; } data[]; \n");
2781 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2782 s << substBinding(BINDING_StorageTexelBuffer,
2783 "layout(set=0,binding=${?},rgba32f) uniform imageBuffer data[];\n");
2785 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2786 s << "#extension GL_EXT_texture_buffer : require \n";
2787 s << substBinding(BINDING_UniformTexelBuffer,
2788 "layout(set=0,binding=${?}) uniform samplerBuffer data[];\n");
2790 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2791 // Left for the consistent of code.
2792 // Header is set one swicth below
2794 case VK_DESCRIPTOR_TYPE_SAMPLER:
2795 s << "#extension GL_EXT_texture_buffer : require \n";
2796 s << substBinding(BINDING_SampledImage,
2797 "layout(set=0,binding=${?}) uniform texture2D ${VAR}[${*}];\n", 1, "tex");
2798 s << substBinding(BINDING_Sampler,
2799 "layout(set=0,binding=${?}) uniform sampler ${VAR}[${*}];\n");
2801 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2802 s << "#extension GL_EXT_texture_buffer : require \n";
2803 s << substBinding(BINDING_Sampler,
2804 "layout(set=0,binding=${?}) uniform sampler ${VAR}[${*}];\n", 1, "samp");
2805 s << substBinding(BINDING_SampledImage,
2806 "layout(set=0,binding=${?}) uniform texture2D ${VAR}[${*}];\n");
2808 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2809 s << "#extension GL_EXT_texture_buffer : require \n";
2810 s << substBinding(BINDING_CombinedImageSampler,
2811 "layout(set=0,binding=${?}) uniform sampler2D data[];\n");
2813 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
2814 s << "layout(local_size_x=1,local_size_y=1,local_size_z=1) in; \n";
2815 s << substBinding(BINDING_StorageImage + 1,
2816 "layout(r32ui,set=0,binding=${?}) uniform uimage2D idxs; \n");
2817 s << substBinding(BINDING_StorageImage,
2818 "layout(r32ui,set=0,binding=${?}) uniform uimage2D data[]; \n");
2821 TCU_THROW(InternalError, "Not implemented descriptor type");
2826 case VK_SHADER_STAGE_VERTEX_BIT: s << getVertexShaderProlog(); break;
2827 case VK_SHADER_STAGE_FRAGMENT_BIT:
2829 if (testCaseParams.descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)
2831 s << substBinding(BINDING_InputAttachment,
2832 "layout(input_attachment_index=1,set=0,binding=${?}) uniform subpassInput data[]; \n");
2834 s << getFragmentShaderProlog();
2837 case VK_SHADER_STAGE_COMPUTE_BIT:
2840 TCU_THROW(InternalError, "Not implemented shader stage");
2845 case VK_SHADER_STAGE_VERTEX_BIT:
2847 switch (testCaseParams.descriptorType)
2849 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2850 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2851 if (allowVertexStoring)
2852 s << " if (gIndex != 0) data[nonuniformEXT(gIndex)].cnew = data[nonuniformEXT(rIndex)].cold; \n";
2854 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2855 if (allowVertexStoring)
2856 s << " if (gIndex != 0) imageStore(data[nonuniformEXT(gIndex)], 1, imageLoad(data[nonuniformEXT(rIndex)], 0)); \n";
2858 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2859 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2860 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2861 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2862 case VK_DESCRIPTOR_TYPE_SAMPLER:
2863 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2864 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2868 TCU_THROW(InternalError, "Not implemented descriptor type");
2873 case VK_SHADER_STAGE_FRAGMENT_BIT:
2875 switch (testCaseParams.descriptorType)
2877 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
2878 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
2879 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
2881 if (testCaseParams.calculateInLoop)
2882 s << getFragmentLoopSource(
2883 getColorAccess(testCaseParams.descriptorType, "rIndex", false),
2884 getColorAccess(testCaseParams.descriptorType, "loopIdx", false));
2886 s << getFragmentReturnSource(getColorAccess(testCaseParams.descriptorType, "rIndex", false));
2889 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
2890 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
2891 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
2892 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
2893 case VK_DESCRIPTOR_TYPE_SAMPLER:
2894 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
2895 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
2896 if (testCaseParams.calculateInLoop)
2897 s << getFragmentLoopSource(
2898 getColorAccess(testCaseParams.descriptorType, "rIndex", testCaseParams.usesMipMaps),
2899 getColorAccess(testCaseParams.descriptorType, "loopIdx", testCaseParams.usesMipMaps));
2901 s << getFragmentReturnSource(getColorAccess(testCaseParams.descriptorType, "rIndex", testCaseParams.usesMipMaps));
2903 default: TCU_THROW(InternalError, "Not implemented descriptor type");
2908 case VK_SHADER_STAGE_COMPUTE_BIT: // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
2909 s << "void main(void)\n{\n";
2910 if (testCaseParams.calculateInLoop)
2911 s << " for (int i = pc.lowerBound; i < pc.upperBound; ++i) \n"
2912 " imageAtomicAdd(data[nonuniformEXT(texelFetch(iter, i).x)], ivec2(0, 0), 1); \n";
2914 s << " uvec4 c = imageLoad(idxs, ivec2(gl_WorkGroupID.x, gl_WorkGroupID.y)); \n"
2915 " imageAtomicAdd( data[nonuniformEXT(c.r)], ivec2(0, 0), 1); \n";
2918 default: TCU_THROW(InternalError, "Not implemented shader stage");
2921 s << getShaderEpilog();
2926 class StorageBufferInstance : virtual public CommonDescriptorInstance
2929 StorageBufferInstance (Context& context,
2930 const TestCaseParams& testCaseParams);
2932 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
2934 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
2937 StorageBufferInstance::StorageBufferInstance (Context& context,
2938 const TestCaseParams& testCaseParams)
2939 : CommonDescriptorInstance(context,
2940 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
2941 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2942 BINDING_StorageBuffer,
2943 VK_DESCRIPTOR_TYPE_UNDEFINED,
2946 performWritesInVertex(testCaseParams.descriptorType, context),
2951 void StorageBufferInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
2953 BindingStorageBuffer::Data data;
2955 bool vertexStores = false;
2957 ut::DeviceProperties dp(m_context);
2958 vertexStores = dp.physicalDeviceFeatures().vertexPipelineStoresAndAtomics != DE_FALSE;
2960 const deUint32 alignment = static_cast<deUint32>(ut::DeviceProperties(m_context).physicalDeviceProperties().limits.minStorageBufferOffsetAlignment);
2961 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, sizeof(data), alignment, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
2963 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
2964 for (deUint32 infoIdx = 0; infoIdx < variables.validDescriptorCount; ++infoIdx)
2966 const float component = m_colorScheme[infoIdx % m_schemeSize];
2967 const tcu::Vec4 color (component, component, component, 1.0f);
2968 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[infoIdx];
2969 data.cnew = vertexStores ? m_clearColor : color;
2972 deMemcpy(buffer + info.offset, &data, sizeof(data));
2974 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
2976 variables.dataAlignment = deAlign64(sizeof(data), alignment);
2979 bool StorageBufferInstance::verifyVertexWriteResults (IterateCommonVariables& variables)
2981 const tcu::Vec4 threshold (0.002f, 0.002f, 0.002f, 0.002f);
2982 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
2984 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
2985 BindingStorageBuffer::Data data;
2986 for (deUint32 primeIdx = 0; primeIdx < variables.validDescriptorCount; ++primeIdx)
2988 const deUint32 prime = primes[primeIdx];
2989 const float component = m_colorScheme[(prime % variables.validDescriptorCount) % m_schemeSize];
2990 const tcu::Vec4 referenceValue(component, component, component, 1.0f);
2992 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[primeIdx];
2993 deMemcpy(&data, buffer + info.offset, sizeof(data));
2994 const tcu::Vec4 realValue = data.cnew;
2996 const tcu::Vec4 diff = tcu::absDiff(referenceValue, realValue);
2997 if (!tcu::boolAll(tcu::lessThanEqual(diff, threshold)))
3003 class UniformBufferInstance : virtual public CommonDescriptorInstance
3006 UniformBufferInstance (Context& context,
3007 const TestCaseParams& testCaseParams);
3009 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3012 UniformBufferInstance::UniformBufferInstance (Context& context,
3013 const TestCaseParams& testCaseParams)
3014 : CommonDescriptorInstance(context,
3015 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3016 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
3017 BINDING_UniformBuffer,
3018 VK_DESCRIPTOR_TYPE_UNDEFINED,
3021 performWritesInVertex(testCaseParams.descriptorType, context),
3026 void UniformBufferInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3028 BindingUniformBuffer::Data data;
3030 const deUint32 alignment = static_cast<deUint32>(ut::DeviceProperties(m_context).physicalDeviceProperties().limits.minUniformBufferOffsetAlignment);
3031 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, sizeof(data), alignment, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
3033 unsigned char* buffer = static_cast<unsigned char*>(variables.descriptorsBuffer->alloc->getHostPtr());
3034 for (deUint32 infoIdx = 0; infoIdx < variables.validDescriptorCount; ++infoIdx)
3036 const float component = m_colorScheme[infoIdx % m_schemeSize];
3037 VkDescriptorBufferInfo& info = variables.descriptorsBufferInfos[infoIdx];
3038 data.c = tcu::Vec4(component, component, component, 1.0f);
3039 deMemcpy(buffer + info.offset, &data, sizeof(data));
3041 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3043 variables.dataAlignment = deAlign64(sizeof(data), alignment);
3046 class StorageTexelInstance : public CommonDescriptorInstance
3049 StorageTexelInstance (Context& context,
3050 const TestCaseParams& testCaseParams);
3052 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3054 virtual bool verifyVertexWriteResults (IterateCommonVariables& variables);
3057 StorageTexelInstance::StorageTexelInstance (Context& context,
3058 const TestCaseParams& testCaseParams)
3059 : CommonDescriptorInstance(context,
3060 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3061 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
3062 BINDING_StorageTexelBuffer,
3063 VK_DESCRIPTOR_TYPE_UNDEFINED,
3066 performWritesInVertex(testCaseParams.descriptorType, context),
3071 void StorageTexelInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3073 const VkExtent3D imageExtent = { 4, 4, 1 };
3074 const deUint32 imageSize = ut::computeImageSize(imageExtent, m_colorFormat);
3076 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, imageSize, sizeof(tcu::Vec4), VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT);
3077 createBuffersViews(variables.descriptorsBufferViews, variables.descriptorsBufferInfos, m_colorFormat);
3079 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3081 const float component = m_colorScheme[imageIdx % m_schemeSize];
3082 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3084 tcu::clear(pa, m_clearColor);
3085 pa.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3087 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3090 bool StorageTexelInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
3092 const VkExtent3D imageExtent = { 4, 4, 1 };
3093 const tcu::Vec4 threshold (0.002f, 0.002f, 0.002f, 0.002f);
3094 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3096 for (deUint32 primeIdx = 0; primeIdx < variables.validDescriptorCount; ++primeIdx)
3098 const deUint32 prime = primes[primeIdx];
3099 const float component = m_colorScheme[( prime % variables.validDescriptorCount ) % m_schemeSize];
3100 const tcu::Vec4 referenceValue(component, component, component, 1.0f);
3102 const PixelBufferAccess pa = getPixelAccess(primeIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3103 const tcu::Vec4 realValue = pa.getPixel(1, 0);
3105 const tcu::Vec4 diff = tcu::absDiff(referenceValue, realValue);
3106 if (!tcu::boolAll(tcu::lessThanEqual(diff, threshold)))
3112 class UniformTexelInstance : public CommonDescriptorInstance
3115 UniformTexelInstance (Context& context,
3116 const TestCaseParams& testCaseParams);
3118 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3121 UniformTexelInstance::UniformTexelInstance (Context& context,
3122 const TestCaseParams& testCaseParams)
3123 : CommonDescriptorInstance(context,
3124 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3125 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
3126 BINDING_UniformTexelBuffer,
3127 VK_DESCRIPTOR_TYPE_UNDEFINED,
3130 performWritesInVertex(testCaseParams.descriptorType, context),
3135 void UniformTexelInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3137 const VkExtent3D imageExtent = { 4, 4, 1 };
3138 const deUint32 imageSize = ut::computeImageSize(imageExtent, m_colorFormat);
3140 createBuffers(variables.descriptorsBufferInfos, variables.descriptorsBuffer, variables.validDescriptorCount, imageSize, sizeof(tcu::Vec4), VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT);
3141 createBuffersViews(variables.descriptorsBufferViews, variables.descriptorsBufferInfos, m_colorFormat);
3143 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3145 const float component = m_colorScheme[imageIdx % m_schemeSize];
3146 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3148 tcu::clear(pa, tcu::Vec4(component, component, component, 1.0f));
3150 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3153 class DynamicBuffersInstance : virtual public CommonDescriptorInstance
3156 DynamicBuffersInstance (Context& context,
3157 const TestParams& testParams)
3158 : CommonDescriptorInstance(context, testParams) {}
3161 virtual tcu::TestStatus iterate (void);
3162 virtual void updateDescriptors (IterateCommonVariables& variables);
3165 void DynamicBuffersInstance::updateDescriptors (IterateCommonVariables& variables)
3167 DE_ASSERT(variables.dataAlignment);
3169 VkDescriptorBufferInfo bufferInfo =
3171 *variables.descriptorsBuffer.get()->buffer,
3172 0, // always 0, it will be taken from pDynamicOffsets
3173 variables.dataAlignment
3176 VkWriteDescriptorSet updateInfo =
3178 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3180 *variables.descriptorSet, // descriptorSet
3181 m_testParams.descriptorBinding, // descriptorBinding;
3182 0, // to be set in below loop // dstArrayElement
3183 1u, // descriptorCount
3184 m_testParams.descriptorType, // descriptorType
3185 DE_NULL, // pImageInfo
3186 &bufferInfo, // pBufferInfo
3187 DE_NULL // pTexelBufferView
3190 deUint32 descIdx = 0;
3191 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3192 for (deUint32 validIdx = 0; validIdx < variables.validDescriptorCount; ++validIdx)
3194 for (; descIdx < primes[validIdx]; ++descIdx)
3196 updateInfo.dstArrayElement = descIdx;
3197 m_vki.updateDescriptorSets (m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3200 updateInfo.dstArrayElement = primes[validIdx];
3201 m_vki.updateDescriptorSets (m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3205 for (; descIdx < variables.availableDescriptorCount; ++descIdx)
3207 updateInfo.dstArrayElement = descIdx;
3208 m_vki.updateDescriptorSets(m_vkd, 1u, &updateInfo, 0u, DE_NULL);
3212 tcu::TestStatus DynamicBuffersInstance::iterate (void)
3214 IterateCommonVariables v;
3215 iterateCommandSetup (v);
3217 ut::UpdatablePixelBufferAccessPtr programResult;
3218 ut::UpdatablePixelBufferAccessPtr referenceResult;
3219 bool firstPass = true;
3221 DE_ASSERT(v.dataAlignment);
3223 std::vector<deUint32> dynamicOffsets;
3225 deUint32 descIdx = 0;
3226 const std::vector<deUint32> primes = ut::generatePrimes(v.availableDescriptorCount);
3227 for (deUint32 validIdx = 0; validIdx < v.validDescriptorCount; ++validIdx)
3229 for (; descIdx < primes[validIdx]; ++descIdx)
3231 dynamicOffsets.push_back(0);
3234 dynamicOffsets.push_back(static_cast<deUint32>(validIdx * v.dataAlignment));
3238 for (; descIdx < v.availableDescriptorCount; ++descIdx)
3240 dynamicOffsets.push_back(0);
3243 // Unfortunatelly not lees and not more, only exactly
3244 DE_ASSERT(dynamicOffsets.size() == v.availableDescriptorCount);
3246 const VkDescriptorSet descriptorSets[] = { *v.descriptorSet };
3248 v.renderArea.extent.width = m_testParams.frameResolution.width/4;
3249 v.renderArea.extent.height = m_testParams.frameResolution.height/4;
3251 for (int x = 0; x < 4; x++)
3252 for (int y= 0; y < 4; y++)
3255 v.renderArea.offset.x = x * m_testParams.frameResolution.width/4;
3256 v.renderArea.offset.y = y * m_testParams.frameResolution.height/4;
3258 iterateCommandBegin (v, firstPass);
3261 m_vki.cmdBindDescriptorSets(
3262 *v.commandBuffer, // commandBuffer
3263 VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
3264 *v.pipelineLayout, // layout
3266 DE_LENGTH_OF_ARRAY(descriptorSets), // descriptorSetCount
3267 descriptorSets, // pDescriptorSets
3268 v.availableDescriptorCount, // dynamicOffsetCount
3269 dynamicOffsets.data()); // pDynamicOffsets
3271 vk::VkRect2D scissor = makeRect2D(v.renderArea.offset.x, v.renderArea.offset.y, v.renderArea.extent.width, v.renderArea.extent.height);
3272 m_vki.cmdSetScissor(*v.commandBuffer, 0u, 1u, &scissor);
3274 vk::beginRenderPass (m_vki, *v.commandBuffer, *v.renderPass, *v.frameBuffer->buffer, v.renderArea, m_clearColor);
3275 m_vki.cmdDraw (*v.commandBuffer, v.vertexCount, 1u, 0u, 0u);
3276 vk::endRenderPass (m_vki, *v.commandBuffer);
3278 iterateCommandEnd(v, programResult, referenceResult);
3279 programResult->invalidate();
3282 return (iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
3285 class DynamicStorageBufferInstance : public DynamicBuffersInstance, public StorageBufferInstance
3288 DynamicStorageBufferInstance (Context& context,
3289 const TestCaseParams& testCaseParams);
3290 tcu::TestStatus iterate (void);
3291 void createAndPopulateDescriptors (IterateCommonVariables& variables);
3292 void updateDescriptors (IterateCommonVariables& variables);
3293 bool verifyVertexWriteResults (IterateCommonVariables& variables);
3296 DynamicStorageBufferInstance::DynamicStorageBufferInstance (Context& context,
3297 const TestCaseParams& testCaseParams)
3298 : CommonDescriptorInstance(context,
3299 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3300 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
3301 BINDING_StorageBufferDynamic,
3302 VK_DESCRIPTOR_TYPE_UNDEFINED,
3305 performWritesInVertex(testCaseParams.descriptorType, context),
3307 DynamicBuffersInstance(context, m_testParams), StorageBufferInstance(context, testCaseParams)
3311 tcu::TestStatus DynamicStorageBufferInstance::iterate(void)
3313 return DynamicBuffersInstance::iterate();
3316 void DynamicStorageBufferInstance::createAndPopulateDescriptors(IterateCommonVariables& variables)
3318 StorageBufferInstance::createAndPopulateDescriptors(variables);
3321 void DynamicStorageBufferInstance::updateDescriptors(IterateCommonVariables& variables)
3323 DynamicBuffersInstance::updateDescriptors(variables);
3326 bool DynamicStorageBufferInstance::verifyVertexWriteResults(IterateCommonVariables& variables)
3328 return StorageBufferInstance::verifyVertexWriteResults(variables);
3331 class DynamicUniformBufferInstance : public DynamicBuffersInstance, public UniformBufferInstance
3334 DynamicUniformBufferInstance (Context& context,
3335 const TestCaseParams& testCaseParams);
3336 tcu::TestStatus iterate(void);
3337 void createAndPopulateDescriptors(IterateCommonVariables& variables);
3338 void updateDescriptors(IterateCommonVariables& variables);
3341 DynamicUniformBufferInstance::DynamicUniformBufferInstance (Context& context,
3342 const TestCaseParams& testCaseParams)
3343 : CommonDescriptorInstance(context,
3344 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3345 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
3346 BINDING_UniformBufferDynamic,
3347 VK_DESCRIPTOR_TYPE_UNDEFINED,
3350 performWritesInVertex(testCaseParams.descriptorType, context),
3352 DynamicBuffersInstance(context, m_testParams), UniformBufferInstance(context, testCaseParams)
3356 tcu::TestStatus DynamicUniformBufferInstance::iterate(void)
3358 return DynamicBuffersInstance::iterate();
3361 void DynamicUniformBufferInstance::createAndPopulateDescriptors(IterateCommonVariables& variables)
3363 UniformBufferInstance::createAndPopulateDescriptors(variables);
3366 void DynamicUniformBufferInstance::updateDescriptors(IterateCommonVariables& variables)
3368 DynamicBuffersInstance::updateDescriptors(variables);
3371 class InputAttachmentInstance : public CommonDescriptorInstance
3374 InputAttachmentInstance (Context& context,
3375 const TestCaseParams& testCaseParams);
3377 virtual Move<VkRenderPass> createRenderPass (const IterateCommonVariables& variables);
3378 virtual void createFramebuffer (ut::FrameBufferSp& frameBuffer,
3379 VkRenderPass renderPass,
3380 const IterateCommonVariables& variables);
3381 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3384 InputAttachmentInstance::InputAttachmentInstance (Context& context,
3385 const TestCaseParams& testCaseParams)
3386 : CommonDescriptorInstance(context,
3387 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3388 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
3389 BINDING_InputAttachment,
3390 VK_DESCRIPTOR_TYPE_UNDEFINED,
3393 performWritesInVertex(testCaseParams.descriptorType, context),
3398 void InputAttachmentInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3400 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3401 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, m_testParams.frameResolution, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount);
3402 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3404 for (deUint32 descriptorIdx = 0; descriptorIdx < variables.validDescriptorCount; ++descriptorIdx)
3406 const float component = m_colorScheme[descriptorIdx % m_schemeSize];
3407 const tcu::PixelBufferAccess pa = getPixelAccess(descriptorIdx, m_testParams.frameResolution, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3408 tcu::clear(pa, tcu::Vec4(component, component, component, 1.0f));
3410 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3413 Move<VkRenderPass> InputAttachmentInstance::createRenderPass (const IterateCommonVariables& variables)
3415 std::vector<VkAttachmentDescription> attachmentDescriptions;
3416 std::vector<VkAttachmentReference> inputAttachmentRefs;
3418 const VkAttachmentDescription colorAttachmentDescription =
3420 (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags;
3421 m_colorFormat, // VkFormat format;
3422 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
3423 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
3424 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
3425 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
3426 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
3427 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout;
3428 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout finalLayout;
3430 const VkAttachmentReference colorAttachmentRef =
3432 0u, // deUint32 attachment;
3433 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout;
3435 attachmentDescriptions.push_back(colorAttachmentDescription);
3437 // build input atachments
3439 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3440 const deUint32 inputCount = static_cast<deUint32>(variables.descriptorImageViews.size());
3441 for (deUint32 inputIdx = 0; inputIdx < inputCount; ++inputIdx)
3443 // primes holds the indices of input attachments for shader binding 10 which has input_attachment_index=1
3444 deUint32 nextInputAttachmentIndex = primes[inputIdx] + 1;
3446 // Fill up the subpass description's input attachments with unused attachments forming gaps to the next referenced attachment
3447 for (deUint32 unusedIdx = static_cast<deUint32>(inputAttachmentRefs.size()); unusedIdx < nextInputAttachmentIndex; ++unusedIdx)
3449 const VkAttachmentReference inputAttachmentRef =
3451 VK_ATTACHMENT_UNUSED, // deUint32 attachment;
3452 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout layout;
3455 inputAttachmentRefs.push_back(inputAttachmentRef);
3458 const VkAttachmentDescription inputAttachmentDescription =
3460 VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT, // VkAttachmentDescriptionFlags flags;
3461 variables.descriptorsImages[inputIdx]->format, // VkFormat format;
3462 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
3463 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
3464 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
3465 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp;
3466 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp;
3467 VK_IMAGE_LAYOUT_GENERAL, // VkImageLayout initialLayout;
3468 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout finalLayout;
3471 const VkAttachmentReference inputAttachmentRef =
3473 inputIdx + 1, // deUint32 attachment;
3474 VK_IMAGE_LAYOUT_GENERAL // VkImageLayout layout;
3477 inputAttachmentRefs.push_back(inputAttachmentRef);
3478 attachmentDescriptions.push_back(inputAttachmentDescription);
3482 const VkSubpassDescription subpassDescription =
3484 (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags;
3485 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
3486 static_cast<deUint32>(inputAttachmentRefs.size()), // deUint32 inputAttachmentCount;
3487 inputAttachmentRefs.data(), // const VkAttachmentReference* pInputAttachments;
3488 1u, // deUint32 colorAttachmentCount;
3489 &colorAttachmentRef, // const VkAttachmentReference* pColorAttachments;
3490 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
3491 DE_NULL, // const VkAttachmentReference* pDepthStencilAttachment;
3492 0u, // deUint32 preserveAttachmentCount;
3493 DE_NULL // const deUint32* pPreserveAttachments;
3496 const VkRenderPassCreateInfo renderPassInfo =
3498 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
3499 DE_NULL, // const void* pNext;
3500 (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags;
3501 static_cast<deUint32>(attachmentDescriptions.size()), // deUint32 attachmentCount;
3502 attachmentDescriptions.data(), // const VkAttachmentDescription* pAttachments;
3503 1u, // deUint32 subpassCount;
3504 &subpassDescription, // const VkSubpassDescription* pSubpasses;
3505 0u, // deUint32 dependencyCount;
3506 DE_NULL // const VkSubpassDependency* pDependencies;
3509 return vk::createRenderPass(m_vki, m_vkd, &renderPassInfo);
3512 void InputAttachmentInstance::createFramebuffer (ut::FrameBufferSp& frameBuffer,
3513 VkRenderPass renderPass,
3514 const IterateCommonVariables& variables)
3516 std::vector<VkImageView> inputAttachments;
3517 const deUint32 viewCount = static_cast<deUint32>(variables.descriptorImageViews.size());
3518 inputAttachments.resize(viewCount);
3519 for (deUint32 viewIdx = 0; viewIdx < viewCount; ++viewIdx)
3521 inputAttachments[viewIdx] = **variables.descriptorImageViews[viewIdx];
3523 ut::createFrameBuffer(frameBuffer, m_context, m_testParams.frameResolution, m_colorFormat, renderPass, viewCount, inputAttachments.data());
3526 class SamplerInstance : public CommonDescriptorInstance
3529 SamplerInstance (Context& context,
3530 const TestCaseParams& testCaseParams);
3532 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3533 virtual void updateDescriptors (IterateCommonVariables& variables);
3536 SamplerInstance::SamplerInstance (Context& context,
3537 const TestCaseParams& testCaseParams)
3538 : CommonDescriptorInstance(context,
3539 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3540 VK_DESCRIPTOR_TYPE_SAMPLER,
3542 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
3543 BINDING_SampledImage,
3545 performWritesInVertex(testCaseParams.descriptorType, context),
3550 void SamplerInstance::updateDescriptors (IterateCommonVariables& variables)
3552 DE_ASSERT(variables.descriptorsImages.size() == 1);
3553 DE_ASSERT(variables.descriptorImageViews.size() == 1);
3554 DE_ASSERT(variables.descriptorsBufferInfos.size() == 1);
3555 DE_ASSERT(m_testParams.additionalDescriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
3556 DE_ASSERT(variables.descriptorSamplers.size() == variables.validDescriptorCount);
3560 const VkDescriptorImageInfo imageInfo =
3562 static_cast<VkSampler>(0),
3563 **variables.descriptorImageViews[0],
3564 VK_IMAGE_LAYOUT_GENERAL
3567 const VkWriteDescriptorSet writeInfo =
3569 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3571 *variables.descriptorSet, // descriptorSet
3572 BINDING_SampledImage, // descriptorBinding;
3574 1u, // descriptorCount
3575 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, // descriptorType
3576 &imageInfo, // pImageInfo
3577 DE_NULL, // pBufferInfo
3578 DE_NULL // pTexelBufferView
3581 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3585 CommonDescriptorInstance::updateDescriptors(variables);
3588 void SamplerInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3590 DE_ASSERT(variables.descriptorsImages.size() == 0);
3591 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3592 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3593 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3595 // create and populate an image
3597 VkExtent3D imageExtent = m_testParams.frameResolution;
3598 if (m_testParams.usesMipMaps)
3600 imageExtent.width *= 2;
3601 imageExtent.height *= 2;
3604 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3605 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, 1, m_testParams.usesMipMaps);
3606 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3608 PixelBufferAccess pa = getPixelAccess(0, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, m_testParams.usesMipMaps ? 1 : 0);
3610 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
3612 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
3614 const float component = m_colorScheme[(pixelNum % variables.validDescriptorCount) % m_schemeSize];
3615 pa.setPixel(tcu::Vec4(component, component, component, 1.0f), x, y);
3619 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3622 const tcu::Sampler sampler(
3623 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3624 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3625 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3626 m_testParams.usesMipMaps ? tcu::Sampler::LINEAR_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3627 m_testParams.usesMipMaps ? tcu::Sampler::LINEAR_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3628 0.0f, // lodTreshold
3629 true); // normalizeCoords
3630 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3631 variables.descriptorSamplers.resize(variables.validDescriptorCount);
3633 for (deUint32 samplerIdx = 0; samplerIdx < variables.validDescriptorCount; ++samplerIdx)
3635 variables.descriptorSamplers[samplerIdx] = ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo)));
3639 class SampledImageInstance : public CommonDescriptorInstance
3642 SampledImageInstance (Context& context,
3643 const TestCaseParams& testCaseParams);
3645 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3646 virtual void updateDescriptors (IterateCommonVariables& variables);
3649 SampledImageInstance::SampledImageInstance (Context& context,
3650 const TestCaseParams& testCaseParams)
3651 : CommonDescriptorInstance(context,
3652 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3653 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
3654 BINDING_SampledImage,
3655 VK_DESCRIPTOR_TYPE_SAMPLER,
3658 performWritesInVertex(testCaseParams.descriptorType, context),
3663 void SampledImageInstance::updateDescriptors (IterateCommonVariables& variables)
3665 DE_ASSERT(variables.descriptorSamplers.size() == 1);
3666 DE_ASSERT(variables.descriptorsImages.size() == variables.validDescriptorCount);
3667 DE_ASSERT(variables.descriptorImageViews.size() == variables.validDescriptorCount);
3668 DE_ASSERT(variables.descriptorsBufferInfos.size() == variables.validDescriptorCount);
3672 const VkDescriptorImageInfo samplerInfo =
3674 **variables.descriptorSamplers[0],
3675 static_cast<VkImageView>(0),
3676 static_cast<VkImageLayout>(0)
3679 const VkWriteDescriptorSet writeInfo =
3681 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3683 *variables.descriptorSet, // descriptorSet
3684 BINDING_Sampler, // descriptorBinding;
3686 1u, // descriptorCount
3687 VK_DESCRIPTOR_TYPE_SAMPLER, // descriptorType
3688 &samplerInfo, // pImageInfo
3689 DE_NULL, // pBufferInfo
3690 DE_NULL // pTexelBufferView
3693 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3697 CommonDescriptorInstance::updateDescriptors(variables);
3700 void SampledImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3702 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3703 DE_ASSERT(variables.descriptorsImages.size() == 0);
3704 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3705 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3707 // create an only one sampler for all images
3709 const tcu::Sampler sampler(
3710 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3711 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3712 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3713 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3714 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3715 0.0f, // lodTreshold
3716 true); // normalizeCoords
3717 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3718 variables.descriptorSamplers.push_back(ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo))));
3721 const VkExtent3D& imageExtent = m_testParams.usesMipMaps ? bigImageExtent : smallImageExtent;
3723 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3724 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount, m_testParams.usesMipMaps);
3725 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3727 PixelBufferAccess pixelAccess;
3728 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3730 const float component = m_colorScheme[imageIdx % m_schemeSize];
3732 if (m_testParams.usesMipMaps)
3734 const deUint32 mipCount = ut::computeMipMapCount(imageExtent);
3735 DE_ASSERT(mipCount >= 2);
3736 for (deUint32 mipIdx = 0; mipIdx < mipCount; ++mipIdx)
3738 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipIdx);
3739 tcu::clear(pixelAccess, m_clearColor);
3742 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipCount-1);
3743 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3747 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, 0);
3748 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3751 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3754 class CombinedImageInstance : public CommonDescriptorInstance
3757 CombinedImageInstance (Context& context,
3758 const TestCaseParams& testCaseParams);
3760 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3761 virtual void updateDescriptors (IterateCommonVariables& variables);
3764 CombinedImageInstance::CombinedImageInstance (Context& context,
3765 const TestCaseParams& testCaseParams)
3766 : CommonDescriptorInstance(context,
3767 TestParams(VK_SHADER_STAGE_ALL_GRAPHICS,
3768 testCaseParams.descriptorType,
3769 BINDING_CombinedImageSampler,
3770 VK_DESCRIPTOR_TYPE_UNDEFINED,
3773 performWritesInVertex(testCaseParams.descriptorType),
3778 void CombinedImageInstance::updateDescriptors (IterateCommonVariables& variables)
3780 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3781 const deUint32 primeCount = static_cast<deUint32>(primes.size());
3783 DE_ASSERT(variables.descriptorSamplers.size() == 1);
3784 DE_ASSERT(variables.descriptorsImages.size() == primeCount);
3785 DE_ASSERT(variables.descriptorImageViews.size() == primeCount);
3786 DE_ASSERT(variables.descriptorsBufferInfos.size() == primeCount);
3788 for (deUint32 primeIdx = 0; primeIdx < primeCount; ++primeIdx)
3790 const VkDescriptorImageInfo imageInfo =
3792 **variables.descriptorSamplers[0],
3793 **variables.descriptorImageViews[primeIdx],
3794 VK_IMAGE_LAYOUT_GENERAL
3797 const VkWriteDescriptorSet writeInfo =
3799 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3801 *variables.descriptorSet, // descriptorSet
3802 BINDING_CombinedImageSampler, // descriptorBinding;
3803 primes[primeIdx], // elementIndex
3804 1u, // descriptorCount
3805 m_testParams.descriptorType, // descriptorType
3806 &imageInfo, // pImageInfo
3807 DE_NULL, // pBufferInfo
3808 DE_NULL // pTexelBufferView
3811 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3815 void CombinedImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3817 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3818 DE_ASSERT(variables.descriptorsImages.size() == 0);
3819 DE_ASSERT(variables.descriptorImageViews.size() == 0);
3820 DE_ASSERT(variables.descriptorsBufferInfos.size() == 0);
3821 DE_ASSERT(variables.descriptorSamplers.size() == 0);
3823 const tcu::Sampler sampler(
3824 tcu::Sampler::CLAMP_TO_BORDER, // wrapS
3825 tcu::Sampler::CLAMP_TO_BORDER, // wrapT
3826 tcu::Sampler::CLAMP_TO_BORDER, // wrapR
3827 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // minFilter
3828 m_testParams.usesMipMaps ? tcu::Sampler::NEAREST_MIPMAP_NEAREST : tcu::Sampler::NEAREST, // magFilter
3829 0.0f, // lodTreshold
3830 true); // normalizeCoords
3831 const VkSamplerCreateInfo createInfo = vk::mapSampler(sampler, vk::mapVkFormat(m_colorFormat));
3832 variables.descriptorSamplers.push_back(ut::SamplerSp(new Move<VkSampler>(vk::createSampler(m_vki, m_vkd, &createInfo))));
3834 const VkExtent3D& imageExtent = m_testParams.usesMipMaps ? bigImageExtent : smallImageExtent;
3835 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
3836 imageExtent, m_colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount, m_testParams.usesMipMaps);
3837 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, m_colorFormat);
3839 PixelBufferAccess pixelAccess;
3840 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3842 const float component = m_colorScheme[imageIdx % m_schemeSize];
3844 if (m_testParams.usesMipMaps)
3846 const deUint32 mipCount = ut::computeMipMapCount(imageExtent);
3847 DE_ASSERT(mipCount >= 2);
3848 for (deUint32 mipIdx = 0; mipIdx < mipCount; ++mipIdx)
3850 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipIdx);
3851 tcu::clear(pixelAccess, m_clearColor);
3854 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, mipCount-1);
3855 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3859 pixelAccess = getPixelAccess(imageIdx, imageExtent, m_colorFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer, 0);
3860 pixelAccess.setPixel(tcu::Vec4(component, component, component, 1.0f), 0, 0);
3864 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3867 class StorageImageInstance : public CommonDescriptorInstance
3870 StorageImageInstance (Context& context,
3871 const TestCaseParams& testCaseParams);
3873 virtual tcu::TestStatus iterate (void);
3874 virtual void createAndPopulateDescriptors (IterateCommonVariables& variables);
3875 virtual void updateDescriptors (IterateCommonVariables& variables);
3876 virtual void iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
3877 const IterateCommonVariables& variables,
3879 ut::BufferHandleAllocSp m_buffer;
3880 const deUint32 m_fillColor;
3881 typedef deUint32 m_imageFormat_t;
3884 StorageImageInstance::StorageImageInstance (Context& context,
3885 const TestCaseParams& testCaseParams)
3886 : CommonDescriptorInstance(context,
3887 TestParams (VK_SHADER_STAGE_COMPUTE_BIT,
3888 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
3889 BINDING_StorageImage,
3890 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
3891 (BINDING_StorageImage + 1),
3893 performWritesInVertex(testCaseParams.descriptorType, context),
3900 void StorageImageInstance::updateDescriptors (IterateCommonVariables& variables)
3902 // update image at last index
3904 VkDescriptorImageInfo imageInfo =
3906 static_cast<VkSampler>(0),
3907 **variables.descriptorImageViews[variables.validDescriptorCount],
3908 VK_IMAGE_LAYOUT_GENERAL
3911 const VkWriteDescriptorSet writeInfo =
3913 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // sType
3915 *variables.descriptorSet, // descriptorSet
3916 m_testParams.additionalDescriptorBinding, // descriptorBinding;
3918 1u, // descriptorCount
3919 m_testParams.additionalDescriptorType, // descriptorType
3920 &imageInfo, // pImageInfo
3921 DE_NULL, // pBufferInfo
3922 DE_NULL // pTexelBufferView
3925 m_vki.updateDescriptorSets(m_vkd, 1u, &writeInfo, 0u, DE_NULL);
3928 // update rest images
3929 CommonDescriptorInstance::updateDescriptors(variables);
3932 void StorageImageInstance::createAndPopulateDescriptors (IterateCommonVariables& variables)
3934 const VkFormat imageFormat = ut::mapType2vkFormat<m_imageFormat_t>::value;
3935 const VkBufferUsageFlags bufferUsage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
3937 // create descriptor buffer, images and views
3939 const VkExtent3D imageExtent = { 4, 4, 1 };
3941 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, variables.descriptorsBuffer,
3942 bufferUsage, imageExtent, imageFormat, VK_IMAGE_LAYOUT_UNDEFINED, variables.validDescriptorCount);
3944 for (deUint32 imageIdx = 0; imageIdx < variables.validDescriptorCount; ++imageIdx)
3946 const PixelBufferAccess pa = getPixelAccess(imageIdx, imageExtent, imageFormat, variables.descriptorsBufferInfos, variables.descriptorsBuffer);
3947 tcu::clear(pa, tcu::UVec4(m_fillColor));
3949 vk::flushAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
3952 // create additional image that will be used as index container
3954 createImages(variables.descriptorsImages, variables.descriptorsBufferInfos, m_buffer,
3955 bufferUsage, m_testParams.frameResolution, imageFormat, VK_IMAGE_LAYOUT_UNDEFINED, 1);
3958 const std::vector<deUint32> primes = ut::generatePrimes(variables.availableDescriptorCount);
3959 const PixelBufferAccess pa = getPixelAccess(variables.validDescriptorCount, m_testParams.frameResolution, imageFormat, variables.descriptorsBufferInfos, m_buffer);
3960 for (deUint32 y = 0, pixel = 0; y < m_testParams.frameResolution.height; ++y)
3962 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixel)
3964 const deUint32 component = primes[pixel % variables.validDescriptorCount];
3965 pa.setPixel(tcu::UVec4(component), x, y);
3970 vk::flushAlloc(m_vki, m_vkd, *m_buffer->alloc);
3973 // create views for all previously created images
3974 createImagesViews(variables.descriptorImageViews, variables.descriptorsImages, imageFormat);
3977 tcu::TestStatus StorageImageInstance::iterate (void)
3979 IterateCommonVariables v;
3980 iterateCommandSetup (v);
3981 iterateCommandBegin (v);
3983 ut::UpdatablePixelBufferAccessPtr programResult;
3984 ut::UpdatablePixelBufferAccessPtr referenceResult;
3986 if (m_testParams.updateAfterBind)
3988 updateDescriptors (v);
3991 copyBuffersToImages (v);
3993 m_vki.cmdDispatch (*v.commandBuffer,
3994 m_testParams.calculateInLoop ? 1 : v.renderArea.extent.width,
3995 m_testParams.calculateInLoop ? 1 : v.renderArea.extent.height,
3998 copyImagesToBuffers (v);
4000 iterateCommandEnd(v, programResult, referenceResult, false);
4002 return ( iterateVerifyResults(v, programResult, referenceResult) ? tcu::TestStatus::pass : tcu::TestStatus::fail)("");
4005 void StorageImageInstance::iterateCollectResults (ut::UpdatablePixelBufferAccessPtr& result,
4006 const IterateCommonVariables& variables,
4009 result = ut::UpdatablePixelBufferAccessPtr(new ut::PixelBufferAccessAllocation(
4010 vk::mapVkFormat(ut::mapType2vkFormat<m_imageFormat_t>::value), m_testParams.frameResolution));
4011 const PixelBufferAccess& dst = *result.get();
4015 vk::invalidateAlloc(m_vki, m_vkd, *variables.descriptorsBuffer->alloc);
4016 for (deUint32 y = 0, pixelNum = 0; y < m_testParams.frameResolution.height; ++y)
4018 for (deUint32 x = 0; x < m_testParams.frameResolution.width; ++x, ++pixelNum)
4020 const deUint32 imageIdx = pixelNum % variables.validDescriptorCount;
4021 const PixelBufferAccess src = getPixelAccess(imageIdx,
4022 variables.descriptorsImages[imageIdx]->extent, variables.descriptorsImages[imageIdx]->format,
4023 variables.descriptorsBufferInfos, variables.descriptorsBuffer);
4024 dst.setPixel(tcu::Vector<m_imageFormat_t, 4>(src.getPixelT<m_imageFormat_t>(0, 0).x()), x, y);
4030 std::vector<m_imageFormat_t> inc(variables.validDescriptorCount, m_fillColor);
4032 for (deUint32 invIdx = variables.lowerBound; invIdx < variables.upperBound; ++invIdx)
4034 ++inc[invIdx % variables.validDescriptorCount];
4037 for (deUint32 invIdx = 0; invIdx < variables.vertexCount; ++invIdx)
4039 const deUint32 row = invIdx / m_testParams.frameResolution.width;
4040 const deUint32 col = invIdx % m_testParams.frameResolution.width;
4041 const m_imageFormat_t color = inc[invIdx % variables.validDescriptorCount];
4042 dst.setPixel(tcu::Vector<m_imageFormat_t, 4>(color), col, row);
4047 class DescriptorIndexingTestCase : public TestCase
4049 const TestCaseParams m_testCaseParams;
4051 DescriptorIndexingTestCase (tcu::TestContext &context, const char *name, const char *description, const TestCaseParams& testCaseParams)
4052 : TestCase(context, name, description)
4053 , m_testCaseParams(testCaseParams)
4057 vkt::TestInstance* createInstance (vkt::Context& context) const // override
4059 switch (m_testCaseParams.descriptorType)
4061 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
4062 return new StorageBufferInstance (context, m_testCaseParams);
4063 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
4064 return new UniformBufferInstance (context, m_testCaseParams);
4065 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
4066 return new StorageTexelInstance (context, m_testCaseParams);
4067 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
4068 return new UniformTexelInstance (context, m_testCaseParams);
4069 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4070 return new DynamicStorageBufferInstance (context, m_testCaseParams);
4071 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4072 return new DynamicUniformBufferInstance (context, m_testCaseParams);
4073 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
4074 return new InputAttachmentInstance (context, m_testCaseParams);
4075 case VK_DESCRIPTOR_TYPE_SAMPLER:
4076 return new SamplerInstance (context, m_testCaseParams);
4077 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
4078 return new SampledImageInstance (context, m_testCaseParams);
4079 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
4080 return new CombinedImageInstance (context, m_testCaseParams);
4081 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
4082 return new StorageImageInstance (context, m_testCaseParams);
4084 TCU_THROW(InternalError, "Unknown Descriptor Type");
4089 virtual void checkSupport (vkt::Context& context) const
4091 context.requireDeviceFunctionality("VK_EXT_descriptor_indexing");
4093 const vk::VkPhysicalDeviceDescriptorIndexingFeaturesEXT& feats = context.getDescriptorIndexingFeatures();
4095 switch (m_testCaseParams.descriptorType)
4097 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
4098 if (!(feats.shaderStorageBufferArrayNonUniformIndexing))
4099 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage buffer descriptor arrays is not supported.");
4101 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageBufferUpdateAfterBind)
4102 TCU_THROW(NotSupportedError, "Update after bind for storage buffer descriptors is not supported.");
4104 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
4105 if (!(feats.shaderUniformBufferArrayNonUniformIndexing))
4106 TCU_THROW(NotSupportedError, "Non-uniform indexing for uniform buffer descriptor arrays is not supported.");
4108 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingUniformBufferUpdateAfterBind)
4109 TCU_THROW(NotSupportedError, "Update after bind for uniform buffer descriptors is not supported.");
4111 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
4112 if (!(feats.shaderStorageTexelBufferArrayNonUniformIndexing))
4113 TCU_THROW(NotSupportedError, "Non-uniform indexing for storage texel buffer descriptor arrays is not supported.");
4115 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageTexelBufferUpdateAfterBind)
4116 TCU_THROW(NotSupportedError, "Update after bind for storage texel buffer descriptors is not supported.");
4118 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
4119 if (!(feats.shaderUniformTexelBufferArrayNonUniformIndexing))
4120 TCU_THROW(NotSupportedError, "Non-uniform indexing for uniform texel buffer descriptor arrays is not supported.");
4122 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingUniformTexelBufferUpdateAfterBind)
4123 TCU_THROW(NotSupportedError, "Update after bind for uniform texel buffer descriptors is not supported.");
4125 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4126 if (!(feats.shaderStorageBufferArrayNonUniformIndexing))
4127 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage buffer dynamic descriptor arrays is not supported.");
4129 if (m_testCaseParams.updateAfterBind)
4130 TCU_THROW(NotSupportedError, "Update after bind for storage buffer dynamic descriptors is not supported.");
4132 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4133 if (!(feats.shaderUniformBufferArrayNonUniformIndexing))
4134 TCU_THROW(NotSupportedError, "Non-uniform indexing over uniform buffer dynamic descriptor arrays is not supported.");
4136 if (m_testCaseParams.updateAfterBind)
4137 TCU_THROW(NotSupportedError, "Update after bind for uniform buffer dynamic descriptors is not supported.");
4139 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
4140 if (!(feats.shaderInputAttachmentArrayNonUniformIndexing))
4141 TCU_THROW(NotSupportedError, "Non-uniform indexing over input attachment descriptor arrays is not supported.");
4143 if (m_testCaseParams.updateAfterBind)
4144 TCU_THROW(NotSupportedError, "Update after bind for input attachment descriptors is not supported.");
4146 case VK_DESCRIPTOR_TYPE_SAMPLER:
4147 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4148 TCU_THROW(NotSupportedError, "Non-uniform indexing over sampler descriptor arrays is not supported.");
4150 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4151 TCU_THROW(NotSupportedError, "Update after bind for sampler descriptors is not supported.");
4153 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
4154 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4155 TCU_THROW(NotSupportedError, "Non-uniform indexing over sampled image descriptor arrays is not supported.");
4157 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4158 TCU_THROW(NotSupportedError, "Update after bind for sampled image descriptors is not supported.");
4160 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
4161 if (!(feats.shaderSampledImageArrayNonUniformIndexing))
4162 TCU_THROW(NotSupportedError, "Non-uniform indexing over combined image sampler descriptor arrays is not supported.");
4164 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingSampledImageUpdateAfterBind)
4165 TCU_THROW(NotSupportedError, "Update after bind for combined image sampler descriptors is not supported.");
4167 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
4168 if (!(feats.shaderStorageImageArrayNonUniformIndexing))
4169 TCU_THROW(NotSupportedError, "Non-uniform indexing over storage image descriptor arrays is not supported.");
4171 if (m_testCaseParams.updateAfterBind && !feats.descriptorBindingStorageImageUpdateAfterBind)
4172 TCU_THROW(NotSupportedError, "Update after bind for storage image descriptors is not supported.");
4175 DE_FATAL("Unknown Descriptor Type");
4180 void initAsmPrograms(SourceCollections& programCollection) const
4183 std::string(*genShaderSource)(VkShaderStageFlagBits, const TestCaseParams&, bool) = &CommonDescriptorInstance::getShaderAsm;
4185 deUint32 vulkan_version = VK_MAKE_VERSION(1, 2, 0);
4186 vk::SpirvVersion spirv_version = vk::SPIRV_VERSION_1_4;
4187 vk::SpirVAsmBuildOptions asm_options(vulkan_version, spirv_version);
4189 if (VK_SHADER_STAGE_VERTEX_BIT & m_testCaseParams.stageFlags)
4191 programCollection.spirvAsmSources.add(
4192 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4193 << (*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, false);
4195 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4197 programCollection.spirvAsmSources.add(
4198 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true), &asm_options)
4199 << (*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, true);
4202 if (VK_SHADER_STAGE_FRAGMENT_BIT & m_testCaseParams.stageFlags)
4204 programCollection.spirvAsmSources.add(
4205 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4206 << (*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, false);
4208 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4210 programCollection.spirvAsmSources.add(
4211 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true), &asm_options)
4212 << (*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, true);
4215 if (VK_SHADER_STAGE_COMPUTE_BIT & m_testCaseParams.stageFlags)
4217 programCollection.spirvAsmSources.add(
4218 ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false), &asm_options)
4219 << (*genShaderSource)(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams, false);
4223 virtual void initPrograms (SourceCollections& programCollection) const
4225 if (m_testCaseParams.minNonUniform) {
4226 initAsmPrograms(programCollection);
4230 std::string(*genShaderSource)(VkShaderStageFlagBits, const TestCaseParams&, bool) = &CommonDescriptorInstance::getShaderSource;
4232 if (VK_SHADER_STAGE_VERTEX_BIT & m_testCaseParams.stageFlags)
4234 programCollection.glslSources.add(
4235 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4236 << glu::VertexSource((*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, false));
4238 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4240 programCollection.glslSources.add(
4241 ut::buildShaderName(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true))
4242 << glu::VertexSource((*genShaderSource)(VK_SHADER_STAGE_VERTEX_BIT, m_testCaseParams, true));
4245 if (VK_SHADER_STAGE_FRAGMENT_BIT & m_testCaseParams.stageFlags)
4247 programCollection.glslSources.add(
4248 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4249 << glu::FragmentSource((*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, false));
4251 if (CommonDescriptorInstance::performWritesInVertex(m_testCaseParams.descriptorType))
4253 programCollection.glslSources.add(
4254 ut::buildShaderName(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, true))
4255 << glu::FragmentSource((*genShaderSource)(VK_SHADER_STAGE_FRAGMENT_BIT, m_testCaseParams, true));
4258 if (VK_SHADER_STAGE_COMPUTE_BIT & m_testCaseParams.stageFlags)
4260 programCollection.glslSources.add(
4261 ut::buildShaderName(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams.descriptorType, m_testCaseParams.updateAfterBind, m_testCaseParams.calculateInLoop, m_testCaseParams.minNonUniform, false))
4262 << glu::ComputeSource((*genShaderSource)(VK_SHADER_STAGE_COMPUTE_BIT, m_testCaseParams, false));
4267 } // - unnamed namespace
4269 void descriptorIndexingDescriptorSetsCreateTests (tcu::TestCaseGroup* group)
4274 const char* description;
4275 TestCaseParams params;
4278 tcu::TestContext& context(group->getTestContext());
4280 TestCaseInfo casesAfterBindAndLoop[] =
4283 "storage_buffer", "Regular Storage Buffer Descriptors",
4285 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4286 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4288 false, // updateAfterBind
4289 false, // calculateInLoop
4290 false, // useMipMaps
4291 false, // minNonUniform
4292 FUZZY_COMPARE, CMP_THRESHOLD
4296 "storage_texel_buffer", "Storage Texel Buffer Descriptors",
4298 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4299 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4301 false, // updateAfterBind
4302 false, // calculateInLoop
4303 false, // useMipMaps
4304 false, // minNonUniform
4305 FUZZY_COMPARE, CMP_THRESHOLD
4309 "uniform_texel_buffer", "Uniform Texel Buffer Descriptors",
4311 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4312 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4314 false, // updateAfterBind,
4315 false, // calculateInLoop
4316 false, // usesMipMaps
4317 false, // minNonUniform
4318 FUZZY_COMPARE, CMP_THRESHOLD
4322 "storage_image", "Storage Image Descriptors",
4324 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4325 VK_SHADER_STAGE_COMPUTE_BIT,
4327 false, // updateAfterBind
4328 false, // calculateInLoop
4329 false, // useMipMaps
4330 false, // minNonUniform
4331 FUZZY_COMPARE, CMP_THRESHOLD
4336 for (int updateAfterBind = 0; updateAfterBind < 2; ++updateAfterBind)
4338 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4340 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesAfterBindAndLoop); ++caseIdx)
4342 TestCaseInfo& info (casesAfterBindAndLoop[caseIdx]);
4343 std::string caseName (info.name);
4344 std::string caseDescription (info.description);
4345 TestCaseParams params (info.params);
4347 caseName += (updateAfterBind ? "_after_bind" : "");
4348 caseName += (calculateInLoop ? "_in_loop" : "");
4350 caseDescription += (updateAfterBind ? " After Bind" : "");
4351 caseDescription += (calculateInLoop ? " In Loop" : "");
4353 params.updateAfterBind = updateAfterBind ? true : false;
4354 params.calculateInLoop = calculateInLoop ? true : false;
4356 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4361 TestCaseInfo casesAfterBindAndLoopAndLOD[] =
4364 "sampler", "Sampler Descriptors",
4366 VK_DESCRIPTOR_TYPE_SAMPLER,
4367 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4369 false, // updateAfterBind
4370 false, // calculateInLoop
4371 false, // usesMipMaps
4372 false, // minNonUniform
4373 FUZZY_COMPARE, CMP_THRESHOLD
4377 "sampled_image", "Sampled Image Descriptors",
4379 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4380 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4382 false, // updateAfterBind
4383 false, // calculateInLoop
4384 false, // usesMipMaps
4385 false, // minNonUniform
4386 FUZZY_COMPARE, CMP_THRESHOLD
4390 "combined_image_sampler", "Combined Image Sampler Descriptors",
4392 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4393 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4395 false, // updateAfterBind
4396 false, // calculateInLoop
4397 false, // usesMipMaps
4398 false, // minNonUniform
4399 FUZZY_COMPARE, CMP_THRESHOLD
4404 for (int updateAfterBind = 0; updateAfterBind < 2; ++updateAfterBind)
4406 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4408 for (int usesMipMaps = 0; usesMipMaps < 2; ++usesMipMaps)
4410 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesAfterBindAndLoopAndLOD); ++caseIdx)
4412 TestCaseInfo& info (casesAfterBindAndLoopAndLOD[caseIdx]);
4413 std::string caseName (info.name);
4414 std::string caseDescription (info.description);
4415 TestCaseParams params (info.params);
4417 caseName += (updateAfterBind ? "_after_bind" : "");
4418 caseName += (calculateInLoop ? "_in_loop" : "");
4419 caseName += (usesMipMaps ? "_with_lod" : "");
4421 caseDescription += (updateAfterBind ? " After Bind" : "");
4422 caseDescription += (calculateInLoop ? " In Loop" : "");
4423 caseDescription += (usesMipMaps ? " Use LOD" : "");
4425 params.updateAfterBind = updateAfterBind ? true : false;
4426 params.calculateInLoop = calculateInLoop ? true : false;
4427 params.usesMipMaps = usesMipMaps ? true : false;
4429 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4435 TestCaseInfo casesNonAfterBindAndLoop[] =
4438 "uniform_buffer", "Regular Uniform Buffer Descriptors",
4440 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4441 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4443 false, // updateAfterBind
4444 false, // calculateInLoop
4445 false, // usesMipMaps
4446 false, // minNonUniform
4447 FUZZY_COMPARE, CMP_THRESHOLD
4451 "storage_buffer_dynamic", "Dynamic Storage Buffer Descriptors",
4453 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4454 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4456 false, // updateAfterBind
4457 false, // calculateInLoop
4458 false, // useMipMaps
4459 false, // minNonUniform
4460 FUZZY_COMPARE, CMP_THRESHOLD
4464 "uniform_buffer_dynamic", "Dynamic Uniform Buffer Descriptors",
4466 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4467 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4469 false, // updateAfterBind
4470 false, // calculateInLoop
4471 false, // useMipMaps
4472 false, // minNonUniform
4473 FUZZY_COMPARE, CMP_THRESHOLD
4477 "input_attachment", "Input Attachment Descriptors",
4479 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4480 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4482 false, // updateAfterBind
4483 false, // calculateInLoop
4484 false, // useMipMaps
4485 false, // minNonUniform
4486 FUZZY_COMPARE, CMP_THRESHOLD
4491 for (int calculateInLoop = 0; calculateInLoop < 2; ++calculateInLoop)
4493 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesNonAfterBindAndLoop); ++caseIdx)
4495 TestCaseInfo& info(casesNonAfterBindAndLoop[caseIdx]);
4496 std::string caseName(info.name);
4497 std::string caseDescription(info.description);
4498 TestCaseParams params(info.params);
4500 caseName += (calculateInLoop ? "_in_loop" : "");
4502 caseDescription += (calculateInLoop ? " In Loop" : "");
4504 params.calculateInLoop = calculateInLoop ? true : false;
4506 group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4511 // Tests that have the minimum necessary NonUniform decorations.
4512 // sampler and sampled_image GLSL already have minimum NonUniform decorations.
4514 TestCaseInfo casesMinNonUniform[] =
4517 "storage_buffer", "Regular Storage Buffer Descriptors",
4519 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4520 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4522 false, // updateAfterBind
4523 false, // calculateInLoop
4524 false, // useMipMaps
4525 true, // minNonUniform
4526 FUZZY_COMPARE, CMP_THRESHOLD
4530 "storage_texel_buffer", "Storage Texel Buffer Descriptors",
4532 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4533 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4535 false, // updateAfterBind
4536 false, // calculateInLoop
4537 false, // useMipMaps
4538 true, // minNonUniform
4539 FUZZY_COMPARE, CMP_THRESHOLD
4543 "uniform_texel_buffer", "Uniform Texel Buffer Descriptors",
4545 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4546 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4548 false, // updateAfterBind,
4549 false, // calculateInLoop
4550 false, // usesMipMaps
4551 true, // minNonUniform
4552 FUZZY_COMPARE, CMP_THRESHOLD
4556 "uniform_buffer", "Regular Uniform Buffer Descriptors",
4558 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4559 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4561 false, // updateAfterBind
4562 false, // calculateInLoop
4563 false, // usesMipMaps
4564 true, // minNonUniform
4565 FUZZY_COMPARE, CMP_THRESHOLD
4569 "combined_image_sampler", "Combined Image Sampler Descriptors",
4571 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4572 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4574 false, // updateAfterBind
4575 false, // calculateInLoop
4576 false, // usesMipMaps
4577 true, // minNonUniform
4578 FUZZY_COMPARE, CMP_THRESHOLD
4582 "combined_image_sampler", "Combined Image Sampler Descriptors",
4584 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4585 (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT),
4587 false, // updateAfterBind
4588 false, // calculateInLoop
4589 true, // usesMipMaps
4590 true, // minNonUniform
4591 FUZZY_COMPARE, CMP_THRESHOLD
4595 "storage_image", "Storage Image Descriptors",
4597 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4598 VK_SHADER_STAGE_COMPUTE_BIT,
4600 false, // updateAfterBind
4601 false, // calculateInLoop
4602 false, // useMipMaps
4603 true, // minNonUniform
4604 FUZZY_COMPARE, CMP_THRESHOLD
4609 for (deUint32 caseIdx = 0; caseIdx < DE_LENGTH_OF_ARRAY(casesMinNonUniform); ++caseIdx)
4611 TestCaseInfo& info(casesMinNonUniform[caseIdx]);
4612 std::string caseName(info.name);
4613 std::string caseDescription(info.description);
4614 TestCaseParams params(info.params);
4616 if (params.usesMipMaps) {
4617 caseName += "_with_lod";
4619 caseName += "_minNonUniform";
4621 caseDescription += " With Minimum NonUniform Decorations";
4623 TestCase* tc = new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params);
4624 group->addChild(tc);
4625 // group->addChild(new DescriptorIndexingTestCase(context, caseName.c_str(), caseDescription.c_str(), params));
4629 } // - DescriptorIndexing