Sign in to follow this  

DXGI_FORMAT_R8G8B8_UNORM?

This topic is 1263 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working with directx for the first time in a a long time. I am working on generating input layouts and notices that DXGI_FORMAT_R8G8B8_UNORM doesn't exist.  R8, R8G8, and R8G8B8A all exist. For some reason R8G8B8 doesn't. Why is that? Why add support for 1, 2 and 4 normalized byte components but leave out support for 3? It seems like it is a common use case to have a RGB color stored as bytes, yet this is left out.

Edited by HappyCoder

Share this post


Link to post
Share on other sites
He wants to use it for input layouts though, but obviously they somewhat unified texture formats and vertex types from DX10+. I once tried to "alias" a RGBA8 by using overlapping elements to regain that byte, but that doesn't work either since element offsets need to be 4-byte aligned too (Edit: Correction the alignment depends on the format used, e.g. RG8 can be 2-byte aligned).

Conclusion:
  • Don't bother to waste that byte. (Edit: Or use it for something else in your vertex)
  • Use other 4-byte types with higher precision, e.g. R10G10B10A2_UNorm or R11G11B10_Float. The latter is quite peculiar since it's a float type without a sign.

Share this post


Link to post
Share on other sites


He wants to use it for input layouts though, but obviously they somewhat unified texture formats and vertex types from DX10+.
You can't use 3-byte aligned vertex formats in D3D9 or GL either. D3D9/10/11 just don't have the formats available, and GL will either return an error, or lie to you and insert the padding behind your back wink.png

Share this post


Link to post
Share on other sites

You can always create your vertex buffer as a structured buffer or byte address buffer, and then us SV_VertexID to manually unpack your data in the shader. However it's almost certainly not going to save you any performance.

Share this post


Link to post
Share on other sites

You can always create your vertex buffer as a structured buffer or byte address buffer, and then us SV_VertexID to manually unpack your data in the shader. However it's almost certainly not going to save you any performance.

 

It won't save performance for sure, but it opens lots of doors for you.  Indirect draw calls are much easier to do with a structured buffer as the data storage system for example.

Share this post


Link to post
Share on other sites

This topic is 1263 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this