Skip to main content
GameDev.net gamedev.net
🔒 Locked

Allowed format in Create View

Started by krywen Mar 9, 2015 at 5:29 PM 3 replies 2.6k views
Original Post
krywen
krywen

When creating a DepthStencilView I'm able to pass a D3D11_DEPTH_STENCIL_VIEW_DESC as an argument, specifying a format from a list.

I'd like to know which format are allowed, respect to the Resouce format.

I.e. Can I use a DXGI_FORMAT which is smaller then the selected resource format?

Can I create a DEPTH_STENCIL_VIEW with format DXGI_FORMAT_D16_UNORM is the selected resource format is DXGI_FORMAT_R32?

Does it have other limitations, like a Depth stencil view cannot be created when the subresource has a some DXGI formats?

I am not albe to find a specification for this. Moreover the same question apply when creating a RenderTargetView.

Thanks in advance

Stefan Fischlschweiger
Stefan Fischlschweiger

From MSDN:

These are valid formats for a depth-stencil view:

  • DXGI_FORMAT_D16_UNORM
  • DXGI_FORMAT_D24_UNORM_S8_UINT
  • DXGI_FORMAT_D32_FLOAT
  • DXGI_FORMAT_D32_FLOAT_S8X24_UINT
  • DXGI_FORMAT_UNKNOWN

A depth-stencil view cannot use a typeless format. If the format chosen is DXGI_FORMAT_UNKNOWN, then the format of the parent resource is used.

And for RenderTargetView:

A render-target-view cannot use the following formats:

  • Any typeless format.
  • DXGI_FORMAT_R32G32B32 if the view will be used to bind a buffer (vertex, index, constant, or stream-output).

If the format is set to DXGI_FORMAT_UNKNOWN, then the format of the resource that the view binds to the pipeline will be used.

MJP
MJP

If you want to know which formats are supported for different uses, then go here and browse to the appropriate page for the feature level that you're targetting.

krywen
krywen

If you want to know which formats are supported for different uses, then go here and browse to the appropriate page for the feature level that you're targetting.

Let's have a look at D3D11, HW supported formats for depth stencil are

  • DXGI_FORMAT_D32_FLOAT_S8X24_UINT
  • DXGI_FORMAT_D32_FLOAT
  • DXGI_FORMAT_D24_UNORM_S8_UINT
  • DXGI_FORMAT_D16_UNORM

- From my undesrtanding these are the only format allowed for resources to be selected in a depth-stencil view, NOT the format allowed in the depth-stencil view, those are listed here https://msdn.microsoft.com/en-us/library/windows/desktop/ff476112%28v=vs.85%29.aspx. Is this correct?

- Still I can't find is it is legal to use in the view a format with different size from the selected resource. E.g. is it legal to use DXGI_FORMAT_D16_UNORM as a format in a D3D11_DEPTH_STENCIL_VIEW_DESC structure when the selected subresource has format DXGI_FORMAT_D32_FLOAT_S8X24_UINT? I only suppose is not legal but cannot find a proper specification for this.

[Edit - Clarification]

MJP
MJP

That list from the DXGI programming guide is the same exact list given in the documentation that you linked to. The only difference is that the DESC documentation states that you can also specify DXGI_FORMAT_UNKNOWN, which is just a way of telling the API "use the same exact format that was used when creating the texture".

You can't create a resource with one format, and then create a resource view with a format that has a different size. See the docs here about strong vs. weak typing. Basically if you create a resource with a TYPELESS format, then you can only create a resource view from the same format "family".

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.