Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[glsl-in] naga rejects use of clamp in constant initializer #1498

Closed
afd opened this issue Oct 29, 2021 · 1 comment · Fixed by #1502
Closed

[glsl-in] naga rejects use of clamp in constant initializer #1498

afd opened this issue Oct 29, 2021 · 1 comment · Fixed by #1502
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language

Comments

@afd
Copy link

afd commented Oct 29, 2021

This shader is legal in GLSL 4.5:

#version 450

const int x = clamp(1, 1, 1);

void main()
{
}

because builtins such as clamp are allowed in constant expressions if invoked with constant expression arguments (see "4.3.3 Constant Expressions" in the GLSL 4.5 spec).

naga (revision 9d2b357) rejects the example with:

error: const values must have an initializer
@JCapucho JCapucho added kind: bug Something isn't working area: front-end Input formats for conversion lang: GLSL OpenGL Shading Language labels Oct 29, 2021
@sjinno
Copy link
Contributor

sjinno commented Oct 30, 2021

I would like to work on this issue if it's okay :) @jimblandy will be mentoring me.

sjinno added a commit to sjinno/naga that referenced this issue Nov 1, 2021
Failure on globally initialized math functions was not returning a proper error message.

For example, issue gfx-rs#1498 states, the following sample code

```

const x = clamp(1, 1, 1);

void main() {}
```

would return an error message: `error: const values must have an initializer`, which is not accurate since it does have an initializer.

The correct/intuitive error message should now print `error: Not implemented: Clamp
` for this sample case.
@JCapucho JCapucho linked a pull request Nov 7, 2021 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants