From d0dba760e72b93a17e94b94a2d3038f781f03ffc Mon Sep 17 00:00:00 2001 From: Chip Davis Date: Tue, 28 Nov 2023 14:05:21 -0800 Subject: [PATCH] MVKPipeline: Enable the cube texture gradient workaround for Apple Silicon. Update SPIRV-Cross to pull in the code for the workaround. Fixes 8 tests under `dEQP-VK.glsl.texture_functions.texturegrad.*`. --- Docs/Whats_New.md | 1 + ExternalRevisions/SPIRV-Cross_repo_revision | 2 +- MoltenVK/MoltenVK/API/mvk_private_api.h | 1 + MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 1 + MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 4 +++- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index e0abbf70..724532ae 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -27,6 +27,7 @@ Released TBD - Fix initial value of `VkPhysicalDeviceLimits::timestampPeriod` on non-Apple Silicon GPUs. - Update to latest SPIRV-Cross: - MSL: Fix regression error in argument buffer runtime arrays. + - MSL: Work around broken cube texture gradients on Apple Silicon. diff --git a/ExternalRevisions/SPIRV-Cross_repo_revision b/ExternalRevisions/SPIRV-Cross_repo_revision index 9f579560..cd24745d 100644 --- a/ExternalRevisions/SPIRV-Cross_repo_revision +++ b/ExternalRevisions/SPIRV-Cross_repo_revision @@ -1 +1 @@ -4818f7e7ef7b7078a3a7a5a52c4a338e0dda22f4 +50e90dd74e0e43e243f12a70f0326d2cf8ed3945 diff --git a/MoltenVK/MoltenVK/API/mvk_private_api.h b/MoltenVK/MoltenVK/API/mvk_private_api.h index af6c3ffc..dd0b31ca 100644 --- a/MoltenVK/MoltenVK/API/mvk_private_api.h +++ b/MoltenVK/MoltenVK/API/mvk_private_api.h @@ -152,6 +152,7 @@ typedef struct { VkBool32 needsSampleDrefLodArrayWorkaround; /**< If true, sampling from arrayed depth images with explicit LoD is broken and needs a workaround. */ VkDeviceSize hostMemoryPageSize; /**< The size of a page of host memory on this platform. */ VkBool32 dynamicVertexStride; /**< If true, VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE is supported. */ + VkBool32 needsCubeGradWorkaround; /**< If true, sampling from cube textures with explicit gradients is broken and needs a workaround. */ } MVKPhysicalDeviceMetalFeatures; /** diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index cca95d57..dfad9cf0 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -1759,6 +1759,7 @@ void MVKPhysicalDevice::initMetalFeatures() { if (!mvkOSVersionIsAtLeast(14.0, 17.0, 1.0)) { _metalFeatures.needsSampleDrefLodArrayWorkaround = true; } + _metalFeatures.needsCubeGradWorkaround = true; // fallthrough case kIntelVendorId: case kNVVendorId: diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 0b266340..c85ef684 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -1680,6 +1680,7 @@ void MVKGraphicsPipeline::initShaderConversionConfig(SPIRVToMSLConversionConfigu shaderConfig.options.mslOptions.argument_buffers = useMetalArgBuff; shaderConfig.options.mslOptions.force_active_argument_buffer_resources = useMetalArgBuff; shaderConfig.options.mslOptions.pad_argument_buffer_resources = useMetalArgBuff; + shaderConfig.options.mslOptions.agx_manual_cube_grad_fixup = _device->_pMetalFeatures->needsCubeGradWorkaround; MVKPipelineLayout* layout = (MVKPipelineLayout*)pCreateInfo->layout; layout->populateShaderConversionConfig(shaderConfig); @@ -2517,7 +2518,8 @@ namespace SPIRV_CROSS_NAMESPACE { opt.manual_helper_invocation_updates, opt.check_discarded_frag_stores, opt.sample_dref_lod_array_as_grad, - opt.replace_recursive_inputs); + opt.replace_recursive_inputs, + opt.agx_manual_cube_grad_fixup); } template