Sign in to follow this  
Malder1

Why during PreLoad texture method several frames is skiped?

Recommended Posts

I've noticed strange problem in Direct3D. I need to often load and show large new textured quads on the fly (every 5 seconds). There is strange problem with it. After loading texture I call PreLoad method to copy MANAGED texture to video memory from system memory (or it occurs automatically when you first time show new texture on the screen). But during this copying, I noticed that current quads in my 3D scene jerk for a moment. I've tried to call PreLoad method in another thread with more lower priority, but with same result. I've completed another test. I devided my large texture to 8 small textures. Because of this I call PreLoad 8 times for each texture. And I have SAME RESULT with jerking. After this I added Sleep(5) after each PreLoad call and now loading of textures don't affect to 3D scene - it draws OK. I thought maybe my main thread stops during PreLoad? I added counter and it shown me that it works without any skips. So I do summary, PreLoad method or first show of textured quad (if you don't make PreLoad call) add delay and skip several frames. Maybe copying of texture from system mem. to video mem. freezes 3D processing? But is there another solution if we use MANAGED textures?

Share this post


Link to post
Share on other sites
Ok, since the other thread is closed, here's what you added there:
Quote:
Original post by Malder1
I'd like to say more exact about this intersting problem.
It seems when Direct3D copies managed texture from system memory to video memory (for first usage in 3D scene) this task fully STOPS 3D rendering during at this moment, especially it noticable for large textures (1024 x 1024). So I see that my scene a little jerk at this moment.

Earlier I though that 3D video card can render scene and load new texture to VRAM on the fly without pauses.

Share this post


Link to post
Share on other sites
If the card needs a texture to render the given scene, and the texture's not available, it'll obviously wait for the texture to load before rendering.

If you call PreLoad, and render a scene that does *not* use the preloaded textures, then there should be no stalling. If there is, it's a driver/card issue. On the other hand, if the preloaded texture is used in the scene, then the card will still have to wait for it to load.

The point behind providing PreLoad, is that you call it a (short) while before using your textures, to give the card a chance to load them before they're needed (and hence avoid the pause you get)

Share this post


Link to post
Share on other sites
(Sorry for double posting!)

Thanks for your response!

Please imagine that we have 2D (via Direct3D) game where background (high quality textures) continiously scrolls without pauses.

At some moment (e.g. 5 seconds before real appearance) I need to prepare new texture and call PreLoad method to be sure that in the nearest future this new texture will be drawn instantly when hour "X" occurs.

So the new texture is NOT USED in 3D scene yet, when I CALL PreLoad method.
And I hoped that it should not pauses 3D rendering in this case.

Share this post


Link to post
Share on other sites
As we've tested, this problem happens on NVIDIA GeForce 6800, GeForce 2, GeForce 4 Ti, GeForce 4 MX440, ATI Radeon 9600XT.

Loading of a texture: writing to texture using scanlines, then PreLoad to put it to video memory) fully pauses 3D rending during this period.

In Microsoft's Direct3D forum we discussed several ideas, but they don't work.

The only one way, it use separated thread, critical sections, deviding large texture to small 128x128 and call Sleep(0) after loading of each small texture.
It helps almost on all PCs, but slow downing time of loading in two times.

Share this post


Link to post
Share on other sites
Reading the documentation, the Preload call has one item in the remarks section that I wonder could it be the culprit:

Quote:


IDirect3DBaseTexture9::PreLoad detects "thrashing" conditions where more resources are being used in each frame than can fit in video memory simultaneously. Under such circumstances IDirect3DBaseTexture9::PreLoad silently does nothing.



Are you sure there is room in VRAM for your texture? If you are replacing a number of large high resolution textures, could you possibly be close to running out of VRAM?

It's unfortunate that PreLoad() doesn't return an error case, that, while not fatal, at least would tell you in VRAM is full or not.

Just a thought.

-S

Share this post


Link to post
Share on other sites
Yes, there is enough space in video memory (128 MB) and I tried with special test application which only loads small textures and one large (1024x1024).

We can don't call PreLoad method, but when textured quad first time appears on the screen, at this moment Direct3D will copy texture from system memory to VRAM (and of course, image will jerk during this moment)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this