filling a texture [dx9]

Started by
4 comments, last by DirectXer 16 years, 4 months ago
Hi guys, I'm currently porting my software renderer from DirectDraw to Direct3D. I searched the Net for a while and figured out that the fastest way to go is to draw everything to a dynamic texture and then render this as a fixed textured quad. This works great in general, but everything I need is a fast way to clear this 'emulated back buffer'. I suppose locking the texture, filling each texel with the clear color and then unlocking it again is very slow, isn't it? Is there a fast way or at least an alternative to get this done? Pls help, thx in advance
Advertisement
If I understand correctly, you're binding your dynamic texture to your device as a render target (IDirect3DDevice9::SetRenderTarget)

Thus you are able to clear it using IDirect3DDevice9::Clear as with any render target, be it the one the application created for you or one you created yourself. I don't think there's a faster way.

Also, according to the description you give about what you're doing, I believe you don't even need to create an additionnal dynamic texture to render to. You could render directly to your application's back buffer.

JA
no, I don't use this texture as a render target, because i need to manipulate each pixel on the back buffer. As simply locking the d3d back buffer itself is very slow, i write the pixels to a texture and then render this texture.

I have just found IDirect3DDevice9::ColorFill(), now I wonder if this is a fast way to get my work done? According to the MSDN ColorFill() just blits (a rect of) the specified color to a surface. Hence I would just have to obtain the underlying surface of my texture by IDirect3DTexture9::GetSurfaceLevel() and pass it to ColorFill. Do u think this could be fast?

Thx ur answer!
- DXer

edit: another thing i'm wondering about is that my texture has the format A1R5G5B5 (16-bit) and ColorFill expects a D3DCOLOR value (32-bit). What about this?

edit2: hmm i tried it out myself, and it looks like ColorFill() too works only with render targets... hmm what about stretchRect()?

[Edited by - DirectXer on December 1, 2007 5:00:06 PM]
no one any idea of fast filling / clearing a simple dynamic texture?
Well, you're going to be writing to the texture every frame anyway (Via Lock(), one would assume), so you might as well just lock the whole texture and fill it with a solid colour. I doubt it'll be that slow at all.
hmm I'm not sure yet, because there are some special cases in which I just need to clear the texture..

searching the net i found this thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=164005
It covers the same subject related to DX8. It says that CopyRects is ok for this purpose, so I searched the DX-doc and they say: "IDirect3DDevice9::UpdateSurface is similar to IDirect3DDevice8::CopyRects in Microsoft DirectX 8.0." But there is also IDirect3DDevice9::StretchRect which looks very fast.

Which one is faster or more suitable?

rgds DXer

This topic is closed to new replies.

Advertisement