7 Replies - 3922 Views - Last Post: 25 July 2012 - 11:57 AM Rate Topic: -----

#1 Kain6622  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 250
  • Joined: 18-March 10

DirectX 10 Formats Question

Posted 25 July 2012 - 03:03 AM

Hi, I though I'd brings this topic up, mainly in hope to get help with my work but also to help future developers. Basically I'm working on a configuration dailog for initializing DirectX 10 and have notices that the DXGIOutput has several formats that will give a valid initialization with the usual display resolutions, the only issue is what each of them stand for apart from the one used by default (e.g. DXGI_FORMAT_R8G8B8A8_UNORM), can someone help me figure out what each of the below formats are for and also state if they have used any other formats for creating the device and swapchain:

DXGI_FORMAT_R10G10B10A2_UNORM        // ??
DXGI_FORMAT_R8G8B8A8_UNORM           // 32-bit
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB      // 32-bit ??
DXGI_FORMAT_B8G8R8A8_UNORM           // 32-bit reversed?
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM // ??
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB        // ??



They all seem to be 32-bit but does directX 10 support 16-bit too and what formats use this?

Thank you in advance

Is This A Good Question/Topic? 0
  • +

Replies To: DirectX 10 Formats Question

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 05:22 AM

Have you checked out the DirectX docs?
Was This Post Helpful? 0
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 05:51 AM

This is why you should visit MSDN

http://msdn.microsof...9(v=vs.85).aspx
Was This Post Helpful? 0
  • +
  • -

#4 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,253
  • Joined: 24-April 12

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 08:12 AM

I was just about to post the link StayCrisp put up and then noticed he had already put it up.

I haven't used DirectX in quite a long time and it was DirectX 9 back when I did.

But anyway, commenting on what MSDN says there:

DXGI_FORMAT_R10G10B10A2_UNORM
A four-component, 32-bit unsigned-normalized-integer format that supports 10 bits for each color and 2 bits for alpha.


I'm not sure how familiar you are with color theory. R,G,B stand for the 3 primary colors - Red,Green, and Blue. By mixing them you can get any color imaginable. The A here stands for "alpha" which is transperancy or how much you can see through one color to the color that's behind it when they are layered. Especially for sprites this is very useful.

This is all about how to arrange the 32 bits to contain the most appropriate information for the job at hand. Unsigned integer obviously means that each of these components can't be negative and are non-decimal numbers. I'm not sure what normalized means here but I'm not sure that matters. (edit:After reading the documentation a little more closely, I see what they mean by normalized, I think. But oddly enough, it means that some of these "integers" represent fractional values.) I've seen colors represented as normalized vectors where once the length goes past one it just remains white, but I don't think that's what it's talking about here.

Anyway, you've got 10 bits for R,G, and B which leaves 2 bits for Alpha. I believe that's just controlling the resolution of each component. You get slightly higher color resolution than 8 bit there, but the alpha channel is suffering for it and only has 4 possible values. Sounds to me that that's going to be opaque, transparent, or 2 shades of in between.


DXGI_FORMAT_R8G8B8A8_UNORM
A four-component, 32-bit unsigned-normalized-integer format that supports 8 bits per channel including alpha.
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
A four-component, 32-bit unsigned-normalized integer sRGB format that supports 8 bits per channel including alpha.



The only difference here is that all channels are 8 bit including alpha. So you lose some color resolution, but you gain alpha resolution. The difference between the two above is one is sRGB. Honestly, I don't know what that is. And Microsoft's documentation is as lacking as it always is here(edit: actually there's a little more info at the bottom of the page that I just saw. MS's documentation is still notoriously bad though.). But Wikipedia comes to the rescue:

http://en.wikipedia.org/wiki/SRGB

DXGI_FORMAT_B8G8R8A8_UNORM reversed?

Yep. It would appear that way to me. I've never done color that way and it seems a bit odd. But I would imagine they included it to support any sort of picture file format. There's no inherent reason that it has to be arranged in the R,G,B,A order. That's just arbitrarily chosen (although pretty much a standard in Windows). But I would imagine some other system somewhere commonly uses B,G,R (that's in alphabetical order). So they decided to help those people out. I'm just guessing.

DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
A four-component, 32-bit 2.8-biased fixed-point format that supports 10 bits for each color channel and 2-bit alpha.


I have no idea what 2.8 biased fixed-point means. (edit:There seems to be a "somewhat cryptic" explanation of this under DXGI_FORMAT_R11G11B10_FLOAT. It sounds like it's the bits and number that they represent that are "biased" and not the color. I'll leave it to you to research that one further. It doesn't seem important to anything I'm likely to work on in the near future. I think the word biased here means that the numbers don't have a 1 for 1 representation, maybe 2.8 means that each integer covers a value of 2.8?)

DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
A four-component, 32-bit unsigned-normalized standard RGB format that supports 8 bits for each channel including alpha.


Again, kind of backward but with sRGB color. If you think about it, these are just bit settings. So, you could use them to represent colors in any way you want. So, I'm sure different groups developed different standards over the years.

I just noticed there's some better explanation of some things at the bottom of the document like this:

_UNORM

Unsigned normalized integer; which is interpreted in a resource as an unsigned integer, and is interpreted in a shader as an unsigned normalized floating-point value in the range [0, 1]. All 0's maps to 0.0f, and all 1's maps to 1.0f. A sequence of evenly spaced floating-point values from 0.0f to 1.0f are represented. For instance, a 2-bit UNORM represents 0.0f, 1/3, 2/3, and 1.0f.


So, it sounds like these color channel values are normalized between a value of 0 and 1 (basically percentage) when they reach the shader.

This post has been edited by BBeck: 25 July 2012 - 08:47 AM

Was This Post Helpful? 1
  • +
  • -

#5 Kain6622  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 250
  • Joined: 18-March 10

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 08:18 AM

I've been to those docs already but find them unclear at the formats can be used for more than just when creating the device | back buffer | textures etc but they dont have a listing of common formats for each command/function call that uses them. The SDK code for some of the examples is difficult to read in my opinion due to lack/incomplete commenting (my opinion anyway). I'm trying to figure out myself the types for the different function calls that are valid for certain functions (common) and for anyone in future with the same question (in this post related to listing the display modes available from a certain format, ask i listed at least some of them in my first post).

This post came about from books like Introduction to 3D programming in DirectX 10 - that just use one format (DXGI_FORMAT_R8G8B8A8_UNORM) without saying what others could be possible to use if you want. Looking at the DXGI_MODE_DESC on MSDN they have some further information but lack detail that one might want to know about the formats they choose. The general impression i'm getting is that you only get the choice of 32-bit in directx 10 but i'm pretty sure i'm wrong but I'm not sure :wacko:

{Edit}: BBeck - your post didn't show whilst I was typing this one, will have a read then update :)

This post has been edited by Kain6622: 25 July 2012 - 08:19 AM

Was This Post Helpful? 0
  • +
  • -

#6 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,253
  • Joined: 24-April 12

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 09:01 AM

View PostKain6622, on 25 July 2012 - 08:18 AM, said:

The general impression i'm getting is that you only get the choice of 32-bit in directx 10 but i'm pretty sure i'm wrong but I'm not sure :wacko:

{Edit}: BBeck - your post didn't show whilst I was typing this one, will have a read then update :)


Most of them do seem to be 32 bit. I see 64 bit and 128 bit in there though. Going the other direction, I seem to remember that color was not represented as R,G,B.

Before 32 bits was practical, you had 8 bit and 16 bit color. It takes 24 bits just to have a byte for R,G, and B. So, earlier color formats worked in a completly different way. They used "paletted" color. In the earliest form I think 8 bit just mapped to specific colors. As it went to 16 bit, they started doing things like having more of a 32 bit range of colors but only being able to use 16 bits worth of them at a time. The colors were stored in an array or something and the color value pointed to the element in that array. Back then the number of bits only allowed for 256 colors (8-bit). So, you either had to go with the default colors that that evaluated to, or build your own pallet of colors and then point to each color in the pallet. Later you could change the colors in your pallet and kind of "tailor" it to what you were doing.

So, that may be why I don't seem to see the old 8 bit and 16 bit color scheme represented here.

Honestly, I would use R8G8B8A8 and forget about it. Sounds like that's what everyone else is doing. But I can understand why you would want to know what these others represent and why they are provided.
Was This Post Helpful? 1
  • +
  • -

#7 Kain6622  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 250
  • Joined: 18-March 10

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 09:34 AM

Thanks for the replies, I do guess that it is only the initial setup for DirectX 10 that requires the use of DXGI_FORMAT_R8G8B8A8 still giving you flexibility to just use lower res textures to gain the same effect but still interested to know what these other formats would actually affect and do when in use but as some might want to say is try and find out :) but if I find anything more out i'll update this post with the results. Thanks again
Was This Post Helpful? 1
  • +
  • -

#8 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 Formats Question

Posted 25 July 2012 - 11:57 AM

All they do is enable you to use resource data in that particular format. I don't really see what you are asking here.

MSDN explains it well again:

http://msdn.microsof...5(v=vs.85).aspx

But it's good that you are interested, pick your battles though :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1