Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 bobobobo   Members   -  Reputation: 123

Like
0Likes
Like

Posted 27 September 2011 - 05:10 PM

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!)

Sponsor:

#2 MJP   Moderators   -  Reputation: 10110

Like
2Likes
Like

Posted 27 September 2011 - 06:59 PM

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.

#3 bobobobo   Members   -  Reputation: 123

Like
0Likes
Like

Posted 27 September 2011 - 07:09 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS