Respect pipelineStageCreationFeedbackCount

PipelineCreationFeedback was writing past the end of the
pPipelineStageCreationFeedbacks array by not respecting
the value of pipelineStageCreationFeedbackCount. This CL
adds bounds checks to make sure this doesn't happen.

Tests: dEQP-VK.pipeline.monolithic.creation_feedback.graphics_tests.vertex_stage_fragment_stage_no_cache_zero_out_feedback_cout
Bug: b/247516349
Change-Id: I62601f84b9044bb6752e48dad3861a5694cd14ac
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/68330
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 01fc82d..504cd4d 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -154,7 +154,7 @@
 
 	void stageCreationBegins(uint32_t stage)
 	{
-		if(pipelineCreationFeedback)
+		if(pipelineCreationFeedback && (stage < pipelineCreationFeedback->pipelineStageCreationFeedbackCount))
 		{
 			// Record stage creation begin time
 			pipelineCreationFeedback->pPipelineStageCreationFeedbacks[stage].duration = now();
@@ -167,14 +167,17 @@
 		{
 			pipelineCreationFeedback->pPipelineCreationFeedback->flags |=
 			    VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
-			pipelineCreationFeedback->pPipelineStageCreationFeedbacks[stage].flags |=
-			    VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
+			if(stage < pipelineCreationFeedback->pipelineStageCreationFeedbackCount)
+			{
+				pipelineCreationFeedback->pPipelineStageCreationFeedbacks[stage].flags |=
+				    VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
+			}
 		}
 	}
 
 	void stageCreationEnds(uint32_t stage)
 	{
-		if(pipelineCreationFeedback)
+		if(pipelineCreationFeedback && (stage < pipelineCreationFeedback->pipelineStageCreationFeedbackCount))
 		{
 			pipelineCreationFeedback->pPipelineStageCreationFeedbacks[stage].flags |=
 			    VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT;