Problem mapping a DXGI_FORMAT_BC3_UNORM texture

Started by
1 comment, last by MJP 10 years, 4 months ago

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.

Advertisement

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.

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.

This topic is closed to new replies.

Advertisement