Followers 0

17 posts in this topic

How I can save to a file a ID3D11ShaderResourceView and also with the same format (DXGI_FORMAT_R16G16B16A16_FLOAT) ?

0

Share on other sites

Not sure how to use the thing with the Map to read texture data.

0

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...

2

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
0

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.

1

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;
D3DX11SaveTextureToFile(m_D3D->GetDeviceContext(), tempResource, D3DX11_IFF_DDS, L"file.dds");

Edited by xlope01
0

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 [tt]tempResource->Release()[/tt] when you're done.
1

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 [tt]tempResource->Release()[/tt] 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".

0

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
1

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 ?

It is a render target(2048x2048).

As for PIX I can't get it to work for some reason.

0

Share on other sites
Read here and especially here. Use at your own risk, but uninstalling that platform update worked fine for me.

Edit: Ah yeah, what did you mean by "empty file" ? All zeroes (so no valid dds file at all) ? Black texture ? How did you check that ? Edited by unbird
1

Share on other sites

if i open the dds file with a text editor the first line is this

DDS |             0                                                            DX10



and after that it is filled with spaces until the end of the file. (size16MB for a 2048x2048 render target)

of course I can not open the file in any photo/paint editor, it says error etc

0

Share on other sites

That doesn't mean it's a bad file. Maybe your tools just can't cope with half-floats.

Try to load it in the DirectX texture tool: You find it in the SDK folder under \Utilities\bin\x86\DxTex.exe.

1

Share on other sites

That tool won't load it. The D3DX11 functions will save out DDS files using the newer DX10 DDS format, and there's almost no applications that will open it. In fact the only one I know of is Visual Studio 2012.

2

Share on other sites

Strange. I tried something similar before suggesting: I saved (using SlimDX, which uses the above function under the hood) the backbuffer texture 1920x1080 with four channel half-floats. DxTex - both the 32 and 64 bit - load them fine. I don't see such a DX10 marker with a raw/hex viewer though. Is there some trigger (say, size) which "makes" it a DX10 DDS only?

Also: you can "test" it with the corresponding loading function D3DX11CreateTextureFromFile and render it. Maybe first try a non-DDS format.

Edit: Update: Could go up to 4096^2 and again both DxTex load them fine. @xlope: Something is still off at your side I think. A 2048^2 texture should be 32 MB in size (2048*2048*4*2 = 33'554'432). And another [b]Edit[/b]: Wait, maybe I'm silly now, I don't know if DDS does support compression. But a 2048^2 texture saves to approximately 32 MB on my side.

Edited by unbird
1

Share on other sites

IT is actually working if I load with D3DX11CreateShaderResourceViewFromFile from the dds file that I make with D3DX11SaveTextureToFile (not sure why i can not open it with any photo/paint editor or  DxTex)

2048^2 is 32MB with R16G16B16A16, and with R11G11B10 is 16MB

0

Share on other sites
Aaaah, there's the problem. R11G11B10_FLOAT is a newer format. Tried it, suddenly I've got this DX10 marker. Jep, DxTex doesn't cope with that.

Pity that. I think you have to live with it, unfortunately. Neither can I name you a tool which supports it, sorry.

Just as an aside: Make sure to get PIX working. Here's a screenshot from the image save call.

One can see clearly what's happening, namely the exact sequence Zaoshi Kaba described (the last couple of events in the list). The temporary texture also gets a nice debug name.
0

Create an account

Register a new account