Work around problems with explicit LoD with arrayed depth images on Apple Silicon.

Use an explicit gradient to make it sample the correct level.

Update SPIRV-Cross to pull in the change needed for this.
This commit is contained in:
Chip Davis 2023-02-03 14:46:37 -08:00
parent e8885a24e8
commit 2c01c8b7e0
5 changed files with 12 additions and 2 deletions

View File

@ -20,6 +20,8 @@ Released TBA
- Fix issue where extension `VK_KHR_fragment_shader_barycentric`
was sometimes incorrectly disabled due to a Metal driver bug.
- Work around problems with using explicit LoD with arrayed depth images
on Apple Silicon.

View File

@ -1 +1 @@
eb9b2732982b8eea3395216be825a74dd84fe4be
4e2fdb25671c742a9fbe93a6034eb1542244c7e1

View File

@ -979,6 +979,7 @@ typedef struct {
VkBool32 programmableSamplePositions; /**< If true, programmable MSAA sample positions are supported. */
VkBool32 shaderBarycentricCoordinates; /**< If true, fragment shader barycentric coordinates are supported. */
MTLArgumentBuffersTier argumentBuffersTier; /**< The argument buffer tier available on this device, as a Metal enumeration. */
VkBool32 needsSampleDrefLodArrayWorkaround; /**< If true, sampling from arrayed depth images with explicit LoD is broken and needs a workaround. */
} MVKPhysicalDeviceMetalFeatures;
/** MoltenVK performance of a particular type of activity. */

View File

@ -1493,6 +1493,9 @@ void MVKPhysicalDevice::initMetalFeatures() {
_metalFeatures.clearColorFloatRounding = MVK_FLOAT_ROUNDING_DOWN;
break;
case kAppleVendorId:
// TODO: Other GPUs?
_metalFeatures.needsSampleDrefLodArrayWorkaround = true;
// fallthrough
case kIntelVendorId:
case kNVVendorId:
default:

View File

@ -1152,6 +1152,9 @@ bool MVKGraphicsPipeline::addFragmentShaderToPipeline(MTLRenderPipelineDescripto
shaderConfig.options.mslOptions.capture_output_to_buffer = false;
shaderConfig.options.mslOptions.fixed_subgroup_size = mvkIsAnyFlagEnabled(_pFragmentSS->flags, VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) ? 0 : _device->_pMetalFeatures->maxSubgroupSize;
shaderConfig.options.mslOptions.check_discarded_frag_stores = true;
if (_device->_pMetalFeatures->needsSampleDrefLodArrayWorkaround) {
shaderConfig.options.mslOptions.sample_dref_lod_array_as_grad = true;
}
if (_isRasterizing && pCreateInfo->pMultisampleState) { // Must ignore allowed bad pMultisampleState pointer if rasterization disabled
if (pCreateInfo->pMultisampleState->pSampleMask && pCreateInfo->pMultisampleState->pSampleMask[0] != 0xffffffff) {
shaderConfig.options.mslOptions.additional_fixed_sample_mask = pCreateInfo->pMultisampleState->pSampleMask[0];
@ -2253,7 +2256,8 @@ namespace SPIRV_CROSS_NAMESPACE {
opt.vertex_index_type,
opt.force_sample_rate_shading,
opt.manual_helper_invocation_updates,
opt.check_discarded_frag_stores);
opt.check_discarded_frag_stores,
opt.sample_dref_lod_array_as_grad);
}
template<class Archive>