From 85416e297e291e91ce9f7c4237e6082d66849070 Mon Sep 17 00:00:00 2001 From: Chip Davis Date: Fri, 20 Nov 2020 16:06:33 -0600 Subject: [PATCH] MVKGraphicsPipeline: Handle minSampleShading. If it is enabled and nonzero, then force sample-rate shading in the fragment shader. --- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 012ccb32..cbe42663 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -1090,8 +1090,11 @@ bool MVKGraphicsPipeline::addFragmentShaderToPipeline(MTLRenderPipelineDescripto shaderContext.options.mslOptions.view_mask_buffer_index = _viewRangeBufferIndex.stages[kMVKShaderStageFragment]; shaderContext.options.entryPointName = _pFragmentSS->pName; shaderContext.options.mslOptions.capture_output_to_buffer = false; - if (pCreateInfo->pMultisampleState && pCreateInfo->pMultisampleState->pSampleMask && pCreateInfo->pMultisampleState->pSampleMask[0] != 0xffffffff) { - shaderContext.options.mslOptions.additional_fixed_sample_mask = pCreateInfo->pMultisampleState->pSampleMask[0]; + if (pCreateInfo->pMultisampleState) { + if (pCreateInfo->pMultisampleState->pSampleMask && pCreateInfo->pMultisampleState->pSampleMask[0] != 0xffffffff) { + shaderContext.options.mslOptions.additional_fixed_sample_mask = pCreateInfo->pMultisampleState->pSampleMask[0]; + } + shaderContext.options.mslOptions.force_sample_rate_shading = pCreateInfo->pMultisampleState->sampleShadingEnable && pCreateInfo->pMultisampleState->minSampleShading != 0.0f; } if (std::any_of(shaderOutputs.begin(), shaderOutputs.end(), [](const SPIRVShaderOutput& output) { return output.builtin == spv::BuiltInLayer; })) { shaderContext.options.mslOptions.arrayed_subpass_input = true; @@ -2000,7 +2003,8 @@ namespace SPIRV_CROSS_NAMESPACE { opt.arrayed_subpass_input, opt.ios_use_simdgroup_functions, opt.emulate_subgroups, - opt.vertex_index_type); + opt.vertex_index_type, + opt.force_sample_rate_shading); } template