Check resource limits properly
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Wed, 2 Jun 2021 14:41:30 +0000 (16:41 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 10 Jun 2021 09:15:55 +0000 (09:15 +0000)
The tests were not checking the resource limits per stage when
creating the shaders, which could create potential issues on
some drivers. Specially the random generated tests.

Affected tests:

   dEQP-VK.ssbo.layout.*

Components: Vulkan
VK-GL-CTS issue: 2953

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Change-Id: I7509dce38b849a0dd26f9e47d7f74e637930d897

external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp
external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.hpp

index a63fa8a..3cd15d5 100644 (file)
@@ -2609,6 +2609,11 @@ void SSBOLayoutCase::initPrograms (vk::SourceCollections& programCollection) con
 
 TestInstance* SSBOLayoutCase::createInstance (Context& context) const
 {
+       return new SSBOLayoutCaseInstance(context, m_bufferMode, m_interface, m_refLayout, m_initialData, m_writeData, m_usePhysStorageBuffer);
+}
+
+void SSBOLayoutCase::checkSupport(Context& context) const
+{
        if (!context.isDeviceFunctionalitySupported("VK_KHR_relaxed_block_layout") && usesRelaxedLayout(m_interface))
                TCU_THROW(NotSupportedError, "VK_KHR_relaxed_block_layout not supported");
        if (!context.get16BitStorageFeatures().storageBuffer16BitAccess && uses16BitStorage(m_interface))
@@ -2621,7 +2626,17 @@ TestInstance* SSBOLayoutCase::createInstance (Context& context) const
                TCU_THROW(NotSupportedError, "Physical storage buffer pointers not supported");
        if (!context.getDescriptorIndexingFeatures().shaderStorageBufferArrayNonUniformIndexing && usesDescriptorIndexing(m_interface))
                TCU_THROW(NotSupportedError, "Descriptor indexing over storage buffer not supported");
-       return new SSBOLayoutCaseInstance(context, m_bufferMode, m_interface, m_refLayout, m_initialData, m_writeData, m_usePhysStorageBuffer);
+
+       const vk::VkPhysicalDeviceProperties &properties = context.getDeviceProperties();
+       // Shader defines N+1 storage buffers: N to operate and one more to store the number of cases passed.
+       deUint32 blockCount = 1u;
+       for (deInt32 blockIdx = 0u; blockIdx < m_interface.getNumBlocks(); blockIdx++)
+       {
+               blockCount += m_interface.getBlock(blockIdx).getArraySize() ? m_interface.getBlock(blockIdx).getArraySize() : 1u;
+       }
+
+       if (properties.limits.maxPerStageDescriptorStorageBuffers < blockCount)
+               TCU_THROW(NotSupportedError, "Descriptor set storage buffers count higher than the maximum supported by the driver");
 }
 
 void SSBOLayoutCase::delayedInit (void)
index aa8ad2a..5008098 100644 (file)
@@ -244,6 +244,7 @@ public:
        virtual void                            delayedInit                                     (void);
        virtual void                            initPrograms                            (vk::SourceCollections& programCollection) const;
        virtual TestInstance*           createInstance                          (Context& context) const;
+       virtual void                            checkSupport                            (Context &context) const;
 
 protected:
        BufferMode                                      m_bufferMode;