KhronosGroup / OpenGL-API

OpenGL and OpenGL ES API Issue Tracker
34 stars 5 forks source link

Layout qualifiers on formal parameters for image load/store #53

Closed NicolBolas closed 5 years ago

NicolBolas commented 5 years ago

GLSL has a pretty strong statement that layout qualifiers are not allowed on formal parameters.

Layout qualifiers cannot be used on formal function parameters, but they are not included in parameter matching.

That seems pretty ironclad. However, the GLSL specification has several places in it that implies strongly that image variables can have format layout qualifiers:

Format layout qualifiers can be used on image variable declarations

Note that there is no statement exempting parameters, which are still (I think?) variable declarations.

Furthermore:

it is a compile-time error to pass an image uniform variable or function parameter declared without a format layout qualifier to an image load or atomic function.

That too strongly implies the ability to apply layout qualifiers to function parameters. The reason being that image load/atomic operations require layout qualifiers on the variable they're used on. So without being able to put layout qualifiers on formal parameters, you would be unable to use image load/atomic operations on them.

Also, I skimmed through ARB_bindless_texture, and I didn't find a place that explicitly rescinded the prohibition from the first quote (the quote is from section 4.10, which bindless_texture doesn't touch). Which means you can't work with them there either. My guess is that the writers of that extension assumed that it was already legal.

In ARB_image_load_store, there was some disagreement or confusion about the issue. Directly before the statement quoted at the top is a code example that uses layout qualifiers in formal parameters. When the text was moved to GLSL 4.20, those layout qualifiers disappeared.

So... what's going on here? Is the intent of the spec to not allow users to use image load/atomic operations on image variables passed through function parameters? If so, then ARB_bindless_texture needs to be updated to allow it (presumably?). And if not, then GLSL itself needs to be changed to correct this.

jeffbolznv commented 5 years ago

See https://github.com/KhronosGroup/GLSL/issues/57. I think it was left as "You currently can't use layouts on function parameters, but somebody could write an extension to add it".

pdaniell-nv commented 5 years ago

Closing since this is covered by KhronosGroup/GLSL#57.