I have some screenshot code (pasted below) which was working fine until I enabled MSAA. The first time I tried to use this code, it complained that the texture I'm creating needed to match the sample count of the source texture. Fine- my MSAA value is 8 currently, so I set the screenshot texture to a sample count of 8 also.

Now when I try to use the code, it complains:

ERROR: ID3D10Device::CreateTexture2D: A multisampled Texture2D cannot be bound to certain parts of the graphics pipeline, but must have at least one BindFlags bit set. The following BindFlags bits (0) cannot be set in this case: D3D10_BIND_VERTEX_BUFFER (0), D3D10_BIND_INDEX_BUFFER (0), D3D10_BIND_CONSTANT_BUFFER (0), D3D10_BIND_STREAM_OUTPUT (0)

Note- this happens when I call CreateTexture2D(). However, if I take the hint and try a BindFlag with my created texture (D3D10_BIND_RENDER_TARGET for example) I get the exact same error message when D3DX10SaveTextureToFile() is called.

Here is the code:

ID3D10Resource* pScreen;
mpRenderTargetView->GetResource( &pScreen );


texDesc.ArraySize = 1;
texDesc.BindFlags = D3D10_BIND_RENDER_TARGET;
texDesc.CPUAccessFlags = 0;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;    
texDesc.Width = (unsigned int)mWindowSize.x;
texDesc.Height = (unsigned int)mWindowSize.y;
texDesc.MipLevels = 1;
texDesc.MiscFlags = 0;
texDesc.SampleDesc.Count = 8;
texDesc.SampleDesc.Quality = 0;
texDesc.Usage = D3D10_USAGE_DEFAULT;

ID3D10Texture2D *texture;
hr = mpD3DDevice->CreateTexture2D( &texDesc, 0, &texture );
mpD3DDevice->CopyResource( texture, pScreen );

char* filename = "TestFile.dds"

D3DX10SaveTextureToFile( texture, D3DX10_IFF_DDS, filename );

I should also mention that I've tried various file formats with no success yet. This function has been a real pain in the butt so if there's a better way of doing this, I'd love to know it!


I imagine it simply doesn't understand multisampled images, I can't think of an image format that supports them.

ResolveSubresource(..) will let you copy from a multisampled source to a non-multisampled target, which you shouldn't have trouble saving.

| improve this answer | |
  • \$\begingroup\$ Looks like it should work great- thank you so much! \$\endgroup\$ – Raptormeat Aug 16 '12 at 22:05
  • 1
    \$\begingroup\$ @Raptormeat If it works out, let me know (also wouldn't complain if you accepted my answer, if it works :) ) \$\endgroup\$ – user13213 Aug 28 '12 at 17:31
  • \$\begingroup\$ So sorry this took so long to verify. I finally tried this out and, of course, it's perfect. Thank you for the tip!!! \$\endgroup\$ – Raptormeat Sep 12 '12 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.