Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

2D rendering performance

Started by DarkZoulz 3 replies 950+ views
Original Post
DarkZoulz
DarkZoulz
Hi, i'm attempting to roll my own sprite system with directx 9. I am aware of the ID3DXSprite interface, but want to be able to connect pixelshader programs to seperate sprites etc. and I don't think that is possible with the supplied interface. Anyhow, what i'm wondering is if making a drawprimitive call for each sprite in my scene is that much of a performance hit? I know it would probably be better to send all my sprites in one drawprimitive call, but I can't think of a reasonable way of doing this. One way might be to add all the sprites to a vertexbuffer and just render that, but i'd really like to be able to transform each sprite by a matrix to be able to scale and rotate them. Any advice?
MrFlibble
MrFlibble

What you want to do is keep the number of DrawPrimitive calls to an absolute minimum by batching up as many primitives as possible.

It might be better for you to transform all of your sprites CPU side, then just throw the post-transformed data at the graphics card via a vertex buffer and a single DrawPrimitive call.

What you could do is be very cheeky and actually encode the matrix into the Vertex declaration, declare addtional D3DDECLTYPE_FLOAT4's as TEXCOORDS and then transfer them to a matrix to transform perhaps? Obviously this would need a custom vertex & pixel shader though :)
MrF.--Code..reboot..code..reboot..sigh!
DarkZoulz
DarkZoulz
I think I will go with transforming the sprites CPU side, as I don't want the engine to require a card with shader support.

Thanks a bunch! :)
JasonBlochowiak
JasonBlochowiak
Quote:
Original post by DarkZoulz
I think I will go with transforming the sprites CPU side, as I don't want the engine to require a card with shader support.

Thanks a bunch! :)


Wait, you want to not use ID3DXSprite so you can use shaders, but you don't want to use shaders?
DarkZoulz
DarkZoulz
Quote:
Original post by JasonBlochowiak
Quote:
Original post by DarkZoulz
I think I will go with transforming the sprites CPU side, as I don't want the engine to require a card with shader support.

Thanks a bunch! :)


Wait, you want to not use ID3DXSprite so you can use shaders, but you don't want to use shaders?


Hehe, I want to use shaders. But if the end-users card does not support shaders, I still want him/her to be able to play. In other words, I don't want my 2D engine to be dependent on shaders solely. But now that you mention it, I could check at startup if the users hardware supports shaders, and if so do everything on the GPU. Otherwise, on CPU.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.