Can you cpu access a texcube you load from a DDS?

Started by
1 comment, last by bobobobo 12 years, 6 months ago
I'm trying to load a texture cube from a .dds file.

Now its loaded, and it renders fine, (which means its loading fine!)

But _after_ loading, I need to do some processing on the texcube using CPU ops.

So I have:


// LOAD THE CUBEMAP
D3DX11_IMAGE_LOAD_INFO loadInfo ;
loadInfo.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
DX_CHECK( D3DX11CreateTextureFromFileA( d3d, "C:/SHARE/res/office.dds", &loadInfo, 0, (ID3D11Resource**)&cubeTex, 0 ), "load texture cube" );

So that works. But when I try to call ID3D11DeviceContext::Map later on that texCube:


D3D11_TEXTURE2D_DESC cubeTexDesc ;
cubeTex->GetDesc(&cubeTexDesc);
if( cubeTexDesc.CPUAccessFlags & D3D11_CPU_ACCESS_READ ) // FALSE!!

I tried forcing:


// LOAD THE CUBEMAP
D3DX11_IMAGE_LOAD_INFO loadInfo ;
loadInfo.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
loadInfo.CpuAccessFlags = D3D11_CPU_ACCESS_READ ;
DX_CHECK( D3DX11CreateTextureFromFileA( d3d, "C:/SHARE/res/office.dds", &loadInfo, 0, (ID3D11Resource**)&cubeTex, 0 ), "load texture cube" ); // LOAD FAILS with cpuAccessFlags!!!


But that doesn't work (the texture load fails!)
Advertisement
You can only read STAGING resources on the CPU. So you should load your cubemap as STAGING, do your manipulations, and then using the staging data to initialize an IMMUTABLE resource.

You can only read STAGING resources on the CPU. So you should load your cubemap as STAGING, do your manipulations, and then using the staging data to initialize an IMMUTABLE resource.


Yes. These are the params that worked:


// to load it here you actually have to load it AGAIN as a STAGING texture.
ID3D11Texture2D* stageCubeTex ;


D3DX11_IMAGE_LOAD_INFO loadInfo ;
loadInfo.MiscFlags = D3D11_RESOURCE_MISC_FLAG::D3D11_RESOURCE_MISC_TEXTURECUBE ;
loadInfo.Usage = D3D11_USAGE::D3D11_USAGE_STAGING;
loadInfo.CpuAccessFlags = D3D11_CPU_ACCESS_FLAG::D3D11_CPU_ACCESS_READ;
loadInfo.FirstMipLevel = 0 ;
loadInfo.MipLevels = 1 ;
loadInfo.BindFlags = 0 ;


DX_CHECK( D3DX11CreateTextureFromFileA( d3d, "C:/SHARE/res/office.dds", &loadInfo, 0, (ID3D11Resource**)&stageCubeTex, 0 ), "load texture cube STAGING" );


D3D11_TEXTURE2D_DESC stageCubeTexDesc ;
stageCubeTex->GetDesc(&stageCubeTexDesc);

So I'm basically loading it twice. The staging one gets discarded after I work with it.

This topic is closed to new replies.

Advertisement