From 29b16beccef41501a140b92865e95d2454900560 Mon Sep 17 00:00:00 2001 From: Camden Stocker Date: Mon, 9 Sep 2019 11:04:49 -0600 Subject: [PATCH] tests: Add test file for BP and move 1 test Fix formatting issue Change-Id: I40d125805b7d41da7a4715e194dbe945e4f91591 --- layers/best_practices.cpp | 5 ++- tests/vklayertests_best_practices.cpp | 51 ++++++++++++++++++++++++++ tests/vklayertests_pipeline_shader.cpp | 6 --- 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 tests/vklayertests_best_practices.cpp diff --git a/layers/best_practices.cpp b/layers/best_practices.cpp index 963aa3db418..cbffe1ace4a 100644 --- a/layers/best_practices.cpp +++ b/layers/best_practices.cpp @@ -812,12 +812,13 @@ void BestPractices::PostCallRecordQueueBindSparse(VkQueue queue, uint32_t bindIn } bool BestPractices::PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, - const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects) { + const VkClearAttachment* pAttachments, uint32_t rectCount, + const VkClearRect* pRects) const { bool skip = false; const CMD_BUFFER_STATE* cb_node = GetCBState(commandBuffer); if (!cb_node) return skip; - // Warn if this is issued prior to Draw Cmd and clearing the entire attachment + // Warn if this is issued prior to Draw Cmd and clearing the entire attachment if (!cb_node->hasDrawCmd && (cb_node->activeRenderPassBeginInfo.renderArea.extent.width == pRects[0].rect.extent.width) && (cb_node->activeRenderPassBeginInfo.renderArea.extent.height == pRects[0].rect.extent.height)) { // There are times where app needs to use ClearAttachments (generally when reusing a buffer inside of a render pass) diff --git a/tests/vklayertests_best_practices.cpp b/tests/vklayertests_best_practices.cpp new file mode 100644 index 00000000000..720f69f90cd --- /dev/null +++ b/tests/vklayertests_best_practices.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015-2019 The Khronos Group Inc. + * Copyright (c) 2015-2019 Valve Corporation + * Copyright (c) 2015-2019 LunarG, Inc. + * Copyright (c) 2015-2019 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Author: Camden Stocker + */ + +#include "cast_utils.h" +#include "layer_validation_tests.h" + +TEST_F(VkLayerTest, CmdClearAttachmentTest) { + TEST_DESCRIPTION("Various tests for validating usage of vkCmdClearAttachments"); + + VkValidationFeatureEnableEXT enables[] = {VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT}; + VkValidationFeaturesEXT features = {}; + features.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT; + features.enabledValidationFeatureCount = 1; + features.pEnabledValidationFeatures = enables; + InitFramework(myDbgFunc, m_errorMonitor, &features); + InitState(); + ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); + + m_commandBuffer->begin(); + m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); + + // Main thing we care about for this test is that the VkImage obj we're + // clearing matches Color Attachment of FB + // Also pass down other dummy params to keep driver and paramchecker happy + VkClearAttachment color_attachment; + color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + color_attachment.clearValue.color.float32[0] = 1.0; + color_attachment.clearValue.color.float32[1] = 1.0; + color_attachment.clearValue.color.float32[2] = 1.0; + color_attachment.clearValue.color.float32[3] = 1.0; + color_attachment.colorAttachment = 0; + VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1}; + + // Call for full-sized FB Color attachment prior to issuing a Draw + m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, + "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw"); + vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); + m_errorMonitor->VerifyFound(); +} diff --git a/tests/vklayertests_pipeline_shader.cpp b/tests/vklayertests_pipeline_shader.cpp index c1cc9d93a60..420fe1bfdf8 100644 --- a/tests/vklayertests_pipeline_shader.cpp +++ b/tests/vklayertests_pipeline_shader.cpp @@ -2564,12 +2564,6 @@ TEST_F(VkLayerTest, CmdClearAttachmentTests) { color_attachment.colorAttachment = 0; VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1}; - // Call for full-sized FB Color attachment prior to issuing a Draw - m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw"); - vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); - m_errorMonitor->VerifyFound(); - clear_rect.rect.extent.width = renderPassBeginInfo().renderArea.extent.width + 4; clear_rect.rect.extent.height = clear_rect.rect.extent.height / 2; m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdClearAttachments-pRects-00016");