|
Faster Translucent Effects? |
Onewing
Member #6,152
August 2005
|
I'm working on tuning up a program and a lot of the slow down comes from using draw_trans_sprite. Is there any way I can speed this up w/o adding additional libraries. As I said, I'm working on tuning up a program, so I don't really want to add more libraries to it. I replaced one routine that drew a BLACK-filled bitmap to "dim" the screen with a simple draw_lit_sprite and noticed about 10fps increase! Now I also have a 300 X 300 area being drawn via draw_trans_sprite and seems to really slow it down. At home, my machine can easily pump 60+fps, but at work, on a 2.4GHz Celeron, she's lucky to go 30. Am I sore out of luck? ------------ |
GullRaDriel
Member #3,861
September 2003
|
#1 Profile, Benchmark. #2 Give code. There are optimization guru there. What else ? I do not know. You do not want additional library, so refer to #1 "Code is like shit - it only smells if it is not yours" |
HoHo
Member #4,534
April 2004
|
Tell us more about what kind of bitmap types and bitdepths are you using. Would it be possible to make that small area to not being updated every frame? [edit] And yes, code would be nice. I'm bored and I might provide you with some nice graphs, similar to what I showed here, assuming your program compiles and runs on Linux __________ |
Matt Smith
Member #783
November 2000
|
Why no additional library? fblend depends only on Allegro. At least look at the fblend code, because this style of speedup is the best you can do in software. |
Onewing
Member #6,152
August 2005
|
Quote: Tell us more about what kind of bitmap types and bitdepths are you using. Oh, right right. Everything is truecolor, color depth 32 bits. (I'm thinking of going to the wonderfull paletted world of 8-bit in the future ) Screenshot: I circled (in red) the area that is being translucent each frame. {"name":"591418","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/b\/3b54ab9457c82ace6d391f0061127ed3.jpg","w":645,"h":485,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/b\/3b54ab9457c82ace6d391f0061127ed3"} The green blocks are above the water, floating, rippling the water. The turned-off blocks are submerged under the water. I've got an option that turns off rippling the water all together, but it's still drawing it with translucency and the fps is just about the same. [edit] Quote: Why no additional library? fblend depends only on Allegro. Well, originally, I wanted to keep it as close to vanilla allegro as possible. Plus, less libraries makes it less of a pain since I just supply the source to linux users. I've heard many good things about fblend, I'd just prefer to learn more about what I can do with what I have before adding more to it. Am I making any sense? ------------ |
GullRaDriel
Member #3,861
September 2003
|
Quote: Am I making any sense? No. You just have to take a look at fblend source to see how to achieve what you need. "Code is like shit - it only smells if it is not yours" |
HoHo
Member #4,534
April 2004
|
Quote: Oh, right right. Everything is truecolor, color depth 32 bits I hope you aren't using anything but regular bitmaps sitting in RAM. How much rendering time is spent in drawing the translucent pixels? In percentages or in some other meaningful numbers? __________ |
juvinious
Member #5,145
October 2004
|
Allegro isn't going to get any faster with the blending routines despite what you do unless you forgo blending altogether. If you want faster blending you will need to look into a 3rd party options such as fblend. __________________________________________ |
Onewing
Member #6,152
August 2005
|
Quote: How much rendering time is spent in drawing the translucent pixels? In percentages or in some other meaningful numbers? Well, if I take out both the water update and draw functions, back at home it would increase from about 60fps to 90fps. Also, I don't draw each pixel under a translucent mode. The pseudo-algorithm/logic of the water process is as follows 1) Stretch background image to the container size (placed on bmp called bImage) Steps 4 & 6 are the main buggers of the algorithm, but on a high-end machine, the effect is rather aesthetic (in my opinion at least, haha). I took a look at fblend real quick. If I can just steal this function (or use it somehow) without having link fblend all together, that might be a solution.
------------ |
HoHo
Member #4,534
April 2004
|
Quote: Well, if I take out both the water update and draw functions, back at home it would increase from about 60fps to 90fps That doesn't seem all that big difference. Have you profiled your program? Also you seem to be doing a lot of streching. Are you sure it is faster than using correct size from the start? __________ |
Onewing
Member #6,152
August 2005
|
Quote: Have you profiled your program? Have any recommended profilers for WindowsXP? Googling... ------------ |
GullRaDriel
Member #3,861
September 2003
|
What compiler do you use ? Example with gcc: compile with -pg Launch the program Use gprof to have the information. "Code is like shit - it only smells if it is not yours" |
HoHo
Member #4,534
April 2004
|
Quote: Have any recommended profilers for WindowsXP? As said, there is gprof. Also MSVC6 enterprise edition used to have a profiler, I'm not sure about the later versions. Of cource as I said, if you could share your code I might take a look at it myself __________ |
Onewing
Member #6,152
August 2005
|
Quote: And yes, code would be nice. I'm bored and I might provide you with some nice graphs, similar to what I showed here, assuming your program compiles and runs on Linux I never saw this editted portion of your above post. Anyway, Toggles is on the depot and, if you have the right libraries (which I believe are listed in the readme), should compile on Linux if you get the 1.2.15 version. This code hasn't been touched since last August and doesn't include any of the recent optimizations I've been working on. I'm still new to the linux environment, so I haven't quite learned all the tricks to make it easier to supply to you guys. [Edit] ------------ |
Paul whoknows
Member #5,081
September 2004
|
Quote: Everything is truecolor, color depth 32 bits. You can use Fladimir's routines, but only for 32 bits alpha blending. ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
Onewing
Member #6,152
August 2005
|
Well, to be honest, I threw that simple fblend function (that I listed above) directly into my code and it worked pretty nicely. I also moved my logic around (do the blending then the stretching), which improved things. Now it's running at 85+fps on my home machine with the water. Not too shabby. I might still try to do the profiler thing, if not for simply educational purposes... Credits to all! ------------ |
Fladimir da Gorf
Member #1,565
October 2001
|
The function you posted doesn't use MMX when it's alvailable. Better use the whole FBlend to speed everything up even more. I've always wondered why people are so afraid of third party libraries, anyways... OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
CursedTyrant
Member #7,080
April 2006
|
Quote: I've always wondered why people are so afraid of third party libraries, anyways... Because they go bump in the night and eat small children, why else? --------- |
Onewing
Member #6,152
August 2005
|
Quote: I've always wondered why people are so afraid of third party libraries, anyways... Well, for me at least, the whole hobbyist game programming thing is 1) a hobby and 2) educational. Using more libraries makes option 1 more fitting, as you can produce a greater range of results faster but code-wise, the limit approaches "make_awesome_game();" Hence, I try to figure things out with what I have first, then add libraries if I ahve to. Also, as I mentioned, I don't know how to properly make a linux binary, but I offer them the source so they can attempt to build it. Each library, as far as I can tell, adds to the amount of work they have to do. That I find very bad. So, just stripping a function from the library seems to be the quickest and efficient solution to the bullet points above. Although, it doesn't do much for the knowledge-portion other than realizing I should never use draw_trans_sprite again. ------------ |
Paul whoknows
Member #5,081
September 2004
|
Quote: I should never use draw_trans_sprite again.
Why? what's wrong with draw_trans_sprite? ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
Milan Mimica
Member #3,877
September 2003
|
Just to mention that in the SVN version of AllegroGL, draw_trans_sprite() is implemented using OpenGL when drawing to screen, which means it can be quite fast.
-- |
|