SPIRV-Cross/reference/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 Updates for pull request #1162 2019-09-24 14:35:25 -04:00
default-member-names.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
descriptor-array-unnamed.asm.frag MSL: Do not declare array of UBO/SSBO as spvUnsafeArray<T>. 2019-10-26 16:10:08 +02: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 Implement constant empty struct correctly on all backends. 2019-10-26 16:10:11 +02:00
extract-packed-from-composite.asm.frag MSL: Do not generate UnsafeArray<> for any array inside buffer objects. 2019-10-24 12:22:30 +02:00
frem.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
function-overload-alias.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
image-extract-reuse.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
implicit-read-dep-phi.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
inf-nan-constant.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
interpolation-qualifiers-struct.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
line-directive.line.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
locations-components.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
lut-promotion-initializer.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
min-lod.msl22.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
op-constant-null.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
op-image-sampled-image.asm.frag MSL: Do not generate UnsafeArray<> for any array inside buffer objects. 2019-10-24 12:22:30 +02:00
pass-by-value.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
phi-loop-variable.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04: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 Updates for pull request #1162 2019-09-24 14:35:25 -04:00
single-function-private-lut.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
srem.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
storage-class-output-initializer.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
texel-fetch-no-lod.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
texture-atomics.asm.frag Removed bounds checks in favor of SPIRV-Tools pass '--graphics-robust-access' 2019-10-21 16:39:53 -04:00
texture-atomics.asm.graphics-robust-access.frag Removed bounds checks in favor of SPIRV-Tools pass '--graphics-robust-access' 2019-10-21 16:39:53 -04:00
texture-sampling-fp16.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
undef-variable-store.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
unknown-depth-state.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
unord-relational-op.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
unreachable.asm.frag Updates for pull request #1162 2019-09-24 14:35:25 -04:00
vector-shuffle-oom.asm.frag MSL: Do not generate UnsafeArray<> for any array inside buffer objects. 2019-10-24 12:22:30 +02:00