Jump to content
  • Advertisement
Sign in to follow this  
rwang

render to texture too slow

This topic is 3585 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 am trying to simulate the planar smoke effect by using GPU. One problem I have is that render to texture is extremely slow. I have to render to texture around 30~40 times per frame. (I know it is a lot, but i have to solve the linear equation by using the jacobi iteration) but still, the Demo from GPU Gem and RenderMonckey they are also doing this but much faster. (i am using G16R16F as the texture format.) I am thinking maybe i did something wrong in my code? i am creating the texture and render target like this: D3DXCreateRenderToSurface(gd3dDevice, mWidth, mHeight, mTexFormat, false, D3DFMT_D24X8, &mRTS); D3DXCreateTexture(gd3dDevice, mWidth, mHeight, 0, usage, mTexFormat, D3DPOOL_DEFAULT, &m_divergence_texture); m_divergence_texture->GetSurfaceLevel(0, &m_divergence_surface); in each frame, i have to pass the texture to the shader and do some swapping. Does anyone know why it is very slow? Thanks a lot! Ran

Share this post


Link to post
Share on other sites
Advertisement
i have tried 64x64 texture.
the demos from GPU gem and RenderMonkey use 128x128 and still much faster.

Share this post


Link to post
Share on other sites
it is not the problem of the shader, i am using the exactly same shader as render monckey...

Share this post


Link to post
Share on other sites
FPS is very low.
Is there any general advice for optimize the "render to texture"?
like what i shouldn't do... what i should do...
The only thing i know is use "D3DPOOL_DEFAULT" to make it faster...

Share this post


Link to post
Share on other sites
Thanks all your replies:)

I found the reason:
I was using
ID3DXRenderToSurface* mRTS;
D3DXCreateRenderToSurface(gd3dDevice, mWidth, mHeight, mTexFormat, mUseDepthBuffer, mDepthFormat, &mRTS);

Then wrap the draw calls within
mRTS->BeginScene();
...
mRTS->EndScene();

This is causing the performance problem. :(

Now i just set the rendertarget directly to the texture surface without using the "ID3DXRenderToSurface". it is much faster...

One thing i don't understand: what is "ID3DXRenderToSurface" used for?
I can set the render target directly to the surface, why do i still need "ID3DXRenderToSurface"?

Share this post


Link to post
Share on other sites
as far I can tell ID3DXRenderToSurface is just meant to encapsulate the "device->SetRenderTarget" functionality to make it easier to use...in practice you should avoid feature I think...

Its best to avoid some D3DX interfaces when the D3D functionality is present. That is, use D3dX for the math library, the FX interface, D3DXSPRITE, but use D3D for things like render-to-texture and other speed critical functions.

About this smoke thing you are doing; I'm not familiar with the method but doing 40 Render target switches and clears per-frame is going to be cumbersome and slow no matter how well optimized...isnt there a way to distribute some of this over more than one frame?

Share this post


Link to post
Share on other sites
thanks Matt.

it is impossible to avoid or distribute the thingy into more than one frame.
i have to solve a linear equation for calculating the pressure value every frame to update the smoke effect.

Anyway, the speed is acceptable for now, i will try more optimization after i finish all other effects for smoke.

Thanks everyone :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!