KhronosGroup / OpenGL-Registry

OpenGL, OpenGL ES, and OpenGL ES-SC API and Extension Registry
678 stars 274 forks source link

for `EXT_YUV_target`, how to set YUV to RGBA convert standard in ReadPixels ? #565

Closed shutaozhenzhen closed 1 year ago

shutaozhenzhen commented 1 year ago

In EXT_YUV_target we can use YUV convert function with standard in shader. But in issues 16, ReadPixels also convert YUV to RGBA . How to set this conversion's standard? Or what is this conversion's standard?

jackohound commented 1 year ago

The short answer is that the YUV to RGBA conversion used in glReadPixels for this case is implementation-dependent.

The OES_EGL_image_external extension allows sampling of external textures that may be in YUV colorspace and where the implementation will perform YUV to RGB conversion, but where the details of that conversion are not exposed to GL. With EXT_YUV_target, TEXTURE_EXTERNAL_OES can be attached to the framebuffer. Issue 16 is intended to clarify that glReadPixels with format=GL_RGBA and type=GL_UNSIGNED_BYTE is allowed with such a framebuffer attachment and will perform a similar YUV to RGB conversion where the details of the conversion are not exposed to GL.

If you need more control over YUV->RGB conversion, then I would suggest you use EXT_YUV_target to sample from the YUV texture, perform whatever conversion you want in the shader, writing the RGB result to an RGB framebuffer. Then you can use glReadPixels to read the RGB data.

Let me know if this resolves the question.

shutaozhenzhen commented 1 year ago

OK, thanks replay.