KhronosGroup / OpenGL-API

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

Spec missing some glTexImage(GL_STENCIL_INDEX8) error cases #86

Closed ianromanick closed 2 years ago

ianromanick commented 2 years ago

The "Errors" block at the end of section 8.5.3 (Texture Image Structure) of the OpenGL 4.6 spec says:

An INVALID_OPERATION error is generated if one of the base internal format and format is DEPTH_COMPONENT or DEPTH_STENCIL, and the other is neither of these values.

An INVALID_OPERATION error is generated if format is STENCIL_INDEX and the base internal format is not STENCIL_INDEX.

I think the STENCIL_INDEX error should have the same conditions as the DEPTH_COMPONENT / DEPTH_STENCIL case.

The spec is clear that glTexImage2D(..., internalformat=RGBA8, ..., format=GL_STENCIL_INDEX, ...) is an error. I believe glTexImage2D(..., internalformat=GL_STENCIL_INDEX8, ..., format=GL_RGBA, ...) should also generate GL_INVALID_OPERATION.

I propose changing the second error to be:

An INVALID_OPERATION error is generated if either base internal format or format is STENCIL_INDEX and the other is not also STENCIL_INDEX.

I think the "either ... or ..." wording is more readable, but language more similar to the previous line would also work.

ianromanick commented 2 years ago

Looking at this after the meeting, I'm wondering if glTexImage2D(..., internalformat=STENCIL_INDEX, ..., format=DEPTH_STENCIL, ...) should be allowed.

By the existing error, quoted above, it is not. However, glTexImage2D(..., internalformat=DEPTH_COMPONENT, ..., format=DEPTH_STENCIL, ...) does seem to be valid. Is that intended? Ugh!

pdaniell-nv commented 2 years ago

Our implementation supports this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 8, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8_EXT, data);

but does not support this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX8, 8, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8_EXT, data);

The first does seem to be explicitly allowed by the spec, and the second throws INVALID_OPERATION. I think your proposed spec fix to clarify the error for STENCIL_INDEX and not DEPTH_STENCIL is good.

pdaniell-nv commented 2 years ago

@oddhack can you change the error on page 215 of the OpenGL 4.6 core spec from:

An INVALID_OPERATION error is generated if format is STENCIL_INDEX and the base internal format is not STENCIL_INDEX.

to

An INVALID_OPERATION error is generated if either base internal format or format is STENCIL_INDEX and the other is not also STENCIL_INDEX.

oddhack commented 2 years ago

This should be fixed in the spec update of May 5, 2022.