PDA

View Full Version : best method of updating alpha only of a framebuffer



zed
12-31-2006, 10:14 AM
so whats best method of updating alpha only of a framebuffer, ie not touching the RGB portion.
u can use glColorMask(0,0,0,1) but i believe ive read the graphics cards makers say this is a bad idea performance wise

is it my only option?

cass
12-31-2006, 10:20 AM
I think that's your only option.

Korval
12-31-2006, 10:01 PM
You might be able to do something with separate color/alpha functions, but that's only available in the higher-end hardware.

MalcolmB
01-01-2007, 05:39 AM
Copy your framebuffer to a texture so you have the RGB values you want to preserve. Then use this texture when updating the alpha.

Brolingstanz
01-01-2007, 06:50 AM
I'd have to go along with Cass. If you take Zed's question literally, the only way to "not touch" the RGB portion is to mask it off. Not touching precludes copying/texturing and blending, doesn't it?

Perhaps he had no intention of introducing such a stringent restriction, but IMHO that's what he did :-)

P.S. Performance wise, how bad could masking be? Worse than blending or copying/texturing?

Frogblast
01-01-2007, 07:57 AM
I can't imagine that masking can be very expensive at all on modern hardware. It certainly must be cheaper than blending or copying.

You should really benchmark color masking yourself before dismissing it outright. Those features are there, because they are the right way to address this need.

There might be some special cases where it is significantly slower, but not generally. ie, some hardware likely implements things glClear as a 2D blit rather than a 3D op, and enabling masking might disable that optimization. But for general 3D drawing, I can't imagine seeing a large difference.

Korval
01-01-2007, 08:31 AM
I can't imagine that masking can be very expensive at all on modern hardware. It certainly must be cheaper than blending or copying.Well, hardware is designed for the most common operation. Which is writing one 32-bit color. Writing to individual bytes is actually much harder than shoving a 32-bit word across a bus; the latter requires a much simpler memory controller. So I could see masking actually being implemented as a specialized blend-style read/modify/write.

Zengar
01-01-2007, 12:39 PM
Zed, please tell us about the performance after you tried it :-)

zed
01-01-2007, 12:46 PM
my question was based on this from a ATI/NVIDIA performance pdf


nvidia specific FB operations
* do not mask off only some color channels unless really necessaryand since the pdf looks like a slide from a talk I thought perhaps they mentioned an alternative method of doing it,
which appears not to be readily available.

though it seems to impley that ati doesnt have the performance degradation from part channel color masking

zed
01-01-2007, 01:17 PM
Originally posted by Zengar:
Zed, please tell us about the performance after you tried it :-) sorry ive since switched to a different method for updating the alpha ( i usually try a few different methods before deciding on a final choice ), this was all for DOF, which does seem to be pretty sweet now (though wether it adds to gameplay is questionable, it certainly detracts from the framerate)
http://www.zedzeek.com/DOF1.jpg
http://www.zedzeek.com/DOF2.jpg
http://www.zedzeek.com/DOF3.jpg

next step HDR, cant say im looking forward to it :(

cass
01-04-2007, 03:25 AM
Depending on the specific hardware, color mask can cost you just the bandwidth for updating alpha, or the bandwidth for updating RGB and A.

When it does cost you the full bandwidth, it usually also costs a full read-modify-write (like a blend) rather than a simple write.

There are also situations where leaving alpha in some unnecessarily "dirty" state could interfere with color compression.

It's difficult to make general statements about what to avoid and what to use freely for best perf. Especially in a hardware neutral way...