Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 = ""

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!

share|improve this question
up vote 2 down vote accepted

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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