Create debug report recorder earlier
authorRicardo Garcia <rgarcia@igalia.com>
Fri, 23 Oct 2020 10:18:22 +0000 (12:18 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 6 Nov 2020 09:21:15 +0000 (04:21 -0500)
Change debug report recorder creation so it happens before the device is
created, so any error messages reported during device creation can be
properly reported.

This commit doesn't affect normal test runs, but it could be beneficial
to detect system setup problems.

Components: Vulkan
VK-GL-CTS issue: 2627

Change-Id: Iefe7c46e2a90673e8625a541f35fbfb35c1afd8d

external/vulkancts/modules/vulkan/vktTestCase.cpp
external/vulkancts/modules/vulkan/vktTestCase.hpp
external/vulkancts/modules/vulkan/vktTestPackage.cpp

index 52c7c9760255751ac0fc49f468a15ea25f8fa311..3680f8e79e82d58a76105117576b04d80426a521 100644 (file)
@@ -325,7 +325,11 @@ public:
        deUint32                                                                                                                getSparseQueueFamilyIndex                               (void) const { return m_sparseQueueFamilyIndex;                                                         }
        VkQueue                                                                                                                 getSparseQueue                                                  (void) const;
 
+       bool                                                                                                                    hasDebugReportRecorder                                  (void) const { return m_debugReportRecorder.get() != nullptr;                           }
+       vk::DebugReportRecorder&                                                                                getDebugReportRecorder                                  (void) const { return *m_debugReportRecorder.get();                                                     }
+
 private:
+       using DebugReportRecorderPtr            = de::UniquePtr<vk::DebugReportRecorder>;
 
        const deUint32                                          m_maximumFrameworkVulkanVersion;
        const deUint32                                          m_availableInstanceVersion;
@@ -337,6 +341,7 @@ private:
        const vector<string>                            m_instanceExtensions;
        const Unique<VkInstance>                        m_instance;
        const InstanceDriver                            m_instanceInterface;
+       const DebugReportRecorderPtr            m_debugReportRecorder;
 
        const VkPhysicalDevice                          m_physicalDevice;
        const deUint32                                          m_deviceVersion;
@@ -352,11 +357,24 @@ private:
        const DeviceDriver                                      m_deviceInterface;
 };
 
-static deUint32 sanitizeApiVersion(deUint32 v)
+namespace
+{
+
+deUint32 sanitizeApiVersion(deUint32 v)
 {
        return VK_MAKE_VERSION( VK_VERSION_MAJOR(v), VK_VERSION_MINOR(v), 0 );
 }
 
+de::MovePtr<vk::DebugReportRecorder> createDebugReportRecorder (const vk::PlatformInterface& vkp, const vk::InstanceInterface& vki, vk::VkInstance instance, bool printValidationErrors)
+{
+       if (isDebugReportSupported(vkp))
+               return de::MovePtr<vk::DebugReportRecorder>(new vk::DebugReportRecorder(vki, instance, printValidationErrors));
+       else
+               TCU_THROW(NotSupportedError, "VK_EXT_debug_report is not supported");
+}
+
+} // anonymous
+
 DefaultDevice::DefaultDevice (const PlatformInterface& vkPlatform, const tcu::CommandLine& cmdLine)
        : m_maximumFrameworkVulkanVersion       (VK_API_MAX_FRAMEWORK_VERSION)
        , m_availableInstanceVersion            (getTargetInstanceVersion(vkPlatform))
@@ -368,6 +386,12 @@ DefaultDevice::DefaultDevice (const PlatformInterface& vkPlatform, const tcu::Co
        , m_instance                                            (createInstance(vkPlatform, m_usedApiVersion, m_instanceExtensions, cmdLine))
 
        , m_instanceInterface                           (vkPlatform, *m_instance)
+       , m_debugReportRecorder                         (cmdLine.isValidationEnabled()
+                                                                                ? createDebugReportRecorder(vkPlatform,
+                                                                                                                                        m_instanceInterface,
+                                                                                                                                        *m_instance,
+                                                                                                                                        cmdLine.printValidationErrors())
+                                                                                : de::MovePtr<vk::DebugReportRecorder>(DE_NULL))
        , m_physicalDevice                                      (chooseDevice(m_instanceInterface, *m_instance, cmdLine))
        , m_deviceVersion                                       (getPhysicalDeviceProperties(m_instanceInterface, m_physicalDevice).apiVersion)
 
@@ -656,6 +680,16 @@ bool Context::isBufferDeviceAddressSupported(void) const
                   isDeviceFunctionalitySupported("VK_EXT_buffer_device_address");
 }
 
