Do not attempt to initialize dynamic state vars with pipeline state Pipeline variables, like scissor, viewport and blend constants, may not be provided by the pipeline state if they are set to use the dynamic state instead. In that case, the related initialization structures may be null and should not be used. Bug b/118619338 Change-Id: Ieb5ff066b06ecfe444c6d26e43c70fd18d2f9c31 Tests: dEQP-VK.image.texel_view_compatible.graphic.extended.* Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29053 Tested-by: Alexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp index 815923f..d4d53e1 100644 --- a/src/Vulkan/VkPipeline.cpp +++ b/src/Vulkan/VkPipeline.cpp
@@ -313,8 +313,15 @@ UNIMPLEMENTED("pCreateInfo->pViewportState settings"); } - scissor = viewportState->pScissors[0]; - viewport = viewportState->pViewports[0]; + if(!hasDynamicState(VK_DYNAMIC_STATE_SCISSOR)) + { + scissor = viewportState->pScissors[0]; + } + + if(!hasDynamicState(VK_DYNAMIC_STATE_VIEWPORT)) + { + viewport = viewportState->pViewports[0]; + } } const VkPipelineRasterizationStateCreateInfo* rasterizationState = pCreateInfo->pRasterizationState; @@ -393,10 +400,13 @@ UNIMPLEMENTED("colorBlendState"); } - blendConstants.r = colorBlendState->blendConstants[0]; - blendConstants.g = colorBlendState->blendConstants[1]; - blendConstants.b = colorBlendState->blendConstants[2]; - blendConstants.a = colorBlendState->blendConstants[3]; + if(!hasDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS)) + { + blendConstants.r = colorBlendState->blendConstants[0]; + blendConstants.g = colorBlendState->blendConstants[1]; + blendConstants.b = colorBlendState->blendConstants[2]; + blendConstants.a = colorBlendState->blendConstants[3]; + } if(colorBlendState->attachmentCount == 1) {