Advertisement Jump to content
Sign in to follow this  

OpenGL glBlendFunc vs glBlendFunci

This topic is 1787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, right now im porting my engine from DX to OpenGL and I have encountered some difficulties with glBlendfunc.


Primarily I have 2 questions



From the docs:



glBlendFunc defines the operation of blending for all draw buffers when it is enabled. glBlendFunci defines the operation of blending for a single draw buffer specified by buf when enabled for that draw buffer.


which of the two calls is dominating the other one? Or how will my rendertarget in slot 0 be blended if I set glBlendFunc (GL_ZERO, GL_ONE) AND glBlendFunci (0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)? Is this behaviour well defined?



I have tested a simple scene using blending. Configuring the pipeline state with glBlendFunci instead of glBlendFunc causes serious performace issues dropping fps from >250 to 0.5. I find it hard to explain, since the funcionality should be supported (I'm running a 3.3 core context on a GeForce 9800 GT). I'd like to know if someone here knows any hints regarding this.


Thanks in advance!


Share this post

Link to post
Share on other sites

This isn't documented for glBlendFunc and it doesn't seem to be covered in the GL spec either.  That would indicate that the interaction is that the most recently set state is the one that is used for each buffer, but otherwise no preference.  For your example, if you call glBlendFunc (GL_ZERO, GL_ONE) THEN call glBlendFunci (0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), then all buffers will use GL_ZERO, GL_ONE with the exception of slot 0 which uses GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA.


Dropping to less than 1 FPS is normally a good indication that your per-fragment pipeline has gone to software emulation.  So the GL driver supports it, but just not with hardware acceleration.  Unfortunately GL doesn't provide a way of determining when this is going to happen.


The 9800 GT is a DirectX 10 part, whereas separate blend funcs per slot is a DirectX 10.1 feature, so it just seems most likely that your GFX card doesn't support this in hardware.  However GL specifies that it must be supported in the GL_VERSION used by your driver, so hence it drops you to software emulation.  The obvious solution is to just not use glBlendFunci.

Share this post

Link to post
Share on other sites

Thank you,

your reply was most helpful!


Also I empirically verified your therory about latest state set overwriting the previous the same scene into 2 buffers.

I assume that this would be driver dependent - I could verify this on the latest Nvidia GeForce driver.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!