Question about calls to ID3DXSprite::Begin/End

Started by
3 comments, last by ChugginWindex 13 years, 6 months ago
I sort of posted this in the Graphics forum and haven't gotten any replies, so maybe it's more suited here in a slightly different form.

Is there any harm in having more than one set of Begin()/End() pairs with either the D3D graphics device itself or the D3DXSprite device during one main loop iteration? I'm trying to keep elements of an overlay such as a HUD or menu separated from two dimensional sprites and such in the actual scene without having to reserve special weights for the them. I figure making two separate rendering calls would solve my problem, but will this slow me down much?
Advertisement
Nah, fine in moderation. Basically ID3DXSprite can only batch over to the GPU stuff that is sent between a call to Begin and End that has compatible render states but it would be highly abnormal to be able to render your entire scene in one batch.

It's more of a problem when people miss the point and start rendering every single sprite one at a time in it's own Begin/End pair. What you describe will be fine.

Evil Steve did once post something about spying on what the ID3DXSprite interface was doing internally though. As I recall, it was quite scary. If you are really concerned about performance, you might like to consider rolling out your own quad rendering system using vertex and index buffers. I've never touched the sprite thing with a barge pole personally.
Thanks for the reply, that's essentially what I thought. I've seen tons of people posting in the beginner forum with questions about why their speeds were so slow when they were doing exactly what you mentioned, putting every draw call within its own Begin/End pairs. I just wanted to make sure what I was thinking was the correct thing to do.

Any chance you actually know where I can find Evil Steve's post about the internals of D3DXSprite? I'm interested in reading it but I can't seem to find anything on it (he's quite active around here which makes the search function tough)
Sure, here it is. Was quite tough to find since Steve has posted on pretty much every thread that ever mentions ID3DXSprite [smile].

This was posted in 2006 though so it is quite possible that the internals of ID3DXSprite have changed or been improved in updates to the DXSDK since.
Wow, thanks for the link. After reading that it makes me wonder if Microsoft ever updated the sprite interface (as well as the font interface) in directx9 to get rid of those problems. On one hand that was 4 years ago and they've released a ton of updates for DX9/10/whatever. But on the other hand, I know that there was a serious performance increase between DirectX 8 and 9's Sprite interace, so maybe they just never updated it again? For some reason it's terribly difficult to find info about changes to D3DXSprite...

This topic is closed to new replies.

Advertisement