mdx - aug-sdk: readback from multisampled rendertarget
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,
What are/were you trying to do? Usually you shouldn't have to read back from the rendertarget...
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():
Jack
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
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 :)
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 :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement