Jump to content

  • Log In with Google      Sign In   
  • Create Account

glBlendFunc vs glBlendFunci


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Wh0p   Members   -  Reputation: 340

Like
0Likes
Like

Posted 25 February 2014 - 10:43 AM

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

 

Primarily I have 2 questions

 

1.)

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?

 

2.)

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!

 



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8275

Like
2Likes
Like

Posted 25 February 2014 - 01:25 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Wh0p   Members   -  Reputation: 340

Like
0Likes
Like

Posted 25 February 2014 - 01:50 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS