Sign in to follow this  

mdx - aug-sdk: readback from multisampled rendertarget

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

This topic is 3780 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this