Sign in to follow this  
16bit_port

[D3D10] Texture issue

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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