Sign in to follow this  
coderchris

dx10 & dx9 texture format confusion

Recommended Posts

Hi there, So, Im trying to write an abstract texture class that can take some image data specified in some interfaced formats that I make avaliable (eg RGBA8, RG16F, ect..). At runtime, these formats are converted to the most appropriate format for whatever render API is being used, and components possibly reversed, ect.. now, looking at the Dx API, it would make sense to me that the components are specified in the order I see them; so for rgba8, you would have an array like this [red0, green0, blue0, alpha0, red1, green1, blue1, alpha1, ....] However, in the dx9 documentation it states that its formats are kind of backwards of what I just described. Annoying, but I can write code that simply reverses the components no problem. DX10 on teh other hand, doesnt describe in the least how the components are ordered. Furthermore, I have read numerous times (outside of the docs) that certain dx10 formats that are listed in the DXGI header arent actually avaliable?? (for example, rgb8) 1) what is the actual ordering of components for dx9 and more importantly dx10 formats? 2)Are all the formats listed in the DXGI header for dx10 actually all avaliable or is there some kind of CAPS i have to look at? 3)If dx10 component order actually is reversed, is it benifitial for me to reverse all my interface formats as well? 4) Do DDS image files maintain the proper ordering of components for whatever format they represent? 5) (sorry on more :P) Is it safe to assume that if I create a directx10 texture with CreateTexture2D(), that I will be able to lock the texture later and use the SAME texture format that I told it to use when creating the texture or is there again some type of check I need to do to make sure internally it didnt mangle my requested format? Sorry for all the questions, im sure im missing over something in the docs somewhere :o This texture stuff is just so tidious and i cant stand any more headaces lol

Share this post


Link to post
Share on other sites
1. For D3D10 the channels are ordered in the same way as they appear in the name. For 9 the situation is more complex. I haven’t check this out for any format yet but the general rule is that for the “old” formats (lnot more than 10 bit per channels) the colors are encoded as word or dword and the name contains the channel in the order they apper in the word/dword. Starting with the most significant bit. For other formats the channels are defines in the order as they would appear in a struct/array like in 10.
2. No you can’t use all formats listed for every purpose. There is a table what formats are mandatory and what’s optional. Unfortunately it’s still not in the documentation.
3. It’s not really reversed it’s just another order. You will need to handle different orders anyway.
4. DDS files will contain the order that is declared in the DDS header. Be carefull as there were some extensions for Direct3D 10 which most programs doesn’t handle right now.
5. Direct3D will create a texture with the format you want or it would not create them at all. Therefore it’s save to assume that the data are ordered in the way of the creation format.

Share this post


Link to post
Share on other sites
My understanding is that D3D10 uses a big endian naming, while D3D9 uses little endian. So basically D3D9 will be reversed compared to D3D10. It's D3D9 that's odd man out here, since OpenGL seems to use the same convention as D3D10.

Most D3D9 and D3D10 formats are the same (apart from being named in reverse order), except for the 8 bit per component formats. D3D10 uses RGBA, while D3D9 uses ARGB, which is BGRA.

Share this post


Link to post
Share on other sites
Thanks a bunch guys, that pretty much cleared up any questions I had :)

Quote:

2. No you can’t use all formats listed for every purpose. There is a table what formats are mandatory and what’s optional. Unfortunately it’s still not in the documentation.


Hmm, so I cant use them for every purpose, but lets say im just creating a standard managed texture; am i then able to use them all?

Also, would you know where I can find this table for whats mandatory?

Share this post


Link to post
Share on other sites
Quote:
Original post by coderchris
Quote:

2. No you can’t use all formats listed for every purpose. There is a table what formats are mandatory and what’s optional. Unfortunately it’s still not in the documentation.


Hmm, so I cant use them for every purpose, but lets say im just creating a standard managed texture; am i then able to use them all?
Only D3DPOOL_SCRATCH has no format restrictions, in all other cases you should be calling IDirect3D9::CheckDeviceFormat() to validate. For D3D10 you can call ID3D10Device::CheckFormatSupport()

Quote:
Original post by coderchris
Also, would you know where I can find this table for whats mandatory?
I'm pretty sure the table Ralf is referring to is part of the functional specification which is NDA/restricted access only. It's a great Excel table that doesn't contain anything you can't get from the public API so I don't know why they don't include it - I've requested they do on several occasions now [rolleyes]


Cheers,
Jack

Share this post


Link to post
Share on other sites
Sorry was busy. I would this post earlier.

[Source]
Table Legend:
-------------
R : Hardware Support Required
o : Hardware Support Optional
- : Disallowed or N/A

# Format (DXGI_FORMAT_*) Bits Per Element (BPE)
| | | Buffer
| | | | Input Assembler Vertex Buffer
| | | | | Input Assembler Index Buffer
| | | | | | Stream Output Buffer
| | | | | | | Texture1D
| | | | | | | | Texture2D
| | | | | | | | | Texture3D
| | | | | | | | | | TextureCube
| | | | | | | | | | | Shader ld
| | | | | | | | | | | | Shader sample (any general filter mode)
| | | | | | | | | | | | | Shader sample_c (comparison filter)
| | | | | | | | | | | | | | Shader sample (mono 1-bit filter)
| | | | | | | | | | | | | | | Mipmap
| | | | | | | | | | | | | | | | Mipmap Auto-Generation
| | | | | | | | | | | | | | | | | RenderTarget
| | | | | | | | | | | | | | | | | | Blendable RenderTarget
| | | | | | | | | | | | | | | | | | | Depth/Stencil Target
| | | | | | | | | | | | | | | | | | | | CPU Lockable
| | | | | | | | | | | | | | | | | | | | | MultisampleRenderTarget
| | | | | | | | | | | | | | | | | | | | | | Multisample Resolve
| | | | | | | | | | | | | | | | | | | | | | | Cast within Bit Layout
| | | | | | | | | | | | | | | | | | | | | | | |
0 UNKNOWN 0 R - - - - - - - - - - - - - - - - R - - -
1 R32G32B32A32_TYPELESS 128 - - - - R R R R - - - - R - - - - R - - R
2 R32G32B32A32_FLOAT 128 R R - R R R R R R o - - R R R R - R o R R
3 R32G32B32A32_UINT 128 R R - R R R R R R - - - R - R - - R o - R
4 R32G32B32A32_SINT 128 R R - R R R R R R - - - R - R - - R o - R
5 R32G32B32_TYPELESS 96 - - - - R R R R - - - - R - - - - R - - R
6 R32G32B32_FLOAT 96 R R - R R R R R R o - - R o o o - R o R R
7 R32G32B32_UINT 96 R R - R R R R R R - - - R - o - - R o - R
8 R32G32B32_SINT 96 R R - R R R R R R - - - R - o - - R o - R
9 R16G16B16A16_TYPELESS 64 - - - - R R R R - - - - R - - - - R - - R
10 R16G16B16A16_FLOAT 64 R R - - R R R R R R - - R R R R - R o R R
11 R16G16B16A16_UNORM 64 R R - - R R R R R R - - R R R o - R o R R
12 R16G16B16A16_UINT 64 R R - - R R R R R - - - R - R - - R o - R
13 R16G16B16A16_SNORM 64 R R - - R R R R R R - - R R R - - R o R R
14 R16G16B16A16_SINT 64 R R - - R R R R R - - - R - R - - R o - R
15 R32G32_TYPELESS 64 - - - - R R R R - - - - R - - - - R - - R
16 R32G32_FLOAT 64 R R - R R R R R R o - - R R R R - R o R R
17 R32G32_UINT 64 R R - R R R R R R - - - R - R - - R o - R
18 R32G32_SINT 64 R R - R R R R R R - - - R - R - - R o - R

