Jump to content
  • Advertisement
Sign in to follow this  
bobobobo

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

This topic is 2639 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!