SPIRV-Cross/shaders-msl/asm/frag
Chip Davis aca9b6879a MSL: Support pull-model interpolation on MSL 2.3+.
New in MSL 2.3 is a template that can be used in the place of a scalar
type in a stage-in struct. This template has methods which interpolate
the varying at the given points. Curiously, you can't set interpolation
attributes on such a varying; perspective-correctness is encoded in the
type, while interpolation must be done using one of the methods. This
makes using this somewhat awkward from SPIRV-Cross, requiring us to jump
through a bunch of hoops to make this all work.

Using varyings from functions in particular is a pain point, requiring
us to pass the stage-in struct itself around. An alternative is to pass
references to the interpolants; except this will fall over badly with
composite types, which naturally must be flattened.  As with
tessellation, dynamic indexing isn't supported with pull-model
interpolation. This is because of the need to reference the original
struct member in order to call one of the pull-model interpolation
methods on it. Also, this is done at the variable level; this means that
if one varying in a struct is used with the pull-model functions, then
the entire struct is emitted as pull-model interpolants.

For some reason, this was not documented in the MSL spec, though there
is a property on `MTLDevice`, `supportsPullModelInterpolation`,
indicating support for this, which *is* documented. This does not appear
to be implemented yet for AMD: it returns `NO` from
`supportsPullModelInterpolation`, and pipelines with shaders using the
templates fail to compile. It *is* implemeted for Intel. It's probably
also implemented for Apple GPUs: on Apple Silicon, OpenGL calls down to
Metal, and it wouldn't be possible to use the interpolation functions
without this implemented in Metal.

Based on my testing, where SPIR-V and GLSL have the offset relative to
the pixel center, in Metal it appears to be relative to the pixel's
upper-left corner, as in HLSL. Therefore, I've added an offset 0.4375,
i.e. one half minus one sixteenth, to all arguments to
`interpolate_at_offset()`.

This also fixes a long-standing bug: if a pull-model interpolation
function is used on a varying, make sure that varying is declared. We
were already doing this only for the AMD pull-model function,
`interpolateAtVertexAMD()`; for reasons which are completely beyond me,
we weren't doing this for the base interpolation functions. I also note
that there are no tests for the interpolation functions for GLSL or
HLSL.
2020-11-05 11:57:45 -06:00
..
combined-sampler-reuse.asm.frag Fix case where SampledImage would get flushed to temporary. 2018-04-27 10:06:30 +02:00
default-member-names.asm.frag Update to latest glslang/SPIRV-Tools. 2019-01-30 13:41:57 +01:00
descriptor-array-unnamed.asm.frag MSL: Emit proper name for optimized UBO/SSBO arrays. 2019-02-25 11:09:00 +01:00
disable-renamed-output.frag-output.asm.frag MSL: Force disabled fragment builtins to have the right name. 2020-04-15 19:25:18 -05:00
empty-struct.asm.frag Update glslang and SPIRV-Tools. 2018-09-27 11:10:22 +02:00
extract-packed-from-composite.asm.frag Update to latest glslang/SPIRV-Tools. 2019-01-30 13:41:57 +01:00
frem.asm.frag Add OpFRem tests. 2018-02-15 13:36:59 +01:00
function-overload-alias.asm.frag Handle overloaded functions which share the same OpName. 2018-02-23 14:15:51 +01:00
image-extract-reuse.asm.frag Fix usage tracking issue for OpImage. 2018-04-27 11:11:24 +02:00
implicit-read-dep-phi.asm.frag Add test shader where a phi variable invalidates a temporary. 2018-03-09 14:42:26 +01:00
inf-nan-constant.asm.frag Add Windows support in Travis CI. 2018-10-27 00:22:30 +02:00
interpolation-qualifiers-struct.asm.frag MSL: Handle interpolation qualifiers. 2018-09-05 12:02:07 -05:00
line-directive.line.asm.frag Support emitting OpLine directive. 2019-05-28 13:44:24 +02:00
locations-components.asm.frag Update to latest glslang/SPIRV-Tools. 2019-01-30 13:41:57 +01:00
lut-promotion-initializer.asm.frag Add LUT test cases for OpVariable with initializer. 2018-07-05 14:51:07 +02:00
min-lod.msl22.asm.frag MSL: Support MinLod operand. 2019-06-19 09:43:03 +02:00
op-constant-null.asm.frag CompilerMSL support and tests for OpUndef. 2017-11-15 22:44:42 -05:00
op-image-sampled-image.asm.frag Update to latest glslang/SPIRV-Tools. 2019-01-30 13:41:57 +01:00
pass-by-value.asm.frag MSL: Properly support passing parameters by value. 2018-08-06 15:43:51 +02:00
phi-loop-variable.asm.frag CompilerMSL support and tests for OpUndef. 2017-11-15 22:44:42 -05:00
pull-model-interpolation.asm.msl23.frag MSL: Support pull-model interpolation on MSL 2.3+. 2020-11-05 11:57:45 -06:00
sample-and-compare.asm.frag MSL: Fix textures which are sampled and compared against. 2019-02-22 12:27:40 +01:00
single-function-private-lut.asm.frag Support LUTs in single-function CFGs on Private storage class. 2019-02-06 10:38:59 +01:00
srem.asm.frag Add SREM tests for HLSL/MSL. 2018-05-24 10:34:36 +02:00
storage-class-output-initializer.asm.frag Support initializers on StorageClassOutput. 2019-01-30 10:29:08 +01:00
texel-fetch-no-lod.asm.frag Deal with OpImageFetch without explicit LOD. 2018-04-30 10:54:44 +02:00
texture-sampling-fp16.asm.frag Update external repos. 2019-07-13 16:50:21 -05:00
undef-variable-store.asm.frag CompilerMSL support and tests for OpUndef. 2017-11-15 22:44:42 -05:00
unknown-depth-state.asm.frag Support OpTypeImage with depth == 2 (unknown) properly. 2018-07-04 14:26:23 +02:00
unord-relational-op.asm.frag Add tests for FUnord comparisons of vectors. 2018-09-01 12:42:07 -05:00
unreachable.asm.frag Add unreachable tests for MSL/HLSL. 2018-01-15 09:39:15 +01:00
vector-shuffle-oom.asm.frag Use declared binding in SPIR-V as a fallback for explicit MSL binds. 2018-04-04 12:25:11 +02:00