+bool Context::hasDebugReportRecorder () const
+{
+       return m_device->hasDebugReportRecorder();
+}
+
+vk::DebugReportRecorder& Context::getDebugReportRecorder () const
+{
+       return m_device->getDebugReportRecorder();
+}
+
 // TestCase
 
 void TestCase::initPrograms (SourceCollections&) const
index 7553b2a830d818936d03846495cedff562d682a2..c15545079adbd284c87b650a2df05cee1fbb7fef 100644 (file)
@@ -110,6 +110,9 @@ public:
        bool                                                                            resultSetOnValidation                   () const                { return m_resultSetOnValidation;       }
        void                                                                            resultSetOnValidation                   (bool value)    { m_resultSetOnValidation = value;      }
 
+       bool                                                                            hasDebugReportRecorder                  () const;
+       vk::DebugReportRecorder&                                        getDebugReportRecorder                  () const;
+
 protected:
        tcu::TestContext&                                                       m_testCtx;
        const vk::PlatformInterface&                            m_platformInterface;
index 35abd4202d3d83df9506372445bc917e896d520f..b6d3fec93406c47ff3ee294bf138c3add151a65b 100644 (file)
@@ -178,19 +178,6 @@ using de::UniquePtr;
 using de::MovePtr;
 using tcu::TestLog;
 
-namespace
-{
-
-MovePtr<vk::DebugReportRecorder> createDebugReportRecorder (const vk::PlatformInterface& vkp, const vk::InstanceInterface& vki, vk::VkInstance instance, bool printValidationErrors)
-{
-       if (isDebugReportSupported(vkp))
-               return MovePtr<vk::DebugReportRecorder>(new vk::DebugReportRecorder(vki, instance, printValidationErrors));
-       else
-               TCU_THROW(NotSupportedError, "VK_EXT_debug_report is not supported");
-}
-
-} // anonymous
-
 // TestCaseExecutor
 
 class TestCaseExecutor : public tcu::TestCaseExecutor
@@ -212,7 +199,6 @@ private:
        const UniquePtr<vk::Library>                            m_library;
        Context                                                                         m_context;
 
-       const UniquePtr<vk::DebugReportRecorder>        m_debugReportRecorder;
        const UniquePtr<vk::RenderDocUtil>                      m_renderDoc;
        vk::VkPhysicalDeviceProperties                          m_deviceProperties;
        tcu::WaiverUtil                                                         m_waiverMechanism;
@@ -239,12 +225,6 @@ TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
        : m_prebuiltBinRegistry (testCtx.getArchive(), "vulkan/prebuilt")
        , m_library                             (createLibrary(testCtx))
        , m_context                             (testCtx, m_library->getPlatformInterface(), m_progCollection)
-       , m_debugReportRecorder (testCtx.getCommandLine().isValidationEnabled()
-                                                        ? createDebugReportRecorder(m_library->getPlatformInterface(),
-                                                                                                                m_context.getInstanceInterface(),
-                                                                                                                m_context.getInstance(),
-                                                                                                                testCtx.getCommandLine().printValidationErrors())
-                                                        : MovePtr<vk::DebugReportRecorder>(DE_NULL))
        , m_renderDoc                   (testCtx.getCommandLine().isRenderDocEnabled()
                                                         ? MovePtr<vk::RenderDocUtil>(new vk::RenderDocUtil())
                                                         : MovePtr<vk::RenderDocUtil>(DE_NULL))
@@ -366,8 +346,8 @@ void TestCaseExecutor::deinit (tcu::TestCase*)
        if (m_renderDoc) m_renderDoc->endFrame(m_context.getInstance());
 
        // Collect and report any debug messages
-       if (m_debugReportRecorder)
-               collectAndReportDebugMessages(*m_debugReportRecorder, m_context);
+       if (m_context.hasDebugReportRecorder())
+               collectAndReportDebugMessages(m_context.getDebugReportRecorder(), m_context);
 }
 
 tcu::TestNode::IterateResult TestCaseExecutor::iterate (tcu::TestCase*)