Jump to content
  • Advertisement
Sign in to follow this  
gjoel

mdx - aug-sdk: readback from multisampled rendertarget

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

This is a short description of how to get it working, just in case someone needs it. Background: I needed to read back from multisampled rendertargets. The utility-class RenderToSurface will not work in this case, so I created my own wrapper-class, manually creating rendertargets, depth/stencil and setting them on the device before rendering. This works marvelously... only, if you actually need readback to system memory like I do, you run into trouble since you can't read back from a multisampled surface (actually you used to be able to, but the august-sdk ruined this). The "lockable"-flag can not be set for multisampled rendertargets, and the readback using Direct3D.SurfaceLoader(..) will take a couple of seconds to return when using non-lockable surfaces (why this even works baffles me). The solution is this: Create a texture (usage=rendertarget), use GetSurfaceLevel(0) to get the surface from the texture, and use SurfaceLoader.FromSurface(..) to copy from the multisampled surface to the texture-surface. Then create an offscreenplainsurface, and copy to it from the texture-surface using GetRendertargetData(..). This is the only way I can get working at a proper speed - every shortcut I have tried, e.g. saving directly from the texture, results in multi-second readback times. Anyway, I hope this either proves useful to some poor sob out there, or results in someone suggesting a better approach :) Cheers,

Share this post


Link to post
Share on other sites
Advertisement
How interesting... from a quick glance at the MDX docs, it seems the desktop version does not have GetFrontBuffer() - which exists in the native API and also the Windows Mobile D3D...

Device.GetFrontBuffer():
Quote:
This method is the only way to capture an anti-aliased screen shot. This method is slow by design, and should not be used in a performance-critical path.


Jack

Share this post


Link to post
Share on other sites
Ok, I should have been more specific: I'm trying to do a screenshot at a resolution larger than monitor-size. So I will never actually render the data to the physical monitor - ie. the front-buffer is not interesting to me.

An alternative solution would of course be to texture a quad with the multisampled RT, and render it to a non-multisampled rendertarget. This, if possible, is even less elegant than my suggested solution :)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!