 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
haust
Joined: 01 Oct 2005 Posts: 25 Location: France
|
Posted: Thu Oct 27, 2005 9:46 am Post subject: Perfomance issue.... |
|
|
Well I would like some comments on the tests I performed with v0.11 to determine how many sprites I could blit in brute force.
Following is the little app I've coded for the test. It just load an image then when you press cross sprites are added and when you press circle sprites are removed. In the upper left the FPS and the sprites count are displayed.
Currentlty I could blit 63 sprites 16x16 @ 60 FPS with transparency turned off, and somthing like 47 sprite with transparency turned on.
Is something wrong ??
One thing I've discovered is that Controls.read() eats lots of time. So much that with 2 Controls.read() calls and no sprite displayed FPS started @30 !! Therefore Controls.read() should be called once per app loop and stored for future use in that loop. Maybe some of you already knew it but I didn't....
vh
| Code: | -- -----------------------------------------------------------------------
-- CFpsTester
-- -----------------------------------------------------------------------
CFpsTester = {}
CFpsTesterMetaTable = { __index = CFpsTester }
-- -----------------------------------------------------------------------
-- CFpsTester:new
-- -----------------------------------------------------------------------
function CFpsTester:new(ImageName)
local Table =
{
m_Image = Image.load(ImageName),
m_SpriteSize = { m_Width = 16, m_Height = 16 },
m_Sprites = {},
m_Frames = 0,
m_FPS = 0,
m_Timer = -1,
m_CurrentTime = 0,
m_LastFPSTime = 0,
m_InkColor = Color.new(0, 255, 0),
m_BackColor = Color.new(55, 102, 104),
m_Buttons = -1,
}
setmetatable(Table, CFpsTesterMetaTable);
local Now = os.date("*t");
local Seed = Now.hour + Now.min + Now.wday + Now.year + Now.yday + Now.month + Now.sec + Now.day;
math.randomseed(Seed);
Table.m_Timer = Timer.new();
Table.m_Timer:start();
Table.m_Buttons = Controls.read();
return (Table);
end
-- -----------------------------------------------------------------------
-- CFpsTester:update
-- -----------------------------------------------------------------------
function CFpsTester:update()
self.m_Buttons = Controls.read();
self.m_CurrentTime = self.m_Timer:time();
if (1000 <= (self.m_CurrentTime - self.m_LastFPSTime)) then
self.m_LastFPSTime = self.m_CurrentTime;
self.m_FPS = self.m_Frames;
self.m_Frames = 0;
end
self.m_Frames = self.m_Frames + 1;
if (self.m_Buttons:cross()) then
self:privateAddSprite();
end
if (self.m_Buttons:circle()) then
self:privateRemoveSprite();
end
end
-- -----------------------------------------------------------------------
-- CFpsTester:draw
-- -----------------------------------------------------------------------
function CFpsTester:draw(TargetImage)
TargetImage:clear(self.m_BackColor);
for Index, Sprite in self.m_Sprites do
TargetImage:blit(Sprite.m_X, Sprite.m_Y, self.m_Image, Sprite.m_SourceX, Sprite.m_SourceY, self.m_SpriteSize.m_Width, self.m_SpriteSize.m_Height, false);
end
TargetImage:print(5, 5, "FPS " .. tostring(self.m_FPS), self.m_InkColor);
TargetImage:print(5, 15, "Sprites " .. tostring(table.getn(self.m_Sprites)), self.m_InkColor);
end
-- -----------------------------------------------------------------------
-- CFpsTester:checkExistApp
-- -----------------------------------------------------------------------
function CFpsTester:checkExistApp()
return (self.m_Buttons:start());
end
-- -----------------------------------------------------------------------
-- CFpsTester:privateAddSprite
-- -----------------------------------------------------------------------
function CFpsTester:privateAddSprite()
local Sprite =
{
m_X = math.random(screen:width() - self.m_SpriteSize.m_Width),
m_Y = math.random(screen:height() - self.m_SpriteSize.m_Height),
m_SourceX = math.random(self.m_Image:width() - self.m_SpriteSize.m_Width),
m_SourceY = math.random(self.m_Image:height() - self.m_SpriteSize.m_Height),
}
self.m_Sprites[table.getn(self.m_Sprites) + 1] = Sprite;
end
-- -----------------------------------------------------------------------
-- CFpsTester:privateRemoveSprite
-- -----------------------------------------------------------------------
function CFpsTester:privateRemoveSprite()
self.m_Sprites[table.getn(self.m_Sprites)] = nil;
end
g_App = -1;
-- -----------------------------------------------------------------------
-- Update
-- -----------------------------------------------------------------------
function Update()
g_App:update();
end
-- -----------------------------------------------------------------------
-- Draw
-- -----------------------------------------------------------------------
function Draw()
g_App:draw(screen);
screen.waitVblankStart()
screen.flip()
end
-- -----------------------------------------------------------------------
-- main
-- -----------------------------------------------------------------------
function main()
g_App = CFpsTester:new("Image.png"); -- for safety should be at least 64x64
while (false == g_App:checkExistApp()) do
Update();
Draw();
end
end
main();
|
|
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Thu Oct 27, 2005 1:19 pm Post subject: |
|
|
those findings are concurrent with my own.. lua is very slow when it comes to multiple small blits. you have to be clever and combine your small blits into a few large ones, only update what has changed, etc.. i hope my game will be a good example of this when i finally release it. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
Durante
Joined: 02 Oct 2005 Posts: 65 Location: Austria
|
Posted: Fri Oct 28, 2005 11:11 am Post subject: |
|
|
Just for shits and giggles I did some tests on my version of Luaplayer. I can do about 110 64 * 64 alpha blended 32 bit blits to the screen currently, in the 60 fps timeframe. Not that much, but enough for my purposes.
Last edited by Durante on Sat Oct 29, 2005 3:26 am; edited 2 times in total |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Fri Oct 28, 2005 12:26 pm Post subject: |
|
|
| Durante wrote: | | Just for shits and giggles I did some tests on my version of Luaplayer. I can do about 110 64 * 64 alpha blended 32 bit blits to the screen currently, in the 60 fps timeframe. Not that much, but enough for my purposes. |
what's different in your version, and why aren't your changes in v0.12? _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
Durante
Joined: 02 Oct 2005 Posts: 65 Location: Austria
|
Posted: Fri Oct 28, 2005 12:35 pm Post subject: |
|
|
| chaos wrote: | | what's different in your version, | Among other things, that it uses pspGL to blit images to the screen. | chaos wrote: | | and why aren't your changes in v0.12? | Because Shine decided to go with Gu, and so they're incompatible. But it shouldn't be hard to get at least the same performance out of Gu. Just have some patience or implement it yourself.
For more information read this thread:
http://forums.ps2dev.org/viewtopic.php?t=3583 |
|
| Back to top |
|
 |
