From 00e84bbf11af2cf01af20399075f56b42e8a682c Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Tue, 24 Jul 2018 11:07:44 -0700 Subject: [PATCH 1/2] CreatePipelines should not return SUCCESS when MSL translation fails. When vertex shader translation fails, we were already calling setConfigurationResult, but we were not doing this for fragment shaders. --- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index ea7df6d7..506f2cf2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -284,7 +284,12 @@ MTLRenderPipelineDescriptor* MVKGraphicsPipeline::getMTLRenderPipelineDescriptor // Fragment shader if (mvkAreFlagsEnabled(pSS->stage, VK_SHADER_STAGE_FRAGMENT_BIT)) { shaderContext.options.entryPointStage = spv::ExecutionModelFragment; - plDesc.fragmentFunction = mvkShdrMod->getMTLFunction(&shaderContext, pSS->pSpecializationInfo, _pipelineCache).mtlFunction; + id mtlFunction = mvkShdrMod->getMTLFunction(&shaderContext, pSS->pSpecializationInfo, _pipelineCache).mtlFunction; + if ( !mtlFunction ) { + setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "Fragment shader function could not be compiled into pipeline. See previous error.")); + return nil; + } + plDesc.fragmentFunction = mtlFunction; } } From 93ff3564b12e6397b0a3ab6812a29c44904212fb Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Tue, 24 Jul 2018 13:23:43 -0700 Subject: [PATCH 2/2] Do not kill pipeline when fragment shader is invalid. --- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 506f2cf2..a295cae3 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -287,7 +287,6 @@ MTLRenderPipelineDescriptor* MVKGraphicsPipeline::getMTLRenderPipelineDescriptor id mtlFunction = mvkShdrMod->getMTLFunction(&shaderContext, pSS->pSpecializationInfo, _pipelineCache).mtlFunction; if ( !mtlFunction ) { setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "Fragment shader function could not be compiled into pipeline. See previous error.")); - return nil; } plDesc.fragmentFunction = mtlFunction; }