2
$\begingroup$

My understanding is:

  1. the 'framebuffer' in OpenGL is a collection of buffers: many (due to swapping or stereo rendering) color buffers, (only one?) z-buffer and (only one?) stencil buffer;
  2. each OpenGL application has a 'default framebuffer', but can have more 'framebuffer objects';
  3. a 'compositing window manager' aka 'compositor' only cares about an application's current front color buffer of its 'default framebuffer'. The compositor calls this buffer 'off screen buffer'.
  4. the compositor reads all applications' 'off screen buffers' and composites them onto a single image called screen buffer' aka 'video buffer' aka 'regen(eration) buffer';
  5. a display controller will read (scan?) the 'screen buffer' and convert it to a signal to be sent to the physical screen.

Main question:

Can it be (eg. if I run a video game full-screen) that the compositor could simply declare the application's off-screen buffer the same as its 'screen buffer' so that the same location in memory that fragments had their colors originally blended onto will actually be the location the display controller will read from? I.e. OpenGL will render to some area in either VRAM or RAM and without coincidence this same location will be read by the display controller even after any sort of compositor stage.

Additionally:

  • Does the compositor designate the 'off screen buffer' for the application (or multiple locations for double/triple buffering or stereo) and it's up to the application to fill that area in memory and "ring the compositor" when its ready or
  • does the application create the buffer and the compositor is only told where to read from (eg. the app's OpenGL draws to a back buffer, designates it as the front and tells the compositor to read it)?
  • or is it a mix of the two?
$\endgroup$
3
  • $\begingroup$ "the application's off-screen buffer the same as its 'screen buffer'" I think you misusued your own terminology here. You defined the "off-screen buffer" as being the front buffer, which is not what you render to. You render to the back buffer. So this would not be "the same location in memory that fragments had their colors originally blended onto". So what exactly are you looking for here? $\endgroup$ Commented Jun 25, 2020 at 16:52
  • $\begingroup$ @NicolBolas Yes, it is my understanding, too, that the back buffer is rendered to (and not the front buffer). I found on wikipedia that 'Software double buffering' copies the back buffer's content to the front buffer. However, it notes compositors can copy directly from the back buffer, thus considering it the 'off-screen buffer' instead of the front buffer. Does it simply copy from back buffer to front buffer in full-screen mode? If so, my main question is answered with 'no' for software double buffering. But, what about 'page flipping'? $\endgroup$ Commented Jun 26, 2020 at 8:08
  • $\begingroup$ @NicolBolas In 'page flipping' the back buffer is rendered to, but this same location is marked as the front buffer when rendering is finished. Thus the front buffer is both the original location fragments were blended to and the location seen as 'off-screen buffer' by a compositor. But if the OpenGL application is in full-screen mode... could the compositor not also mark this original buffer rendered to as both the 'off-screen buffer' and the 'screen buffer'? If yes, then the answer to my original question is 'yes'. $\endgroup$ Commented Jun 26, 2020 at 8:22

1 Answer 1

1
$\begingroup$

Can it be (eg. if I run a video game full-screen) that the compositor could simply declare the application's off-screen buffer the same as its 'screen buffer'

Yes. This is one of the things that "fullscreen exclusive" mode would do for you: it enables the application's swap buffers (front/back default framebuffers) to be directly scanned out by the GPU's display engine, without needing to go through a compositor first, saving a little bit of performance.

Nowadays there is also support for "borderless windowed fullscreen" (see Fullscreen Optimizations for Windows 10 for instance, though I expect other OSes have similar functionality). This is a mode where you still go through the compositor, but the compositor has a shortcut method when it detects that your app is covering the full screen with no other windows rendering on top of it. In that case it can skip the compositing steps and scan out directly from your swap buffers, while retaining the ability to seamlessly switch back to compositing mode if another window should pop up (such as an overlay, or if you Alt+Tab away from the game, etc.)

Does the compositor designate the 'off screen buffer' for the application

Also yes. When you set up an OpenGL context (or any other graphics API context) your app will request the number and format of swap buffers it wants (subject to the choices offered by the OS/driver); then the OS/driver will give you the buffers, and you render into them. You can create your own framebuffers as well, such as depth/stencil buffers or other offscreen buffers for whatever purpose, but ultimately your app will need to put the image you want to show up on the screen into the provided swap buffers. The buffers will be set up so the compositor can also access them. When you do a glSwapBuffers call, you're informing the OS/compositor that you finished a new frame and asking it to please show that on the screen (either by scanning it out directly or by including it in the next compositor frame).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.