Pixel rounding

Bugs will be moved here once resolved.

Post » Mon Apr 16, 2012 9:40 pm

Well not really a bug, but I didn't know where to post it and I want this to catch someone's attention badly, so @Ashley :)

I did some experiments with mobile exports as you may know already and it came to me, that doing pixel rounding the way it's done in the runtime by Math.round(x) is the slowest way available to round a number.
Done some research and it seems that you can achieve double the speed by rounding using something called a Hack rounding with bitwise or:
[code]rounded = (0.5 + somenum) | 0;[/code]
tested it by changing every instance of [code]if (this.runtime.pixel_rounding) ... Math.round[/code] to the above code and i could actually see a little performance boost in more complex creations.

so... any chance this would be implemented in next c2 version pretty please? :)

cheers!
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Apr 16, 2012 11:31 pm

How much of a performance boost could you measure?

I'd have thought it was negligable, since doing something like drawing a sprite probably takes 1000 times longer than the call to Round().
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Tue Apr 17, 2012 9:24 am

around 2 fps gain. not much but still... :)
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Apr 17, 2012 3:43 pm

OK, well every little helps on mobile, so I've used the (x + 0.5) | 0 form in the next build. It won't be changelogged though since it's a really small change.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Tue Apr 17, 2012 4:00 pm

well no problem for me it's not changelogged :) thanks and cheers!
B
81
S
50
G
10
Posts: 555
Reputation: 13,009


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests