2
\$\begingroup\$

I was wondering if anyone could elaborate any further on something that's been bugging me.

In DirectX9 the main supported back buffer formats were D3DFMT_X8R8B8G8 and D3DFMT_A8R8G8B8 (Both being BGRA in layout).

http://msdn.microsoft.com/en-us/library/windows/desktop/bb174314(v=vs.85).aspx

With the initial version of DirectX10 their was no support for BGRA and all the textbooks and online tutorials recommend DXGI_FORMAT_R8G8B8A8_UNORM (being RGBA in layout).

Now with DirectX11 BGRA is supported again and it seems as if microsoft recommends using a BGRA format as the back buffer format.

http://msdn.microsoft.com/en-us/library/windows/apps/hh465096.aspx

Are there any suggestions or are there performance implications of using one or the other?

(I assume not as obviously by specifying the format of the underlying resource the runtime will handle what bits your passing through and than infer how to utilise them based on the format.)

\$\endgroup\$
  • \$\begingroup\$ I wouldn't expect a perf difference between RGBA and BGRA. But why don't you do a quick test and find out? Draw a full-screen triangle with a very simple shader, and see if you can measure a framerate difference between the two formats. \$\endgroup\$ – Nathan Reed Nov 12 '13 at 17:35
  • \$\begingroup\$ I got your accounts merged Nathan, try to remember your account info. \$\endgroup\$ – MichaelHouse Nov 13 '13 at 0:01
  • \$\begingroup\$ Thanks the issue is I cant login with my gmail account whilst at work :[ (I cant access any google services apart from google search with our current policy) annoying IT department! \$\endgroup\$ – Nathan Nov 13 '13 at 0:10
4
\$\begingroup\$

Now when using the discard presentation in a Win32 app it passes the render target to DWM which then blits the target to the screen and when in full screen mode (provided you have resized your back buffer and refresh rate correctly) it will disable DWM and perform flips to render the scene.

Now with metro apps there's no such thing as full screen exclusive (as they are essentially borderless window). So they would blit all the time (the discard presentation model is actually not allowed for metro apps).

So you have to set the presentation model to flip in Win32 apps and metro apps(with this being your only option for metro :]). It will than pass your render target to DWM (I assume maybe it allows you access to its underlying target to draw into and uses dirty rectangles), and instead of blitting it will straight up flip/merge your target into the screen space it currently resides in and you get flip performance and in full screen it does the flip (assuming you resized buffers and refresh rate).

Now for some reason the windows default back buffer for the OS is BGR and if you use this as your back buffer format the flip is slightly faster as it doesn't have to swizzle or do whatever it does to merge/flip. But you can use either RGBA or BGRA.

Heres the msdn explaining the new presentation model: http://msdn.microsoft.com/en-us/library/windows/desktop/hh706346%28v=vs.85%29.aspx

And heres another msdn confirming the slightly faster flip with bgra: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/f56e4449-f3e1-491e-9f64-e65e989a518a/best-swap-buffer-format-rgba-or-bgra-

\$\endgroup\$
  • 1
    \$\begingroup\$ Holy run-on sentence, Batman. Can you edit your answer and try splitting it into sentences and paragraphs better? \$\endgroup\$ – Nathan Reed Nov 12 '13 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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