Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Does it make sense to store pixel in 3 separate channels during rendering?  (Read 1003 times)
0 Members and 1 Guest are viewing this topic.
Offline phu004

JGO Coder


Medals: 4
Projects: 9
Exp: 10 years


NoSuchPersonException


« Posted 2013-05-29 06:06:59 »

After spending quite a few  hours on optimizing a software renderer,  I realized if you have to do multiple color manipulation on a pixel,  it's might be just faster to represent it in 3 separate channel instead of of rrggbb format throughout the rendering process.  

Imagine we have the following tasks:  

1. change the brightness level of a pixel,  
2. then alpha blend it with another pixel,
3. then average it with neighboring pixels.  

Each of the task requires us to
A. extract the r, g, b channel from the pixel,  
B. apply changes to each channel and  
C. convert it back to rrggbb format.  

As a result the total amount of work is  3 x A + 3 x B + 3 x C.  However if pixels are represented in separate r g b channels,  we won't need step A and C any more. That reduces the total work to 3 x B + C (we need a single step C at the end since  only pixel in the format rrggbb can be written to the screen buffer)

That's just my Theory...




  
Offline HeroesGraveDev

JGO Kernel


Medals: 244
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2013-05-29 06:48:50 »

1. Here we recommend OpenGL which handles most of this anyway on hardware.
2. The amount of performance increase would be pathetic. Your time would be better spent optimising something else.
3. It makes code messy.
4. If it were a good idea, it would already be done.

Simply, if you are at the stage where you need to optimise colour operations, you need to be using OpenGL.

Offline pitbuller
« Reply #2 - Posted 2013-05-29 08:03:45 »

Bandwith is the king not the ALU operations.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HeroesGraveDev

JGO Kernel


Medals: 244
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #3 - Posted 2013-05-29 08:14:17 »

Also, note that in my previous post I mean that IF it actually does give a performance increase, then those are the problems.

It may make performance worse, if anything.

Offline phu004

JGO Coder


Medals: 4
Projects: 9
Exp: 10 years


NoSuchPersonException


« Reply #4 - Posted 2013-05-29 09:01:15 »

Quote
1. Here we recommend OpenGL which handles most of this anyway on hardware.
2. The amount of performance increase would be pathetic. Your time would be better spent optimising something else.
3. It makes code messy.
4. If it were a good idea, it would already be done.

Simply, if you are at the stage where you need to optimise colour operations, you need to be using OpenGL.

I totally agree with what you have said,  except I believe the performance gain could be huge in some scenarios.  In my swimming pool project, there is a place where the camera is able to look at the bottom of the pool through a foggy window. To render each pixel on the bottom of the pool, I have to literally unpack and pack the color data 4 times. That definitely a lot of overhead there  Undecided



Offline Roquen
« Reply #5 - Posted 2013-05-29 09:38:10 »

Bandwith is the king not the ALU operations.
This...very much this.

Besides if you have separate channels, then you have to fold them at the end.  Depending on what blending operations you're performing you don't have to completely separate the values.  So given AARRGGBB can be masked into AA00GG00 & 00RR00BB.  There's should be plenty of resources on doing this.
Offline phu004

JGO Coder


Medals: 4
Projects: 9
Exp: 10 years


NoSuchPersonException


« Reply #6 - Posted 2013-05-30 10:59:13 »

After re-examine the code of my color math, I realized that it won't increase the performance by using 3 separate channels. The overhead introduced by more array read will probably overshadow the benefit gain from  having less fold/unfold operations on the color channels.

Quote
Bandwith is the king not the ALU operations.

Do you mean i should try to include more parallelism in the rendering pipeline instead of optimizing ALU operations?  
Offline philfrei
« Reply #7 - Posted 2013-05-30 19:23:16 »

I tried both methods when I was experimenting with animating a perlin-noise based graphic. For the limited amount of graphics I was doing, the three-array case timed minutely better, but so much less of a factor than the time spent in the perlin function that I just left things in the integer rrggbb form. It didn't seem worth the trouble to go back to managing the multiple arrays.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (20 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (28 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (64 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!