microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.05k stars 679 forks source link

[SPIR-V] Varying error behavior with bit functions on 16 bit types #6864

Open noahwhygodwhy opened 1 month ago

noahwhygodwhy commented 1 month ago

Description

When using functions like firstbithigh, firstbitlow, and countbits, there are varying errors. The correct error is something along the lines of error: firstbithigh is currently limited to 32-bit width components when targetting SPIR-V however that isn't always the result.

Steps to Reproduce

Example of "correct" behavior: https://godbolt.org/z/ecPqhxWGx Example of segfault: https://godbolt.org/z/4qYG1Y8Mv Example of possibly correct, but more vague error: https://godbolt.org/z/5x37qdnxs

Actual Behavior

I feel the correct behavior is, if asking for these ops to work for 16 bit values is off the table, for them to all produce the same error (and definitely not segfault)

Environment

s-perron commented 3 weeks ago

Placing in the backlog. We will not be adding support for the 16-bit types. The SPIR-V instruction do not allow 16-bit types. We would have to do lots of extra work to get the correct value, and can be misleading to users if they expect access to a single instruction. Like with 64-bit values, we will leave it to the user to do what is needed.

As for fixing up the error messages, I would like to get to it. However, I don't know if we will get to it for the next release.