Patch regression in FSR tests

FSR tests were recently repeated few times - for pipeline libraries
and for secondary command buffers in dynamic rendering cases. As a
result there were cases where delayed group creation with
createChildren had another nested call to createChildren. This CL
modifies code to use only two delayed group creation calls - for
renderpass2 and dynamic_rendering sub-groups.

VK-GL-CTS issue: 3760

Bug: b/235495021
Change-Id: I5f8d825b6b5a297b2406f07f6c8938ec58a6331d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/66448
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/tests/regres/deqp-patches/deqp-fsr.patch b/tests/regres/deqp-patches/deqp-fsr.patch
new file mode 100644
index 0000000..47afd34
--- /dev/null
+++ b/tests/regres/deqp-patches/deqp-fsr.patch
@@ -0,0 +1,202 @@
+From 353f3d1100ed6590bc09a6632ebd5440b197f79f Mon Sep 17 00:00:00 2001
+From: Nicolas Capens <capn@google.com>
+Date: Mon, 13 Jun 2022 11:27:21 -0400
+Subject: [PATCH] Fix regresion in FSR tests
+
+FSR tests were recently repeated few times - for pipeline libraries
+and for secondary command buffers in dynamic rendering cases. As a
+result there were cases where delayed group creation with
+createChildren had another nested call to createChildren. This CL
+modifies code to use only tow delayed group creation calls - for
+renderpass2 and dynamic_rendering sub-groups.
+
+Components: Vulkan
+
+VK-GL-CTS issue: 3760
+
+Affects:
+dEQP-VK.fragment_shading_rate.*
+
+Change-Id: If8da1532c0c924ef812ab055de4c71c5b9ba86b4
+---
+ .../vktFragmentShadingRateTests.cpp           | 147 +++++++++---------
+ 1 file changed, 72 insertions(+), 75 deletions(-)
+
+diff --git a/external/vulkancts/modules/vulkan/fragment_shading_rate/vktFragmentShadingRateTests.cpp b/external/vulkancts/modules/vulkan/fragment_shading_rate/vktFragmentShadingRateTests.cpp
+index d8430c10b..344c87a49 100644
+--- a/external/vulkancts/modules/vulkan/fragment_shading_rate/vktFragmentShadingRateTests.cpp
++++ b/external/vulkancts/modules/vulkan/fragment_shading_rate/vktFragmentShadingRateTests.cpp
+@@ -429,6 +429,7 @@ void createMiscTests(tcu::TestContext& testCtx, tcu::TestCaseGroup* parentGroup)
+ void createTests (tcu::TestCaseGroup* group, SharedGroupParams groupParams)
+ {
+ 	tcu::TestContext& testCtx = group->getTestContext();
++
+ #ifndef CTS_USES_VULKANSC
+ 	createBasicTests(testCtx, group, groupParams);
+ #endif // CTS_USES_VULKANSC
+@@ -450,91 +451,87 @@ void createTests (tcu::TestCaseGroup* group, SharedGroupParams groupParams)
+ 	}
+ }
+ 
+-void createPipelineConstructionTypePermutations(tcu::TestContext& testCtx, tcu::TestCaseGroup* parentGroup, SharedGroupParams baseGroupParams)
++void createPipelineConstructionTypePermutations(tcu::TestCaseGroup* parentGroup, SharedGroupParams baseGroupParams)
+ {
+-	parentGroup->addChild(createTestGroup(testCtx, "monolithic", "Monolithic pipeline tests", createTests,
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				baseGroupParams->useDynamicRendering,
+-				baseGroupParams->useSecondaryCmdBuffer,
+-				baseGroupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass,
+-				vk::PIPELINE_CONSTRUCTION_TYPE_MONOLITHIC,
+-			})));
+-	parentGroup->addChild(createTestGroup(testCtx, "pipeline_library", "Graphics pipeline library tests", createTests,
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				baseGroupParams->useDynamicRendering,
+-				baseGroupParams->useSecondaryCmdBuffer,
+-				baseGroupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass,
+-				vk::PIPELINE_CONSTRUCTION_TYPE_LINK_TIME_OPTIMIZED_LIBRARY,
+-			})));
+-	parentGroup->addChild(createTestGroup(testCtx, "fast_linked_library", "Fast linked graphics pipeline library tests", createTests,
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				baseGroupParams->useDynamicRendering,
+-				baseGroupParams->useSecondaryCmdBuffer,
+-				baseGroupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass,
+-				vk::PIPELINE_CONSTRUCTION_TYPE_FAST_LINKED_LIBRARY,
+-			})));
+-}
++	tcu::TestContext& testCtx = parentGroup->getTestContext();
+ 
+-} // anonymous
++	auto constructGroupParams = [](SharedGroupParams baseGroupParams, vk::PipelineConstructionType pipelineConstructionType)
++	{
++		return SharedGroupParams(new GroupParams
++		{
++			baseGroupParams->useDynamicRendering,
++			baseGroupParams->useSecondaryCmdBuffer,
++			baseGroupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass,
++			pipelineConstructionType,
++		});
++	};
+ 
+-tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
+-{
+-	de::MovePtr<tcu::TestCaseGroup> mainGroup(new tcu::TestCaseGroup(testCtx, "fragment_shading_rate", "Fragment shading rate tests"));
+-	de::MovePtr<tcu::TestCaseGroup> renderpass2Group(new tcu::TestCaseGroup(testCtx, "renderpass2", "Draw using render pass object"));
+-	createPipelineConstructionTypePermutations(testCtx, renderpass2Group.get(),
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				false,																// bool							useDynamicRendering;
+-				false,																// bool							useSecondaryCmdBuffer;
+-				false,																// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
+-				vk::PipelineConstructionType(0)		// placeholder					// PipelineConstructionType		pipelineConstructionType;
+-			}));
++	de::MovePtr<tcu::TestCaseGroup> monolithic(new tcu::TestCaseGroup(testCtx, "monolithic", "Monolithic pipeline tests"));
++	createTests(monolithic.get(), constructGroupParams(baseGroupParams, vk::PIPELINE_CONSTRUCTION_TYPE_MONOLITHIC));
++	parentGroup->addChild(monolithic.release());
+ 
+ #ifndef CTS_USES_VULKANSC
+-	de::MovePtr<tcu::TestCaseGroup> dynamicRenderingGroup(new tcu::TestCaseGroup(testCtx, "dynamic_rendering", "Draw using VK_KHR_dynamic_rendering"));
+-	de::MovePtr<tcu::TestCaseGroup> drPrimaryCmdBuffGroup(new tcu::TestCaseGroup(testCtx, "primary_cmd_buff", "Draw using Draw commands are recorded in primary command buffer"));
+-	createPipelineConstructionTypePermutations(testCtx, drPrimaryCmdBuffGroup.get(),
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				true,																// bool							useDynamicRendering;
+-				false,																// bool							useSecondaryCmdBuffer;
+-				false,																// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
+-				vk::PipelineConstructionType(0)		// placeholder					// PipelineConstructionType		pipelineConstructionType;
+-			}));
+-	de::MovePtr<tcu::TestCaseGroup> drPartialSecondaryCmdBuffGroup(createTestGroup(testCtx, "partial_secondary_cmd_buff", "Secondary command buffer doesn't include begin/endRendering", createTests,
+-		SharedGroupParams(
+-			new GroupParams
+-			{
+-				true,																// bool							useDynamicRendering;
+-				true,																// bool							useSecondaryCmdBuffer;
+-				false,																// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
+-				vk::PIPELINE_CONSTRUCTION_TYPE_MONOLITHIC,							// PipelineConstructionType		pipelineConstructionType;
+-			})));
+-	de::MovePtr<tcu::TestCaseGroup> drCompleteSecondaryCmdBuffGroup(createTestGroup(testCtx, "complete_secondary_cmd_buff", "Secondary command buffer contains completely dynamic renderpass", createTests,
+-		SharedGroupParams(
+-			new GroupParams
++	de::MovePtr<tcu::TestCaseGroup> pipelineLibrary(new tcu::TestCaseGroup(testCtx, "pipeline_library",	"Graphics pipeline library tests"));
++	de::MovePtr<tcu::TestCaseGroup> fastLinkedLibrary(new tcu::TestCaseGroup(testCtx, "fast_linked_library",	"Fast linked graphics pipeline library tests"));
++
++	// repeat tests but using different pipeline construction types
++	createTests(pipelineLibrary.get(), constructGroupParams(baseGroupParams, vk::PIPELINE_CONSTRUCTION_TYPE_LINK_TIME_OPTIMIZED_LIBRARY));
++	createTests(fastLinkedLibrary.get(), constructGroupParams(baseGroupParams, vk::PIPELINE_CONSTRUCTION_TYPE_FAST_LINKED_LIBRARY));
++
++	parentGroup->addChild(pipelineLibrary.release());
++	parentGroup->addChild(fastLinkedLibrary.release());
++#endif // CTS_USES_VULKANSC
++}
++
++#ifndef CTS_USES_VULKANSC
++void createDynamicRenderingPermutations(tcu::TestCaseGroup* parentGroup)
++{
++	tcu::TestContext& testCtx = parentGroup->getTestContext();
++
++	auto constructGroupParams = [](bool useSecondaryCmdBuffer, bool secondaryCmdBufferCompletelyContainsDynamicRenderpass)
++	{
++		return SharedGroupParams(new GroupParams
+ 			{
+-				true,																// bool							useDynamicRendering;
+-				true,																// bool							useSecondaryCmdBuffer;
+-				true,																// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
+-				vk::PIPELINE_CONSTRUCTION_TYPE_MONOLITHIC,							// PipelineConstructionType		pipelineConstructionType;
+-			})));
+-
+-	dynamicRenderingGroup->addChild(drPrimaryCmdBuffGroup.release());
+-	dynamicRenderingGroup->addChild(drPartialSecondaryCmdBuffGroup.release());
+-	dynamicRenderingGroup->addChild(drCompleteSecondaryCmdBuffGroup.release());
++				true,														// bool							useDynamicRendering;
++				useSecondaryCmdBuffer,										// bool							useSecondaryCmdBuffer;
++				secondaryCmdBufferCompletelyContainsDynamicRenderpass,		// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
++				vk::PIPELINE_CONSTRUCTION_TYPE_MONOLITHIC,					// PipelineConstructionType		pipelineConstructionType;
++			});
++	};
++
++	de::MovePtr<tcu::TestCaseGroup> drPrimaryCmdBuffGroup			(new tcu::TestCaseGroup(testCtx, "primary_cmd_buff",			"Draw using Draw commands are recorded in primary command buffer"));
++	de::MovePtr<tcu::TestCaseGroup> drPartialSecondaryCmdBuffGroup	(new tcu::TestCaseGroup(testCtx, "partial_secondary_cmd_buff",	"Secondary command buffer doesn't include begin/endRendering"));
++	de::MovePtr<tcu::TestCaseGroup> drCompleteSecondaryCmdBuffGroup	(new tcu::TestCaseGroup(testCtx, "complete_secondary_cmd_buff",	"Secondary command buffer contains completely dynamic renderpass"));
++
++	// repeat tests but with different location of dynamic rendering commands
++	createPipelineConstructionTypePermutations(drPrimaryCmdBuffGroup.get(), constructGroupParams(false, false));
++	createTests(drPartialSecondaryCmdBuffGroup.get(),  constructGroupParams(true, false));
++	createTests(drCompleteSecondaryCmdBuffGroup.get(), constructGroupParams(true, true));
++
++	parentGroup->addChild(drPrimaryCmdBuffGroup.release());
++	parentGroup->addChild(drPartialSecondaryCmdBuffGroup.release());
++	parentGroup->addChild(drCompleteSecondaryCmdBuffGroup.release());
++}
+ #endif // CTS_USES_VULKANSC
+ 
++} // anonymous
++
++tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
++{
++	de::MovePtr<tcu::TestCaseGroup> mainGroup			(new tcu::TestCaseGroup(testCtx, "fragment_shading_rate", "Fragment shading rate tests"));
++	de::MovePtr<tcu::TestCaseGroup> renderpass2Group	(createTestGroup(testCtx, "renderpass2", "Draw using render pass object",
++		createPipelineConstructionTypePermutations,
++		SharedGroupParams(new GroupParams
++		{
++			false,																// bool							useDynamicRendering;
++			false,																// bool							useSecondaryCmdBuffer;
++			false,																// bool							secondaryCmdBufferCompletelyContainsDynamicRenderpass;
++			vk::PipelineConstructionType(0)		// placeholder					// PipelineConstructionType		pipelineConstructionType;
++		})));
+ 	mainGroup->addChild(renderpass2Group.release());
++
+ #ifndef CTS_USES_VULKANSC
++	de::MovePtr<tcu::TestCaseGroup> dynamicRenderingGroup(createTestGroup(testCtx, "dynamic_rendering", "Draw using VK_KHR_dynamic_rendering", createDynamicRenderingPermutations));
+ 	mainGroup->addChild(dynamicRenderingGroup.release());
+ #endif // CTS_USES_VULKANSC
+ 
+-- 
+2.36.0.windows.1
+
diff --git a/tests/regres/deqp.json b/tests/regres/deqp.json
index 982be8b..142dd7f 100644
--- a/tests/regres/deqp.json
+++ b/tests/regres/deqp.json
@@ -3,6 +3,7 @@
     "branch": "",
     "sha": "50754c3c19c0ade27dedb8162288e4b1af9518fa",
     "patches": [
-        "tests/regres/deqp-patches/deqp-x11.patch"
+        "tests/regres/deqp-patches/deqp-x11.patch",
+        "tests/regres/deqp-patches/deqp-fsr.patch"
     ]
 }