Fix VK_EXT_graphics_pipeline_library related crash
Code to properly get the module from VkPipelineShaderStageCreateInfo
had been added in GraphicsPipeline::compileShaders(), but not in
ComputePipeline::compileShaders().
Copied the code from GraphicsPipeline::compileShaders() to
ComputePipeline::compileShaders() to fix the issue.
Tests: dEQP-VK.pipeline.pipeline_library.graphics_library.misc.non_graphics.shader_module_info_comp
Bug: b/245568070
Change-Id: Ief67a97a2004125186ef4cd40c8fd7e274c29037
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/70148
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 15c3549..e292044 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -585,6 +585,24 @@
auto &stage = pCreateInfo->stage;
const ShaderModule *module = vk::Cast(stage.module);
+ // VK_EXT_graphics_pipeline_library allows VkShaderModuleCreateInfo to be chained to
+ // VkPipelineShaderStageCreateInfo, which is used if stageInfo.module is
+ // VK_NULL_HANDLE.
+ VkShaderModule tempModule = {};
+ if(stage.module == VK_NULL_HANDLE)
+ {
+ const auto *moduleCreateInfo = vk::GetExtendedStruct<VkShaderModuleCreateInfo>(stage.pNext,
+ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
+ ASSERT(moduleCreateInfo);
+ VkResult createResult = vk::ShaderModule::Create(nullptr, moduleCreateInfo, &tempModule);
+ if(createResult != VK_SUCCESS)
+ {
+ return createResult;
+ }
+
+ module = vk::Cast(tempModule);
+ }
+
ASSERT(shader.get() == nullptr);
ASSERT(program.get() == nullptr);