Jump to content
  • Advertisement
Sign in to follow this  
DirectXer

filling a texture [dx9]

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!