Skip to content
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

naga: wrong transliteration of wgsl select to hlsl (2021+) #5484

Closed
AnuraDev opened this issue Apr 3, 2024 · 1 comment
Closed

naga: wrong transliteration of wgsl select to hlsl (2021+) #5484

AnuraDev opened this issue Apr 3, 2024 · 1 comment

Comments

@AnuraDev
Copy link

AnuraDev commented Apr 3, 2024

fn hard_light(cb: vec3<f32>, cs: vec3<f32>) -> vec3<f32> {
    return select(
        screen(cb, 2.0 * cs - 1.0),
        cb * 2.0 * cs,
        cs <= vec3(0.5)
    );
}

gets translated into

float3 hard_light(float3 cb_3, float3 cs_3)
{
    const float3 _e7 = screen(cb_3, ((2.0 * cs_3) - (1.0).xxx));
    return ((cs_3 <= (0.5).xxx) ? ((cb_3 * 2.0) * cs_3) : _e7);
}

and you get this error:

condition for short-circuiting ternary operator must be scalar, for non-scalar types use 'select'

here is the explanation https://github.com/microsoft/DirectXShaderCompiler/wiki/HLSL-2021#logical-operation-short-circuiting-for-scalars.

@teoxoy
Copy link
Member

teoxoy commented Apr 3, 2024

closing as duplicate of #4498

@teoxoy teoxoy closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants