diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 6a0bd6f2c..0887eba4d 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -2208,6 +2208,8 @@ _features.depthClamp = true; _features.vertexPipelineStoresAndAtomics = true; _features.fragmentStoresAndAtomics = true; + _features.geometryShader = true; + _features.shaderCullDistance = true; #if MVK_XCODE_12 _features.shaderInt64 = mslVersionIsAtLeast(MTLLanguageVersion2_3); #else diff --git a/MoltenVK/MoltenVK/Utility/MVKEnvironment.h b/MoltenVK/MoltenVK/Utility/MVKEnvironment.h index cec1740e7..a9fdb1617 100644 --- a/MoltenVK/MoltenVK/Utility/MVKEnvironment.h +++ b/MoltenVK/MoltenVK/Utility/MVKEnvironment.h @@ -176,12 +176,12 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig); /** Support full ImageView swizzles. Disabled by default. */ #ifndef MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE -# define MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE 0 +# define MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE 1 #endif /** Set the fastMathEnabled Metal Compiler option. Set to always use fast math by default. */ #ifndef MVK_CONFIG_FAST_MATH_ENABLED -# define MVK_CONFIG_FAST_MATH_ENABLED MVK_CONFIG_FAST_MATH_ALWAYS +# define MVK_CONFIG_FAST_MATH_ENABLED MVK_CONFIG_FAST_MATH_NEVER #endif /** Set the logging level: */ @@ -241,7 +241,7 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig); * By default, use Metal events, if availalble, on most platforms. */ #ifndef MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE -# define MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE_METAL_EVENTS_WHERE_SAFE +# define MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE_SINGLE_QUEUE #endif #ifndef MVK_ALLOW_METAL_EVENTS // Deprecated # define MVK_ALLOW_METAL_EVENTS 1 @@ -282,7 +282,7 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig); /** Resume MVKDevice VK_ERROR_DEVICE_LOST errors that do not cause MVKPhysicalDevice errors. Disabled by default. */ #ifndef MVK_CONFIG_RESUME_LOST_DEVICE -# define MVK_CONFIG_RESUME_LOST_DEVICE 0 +# define MVK_CONFIG_RESUME_LOST_DEVICE 1 #endif /** Support Metal argument buffers. Disabled by default. */ diff --git a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.cpp b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.cpp index f1672e2ba..3dc03e9a8 100644 --- a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.cpp +++ b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.cpp @@ -340,6 +340,27 @@ MVK_PUBLIC_SYMBOL bool SPIRVToMSLConverter::convert(SPIRVToMSLConversionConfigur } conversionResult.msl = pMSLCompiler->compile(); + struct Patch + { + std::string find; + std::string replace; + }; + + Patch workaround_patches[] = { + { std::string("t3.sample(s3, r0.yzwy.xyz).xyz"), std::string("r0.yzw") }, + { std::string("t5.sample(s5, r2.xyzx.xyz).xyz"), std::string("r2.xyz") }, + }; + + for (Patch workaround_patch : workaround_patches) + { + std::string::size_type pos = 0u; + while((pos = conversionResult.msl.find(workaround_patch.find, pos)) != std::string::npos) + { + conversionResult.msl.replace(pos, workaround_patch.find.length(), workaround_patch.replace); + pos += workaround_patch.replace.length(); + } + } + if (shouldLogMSL) { logSource(conversionResult.resultLog, conversionResult.msl, "MSL", "Converted"); } #ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS