• Advertisement
Sign in to follow this  

ID3D11ShaderResourceView save to file

This topic is 1691 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

Advertisement

Have you taken a look at the DirectXTK library?  I believe this method is already implemented for you, or at least it can provide you with a reference implementation to start from...

Share this post


Link to post
Share on other sites

Have you taken a look at the DirectXTK library?  I believe this method is already implemented for you, or at least it can provide you with a reference implementation to start from...

This is exactly what I need from the DirectXTK library:

HRESULT SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
                                  _In_ ID3D11Resource* pSource,
                                  _In_z_ LPCWSTR fileName );

however this library need Windows 8 SDK(that needs w8, and I don't have). It looks like only for this method I only missing <DirectXMath.h> and <wrl.h>, any suggestion ?

 

edit: I currently use DirectX SDK (June 2010)

Edited by xlope01

Share this post


Link to post
Share on other sites

The Windows 8 SDK can be installed on Win 7. Haven't tried myself, but one can even use it with VS 2010 as it seems. (Edit, corrected link).
 
Since you're using the June 2010 DX SDK, you can take a look at the D3DX legacy library, in particular D3DX11SaveTextureToFile.

 

"D3DX11SaveTextureToFile" was the first thing I did before trying anything else, but it didn't work, it just writes an empty file(16mb size).

ID3D11ShaderResourceView* my_ID3D11ShaderResourceView ;
ID3D11Resource* tempResource;
my_ID3D11ShaderResourceView->GetResource(&tempResource);
D3DX11SaveTextureToFile(m_D3D->GetDeviceContext(), tempResource, D3DX11_IFF_DDS, L"file.dds");
Edited by xlope01

Share this post


Link to post
Share on other sites
I'm currently not at home to test this, but maybe you need a temporary staging texture still, like Zaoshi Kaba suggests. Things to try:
 
- What HRESULT do you get from that call ?
- Compile with the debug library (d3dx11d.lib)
 
Also, don't forget to tempResource->Release() when you're done.

Share this post


Link to post
Share on other sites

I'm currently not at home to test this, but maybe you need a temporary staging texture still, like Zaoshi Kaba suggests. Things to try:
 
- What HRESULT do you get from that call ?
- Compile with the debug library (d3dx11d.lib)
 
Also, don't forget to tempResource->Release() when you're done.

HRESULT gives  S_OK

I have try everything i can with the "D3DX11SaveTextureToFile" but still cant get it working, and i don't want/need to migrate from June 2010 DX SDK to Windows 8 SDK to use the "SaveDDSTextureToFile".

Share this post


Link to post
Share on other sites
Strange. That function should work fine even for non-staging textures (IIRC it will create a temporary automatically). Fire up PIX and see what's going on.

Edit: How do you actually populate the texture in the first place ? Load it ? Fill it manually with Map/Update or at creation ? Is it also a render target ? Edited by unbird

Share this post


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

  • Advertisement