-
Notifications
You must be signed in to change notification settings - Fork 714
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
[SPIR-V] All attempts at decorating an instruction with Inline-SPIRV fail. #7064
Comments
Attempt 1 couldn't possibly work, you just disabled validation so you didn't see the fundamental issue with it: https://godbolt.org/z/7nqeMr17K
(all |
The DirectXShaderCompiler/tools/clang/test/CodeGenSPIRV/spv.intrinsicDecorate.hlsl Lines 46 to 47 in 905add5
I wish there was a better documentation, but at least that seems to work: https://godbolt.org/z/xqTMnroqn Well, except it decorates the variable, so maybe that test is doing something useless all along (and the decoration disappears with optimizations. The exact needed thing is EDIT: C++ attributes on expressions have been proposed but AFAICT not accepted yet into any future C++ standard: With that proposal, your code would look like this: result.lo = (
[[vk::ext_decorate(
spv::DecorationFPRoundingMode,
spv::FPRoundingModeRTN,
)]]
lo + rhs.lo
); (the extra parens are necessary for syntactic disambiguation) You could then define |
[[vk::ext_decorate(39, 0)]] fAdd(lo,rhs.lo); fails with
btw if just my last example template<typename T>
[[vk::ext_decorate(spv::DecorationFPRoundingMode,spv::FPRoundingModeRTN)]]
[[vk::ext_instruction(spv::OpFAdd)]]
T fAddRTN(T lhs, T rhs); worked no "yet unapproved C++ standard addition" would have to be implemented. |
Description
I'm trying to make a proof-of-concept interval arithmetic library in HLSL.
This requires me to leverage the
float_controls2
extension and set rounding modes per instruction.I can't figure out the syntax to
OpDecorate
an isntruction.Steps to Reproduce
Attempt 1, take an intermediate of the
OpFAdd
and attempt to `OpDecorate that.Attempt 2, try and use your
vk::ext_decorate
on an intrinsicActual Behavior
Attempt 1 kind-of-works but only with
-O0
and kind-of becauseOpDecorate
can't return anything so while I can annotate an immediate, I can't get it out and use it meaningfullyhttps://godbolt.org/z/9E346eazG
However if I progress onto
-O1
the optimizer breaks the code altogether (goes from valid but dead to invalid), moving the decoration on the immediate result to a constant it optimized tohttps://godbolt.org/z/5TYr85Kvf
Attempt 2 doesn't emit any
OpDecorate
at all, even in-O0
, its just ignoredhttps://godbolt.org/z/xnK6azeqM
Environment
The text was updated successfully, but these errors were encountered: