VK_KHR_maintenance2: Tessellation domain origin
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / tessellation / vktTessellationUtil.cpp
index 58f6c96..c2f70b4 100644 (file)
@@ -106,18 +106,6 @@ Move<VkCommandPool> makeCommandPool (const DeviceInterface& vk, const VkDevice d
        return createCommandPool(vk, device, &info);
 }
 
-Move<VkCommandBuffer> makeCommandBuffer (const DeviceInterface& vk, const VkDevice device, const VkCommandPool commandPool)
-{
-       const VkCommandBufferAllocateInfo info =
-       {
-               VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,         // VkStructureType              sType;
-               DE_NULL,                                                                                        // const void*                  pNext;
-               commandPool,                                                                            // VkCommandPool                commandPool;
-               VK_COMMAND_BUFFER_LEVEL_PRIMARY,                                        // VkCommandBufferLevel level;
-               1u,                                                                                                     // deUint32                             commandBufferCount;
-       };
-       return allocateCommandBuffer(vk, device, &info);
-}
 
 Move<VkDescriptorSet> makeDescriptorSet (const DeviceInterface&                        vk,
                                                                                 const VkDevice                                 device,
@@ -278,13 +266,7 @@ void submitCommandsAndWait (const DeviceInterface& vk,
                                                        const VkQueue                   queue,
                                                        const VkCommandBuffer   commandBuffer)
 {
-       const VkFenceCreateInfo fenceInfo =
-       {
-               VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,    // VkStructureType              sType;
-               DE_NULL,                                                                // const void*                  pNext;
-               (VkFenceCreateFlags)0,                                  // VkFenceCreateFlags   flags;
-       };
-       const Unique<VkFence> fence(createFence(vk, device, &fenceInfo));
+       const Unique<VkFence> fence(createFence(vk, device));
 
        const VkSubmitInfo submitInfo =
        {
@@ -482,9 +464,9 @@ Move<VkFramebuffer> makeFramebufferWithoutAttachments (const DeviceInterface&               v
                renderPass,                                                                             // VkRenderPass                                renderPass;
                0u,                                                                                             // uint32_t                                    attachmentCount;
                DE_NULL,                                                                                // const VkImageView*                          pAttachments;
-               0u,                                                                                             // uint32_t                                    width;
-               0u,                                                                                             // uint32_t                                    height;
-               0u,                                                                                             // uint32_t                                    layers;
+               1u,                                                                                             // uint32_t                                    width;
+               1u,                                                                                             // uint32_t                                    height;
+               1u,                                                                                             // uint32_t                                    layers;
        };
 
        return createFramebuffer(vk, device, &framebufferInfo);
@@ -609,10 +591,16 @@ Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface&   vk,
                VK_FALSE,                                                                                                               // VkBool32                                    primitiveRestartEnable;
        };
 
+       const VkPipelineTessellationDomainOriginStateCreateInfoKHR tessellationDomainOriginStateInfo =
+       {
+               VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR,
+               DE_NULL,
+               (!m_tessellationDomainOrigin ? VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR : *m_tessellationDomainOrigin)
+       };
        const VkPipelineTessellationStateCreateInfo pipelineTessellationStateInfo =
        {
                VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,              // VkStructureType                             sType;
-               DE_NULL,                                                                                                                // const void*                                 pNext;
+               (!m_tessellationDomainOrigin ? DE_NULL : &tessellationDomainOriginStateInfo),
                (VkPipelineTessellationStateCreateFlags)0,                                              // VkPipelineTessellationStateCreateFlags      flags;
                m_patchControlPoints,                                                                                   // uint32_t                                    patchControlPoints;
        };
@@ -627,15 +615,17 @@ Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface&   vk,
                makeExtent2D(m_renderSize.x(), m_renderSize.y()),
        };
 
+       const bool haveRenderSize = m_renderSize.x() > 0 && m_renderSize.y() > 0;
+
        const VkPipelineViewportStateCreateInfo pipelineViewportStateInfo =
        {
                VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,  // VkStructureType                             sType;
                DE_NULL,                                                                                                // const void*                                 pNext;
                (VkPipelineViewportStateCreateFlags)0,                                  // VkPipelineViewportStateCreateFlags          flags;
                1u,                                                                                                             // uint32_t                                    viewportCount;
-               &viewport,                                                                                              // const VkViewport*                           pViewports;
+               haveRenderSize ? &viewport : DE_NULL,                                   // const VkViewport*                           pViewports;
                1u,                                                                                                             // uint32_t                                    scissorCount;
-               &scissor,                                                                                               // const VkRect2D*                             pScissors;
+               haveRenderSize ? &scissor : DE_NULL,                                    // const VkRect2D*                             pScissors;
        };
 
        const bool isRasterizationDisabled = ((m_shaderStageFlags & VK_SHADER_STAGE_FRAGMENT_BIT) == 0);
@@ -719,6 +709,22 @@ Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface&    vk,
                { 0.0f, 0.0f, 0.0f, 0.0f },                                                                     // float                                                                                blendConstants[4];
        };
 
+       std::vector<VkDynamicState> dynamicStates;
+       if (!haveRenderSize)
+       {
+               dynamicStates.push_back(VK_DYNAMIC_STATE_VIEWPORT);
+               dynamicStates.push_back(VK_DYNAMIC_STATE_SCISSOR);
+       }
+
+       const VkPipelineDynamicStateCreateInfo pipelineDynamicStateInfo =
+       {
+               VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,   // VkStructureType                                              sType;
+               DE_NULL,                                                                                                // const void*                                                  pNext;
+               0,                                                                                                              // VkPipelineDynamicStateCreateFlags    flags;
+               static_cast<deUint32>(dynamicStates.size()),                    // uint32_t                                                             dynamicStateCount;
+               (dynamicStates.empty() ? DE_NULL : &dynamicStates[0]),  // const VkDynamicState*                                pDynamicStates;
+       };
+
        const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
        {
                VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,                                                // VkStructureType                                                                      sType;
@@ -734,7 +740,7 @@ Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface&     vk,
                (isRasterizationDisabled ? DE_NULL : &pipelineMultisampleStateInfo),    // const VkPipelineMultisampleStateCreateInfo*          pMultisampleState;
                (isRasterizationDisabled ? DE_NULL : &pipelineDepthStencilStateInfo),   // const VkPipelineDepthStencilStateCreateInfo*         pDepthStencilState;
                (isRasterizationDisabled ? DE_NULL : &pipelineColorBlendStateInfo),             // const VkPipelineColorBlendStateCreateInfo*           pColorBlendState;
-               DE_NULL,                                                                                                                                // const VkPipelineDynamicStateCreateInfo*                      pDynamicState;
+               &pipelineDynamicStateInfo,                                                                                              // const VkPipelineDynamicStateCreateInfo*                      pDynamicState;
                pipelineLayout,                                                                                                                 // VkPipelineLayout                                                                     layout;
                renderPass,                                                                                                                             // VkRenderPass                                                                         renderPass;
                0u,                                                                                                                                             // deUint32                                                                                     subpass;