Sign in to follow this  
aldofi

Problem mapping a DXGI_FORMAT_BC3_UNORM texture

Recommended Posts

aldofi    139

Hi,

 

I'm trying to Map and Umpap mipmap levels of a compressed texture created with the DXGI_FORMAT_BC3_UNORM format.

The problem is that I get an E_INVALIDARG error when I create the texture object with D3D11_CPU_ACCESS_WRITE (even with D3D11_USAGE_DYNAMIC or D3D11_USAGE_DEFAULT flags) using this format, but works ok if i define 1 mipmap level.

 

This is the code I'm using to create the texture:

 

D3D11_TEXTURE2D_DESC tex_desc;
tex_desc.Width = 1056;
tex_desc.Height = 1056;
tex_desc.MipLevels = 2;                                        //works with 1 mip level only
tex_desc.ArraySize = 1;
tex_desc.Format = DXGI_FORMAT_BC3_UNORM;
tex_desc.SampleDesc.Count = 1;
tex_desc.SampleDesc.Quality = 0;
tex_desc.Usage = D3D11_USAGE_DYNAMIC;
tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tex_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
tex_desc.MiscFlags = 0;
 
 
ID3D11Texture2D * myTexture;
 
hr = DxEventNotifier::GetD3DDevice()->CreateTexture2D(&tex_desc, NULL, &myTexture);
assert(myTexture);

 

This problem did not sowed in DX9 using 2 miplevels and D3DFMT_DXT5 format in a line like:

 

IDirect3DTexture9 *              myTexture;

CreateTexture( 1056, 1056, 2, 0, D3DFMT_DXT5, D3DPOOL_MANAGED, &myTexture, NULL ) );

 

 

any suggestions will be appreciated, thanks in advance.

 

Share this post


Link to post
Share on other sites
pcmaster    982

First of all, turn on the debug layer (D3D11_CREATE_DEVICE_DEBUG) and see the output for a more specific error!!!

 

EDIT: I'm getting:

D3D11 ERROR: ID3D11Device::CreateTexture2D: A D3D11_USAGE_DYNAMIC Resource must have MipLevels equal to 1. [ STATE_CREATION ERROR #102: CREATETEXTURE2D_INVALIDMIPLEVELS]
 

So, you cannot have 2+ mipmap levels for a dynamic resource. Use a default resource for that and update individual mipmaps with UdpateResource, I'd say.
 

Edited by pcmaster

Share this post


Link to post
Share on other sites
MJP    19786

Actually the recommend practice from the hardware vendors is to Map a texture with D3D11_USAGE_STAGING, and then use CopyResource or CopySubresourceRegion to copy the contents to a texture with D3D11_USAGE_DEFAULT.

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