KhronosGroup / SPIRV-Cross

SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
Apache License 2.0
1.96k stars 549 forks source link

[MSL] Support SPV_EXT_fragment_invocation_density in MSL 2.2 #1015

Open cdavis5e opened 5 years ago

cdavis5e commented 5 years ago

MSL 2.2 adds a new rasterization rate map type which maps between logical and screen coordinates. Using this new type with the FragCoord builtin should enable us to support the FragSizeEXT builtin from SPV_EXT_fragment_invocation_density. The FragInvocationCountEXT builtin, meanwhile, can be implemented in terms of the number of samples in the render target, assuming sample-rate shading is active. Since Metal doesn't actually support minSampleShading, we'd thus always return the number of samples as the invocation count.

cdavis5e commented 4 years ago

It looks like Apple removed this incomplete feature from the MSL 2.2 headers. Maybe the next version will support this.

oscarbg commented 4 years ago

yep.. but we should reopen as it should have returned today in Xcode 11 GM as it's a new feature of A13 GPU.. see (https://twitter.com/gavkar/status/1171494278545018882) also https://developer.apple.com/videos/play/tech-talks/608/

HansKristian-Work commented 4 years ago

It does not seem like Metal's varying shading rate is remotely compatible with D3D or Vulkan. From what I understand it's varying rasterization rate with required resolve rather than varying shading rate (but fixed raster rate).

cdavis5e commented 4 years ago

It does not seem like Metal's varying shading rate is remotely compatible with D3D or Vulkan. From what I understand it's varying rasterization rate with required resolve rather than varying shading rate (but fixed raster rate).

Part of it's the way it's implemented. Vulkan and D3D12's Tier 2 use an image to set the rate at which the fragment/pixel shader is invoked. Metal, however, uses a pair of piecewise linear functions, which cannot express everything that you can express with a shading rate image. Basically, Metal's functionality is greater than D3D12 Tier 1 VRS (which sets a constant rate for the whole render target) but lesser than Tier 2.

cdavis5e commented 4 years ago

It does not seem like Metal's varying shading rate is remotely compatible with D3D or Vulkan. From what I understand it's varying rasterization rate with required resolve rather than varying shading rate (but fixed raster rate).

Part of it's the way it's implemented. Vulkan and D3D12's Tier 2 use an image to set the rate at which the fragment/pixel shader is invoked. Metal, however, uses a pair of piecewise linear functions, which cannot express everything that you can express with a shading rate image. Basically, Metal's functionality is greater than D3D12 Tier 1 VRS (which sets a constant rate for the whole render target) but lesser than Tier 2.

The other thing is that it's unclear if the rasterization rate map affects depth and stencil rendering. D3D12 is clear that its implementation of VRS does not. Vulkan does not seem to specify. I suspect, though, that because it indicates that it only affects the number of fragment shader invocations, the depth and stencil values are computed normally.