diff options
author | Chip Davis <cdavis@codeweavers.com> | 2020-11-21 00:41:46 +0300 |
---|---|---|
committer | Chip Davis <cdavis@codeweavers.com> | 2020-11-23 19:30:24 +0300 |
commit | fd738e3387535b4e18104336ff04a0c000ab5f45 (patch) | |
tree | 91102c719da448dbb1875b6082627e188f8bf7bc /spirv_cross_c.cpp | |
parent | 782916a7971bbbd450f288c939ea838da0b2e6f1 (diff) |
MSL: Adjust FragCoord for sample-rate shading.
In Metal, the `[[position]]` input to a fragment shader remains at
fragment center, even at sample rate, like OpenGL and Direct3D. In
Vulkan, however, when the fragment shader runs at sample rate, the
`FragCoord` builtin moves to the sample position in the framebuffer,
instead of the fragment center. To account for this difference, adjust
the `FragCoord`, if present, by the sample position. The -0.5 offset is
because the fragment center is at (0.5, 0.5).
Also, add an option to force sample-rate shading in a fragment shader.
Since Metal has no explicit control for this, this is done by adding a
dummy `[[sample_id]]` which is otherwise unused, if none is already
present. This is intended to be used from e.g. MoltenVK when a
pipeline's `minSampleShading` value is nonzero.
Instead of checking if any `Input` variables have `Sample`
interpolation, I've elected to check that the `SampleRateShading`
capability is present. Since `SampleId`, `SamplePosition`, and the
`Sample` interpolation decoration require this cap, this should be
equivalent for any valid SPIR-V module. If this isn't acceptable, let me
know.
Diffstat (limited to 'spirv_cross_c.cpp')
-rw-r--r-- | spirv_cross_c.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/spirv_cross_c.cpp b/spirv_cross_c.cpp index 4b561378..d90d40ab 100644 --- a/spirv_cross_c.cpp +++ b/spirv_cross_c.cpp @@ -690,6 +690,10 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c case SPVC_COMPILER_OPTION_MSL_FIXED_SUBGROUP_SIZE: options->msl.fixed_subgroup_size = value; break; + + case SPVC_COMPILER_OPTION_MSL_FORCE_SAMPLE_RATE_SHADING: + options->msl.force_sample_rate_shading = value != 0; + break; #endif default: |