🔒 Locked
[MDX] Sprite Performance
Advertisement
Original Post
Im building a GUI system. My controls consists of several "parts" so that they can be resized. Each part is drawn using the Sprite class: Sprite.Begin() Sprite.Draw(Part1) Sprite.Draw(Part2) Sprite.Draw(Part3) Sprite.Draw(Part4) Sprite.Flush() Sprite.End() However, im experiencing weird performance issues. Is it a bad idea calling the Draw method for every part. How can I improve the performance? It would seem a lot better to somehow combine all the parts into one Draw. Should I not use the Sprite class?
For my game Snake.Net I was drawing about 1500 tiles per frame. In debug mode I would usually only get about 20FPS, in release mode though it would be the normal 75 and in immediate / release mode about 400FPS. However I only had two Begin calls and only one of those had alpha blending.
How many of these controls do you having going and are you compiling in debug mode?
Also you should definatly use the Sprite class, it's the best way to do anything 2D with D3D. I don't know why people say it's slow, you won't find anything faster.
How many of these controls do you having going and are you compiling in debug mode?
Also you should definatly use the Sprite class, it's the best way to do anything 2D with D3D. I don't know why people say it's slow, you won't find anything faster.
Earlier when I was benchmarking the Sprite class (or rather the unmanaged ID3DXSprite interface upon which it is based) I found that using Sprite gave the same performance as making one DrawPrimitive() call for every texture drawn, which is as fast as can be done manually. The primary limit to my Sprite performance was the maximum fill rate of the video card, i.e. the maximum numbers of pixel writes per time unit. So there would be nothing slow about Sprite that could be made better by drawing manually, at least if you're using the same functionality.
Okay, back to some sprite perfomance questions.
I have a problem that is Killing me!
When I call the Draw2D method of a sprite WITH a new Size (So that it stretches) it renders with blur around it. The blur is like a gradiant towards the pixels around the Rectangle that i specified. However, this only happens when the new Size's width and height arent equal.
How can I stretch a sprite (but only for example the width)???
I have a problem that is Killing me!
When I call the Draw2D method of a sprite WITH a new Size (So that it stretches) it renders with blur around it. The blur is like a gradiant towards the pixels around the Rectangle that i specified. However, this only happens when the new Size's width and height arent equal.
How can I stretch a sprite (but only for example the width)???
Yes, everything should be ok with the texture loading. My textures are ^2 and rendering without a size change works correctly, and rendering with an equal size change works correctly (size width = N & height = N).
Its just when I stretch it unequally that I get some weird blur from surround pixels :S
There must be some way to just simply Stretch the image. No advanced filtering or alpha blending. Just a simple pixel stretch :S
Its just when I stretch it unequally that I get some weird blur from surround pixels :S
There must be some way to just simply Stretch the image. No advanced filtering or alpha blending. Just a simple pixel stretch :S
The interpolation routine might not clamp around the source rectangle boundary, but use adjacent texels as well.
Dunno if there's a way to force clamping, but if you're using fixed rectangles in the source texture (e.g. a tileset) an alternative is to add a 1-pixel border around each rect that duplicates the pixels *on* the border when you're assembling the texture.
Dunno if there's a way to force clamping, but if you're using fixed rectangles in the source texture (e.g. a tileset) an alternative is to add a 1-pixel border around each rect that duplicates the pixels *on* the border when you're assembling the texture.
How can I load a region of a texture (just like the sprite class does). If I load the part outside the sprite class than when I render using the sprite it wont have to cut out a region there, and may not cause the blur.
Can I use the TextureLoader.FromFile() override with the Width and Height parameters?
Can I use the TextureLoader.FromFile() override with the Width and Height parameters?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement