Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Taking MSAA screenshot using D3DX10SaveTextureToFile()


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Raptormeat   Members   -  Reputation: 102

Like
0Likes
Like

Posted 07 August 2012 - 07:57 PM

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


HRESULT hr;

D3D10_TEXTURE2D_DESC texDesc;
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 );

texture->Release();
pScreen->Release();

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- if anyone can offer some help with this I'd really appreciate it!

Sponsor:

#2 DJTN   Members   -  Reputation: 199

Like
0Likes
Like

Posted 08 August 2012 - 07:13 AM

In order to get a screen shot with MSAA you'll need to have a surface and depth stencil surface that match your backbuffer format and orgianl depth stencil surface. They'll also need to have the same multi-sample type (i.e 2x, 4x, 8x, etc...). You then use stretch-rec to copy from one surface to another - saving the destination texture from the destination surface in the stretch-rec method.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS