Jump to content
  • Advertisement
Sign in to follow this  
Seabolt

Reading RenderTarget data crash

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

Hey guys

I'm currently trying to do a technique where I decrease a global alpha value for a render target based on the amount of pixels already revealed.
Now my current algorithm is probably very slow, but we have some constraints and this is the best way so far:

We perform a render pass where we decrease some alpha on some pixels from a texture. Just a basic full screen quad render.
We then take that render target, and set it as a sprite's texture.
The next frame we will grab the sprite's current texture, and use it for the same pass.

This works fine.

But in order to see how many pixel in total have been alpha-ed out, I need to get the texture's raw data and count it up manually. This involves getting the render target's texture into a lockable format
(GetRenderTargetData), and doing a CPU pass over the raw data. The way that the current engine is set up, it will give me an allocated chunk of data that is the texture, and I'm responsible for cleaning it up.
So it Locks, copies the bits, and Unlocks.

The crash is that when I GetRenderTargetData(), some undisclosed time after it. I see an unhandled exception error pop up in the debug output, and then the next time that I draw to the render target, it will crash in the kernel somewhere. I get the feeling that the render target is unusable after I call GetRenderTargetData(), but that doesn't seem right. Any tips or hints I should know? The target and destination surface are the same format and size, and there is no multisampling. The render target is not a power of two if that helps. Thanks guys.

Share this post


Link to post
Share on other sites
Advertisement
To debug your issue try using the debug runtimes, my first guess would be you have a leak somewhere.

However, you can probably do this much more efficiently using occlusion queries to tell you the number of pixels drawn and either alpha testing or maybe clip() in a pixel shader.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!