-
Notifications
You must be signed in to change notification settings - Fork 619
MSL: Also handle signedness mismatches in fragment outputs. #2562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
4c23c9b to
6e8ed14
Compare
I don't think that is legal ... Can you point to spec language? |
The Fragment Output interface section says:
That would indicate that you are correct. However, the CTS actually tests the case where the fragment shader's output and the color attachment's format are mismatched in sign, which suggests that this must be allowed somewhere in the spec... (see |
It turns out that the number of components is not the only place where Vulkan allows differences but Metal insists on strict equivalence. Vulkan _also_ allows the fragment shader and the attachment to differ in signedness--for example, rendering to an `R8G8B8A8_UINT` image where the fragment shader declares its output to be an `ivec4`. To fix this, we must adjust the `[[color]]` output in the interface block to match the render target. Use the shader output specification mechanism to do this; also move the fragment component count here to save some memory at run time. Signed-off-by: Chip Davis <[email protected]>
6e8ed14 to
bae6d54
Compare
|
$#@!ing MSVC... |
|
Does that CTS test what the output value is? The spec language says undefined value, which means it's valid to just write 0 to those in theory (but using mismatched types isn't technically illegal). CTS sometimes have bugs, and it's possible this is one of those cases. |
As a matter of fact, it does. |
|
File a CTS bug then. It's not a valid test with the current spec language. |
|
Based on this finding, I'm not sure where to go with this PR. If we're adding extra complexity and maintenance burden to support a case that only a bogus CTS test cares about, I'm a bit reluctant, but that's doesn't mean I'm blocking it outright. Awaiting a reply before this PR can progress. |
|
|
So while the spec says it's undefined behavior, https://gerrit.khronos.org/c/vk-gl-cts/+/12319 forced all drivers to support this... My main concern is that because now all drivers have that undefined behavior defined, the workgroup could decide to actually make it defined I guess. I've created an internal CTS issue for the public one to address this: https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/6131 While KosmicKrisp works around this, it would be better if we didn't have to. |
It turns out that the number of components is not the only place where Vulkan allows differences but Metal insists on strict equivalence. Vulkan also allows the fragment shader and the attachment to differ in signedness--for example, rendering to an
R8G8B8A8_UINTimage where the fragment shader declares its output to be anivec4.To fix this, we must adjust the
[[color]]output in the interface block to match the render target. Use the shader output specification mechanism to do this; also move the fragment component count here to save some memory at run time.