Skip to main content
gamedev.net
🔒 Locked

Lockable texture as render target

Started by VizOne May 8, 2003 at 11:20 AM 1 replies 1.6k views
Original Post
VizOne
VizOne
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
Osc
Osc
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.
VizOne
VizOne
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.