[D3D10] Texture issue

Started by
3 comments, last by Erik Rufelt 13 years, 6 months ago
I have this array of texture data, which needs to be manually filled in a blank texture. I did this in D3D9 and it worked fine (texture data is correct) and now I need to do the same in D3D10. Each of the texels are in XMCOLOR format.

This is what I did :
ID3D10Texture2D *T;//////// Create texture description   D3D10_TEXTURE2D_DESC desc;   ZeroMemory( &desc, sizeof(D3D10_TEXTURE2D_DESC) );   desc.Width = Texture.Width;   desc.Height = Texture.Height;   desc.MipLevels = 1;   desc.ArraySize = 1;   desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;   desc.SampleDesc.Count = 1;   desc.SampleDesc.Quality = 0;   desc.Usage = D3D10_USAGE_DYNAMIC;     //<-- this is dynamic because I'm going to manually fill it in after the call to CreateTexture2D()   desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;   desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;   desc.MiscFlags = 0;   HRESULT r = m_pd3dDevice->CreateTexture2D( &desc, NULL, &T );   assert( r == S_OK );


I'm getting r = E_INVALIDARG. Any thoughts? Thanks.
Advertisement
Try the DXGI_FORMAT_R8G8B8A8_UNORM format instead. You might need to create your device with the D3D10_CREATE_DEVICE_BGRA_SUPPORT support flag if you want to use a BGRA format.
Quote:
You might need to create your device with the D3D10_CREATE_DEVICE_BGRA_SUPPORT support flag if you want to use a BGRA format.


Still doesn't work and I get an S_OK from D3D10CreateDeviceAndSwapChain too.

Quote:
Try the DXGI_FORMAT_R8G8B8A8_UNORM format instead.


I've tried that and CreateTexture2D succeeds, but since the rgb data is actually bgr I'm getting incorrect colors. I CAN swap the r and b components when I fill it into the blank texture and I suppose that would work but I would like to avoid doing that.
You could always swap the components over when you read the texture in the pixel shader.
You need to use a 10.1 device to use that format. You can specify feature-level 10.0 for it and it will work on the same hardware, but you need to use D3D10CreateDeviceAndSwapChain1.

From the documentation:
Quote:
D3D10_CREATE_DEVICE_BGRA_SUPPORT is only relevant when a device is created with D3D10CreateDevice1 or D3D10CreateDeviceAndSwapChain1 using the D3D10_FEATURE_LEVEL_10_0 or D3D10_FEATURE_LEVEL_10_1 feature levels, the flag will be ignored when a device is created with other feature levels.

Note that BGRA support may be present even if the application didn't specify D3D10_CREATE_DEVICE_BGRA_SUPPORT. The flag merely causes device creation to fail if BGRA support isn't available.

D3D10_CREATE_DEVICE_BGRA_SUPPORT is only valid on Windows 7, Windows Server 2008 R2, and updated Windows Vista (KB971644) systems.

This topic is closed to new replies.

Advertisement