Archived

This topic is now archived and is closed to further replies.

Lockable texture as render target

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

Hi! I need a texture that can be used as a render target and also has to be lockable, as I want to render something into it and then access the pixeldata written to it. However, the DX docs say, that lockable texture have to be in the managed pool, while render target textures have to be in the default pool, so that''s not possible. There is the D3DUSAGE_DYNAMIC flag, is this what I need? I tried to create the texture like:
device->CreateTexture(512, 512, 1, D3DUSAGE_RENDERTARGET|D3DUSAGE_DYNAMIC /* = 0x201 */,
                                    D3DFORMAT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
 
This call fails (D3D_INVALIDCALL). So, how do I create the dynamic texture? Thanks for your help. Regards, Andre

Share this post


Link to post
Share on other sites
Well, if you *really* have to do this then you can use CreateRenderTarget with the Lockable flag set to TRUE, instead of using CreateTexture.

In practice, this is usually an evil thing to do. If you have to read back from an RT, make sure you defer the read by two or three frames to avoid a total pipeline stall.

If possible, find an alternative way of achieving the same result that doesn''t need the read.

Share this post


Link to post
Share on other sites
Thanks for your answer.

I know reading over the bus is slow, however I don''t need realtime rendering.

I found another solution: I create a "normal" render-target texture in the default pool and an offscreen plain surface in system memory.

After rendering to the texture I download the data via GetRenderTargetData(texturesurface, offscreensurface). It seems to work.

Regards,

Andre

Share this post


Link to post
Share on other sites