You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test.hlsl:21:24: error: cannot convert from 'literal int' to 'SomeBitfield'
SomeBitfield val = (SomeBitfield)0;
However, if I switch the order of the field1 and rest members in SomeBitfield, it seemingly works and the generated code looks correct. Is the SomeBitfield val = (SomeBitfield)0 syntax meant to be valid? If yes, it doesn't seem to work reliably. If no, how to I easily (and most efficiently) initialize all members of a bitfield to 0?
I suspect the bug here is in how HLSL flattened initializers work. We may be able to implement a hacky fix that resolves this issue but the correct long-term solution would be to adopt C/C++ initialization rules, which we have a rough feature proposal for.
Description
It is unclear to me how to initialize a bitfield to all 0 in HLSL. It appears a simple syntax works in some cases, but not others.
Steps to Reproduce
test.hlsl
file contains:Compile with:
Actual Behavior
You get this output:
However, if I switch the order of the
field1
andrest
members inSomeBitfield
, it seemingly works and the generated code looks correct. Is theSomeBitfield val = (SomeBitfield)0
syntax meant to be valid? If yes, it doesn't seem to work reliably. If no, how to I easily (and most efficiently) initialize all members of a bitfield to 0?Environment
dxcompiler_xs.dll!DxcCreateInstance: 1.7 - 2310.2307.12501.10025
The text was updated successfully, but these errors were encountered: