tests: Re-enable changes to InitState()
authorCody Northrop <cnorthrop@google.com>
Mon, 22 Aug 2016 16:41:47 +0000 (10:41 -0600)
committerCody Northrop <cnorthrop@google.com>
Mon, 22 Aug 2016 17:19:07 +0000 (11:19 -0600)
The initial series was causing InitState() to be called
twice in tests using VKTriangleTest.

This is a combination of 4 commits:

  tests: Remove InitState from VKTriangleTest

  Revert "Revert "tests: Move device creation from Setup to InitState""
  This reverts commit 5690813b28260c0acbe54ed5f63a66b57d4f3eef.

  Revert "Revert "tests: Enable passing PhysicalDeviceFeatures to InitState""
  This reverts commit 5c61db858c9e83f6a25993ee6262bd5f1a817551.

  Revert "Revert "tests: Change IndependentBlend test to use new InitState parm""
  This reverts commit 24eca2239aab4a76fa2926e5e1fa48d2171c3e6a.

tests/layer_validation_tests.cpp
tests/vkrenderframework.cpp
tests/vkrenderframework.h

index f2f3abc..96a3cb6 100644 (file)
@@ -408,7 +408,6 @@ void VkLayerTest::VKTriangleTest(const char *vertShaderText,
         data.color[i][3] = tri_data[i].a;
     }
 
-    ASSERT_NO_FATAL_FAILURE(InitState());
     ASSERT_NO_FATAL_FAILURE(InitViewport());
 
     VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float),
@@ -3430,6 +3429,7 @@ TEST_F(VkLayerTest, InvalidCommandPoolConsistency) {
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
         "FreeCommandBuffers is attempting to free Command Buffer");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkCommandPool command_pool_one;
     VkCommandPool command_pool_two;
 
@@ -3855,6 +3855,7 @@ TEST_F(VkLayerTest, MismatchedQueueFamiliesOnSubmit) {
                      "attempt to submit them on a queue created in a different "
                      "queue family.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // This test is meaningless unless we have multiple queue families
     auto queue_family_properties = m_device->phy().queue_properties();
     if (queue_family_properties.size() < 2) {
@@ -4367,58 +4368,41 @@ TEST_F(VkLayerTest, DisabledIndependentBlend) {
     TEST_DESCRIPTION("Generate INDEPENDENT_BLEND by disabling independent "
                      "blend and then specifying different blend states for two "
                      "attachements");
-    ASSERT_NO_FATAL_FAILURE(InitState());
-
-    m_errorMonitor->SetDesiredFailureMsg(
-        VK_DEBUG_REPORT_ERROR_BIT_EXT,
-        "Invalid Pipeline CreateInfo: If independent blend feature not "
-        "enabled, all elements of pAttachments must be identical");
     VkPhysicalDeviceFeatures features = {};
     features.independentBlend = VK_FALSE;
-    std::vector<const char *> extension_names;
-    VkDeviceObj noib_device(0, gpu(), extension_names, &features);
+    ASSERT_NO_FATAL_FAILURE(InitState(&features));
 
-    VkCommandPool cmd_pool;
-    VkCommandPoolCreateInfo pool_create_info{};
-    pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
-    pool_create_info.queueFamilyIndex = noib_device.graphics_queue_node_index_;
-    pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+    m_errorMonitor->SetDesiredFailureMsg(
+                VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                "Invalid Pipeline CreateInfo: If independent blend feature not "
+                "enabled, all elements of pAttachments must be identical");
 
-    vkCreateCommandPool(noib_device.device(), &pool_create_info, nullptr,
-                        &cmd_pool);
-    {
-        // Need cmd_buffer's destructor to be called before calling DestroyCommandPool
-        VkCommandBufferObj cmd_buffer(&noib_device, cmd_pool);
-        VkDescriptorSetObj descriptorSet(&noib_device);
-        descriptorSet.AppendDummy();
-        descriptorSet.CreateVKDescriptorSet(&cmd_buffer);
-
-        VkPipelineObj pipeline(&noib_device);
-
-        VkRenderpassObj renderpass(&noib_device);
-
-        VkShaderObj vs(&noib_device, bindStateVertShaderText,
-                       VK_SHADER_STAGE_VERTEX_BIT, this);
-
-        pipeline.AddShader(&vs);
-
-        VkPipelineColorBlendAttachmentState att_state1 = {}, att_state2 = {};
-        att_state1.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
-        att_state1.blendEnable = VK_TRUE;
-        att_state2.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
-        att_state2.blendEnable = VK_FALSE;
-        pipeline.AddColorAttachment(0, &att_state1);
-        pipeline.AddColorAttachment(1, &att_state2);
-        pipeline.CreateVKPipeline(descriptorSet.GetPipelineLayout(),
-                                  renderpass.handle());
-        m_errorMonitor->VerifyFound();
-    }
-    vkDestroyCommandPool(noib_device.device(), cmd_pool, NULL);
+    VkDescriptorSetObj descriptorSet(m_device);
+    descriptorSet.AppendDummy();
+    descriptorSet.CreateVKDescriptorSet(m_commandBuffer);
+
+    VkPipelineObj pipeline(m_device);
+    VkRenderpassObj renderpass(m_device);
+    VkShaderObj vs(m_device, bindStateVertShaderText,
+                   VK_SHADER_STAGE_VERTEX_BIT, this);
+    pipeline.AddShader(&vs);
+
+    VkPipelineColorBlendAttachmentState att_state1 = {}, att_state2 = {};
+    att_state1.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
+    att_state1.blendEnable = VK_TRUE;
+    att_state2.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
+    att_state2.blendEnable = VK_FALSE;
+    pipeline.AddColorAttachment(0, &att_state1);
+    pipeline.AddColorAttachment(1, &att_state2);
+    pipeline.CreateVKPipeline(descriptorSet.GetPipelineLayout(),
+                              renderpass.handle());
+    m_errorMonitor->VerifyFound();
 }
 
 TEST_F(VkLayerTest, RenderPassDepthStencilAttachmentUnused) {
     TEST_DESCRIPTION("Specify no depth attachement in renderpass then specify "
                      "depth attachments in subpass");
+    ASSERT_NO_FATAL_FAILURE(InitState());
 
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -5139,6 +5123,7 @@ TEST_F(VkLayerTest, WaitEventThenSet) {
         "Wait on a event then set it after the wait has been submitted.");
 
     m_errorMonitor->ExpectSuccess();
+    ASSERT_NO_FATAL_FAILURE(InitState());
 
     VkEvent event;
     VkEventCreateInfo event_create_info{};
@@ -5203,6 +5188,7 @@ TEST_F(VkLayerTest, QueryAndCopySecondaryCommandBuffers) {
     TEST_DESCRIPTION(
         "Issue a query on a secondary command buffery and copy it on a primary.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
@@ -5334,6 +5320,7 @@ TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) {
     TEST_DESCRIPTION(
         "Issue a query and copy from it on a second command buffer.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
@@ -5448,6 +5435,7 @@ TEST_F(VkLayerTest, ResetEventThenSet) {
 
     m_errorMonitor->ExpectSuccess();
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkEvent event;
     VkEventCreateInfo event_create_info{};
     event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
@@ -5498,10 +5486,9 @@ TEST_F(VkLayerTest, ResetEventThenSet) {
         vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
     }
     {
-        m_errorMonitor->SetDesiredFailureMsg(
-            VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event "
-                                           "0x1 that is already in use by a "
-                                           "command buffer.");
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                             "that is already in use by a "
+                                             "command buffer.");
         vkSetEvent(m_device->device(), event);
         m_errorMonitor->VerifyFound();
     }
@@ -5596,6 +5583,7 @@ TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) {
     TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call "
         "submitted on separate queues followed by a QueueWaitIdle.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
@@ -5703,6 +5691,7 @@ TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFenc
                      "submitted on separate queues, the second having a fence"
                      "followed by a QueueWaitIdle.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
@@ -5818,6 +5807,7 @@ TEST_F(VkLayerTest,
         "submitted on separate queues, the second having a fence"
         "followed by two consecutive WaitForFences calls on the same fence.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
@@ -5926,6 +5916,8 @@ TEST_F(VkLayerTest,
 }
 
 TEST_F(VkLayerTest, TwoQueuesEnsureCorrectRetirementWithWorkStolen) {
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2)) {
         printf("Test requires two queues, skipping\n");
@@ -6012,12 +6004,14 @@ TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) {
                      "submitted on separate queues, the second having a fence, "
                      "followed by a WaitForFences call.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if ((m_device->queue_props.empty()) ||
         (m_device->queue_props[0].queueCount < 2))
         return;
 
     m_errorMonitor->ExpectSuccess();
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkFence fence;
     VkFenceCreateInfo fence_create_info{};
     fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
@@ -6129,6 +6123,7 @@ TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) {
 
     m_errorMonitor->ExpectSuccess();
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkFence fence;
     VkFenceCreateInfo fence_create_info{};
     fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
@@ -6235,6 +6230,7 @@ TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) {
 
     m_errorMonitor->ExpectSuccess();
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkFence fence;
     VkFenceCreateInfo fence_create_info{};
     fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
@@ -6337,6 +6333,7 @@ TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) {
 
     m_errorMonitor->ExpectSuccess();
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkFence fence;
     VkFenceCreateInfo fence_create_info{};
     fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
@@ -6432,6 +6429,7 @@ TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) {
     TEST_DESCRIPTION(
         "Two command buffers each in a separate SubmitInfo sent in a single "
         "QueueSubmit call followed by a WaitForFences call.");
+    ASSERT_NO_FATAL_FAILURE(InitState());
 
     m_errorMonitor->ExpectSuccess();
 
@@ -6541,6 +6539,7 @@ TEST_F(VkLayerTest, DynamicDepthBiasNotBound) {
         "Run a simple draw calls to validate failure when Depth Bias dynamic "
         "state is required but not correctly bound.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic depth bias
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6555,6 +6554,7 @@ TEST_F(VkLayerTest, DynamicLineWidthNotBound) {
         "Run a simple draw calls to validate failure when Line Width dynamic "
         "state is required but not correctly bound.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic line width
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6569,6 +6569,7 @@ TEST_F(VkLayerTest, DynamicViewportNotBound) {
         "Run a simple draw calls to validate failure when Viewport dynamic "
         "state is required but not correctly bound.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic viewport state
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6583,6 +6584,7 @@ TEST_F(VkLayerTest, DynamicScissorNotBound) {
         "Run a simple draw calls to validate failure when Scissor dynamic "
         "state is required but not correctly bound.");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic scissor state
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6596,6 +6598,8 @@ TEST_F(VkLayerTest, DynamicBlendConstantsNotBound) {
     TEST_DESCRIPTION(
         "Run a simple draw calls to validate failure when Blend Constants "
         "dynamic state is required but not correctly bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic blend constant state
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6609,6 +6613,8 @@ TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) {
     TEST_DESCRIPTION(
         "Run a simple draw calls to validate failure when Depth Bounds dynamic "
         "state is required but not correctly bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     if (!m_device->phy().features().depthBounds) {
         printf("Device does not support depthBounds test; skipped.\n");
         return;
@@ -6626,6 +6632,8 @@ TEST_F(VkLayerTest, DynamicStencilReadNotBound) {
     TEST_DESCRIPTION(
         "Run a simple draw calls to validate failure when Stencil Read dynamic "
         "state is required but not correctly bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic stencil read mask
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6639,6 +6647,8 @@ TEST_F(VkLayerTest, DynamicStencilWriteNotBound) {
     TEST_DESCRIPTION(
         "Run a simple draw calls to validate failure when Stencil Write dynamic"
         " state is required but not correctly bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic stencil write mask
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6652,6 +6662,8 @@ TEST_F(VkLayerTest, DynamicStencilRefNotBound) {
     TEST_DESCRIPTION(
         "Run a simple draw calls to validate failure when Stencil Ref dynamic "
         "state is required but not correctly bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     // Dynamic stencil reference
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -6663,6 +6675,8 @@ TEST_F(VkLayerTest, DynamicStencilRefNotBound) {
 
 TEST_F(VkLayerTest, IndexBufferNotBound) {
     TEST_DESCRIPTION("Run an indexed draw call without an index buffer bound.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
         "Index buffer object not bound to this command buffer when Indexed ");
@@ -6843,6 +6857,8 @@ TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) {
 TEST_F(VkLayerTest, InvalidDescriptorPool) {
     // Attempt to clear Descriptor Pool with bad object.
     // ObjectTracker should catch this.
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
                                          "Invalid Descriptor Pool Object 0xbaad6001");
     uint64_t fake_pool_handle = 0xbaad6001;
@@ -6906,7 +6922,7 @@ TEST_F(VkLayerTest, InvalidDescriptorSetLayout) {
     VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle);
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
                                          "Invalid Descriptor Set Layout Object 0xbaad6001");
-
+    ASSERT_NO_FATAL_FAILURE(InitState());
     VkPipelineLayout pipeline_layout;
     VkPipelineLayoutCreateInfo plci = {};
     plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
@@ -12059,6 +12075,7 @@ TEST_F(VkLayerTest, NumBlendAttachMismatch) {
 TEST_F(VkLayerTest, MissingClearAttachment) {
     TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment "
                      "structure passed to vkCmdClearAttachments");
+    ASSERT_NO_FATAL_FAILURE(InitState());
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
                                          "vkCmdClearAttachments() attachment index 1 not found in attachment "
                                          "reference array of active subpass 0");
@@ -12291,6 +12308,7 @@ TEST_F(VkLayerTest, VtxBufferBadIndex) {
 TEST_F(VkLayerTest, MismatchCountQueueCreateRequestedFeature) {
     TEST_DESCRIPTION("Use an invalid count in a vkEnumeratePhysicalDevices call."
                      "Use invalid Queue Family Index in vkCreateDevice");
+    ASSERT_NO_FATAL_FAILURE(InitState());
 
     const char *mismatch_count_message =
             "Call to vkEnumeratePhysicalDevices() "
@@ -15824,6 +15842,7 @@ TEST_F(VkLayerTest, ImageFormatLimits) {
 
     TEST_DESCRIPTION("Exceed the limits of image format ");
 
+    ASSERT_NO_FATAL_FAILURE(InitState());
     m_errorMonitor->SetDesiredFailureMsg(
         VK_DEBUG_REPORT_ERROR_BIT_EXT,
         "CreateImage extents exceed allowable limits for format");
index cd775f4..52331ff 100644 (file)
@@ -176,25 +176,7 @@ void VkRenderFramework::InitFramework(
     }
 
     /* TODO: Verify requested physical device extensions are available */
-    m_device = new VkDeviceObj(0, objs[0], device_extension_names);
-
-    /* Now register callback on device */
-    if (0) {
-        if (m_CreateDebugReportCallback) {
-            VkDebugReportCallbackCreateInfoEXT dbgInfo;
-            memset(&dbgInfo, 0, sizeof(dbgInfo));
-            dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
-            dbgInfo.pfnCallback = dbgFunction;
-            dbgInfo.pUserData = userData;
-            dbgInfo.flags =
-                VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
-            err = m_CreateDebugReportCallback(this->inst, &dbgInfo, NULL,
-                                              &m_devMsgCallback);
-            ASSERT_VK_SUCCESS(err);
-        }
-    }
-    m_device->get_device_queue();
-    m_depthStencil = new VkDepthStencilObj(m_device);
+    this->device_extension_names = device_extension_names;
 }
 
 void VkRenderFramework::ShutdownFramework() {
@@ -228,9 +210,14 @@ void VkRenderFramework::ShutdownFramework() {
         vkDestroyInstance(this->inst, NULL);
 }
 
-void VkRenderFramework::InitState() {
+void VkRenderFramework::InitState(VkPhysicalDeviceFeatures *features) {
     VkResult U_ASSERT_ONLY err;
 
+    m_device = new VkDeviceObj(0, objs[0], device_extension_names, features);
+    m_device->get_device_queue();
+
+    m_depthStencil = new VkDepthStencilObj(m_device);
+
     m_render_target_fmt = VkTestFramework::GetFormat(inst, m_device);
 
     m_lineWidth = 1.0f;
index 15d4b53..6eb3c35 100644 (file)
@@ -78,7 +78,7 @@ class VkRenderFramework : public VkTestFramework {
                        void *userData = NULL);
 
     void ShutdownFramework();
-    void InitState();
+    void InitState(VkPhysicalDeviceFeatures *features = nullptr);
 
     const VkRenderPassBeginInfo &renderPassBeginInfo() const {
         return m_renderPassBeginInfo;
@@ -122,6 +122,7 @@ class VkRenderFramework : public VkTestFramework {
     PFN_vkDebugReportMessageEXT m_DebugReportMessage;
     VkDebugReportCallbackEXT m_globalMsgCallback;
     VkDebugReportCallbackEXT m_devMsgCallback;
+    std::vector<const char *> device_extension_names;
 
     /*
      * SetUp and TearDown are called by the Google Test framework