Fix for dynamic rendering.

Bug: 300273941
Test: Ran dEQP *dynamic_rendering* tests.
Change-Id: Iec966aea89c8dc2b652672d89235cd281f41b5fe
diff --git a/guest/vulkan_enc/ResourceTracker.cpp b/guest/vulkan_enc/ResourceTracker.cpp
index 1eb1864..95a9ac9 100644
--- a/guest/vulkan_enc/ResourceTracker.cpp
+++ b/guest/vulkan_enc/ResourceTracker.cpp
@@ -6900,12 +6900,29 @@
             graphicsPipelineCreateInfo.pMultisampleState = nullptr;
         }
 
+        bool forceDepthStencilState = false;
+        bool forceColorBlendState = false;
+
+        const VkPipelineRenderingCreateInfo* pipelineRenderingInfo =
+            vk_find_struct<VkPipelineRenderingCreateInfo>(&graphicsPipelineCreateInfo);
+
+        if (pipelineRenderingInfo) {
+            forceDepthStencilState |= pipelineRenderingInfo->depthAttachmentFormat != VK_FORMAT_UNDEFINED;
+            forceDepthStencilState |= pipelineRenderingInfo->stencilAttachmentFormat != VK_FORMAT_UNDEFINED;
+            forceColorBlendState |= pipelineRenderingInfo->colorAttachmentCount != 0;
+        }
+
         // VUID-VkGraphicsPipelineCreateInfo-renderPass-06043
         // VUID-VkGraphicsPipelineCreateInfo-renderPass-06044
         if (graphicsPipelineCreateInfo.renderPass == VK_NULL_HANDLE ||
             !shouldIncludeFragmentShaderState) {
-            graphicsPipelineCreateInfo.pDepthStencilState = nullptr;
-            graphicsPipelineCreateInfo.pColorBlendState = nullptr;
+            // VUID-VkGraphicsPipelineCreateInfo-renderPass-06053
+            if (!forceDepthStencilState) {
+                graphicsPipelineCreateInfo.pDepthStencilState = nullptr;
+            }
+            if (!forceColorBlendState) {
+                graphicsPipelineCreateInfo.pColorBlendState = nullptr;
+            }
         }
     }
     return enc->vkCreateGraphicsPipelines(device, pipelineCache, localCreateInfos.size(),
diff --git a/guest/vulkan_enc/vk_struct_id.h b/guest/vulkan_enc/vk_struct_id.h
index 1c3f5e5..7fc535c 100644
--- a/guest/vulkan_enc/vk_struct_id.h
+++ b/guest/vulkan_enc/vk_struct_id.h
@@ -79,6 +79,8 @@
 REGISTER_VK_STRUCT_ID(VkBindImageMemorySwapchainInfoKHR, VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
 REGISTER_VK_STRUCT_ID(VkBufferOpaqueCaptureAddressCreateInfo, VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
 REGISTER_VK_STRUCT_ID(VkBufferDeviceAddressCreateInfoEXT, VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT);
+REGISTER_VK_STRUCT_ID(VkGraphicsPipelineCreateInfo, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
+REGISTER_VK_STRUCT_ID(VkPipelineRenderingCreateInfo, VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO);
 
 #undef REGISTER_VK_STRUCT_ID