Spritebatch Draw Initial delay for some textures

Started by
2 comments, last by renman29 9 years, 11 months ago

I notice that for one of my 4096x4096 textures, when I do this:

spriteBatch.Draw(tex, pos, splat.src_rect, col, 0f, origin, scale/1.4f, SpriteEffects.None, 0f);

there is a very noticeable delay(little more than 1 second) for the initial draw. After which it draws fine.

It is important to note that all other 4096x4096 textures drawn this way have no initial delay until this one is used( I think it's like the 4th or 5th texture this size).

If I comment out the line, no delay will happen. //

I'm under the impression that for some reason, something under the hood isn't initialized or in video ram until the first draw.

I know it's not a terribly big deal, but it is kind of an annoying glitch tongue.png

Any theories about what might be happening or any ideas on how I could get around this? blink.png

Advertisement

Ok well I kind of found a disturbing and inappropriate temporary workaround for the problem using a private do_once Boolean like so:

if (do_once == false) { spriteBatch.Draw(tex, Vector2.Zero, new Rectangle(0, 0, 1, 1), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); do_once = true; }

//LOL. I really hope there's a better solution...

What happens if you switch the order that you use your large textures? That will tell you if it's something specifically wrong with this texture, or whether you're just stressing your GPU memory.

Five 4096x4096 textures take up 320MB of memory (or more if mip-mapped). How much memory does your video card have?

What happens if you use DXT compression for your large textures?

Ah excellent ideas smile.png

The texture seems ok so stressing out the gpu seems to be the case. Card has 1 Gig (although I'm also loading a lot of other fairly large textures so I'm probably getting close to the 500Mb mark).

Tried switching to DXT for the huge textures (or any large textures for backgrounds which I thought should be a bit lossy anyway) -- IT WORKED!

Quality is still very good! smile.png

If I could hug you right now I would. biggrin.png

This topic is closed to new replies.

Advertisement