Fix color blend state in multisample mixed count tests
authorRicardo Garcia <rgarcia@igalia.com>
Tue, 10 Jan 2023 11:01:08 +0000 (12:01 +0100)
committerPiotr Byszewski <piotr.byszewski@mobica.com>
Sun, 15 Jan 2023 14:38:41 +0000 (14:38 +0000)
Some test variants were passing a null color blend attachment state on
pipeline creation, when the subpass was being created with one color
attachment.

Affects:
dEQP-VK.pipeline.*.multisample.mixed_count.*

VK-GL-CTS issue: 4208
Components: Vulkan

Change-Id: I9e0c7a5be907baef3c2b7bb6286d92eaa6749a66

external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp

index 63b6cc7..20dfb27 100644 (file)
@@ -4816,8 +4816,9 @@ tcu::TestStatus VariableRateTestInstance::iterate (void)
                renderPassCreateInfo.attachmentCount = 1u;
                renderPassCreateInfo.pAttachments = &colorAttachmentDescription;
        }
+       const bool unusedAttachmentSubpass      = (m_params.nonEmptyFramebuffer && m_params.unusedAttachment);
        renderPassCreateInfo.subpassCount       = 1u;
-       renderPassCreateInfo.pSubpasses         = ((m_params.nonEmptyFramebuffer && m_params.unusedAttachment) ? &unusedAttachmentSubpassDescription : &emptySubpassDescription);
+       renderPassCreateInfo.pSubpasses         = (unusedAttachmentSubpass ? &unusedAttachmentSubpassDescription : &emptySubpassDescription);
        const auto renderPassSingleSubpass      = vk::createRenderPass(vkd, device, &renderPassCreateInfo);
 
        // Framebuffers.
@@ -4903,15 +4904,41 @@ tcu::TestStatus VariableRateTestInstance::iterate (void)
        const std::vector<VkViewport>   viewport        { vk::makeViewport(kWidth32, kHeight32) };
        const std::vector<VkRect2D>             scissor         { vk::makeRect2D(kWidth32, kHeight32) };
 
-       const vk::VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo =
+       const VkColorComponentFlags colorComponentFlags = (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT);
+
+       const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
+       {
+               VK_FALSE,                               //      VkBool32                                blendEnable;
+               VK_BLEND_FACTOR_ZERO,   //      VkBlendFactor                   srcColorBlendFactor;
+               VK_BLEND_FACTOR_ZERO,   //      VkBlendFactor                   dstColorBlendFactor;
+               VK_BLEND_OP_ADD,                //      VkBlendOp                               colorBlendOp;
+               VK_BLEND_FACTOR_ZERO,   //      VkBlendFactor                   srcAlphaBlendFactor;
+               VK_BLEND_FACTOR_ZERO,   //      VkBlendFactor                   dstAlphaBlendFactor;
+               VK_BLEND_OP_ADD,                //      VkBlendOp                               alphaBlendOp;
+               colorComponentFlags,    //      VkColorComponentFlags   colorWriteMask;
+       };
+
+       const vk::VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfoNoAttachments =
        {
                vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,   // VkStructureType                                                              sType;
                DE_NULL,                                                                                                                // const void*                                                                  pNext;
                0u,                                                                                                                             // VkPipelineColorBlendStateCreateFlags                 flags;
-               false,                                                                                                                  // VkBool32                                                                             logicOpEnable;
+               VK_FALSE,                                                                                                               // VkBool32                                                                             logicOpEnable;
                vk::VK_LOGIC_OP_CLEAR,                                                                                  // VkLogicOp                                                                    logicOp;
-               0,                                                                                                                              // deUint32                                                                             attachmentCount;
-               DE_NULL,                                                                                                                // const VkPipelineColorBlendAttachmentState*   pAttachments;
+               0u,                                                                                                                             // deUint32                                                                             attachmentCount;
+               nullptr,                                                                                                                // const VkPipelineColorBlendAttachmentState*   pAttachments;
+               { 0.0f, 0.0f, 0.0f, 0.0f }                                                                              // float                                                                                blendConstants[4];
+       };
+
+       const vk::VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfoOneAttachment =
+       {
+               vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,   // VkStructureType                                                              sType;
+               DE_NULL,                                                                                                                // const void*                                                                  pNext;
+               0u,                                                                                                                             // VkPipelineColorBlendStateCreateFlags                 flags;
+               VK_FALSE,                                                                                                               // VkBool32                                                                             logicOpEnable;
+               vk::VK_LOGIC_OP_CLEAR,                                                                                  // VkLogicOp                                                                    logicOp;
+               1u,                                                                                                                             // deUint32                                                                             attachmentCount;
+               &colorBlendAttachmentState,                                                                             // const VkPipelineColorBlendAttachmentState*   pAttachments;
                { 0.0f, 0.0f, 0.0f, 0.0f }                                                                              // float                                                                                blendConstants[4];
        };
 
@@ -4932,6 +4959,8 @@ tcu::TestStatus VariableRateTestInstance::iterate (void)
        outputPipelines.reserve(m_params.subpassCounts.size());
        for (const auto samples : m_params.subpassCounts)
        {
+               const auto colorBlendStatePtr = (unusedAttachmentSubpass ? &colorBlendStateCreateInfoOneAttachment : &colorBlendStateCreateInfoNoAttachments);
+
                multisampleStateCreateInfo.rasterizationSamples = samples;
 
                outputPipelines.emplace_back(vkd, device, m_params.pipelineConstructionType);
@@ -4946,7 +4975,7 @@ tcu::TestStatus VariableRateTestInstance::iterate (void)
                                0u,
                                *vertModule)
                        .setupFragmentShaderState(*pipelineLayout, *renderPassSingleSubpass, 0u, *fragModule, DE_NULL, &multisampleStateCreateInfo)
-                       .setupFragmentOutputState(*renderPassSingleSubpass, 0u, &colorBlendStateCreateInfo, &multisampleStateCreateInfo)
+                       .setupFragmentOutputState(*renderPassSingleSubpass, 0u, colorBlendStatePtr, &multisampleStateCreateInfo)
                        .setMonolithicPipelineLayout(*pipelineLayout)
                        .buildPipeline();
        }
@@ -4971,7 +5000,7 @@ tcu::TestStatus VariableRateTestInstance::iterate (void)
                                subpass,
                                *vertModule)
                        .setupFragmentShaderState(*pipelineLayout, *renderPassMultiplePasses, subpass, *fragModule, DE_NULL, &multisampleStateCreateInfo)
-                       .setupFragmentOutputState(*renderPassMultiplePasses, subpass, &colorBlendStateCreateInfo, &multisampleStateCreateInfo)
+                       .setupFragmentOutputState(*renderPassMultiplePasses, subpass, &colorBlendStateCreateInfoNoAttachments, &multisampleStateCreateInfo)
                        .setMonolithicPipelineLayout(*pipelineLayout)
                        .buildPipeline();
        }