Further upgrading put pixel.

The Partridge Family were neither partridges nor a family. Discuss.
NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: Further upgrading put pixel.

Post by NaturalDemon » December 14th, 2012, 11:37 pm

cameron wrote:A test will only make the game slow down. I want a performance boost to make the game run faster.
wel the basic putpixel ... does already 4 tests out of the box.

Code: Select all

   assert( x >= 0 );
   assert( y >= 0 );
   assert( x < SCREENWIDTH );
   assert( y < SCREENHEIGHT );
this is much more complex than

Code: Select all

if (x >= 0 && x <= screenwidth && y >= 0 && y <= screenheight)
{
PutPixel (.........);
}
you should use7create a frametimer.

Code: Select all

pSysBuffer[ x + SCREENWIDTH * y ]
is any array of the type D3DCOLOR ... you acces the induvidual index directly ... i don´t see how you can speed that up .... unles the cpu it self has some special tools i don´t know off.

read ... http://www.planetchili.net/forum/viewto ... a+blitting

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: Further upgrading put pixel.

Post by Musi » December 14th, 2012, 11:41 pm

you're wrong ... sorry to say

Code: Select all

( x < 0 || x + 20 > SCREENWIDTH ||
            y < 0 || y + 20 > SCREENHEIGHT )
(see image) http://www.planetchili.net/forum/viewto ... e&start=10

is much slower than

Code: Select all

if (x >= 0 && x <= screenwidth && y >= 0 && y <= screenheight)
{
PutPixel (.........);
}
Is it realy slower? im not calling it for every pixel though. Surely one if statment is faster than 400. What about a 100x100 sprite, is one if statement slower than 10,000?

Also i think asserts get removed on the release build.
Musi

There are 10 types of people that understand binary.
Those that do, and those that don't.

NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: Further upgrading put pixel.

Post by NaturalDemon » December 14th, 2012, 11:50 pm

Musi wrote: Is it realy slower? im not calling it for every pixel though. Surely one if statment is faster than 400. What about a 100x100 sprite, is one if statement slower than 10,000?
you are doing ... atleast 6 operation vs atleast 4 operations .. so it's 33,333333% slower than 4
on a 10.000 pixel image .. you would do this test also 10.000x and all of them 33,3333% slower than the most simple solution

x < 0 (operation)
|| (operation)
x + 20 (operation)
(sum) > SCREENWIDTH (operation)
||(operation)
y < 0 (operation)
|| (operation)
y + 20(operation)
(sum) > SCREENHEIGHT (operation)
Musi wrote: Also i think asserts get removed on the release build.
yeah, chili mentioned some ... this means you need to add test on place to prevent any outside of the client coordinates in the currect state (800x600) of the framework

wiki: stack

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: Further upgrading put pixel.

Post by Musi » December 14th, 2012, 11:56 pm

you are doing ... 6 operation vs 4 operations .. so it's 33,333333% faster
on a 10.000 pixel image .. you would do this test also 10.000x and all of them 33,3333% slower than the most simple solution
Ugh, but like i said im not testing every pixel, im testing the sprites coordinates, which is one test to find out if the sprite is all on the screen or not. THEN if the sprite is partly off the screen you test every pixel.
Musi

There are 10 types of people that understand binary.
Those that do, and those that don't.

NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: Further upgrading put pixel.

Post by NaturalDemon » December 15th, 2012, 12:06 am

Ugh, but like i said im not testing every pixel, im testing the sprites coordinates, which is one test to find out if the sprite is all on the screen or not. THEN if the sprite is partly off the screen you test every pixel.

oh, yeah now i see ... sorry

but there are various methods(adaptive loops instead of omitting pixels) ... and i think ... all this stuff aint realy needed ....
because i have been reading all this time and i still don`t have a clear picture ....
but the 2d stuff seams to be harder than the 3d stuff.

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Further upgrading put pixel.

Post by cameron » December 15th, 2012, 12:32 am

The asserts only run in debug mode. So it dosnt slow the game down its just to check if something goes wrong so the tests don't help. The asserts are the tests. So more tests just slows it even more. I need a speed boost. If a speed boost is even possible.
Computer too slow? Consider running a VM on your toaster.

NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: Further upgrading put pixel.

Post by NaturalDemon » December 15th, 2012, 12:41 am

what are you doing?

are you using images?
mutile of the same?
are you loading them on the fly or preload the images?
1920 x 1080?

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Further upgrading put pixel.

Post by cameron » December 15th, 2012, 1:27 am

Im pre loading them.
Computer too slow? Consider running a VM on your toaster.

Zionich
Posts: 24
Joined: December 11th, 2012, 12:57 am

Re: Further upgrading put pixel.

Post by Zionich » December 15th, 2012, 4:37 am

@Cameron

I see what your saying as far as the initial test, before the individual test. I like it.

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: Further upgrading put pixel.

Post by Musi » December 15th, 2012, 11:09 am

I don't think put pixel can get any simpler really, all it does now is change a value in an array. The only thing i can think of that might improve drawing speed is to use something other than memcpy(); to copy it to the back buffer. But again i don't even know if there's a faster way of doing that either.

Are your programs running slow?
Musi

There are 10 types of people that understand binary.
Those that do, and those that don't.

Post Reply