PDA

View Full Version : sRGB Renderbuffers in GL2.1+



skynet
07-11-2011, 03:10 AM
I just ask myself, if it is possible (allowed) to create sRGB renderbuffers just by the means of EXT/ARB_framebuffer_object, EXT/ARB_framebuffer_sRGB and EXT_texture_sRGB (which is already in core 2.1)

By just reading the specs, I could not find any wordening that would allow to create GL_SRGB8[_ALPHA8] renderbuffers.

GL3.0+ specifies it very clearly, though...

Alfonse Reinheart
07-11-2011, 03:39 AM
By just reading the specs, I could not find any wordening that would allow to create GL_SRGB8[_ALPHA8] renderbuffers.

Sure they do.

From EXT_framebuffer_object:



The command

void RenderbufferStorageEXT(enum target, enum internalformat, sizei width, sizei height);

establishes the data storage, format, and dimensions of a renderbuffer object's image. <target> must be RENDERBUFFER_EXT. <internalformat> must be color-renderable

The definition of "color-renderable" is:


* The following base internal formats from table 3.15 are "color-renderable": RGB, RGBA, FLOAT_R_NV, FLOAT_RG_NV, FLOAT_RGB_NV, and FLOAT_RGBA_NV. The sized internal formats from table 3.16 that have a color-renderable base internal format are also color-renderable. No other formats, including compressed internal formats, are color-renderable.

Now, from EXT_texture_sRGB:



Add 4 new rows to Table 3.16 (page 154).

Sized Base R G B A L I D
Internal Format Internal Format bits bits bits bits bits bits bits
--------------------- --------------- ---- ---- ---- ---- ---- ---- ----
SRGB8_EXT RGB 8 8 8
SRGB8_ALPHA8_EXT RGBA 8 8 8 8


The base internal format of GL_SRGB8_EXT and GL_SRGB8_ALPHA8_EXT are RGB and RGBA. Both of these are on the "color-renderable" list and therefore both of them can be used to create FBOs.

skynet
07-11-2011, 04:07 AM
I understand that there's technically no reason to not provide it, but consider:

EXT_framebuffer_object is written against GL1.5, which doesn't contain sRGB stuff yet, so the table EXT_fbo refers to doesn't contain any sRGB formats.

EXT_texture_sRGB was written against GL2.0, but at a time when FBOs were already very well established. But yet, they left anything out that would describe interactions with EXT_fbo.

ARB_framebuffer_object is written against GL2.1, so you're right, in this case table 3.16 would already contain the sRGB formats.

Sometimes this whole extension business is driving me crazy ;-)

Alfonse Reinheart
07-11-2011, 01:03 PM
EXT_framebuffer_object is written against GL1.5, which doesn't contain sRGB stuff yet, so the table EXT_fbo refers to doesn't contain any sRGB formats.

EXT_texture_sRGB was written against GL2.0, but at a time when FBOs were already very well established. But yet, they left anything out that would describe interactions with EXT_fbo.

That's how extensions interact. EXT_texture_sRGB changes a table that EXT_framebuffer_object uses. Therefore, if you have both, then the changes to the table that sRGB makes must be used by EXT_FBO. That's why EXT_FBO doesn't just create a list of color-renderable formats. It refers to a table, which future extensions can update and therefore seamlessly interact with EXT_FBO.

Or, to put it another way, it just works, without either extension having to know about the other. They all interact exactly as the user expects, and it is all well-specified.