Do I need to recreate Direct2D sharable resources?

社会主义新天地 提交于 2020-01-06 02:39:12

问题


According to the documentation, even device-dependent resources are sharable among render targets when those render targets meet some conditions.

Assume I have two RenderTargets(RT1 & RT2) which meet these conditions. I use RT1 to create a new device-dependent resource(ResourceA), and both RT1 & RT2 use this resource to do some drawing.

Now when I'm done with RT1, I get D2DERR_RECREATE_TARGET which means I have to recreate RT1 and draw again.

My question is, should I recreate the ResourceA created by RT1?


回答1:


Short answer: Yes, any resource that was created using RT1 will need to be recreated when, D2DERR_RECREATE_TARGET is encountered.

Long answer: D2D resources can be shared between all RenderTargets that came from the same factory as the d2d factory maintains the internal connections to the underlying D3D device and it's resources. ID2D1RenderTargets are really just ID3DTexture2Ds. As such when the d3d texture has been invalidated all the resources created using the underlying d3d device must be recreated as well.



来源:https://stackoverflow.com/questions/5378644/do-i-need-to-recreate-direct2d-sharable-resources

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!