# Format (DXGI_FORMAT_*) Bits Per Element (BPE)
| | | Buffer
| | | | Input Assembler Vertex Buffer
| | | | | Input Assembler Index Buffer
| | | | | | Stream Output Buffer
| | | | | | | Texture1D
| | | | | | | | Texture2D
| | | | | | | | | Texture3D
| | | | | | | | | | TextureCube
| | | | | | | | | | | Shader ld
| | | | | | | | | | | | Shader sample (any general filter mode)
| | | | | | | | | | | | | Shader sample_c (comparison filter)
| | | | | | | | | | | | | | Shader sample (mono 1-bit filter)
| | | | | | | | | | | | | | | Mipmap
| | | | | | | | | | | | | | | | Mipmap Auto-Generation
| | | | | | | | | | | | | | | | | RenderTarget
| | | | | | | | | | | | | | | | | | Blendable RenderTarget
| | | | | | | | | | | | | | | | | | | Depth/Stencil Target
| | | | | | | | | | | | | | | | | | | | CPU Lockable
| | | | | | | | | | | | | | | | | | | | | MultisampleRenderTarget
| | | | | | | | | | | | | | | | | | | | | | Multisample Resolve
| | | | | | | | | | | | | | | | | | | | | | | Cast within Bit Layout
| | | | | | | | | | | | | | | | | | | | | | | |
19 R32G8X24_TYPELESS 64 - - - - R R - R - - - - R - - - - R - - R
20 D32_FLOAT_S8X24_UINT 64 - - - - R R - R - - - - R - - - R R o - R
21 R32_FLOAT_X8X24_TYPELESS 64 - - - - R R - R R o R - R - - - - R - - R
22 X32_TYPELESS_G8X24_UINT 64 - - - - R R - R R - - - R - - - - R - - R
23 R10G10B10A2_TYPELESS 32 - - - - R R R R - - - - R - - - - R - - R
24 R10G10B10A2_UNORM 32 R R - - R R R R R R - - R R R R - R o R R
25 R10G10B10A2_UINT 32 R R - - R R R R R - - - R - R - - R o - R
26 R11G11B10_FLOAT 32 R R - - R R R R R R - - R R R R - R o R -
27 R8G8B8A8_TYPELESS 32 - - - - R R R R - - - - R - - - - R - - R
28 R8G8B8A8_UNORM 32 R R - - R R R R R R - - R R R R - R o R R
29 R8G8B8A8_UNORM_SRGB 32 - - - - R R R R R R - - R R R R - R o R R
30 R8G8B8A8_UINT 32 R R - - R R R R R - - - R - R - - R o - R
31 R8G8B8A8_SNORM 32 R R - - R R R R R R - - R R R - - R o R R
32 R8G8B8A8_SINT 32 R R - - R R R R R - - - R - R - - R o - R
33 R16G16_TYPELESS 32 - - - - R R R R - - - - R - - - - R - - R
34 R16G16_FLOAT 32 R R - - R R R R R R - - R R R R - R o R R
35 R16G16_UNORM 32 R R - - R R R R R R - - R R R o - R o R R
36 R16G16_UINT 32 R R - - R R R R R - - - R - R - - R o - R
37 R16G16_SNORM 32 R R - - R R R R R R - - R R R - - R o R R
38 R16G16_SINT 32 R R - - R R R R R - - - R - R - - R o - R

# Format (DXGI_FORMAT_*) Bits Per Element (BPE)
| | | Buffer
| | | | Input Assembler Vertex Buffer
| | | | | Input Assembler Index Buffer
| | | | | | Stream Output Buffer
| | | | | | | Texture1D
| | | | | | | | Texture2D
| | | | | | | | | Texture3D
| | | | | | | | | | TextureCube
| | | | | | | | | | | Shader ld
| | | | | | | | | | | | Shader sample (any general filter mode)
| | | | | | | | | | | | | Shader sample_c (comparison filter)
| | | | | | | | | | | | | | Shader sample (mono 1-bit filter)
| | | | | | | | | | | | | | | Mipmap
| | | | | | | | | | | | | | | | Mipmap Auto-Generation
| | | | | | | | | | | | | | | | | RenderTarget
| | | | | | | | | | | | | | | | | | Blendable RenderTarget
| | | | | | | | | | | | | | | | | | | Depth/Stencil Target
| | | | | | | | | | | | | | | | | | | | CPU Lockable
| | | | | | | | | | | | | | | | | | | | | MultisampleRenderTarget
| | | | | | | | | | | | | | | | | | | | | | Multisample Resolve
| | | | | | | | | | | | | | | | | | | | | | | Cast within Bit Layout
| | | | | | | | | | | | | | | | | | | | | | | |
39 R32_TYPELESS 32 - - - - R R R R - - - - R - - - - R - - R
40 D32_FLOAT 32 - - - - R R - R - - - - R - - - R R o - R
41 R32_FLOAT 32 R R - R R R R R R o R - R R R R - R o R R
42 R32_UINT 32 R R R R R R R R R - - - R - R - - R o - R
43 R32_SINT 32 R R - R R R R R R - - - R - R - - R o - R
44 R24G8_TYPELESS 32 - - - - R R - R - - - - R - - - - R - - R
45 D24_UNORM_S8_UINT 32 - - - - R R - R - - - - R - - - R R o - R
46 R24_UNORM_X8_TYPELESS 32 - - - - R R - R R o R - R - - - - R - - R
47 X24_TYPELESS_G8_UINT 32 - - - - R R - R R - - - R - - - - R - - R
48 R8G8_TYPELESS 16 - - - - R R R R - - - - R - - - - R - - R
49 R8G8_UNORM 16 R R - - R R R R R R - - R R R R - R o R R
50 R8G8_UINT 16 R R - - R R R R R - - - R - R - - R o - R
51 R8G8_SNORM 16 R R - - R R R R R R - - R R R - - R o R R
52 R8G8_SINT 16 R R - - R R R R R - - - R - R - - R o - R
53 R16_TYPELESS 16 - - - - R R R R - - - - R - - - - R - - R
54 R16_FLOAT 16 R R - - R R R R R R - - R R R R - R o R R
55 D16_UNORM 16 - - - - R R - R - - - - R - - - R R o - R
56 R16_UNORM 16 R R - - R R R R R R R - R R R o - R o R R
57 R16_UINT 16 R R R - R R R R R - - - R - R - - R o - R
58 R16_SNORM 16 R R - - R R R R R R - - R R R - - R o R R
59 R16_SINT 16 R R - - R R R R R - - - R - R - - R o - R

# Format (DXGI_FORMAT_*) Bits Per Element (BPE)
| | | Buffer
| | | | Input Assembler Vertex Buffer
| | | | | Input Assembler Index Buffer
| | | | | | Stream Output Buffer
| | | | | | | Texture1D
| | | | | | | | Texture2D
| | | | | | | | | Texture3D
| | | | | | | | | | TextureCube
| | | | | | | | | | | Shader ld
| | | | | | | | | | | | Shader sample (any general filter mode)
| | | | | | | | | | | | | Shader sample_c (comparison filter)
| | | | | | | | | | | | | | Shader sample (mono 1-bit filter)
| | | | | | | | | | | | | | | Mipmap
| | | | | | | | | | | | | | | | Mipmap Auto-Generation
| | | | | | | | | | | | | | | | | RenderTarget
| | | | | | | | | | | | | | | | | | Blendable RenderTarget
| | | | | | | | | | | | | | | | | | | Depth/Stencil Target
| | | | | | | | | | | | | | | | | | | | CPU Lockable
| | | | | | | | | | | | | | | | | | | | | MultisampleRenderTarget
| | | | | | | | | | | | | | | | | | | | | | Multisample Resolve
| | | | | | | | | | | | | | | | | | | | | | | Cast within Bit Layout
| | | | | | | | | | | | | | | | | | | | | | | |
60 R8_TYPELESS 8 - - - - R R R R - - - - R - - - - R - - R
61 R8_UNORM 8 R R - - R R R R R R - - R R R R - R o R R
62 R8_UINT 8 R R - - R R R R R - - - R - R - - R o - R
63 R8_SNORM 8 R R - - R R R R R R - - R R R - - R o R R
64 R8_SINT 8 R R - - R R R R R - - - R - R - - R o - R
65 A8_UNORM 8 - - - - R R R R R R - - R R R R - R o R -
66 R1_UNORM 1 - - - - - R - - - - - R - - - - - R - - -
67 R9G9B9E5_SHAREDEXP 32 - - - - R R R R R R - - R - - - - R - - -
68 R8G8_B8G8_UNORM 16 - - - - R R R R R R - - R - - - - R - - -
69 G8R8_G8B8_UNORM 16 - - - - R R R R R R - - R - - - - R - - -
70 BC1_TYPELESS 4 - - - - - R R R - - - - R - - - - R - - R
71 BC1_UNORM 4 - - - - - R R R R R - - R - - - - R - - R
72 BC1_UNORM_SRGB 4 - - - - - R R R R R - - R - - - - R - - R
73 BC2_TYPELESS 8 - - - - - R R R - - - - R - - - - R - - R
74 BC2_UNORM 8 - - - - - R R R R R - - R - - - - R - - R
75 BC2_UNORM_SRGB 8 - - - - - R R R R R - - R - - - - R - - R
76 BC3_TYPELESS 8 - - - - - R R R - - - - R - - - - R - - R
77 BC3_UNORM 8 - - - - - R R R R R - - R - - - - R - - R
78 BC3_UNORM_SRGB 8 - - - - - R R R R R - - R - - - - R - - R
79 BC4_TYPELESS 4 - - - - - R R R - - - - R - - - - R - - R
80 BC4_UNORM 4 - - - - - R R R R R - - R - - - - R - - R
81 BC4_SNORM 4 - - - - - R R R R R - - R - - - - R - - R
82 BC5_TYPELESS 8 - - - - - R R R - - - - R - - - - R - - R
83 BC5_UNORM 8 - - - - - R R R R R - - R - - - - R - - R
84 BC5_SNORM 8 - - - - - R R R R R - - R - - - - R - - R
[/Source]


Regards go to Mike Oneppo who posted it some time ago.

Share this post


Link to post
Share on other sites

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