-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area: naga back-endOutputs of naga shader conversionOutputs of naga shader conversionlang: HLSLD3D Shading LanguageD3D Shading Languagelang: SPIR-VVulkan's Shading LanguageVulkan's Shading LanguagenagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Milestone
Description
NOTE: description edited 2024-4-16, so much of the following discussion may look irrelevant
The WGSL specification says that a && b
only evaluates b
if a
is true, but Naga generally will always evaluate both.
The following input:
fn h() -> bool {
return f() || g();
}
produces the following output WGSL:
fn h() -> bool {
let _e0 = f();
let _e1 = g();
return (_e0 || _e1);
}
The call to g
is hoisted out to a statement and made unconditional, which is incorrect.
This means that even though most backends turn Naga IR's BinaryOperator::LogicalAnd
and BinaryOperator::LogicalOr
into short-circuiting operations in the target language, it doesn't help because the front end has already hoisted the right-hand side, which ought to be conditional, out into its own unconditional statement.
Metadata
Metadata
Assignees
Labels
area: naga back-endOutputs of naga shader conversionOutputs of naga shader conversionlang: HLSLD3D Shading LanguageD3D Shading Languagelang: SPIR-VVulkan's Shading LanguageVulkan's Shading LanguagenagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Type
Projects
Status
In Progress