aca9b6879a
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. |
||
---|---|---|
.. | ||
combined-sampler-reuse.asm.frag | ||
default-member-names.asm.frag | ||
descriptor-array-unnamed.asm.frag | ||
disable-renamed-output.frag-output.asm.frag | ||
empty-struct.asm.frag | ||
extract-packed-from-composite.asm.frag | ||
frem.asm.frag | ||
function-overload-alias.asm.frag | ||
image-extract-reuse.asm.frag | ||
implicit-read-dep-phi.asm.frag | ||
inf-nan-constant.asm.frag | ||
interpolation-qualifiers-struct.asm.frag | ||
line-directive.line.asm.frag | ||
locations-components.asm.frag | ||
lut-promotion-initializer.asm.frag | ||
min-lod.msl22.asm.frag | ||
op-constant-null.asm.frag | ||
op-image-sampled-image.asm.frag | ||
pass-by-value.asm.frag | ||
phi-loop-variable.asm.frag | ||
pull-model-interpolation.asm.msl23.frag | ||
sample-and-compare.asm.frag | ||
single-function-private-lut.asm.frag | ||
srem.asm.frag | ||
storage-class-output-initializer.asm.frag | ||
texel-fetch-no-lod.asm.frag | ||
texture-sampling-fp16.asm.frag | ||
undef-variable-store.asm.frag | ||
unknown-depth-state.asm.frag | ||
unord-relational-op.asm.frag | ||
unreachable.asm.frag | ||
vector-shuffle-oom.asm.frag |