diff --git a/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag b/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag deleted file mode 100644 index 880523f1c..000000000 --- a/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float3 value [[color(0)]]; -}; - -struct main0_in -{ - float3 gl_BaryCoordNoPerspEXT [[barycentric_coord, centroid_no_perspective]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.value = in.gl_BaryCoordNoPerspEXT; - return out; -} - diff --git a/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag b/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag deleted file mode 100644 index b92a2fcbc..000000000 --- a/reference/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float3 value [[color(0)]]; -}; - -struct main0_in -{ - float3 gl_BaryCoordEXT [[barycentric_coord, centroid_perspective]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.value = in.gl_BaryCoordEXT; - return out; -} - diff --git a/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag b/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag deleted file mode 100644 index f893f18af..000000000 --- a/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float3 value [[color(0)]]; -}; - -struct main0_in -{ - float3 gl_BaryCoordNoPerspEXT [[barycentric_coord, sample_no_perspective]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.value = in.gl_BaryCoordNoPerspEXT; - return out; -} - diff --git a/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag b/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag deleted file mode 100644 index ebbdbb3e8..000000000 --- a/reference/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace metal; - -struct main0_out -{ - float3 value [[color(0)]]; -}; - -struct main0_in -{ - float3 gl_BaryCoordEXT [[barycentric_coord, sample_perspective]]; -}; - -fragment main0_out main0(main0_in in [[stage_in]]) -{ - main0_out out = {}; - out.value = in.gl_BaryCoordEXT; - return out; -} - diff --git a/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag b/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag deleted file mode 100644 index 6adc57800..000000000 --- a/shaders-msl-no-opt/asm/frag/barycentric-centroid-noperspective.msl22.asm.frag +++ /dev/null @@ -1,34 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 11 -; Bound: 13 -; Schema: 0 - OpCapability Shader - OpCapability FragmentBarycentricKHR - OpExtension "SPV_KHR_fragment_shader_barycentric" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %value %gl_BaryCoordEXT - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpSourceExtension "GL_EXT_fragment_shader_barycentric" - OpName %main "main" - OpName %value "value" - OpName %gl_BaryCoordEXT "gl_BaryCoordEXT" - OpDecorate %value Location 0 - OpDecorate %gl_BaryCoordEXT BuiltIn BaryCoordNoPerspKHR - OpDecorate %gl_BaryCoordEXT Centroid - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v3float = OpTypeVector %float 3 -%_ptr_Output_v3float = OpTypePointer Output %v3float - %value = OpVariable %_ptr_Output_v3float Output -%_ptr_Input_v3float = OpTypePointer Input %v3float -%gl_BaryCoordEXT = OpVariable %_ptr_Input_v3float Input - %main = OpFunction %void None %3 - %5 = OpLabel - %12 = OpLoad %v3float %gl_BaryCoordEXT - OpStore %value %12 - OpReturn - OpFunctionEnd diff --git a/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag b/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag deleted file mode 100644 index 309b9bb1e..000000000 --- a/shaders-msl-no-opt/asm/frag/barycentric-centroid-perspective.msl22.asm.frag +++ /dev/null @@ -1,34 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 11 -; Bound: 13 -; Schema: 0 - OpCapability Shader - OpCapability FragmentBarycentricKHR - OpExtension "SPV_KHR_fragment_shader_barycentric" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %value %gl_BaryCoordEXT - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpSourceExtension "GL_EXT_fragment_shader_barycentric" - OpName %main "main" - OpName %value "value" - OpName %gl_BaryCoordEXT "gl_BaryCoordEXT" - OpDecorate %value Location 0 - OpDecorate %gl_BaryCoordEXT BuiltIn BaryCoordKHR - OpDecorate %gl_BaryCoordEXT Centroid - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v3float = OpTypeVector %float 3 -%_ptr_Output_v3float = OpTypePointer Output %v3float - %value = OpVariable %_ptr_Output_v3float Output -%_ptr_Input_v3float = OpTypePointer Input %v3float -%gl_BaryCoordEXT = OpVariable %_ptr_Input_v3float Input - %main = OpFunction %void None %3 - %5 = OpLabel - %12 = OpLoad %v3float %gl_BaryCoordEXT - OpStore %value %12 - OpReturn - OpFunctionEnd diff --git a/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag b/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag deleted file mode 100644 index feab1a8e8..000000000 --- a/shaders-msl-no-opt/asm/frag/barycentric-sample-noperspective.msl22.asm.frag +++ /dev/null @@ -1,35 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 11 -; Bound: 13 -; Schema: 0 - OpCapability Shader - OpCapability SampleRateShading - OpCapability FragmentBarycentricKHR - OpExtension "SPV_KHR_fragment_shader_barycentric" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %value %gl_BaryCoordEXT - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpSourceExtension "GL_EXT_fragment_shader_barycentric" - OpName %main "main" - OpName %value "value" - OpName %gl_BaryCoordEXT "gl_BaryCoordEXT" - OpDecorate %value Location 0 - OpDecorate %gl_BaryCoordEXT BuiltIn BaryCoordNoPerspKHR - OpDecorate %gl_BaryCoordEXT Sample - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v3float = OpTypeVector %float 3 -%_ptr_Output_v3float = OpTypePointer Output %v3float - %value = OpVariable %_ptr_Output_v3float Output -%_ptr_Input_v3float = OpTypePointer Input %v3float -%gl_BaryCoordEXT = OpVariable %_ptr_Input_v3float Input - %main = OpFunction %void None %3 - %5 = OpLabel - %12 = OpLoad %v3float %gl_BaryCoordEXT - OpStore %value %12 - OpReturn - OpFunctionEnd diff --git a/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag b/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag deleted file mode 100644 index 5594c6767..000000000 --- a/shaders-msl-no-opt/asm/frag/barycentric-sample-perspective.msl22.asm.frag +++ /dev/null @@ -1,35 +0,0 @@ -; SPIR-V -; Version: 1.0 -; Generator: Khronos Glslang Reference Front End; 11 -; Bound: 13 -; Schema: 0 - OpCapability Shader - OpCapability SampleRateShading - OpCapability FragmentBarycentricKHR - OpExtension "SPV_KHR_fragment_shader_barycentric" - %1 = OpExtInstImport "GLSL.std.450" - OpMemoryModel Logical GLSL450 - OpEntryPoint Fragment %main "main" %value %gl_BaryCoordEXT - OpExecutionMode %main OriginUpperLeft - OpSource GLSL 450 - OpSourceExtension "GL_EXT_fragment_shader_barycentric" - OpName %main "main" - OpName %value "value" - OpName %gl_BaryCoordEXT "gl_BaryCoordEXT" - OpDecorate %value Location 0 - OpDecorate %gl_BaryCoordEXT BuiltIn BaryCoordKHR - OpDecorate %gl_BaryCoordEXT Sample - %void = OpTypeVoid - %3 = OpTypeFunction %void - %float = OpTypeFloat 32 - %v3float = OpTypeVector %float 3 -%_ptr_Output_v3float = OpTypePointer Output %v3float - %value = OpVariable %_ptr_Output_v3float Output -%_ptr_Input_v3float = OpTypePointer Input %v3float -%gl_BaryCoordEXT = OpVariable %_ptr_Input_v3float Input - %main = OpFunction %void None %3 - %5 = OpLabel - %12 = OpLoad %v3float %gl_BaryCoordEXT - OpStore %value %12 - OpReturn - OpFunctionEnd diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 5dfcedb79..94a1765f8 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -13063,7 +13063,11 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in { if (!quals.empty()) quals += ", "; - if (has_member_decoration(type.self, index, DecorationNoPerspective) || builtin == BuiltInBaryCoordNoPerspKHR) + + if (builtin == BuiltInBaryCoordNoPerspKHR || builtin == BuiltInBaryCoordKHR) + SPIRV_CROSS_THROW("Centroid interpolation not supported for barycentrics in MSL."); + + if (has_member_decoration(type.self, index, DecorationNoPerspective)) quals += "centroid_no_perspective"; else quals += "centroid_perspective"; @@ -13072,7 +13076,11 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in { if (!quals.empty()) quals += ", "; - if (has_member_decoration(type.self, index, DecorationNoPerspective) || builtin == BuiltInBaryCoordNoPerspKHR) + + if (builtin == BuiltInBaryCoordNoPerspKHR || builtin == BuiltInBaryCoordKHR) + SPIRV_CROSS_THROW("Sample interpolation not supported for barycentrics in MSL."); + + if (has_member_decoration(type.self, index, DecorationNoPerspective)) quals += "sample_no_perspective"; else quals += "sample_perspective"; diff --git a/test_shaders.py b/test_shaders.py index 475faeb7b..7a5bc7f39 100755 --- a/test_shaders.py +++ b/test_shaders.py @@ -116,23 +116,6 @@ def print_msl_compiler_version(): except subprocess.CalledProcessError: pass -def msl_compiler_supports_version(version): - try: - if platform.system() == 'Darwin': - subprocess.check_call(['xcrun', '--sdk', 'macosx', 'metal', '-x', 'metal', version, '-'], - stdin = subprocess.DEVNULL, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) - print('Current SDK supports MSL {0}. Enabling validation for MSL {0} shaders.'.format(version)) - else: - print('Running on {}, assuming {} is supported.'.format(platform.system(), version)) - # If we're running on non-macOS system, assume it's supported. - return True - except OSError as e: - print('Failed to check if MSL {} is not supported. It probably is not.'.format(version)) - return False - except subprocess.CalledProcessError: - print('Current SDK does NOT support MSL {0}. Disabling validation for MSL {0} shaders.'.format(version)) - return False - def path_to_msl_standard(shader): if '.msl31.' in shader: return '-std=metal3.1' @@ -905,23 +888,7 @@ def test_shader_msl(stats, shader, args, paths): # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. # print('SPRIV shader: ' + spirv) - shader_is_msl22 = '.msl22.' in joined_path - shader_is_msl23 = '.msl23.' in joined_path - shader_is_msl24 = '.msl24.' in joined_path - shader_is_msl30 = '.msl3.' in joined_path - shader_is_msl31 = '.msl31.' in joined_path - skip_validation = (shader_is_msl22 and (not args.msl22)) or \ - (shader_is_msl23 and (not args.msl23)) or \ - (shader_is_msl24 and (not args.msl24)) or \ - (shader_is_msl30 and (not args.msl30)) or \ - (shader_is_msl31 and (not args.msl31)) - - if skip_validation: - print('Skipping validation for {} due to lack of toolchain support.'.format(joined_path)) - - if '.invalid.' in joined_path: - skip_validation = True - + skip_validation = '.invalid.' in joined_path if (not args.force_no_external_validation) and (not skip_validation): validate_shader_msl(shader, args.opt) @@ -1068,18 +1035,8 @@ def main(): sys.stderr.write('Parallel execution is disabled when using the flags --update, --malisc or --force-no-external-validation\n') args.parallel = False - args.msl22 = False - args.msl23 = False - args.msl24 = False - args.msl30 = False - args.msl31 = False if args.msl: print_msl_compiler_version() - args.msl22 = msl_compiler_supports_version('-std=macos-metal2.2') - args.msl23 = msl_compiler_supports_version('-std=macos-metal2.3') - args.msl24 = msl_compiler_supports_version('-std=macos-metal2.4') - args.msl30 = msl_compiler_supports_version('-std=metal3.0') - args.msl31 = msl_compiler_supports_version('-std=metal3.1') backend = 'glsl' if (args.msl or args.metal):