xyuppiex
Joined: 28 Oct 2005 Posts: 2
|
Posted: Fri Oct 28, 2005 7:07 pm Post subject: |
|
|
Durante,
I checked out the LuaPlayer code form the svn on tuesday and added your pspGL files. My blitting speed was cut in half compared to the 0.11 release!
Would you mind posting your lua code for blitting 110 sprites @ 60 fps?
/xyux |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Sat Oct 29, 2005 12:16 am Post subject: |
|
|
| xyuppiex wrote: | Durante,
I checked out the LuaPlayer code form the svn on tuesday and added your pspGL files. My blitting speed was cut in half compared to the 0.11 release!
Would you mind posting your lua code for blitting 110 sprites @ 60 fps?
/xyux |
speed cut is quite simple due 32bit instead of 16 before... _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
Durante
Joined: 02 Oct 2005 Posts: 65 Location: Austria
|
Posted: Sat Oct 29, 2005 3:27 am Post subject: |
|
|
| Durante wrote: | | Just for shits and giggles I did some tests on my version of Luaplayer. I can do about 110 64 * 64 alpha blended 32 bit blits to the screen currently, in the 60 fps timeframe. Not that much, but enough for my purposes. |
Software blits from image to image are indeed slower (a lot). Just don't do them ;)
Also, the code in that thread is a bit out of date.
[edit]
I just vastly improved my pspgl usage, I can now do 140 in 16 ms. That doesn't seem like too much of an increase, but that's because the true advantage only becomes visible if you use many different textures. My game performance increased nearly twofold. |
|
| Back to top |
|
 |
xyuppiex
Joined: 28 Oct 2005 Posts: 2
|
Posted: Sat Oct 29, 2005 12:53 pm Post subject: |
|
|
Durante,
Mind putting together a new pack of files for us to compile?
I need all the speed I can get! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|