[Mesa-dev] [PATCH 09/17] mesa: add blend_func_separatei() helper
Timothy Arceri
tarceri at itsqueeze.com
Mon May 15 06:19:18 UTC 2017
This will be used to add KHR_no_error support.
---
src/mesa/main/blend.c | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 955fda1..ed519bc 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -285,64 +285,75 @@ _mesa_BlendFuncSeparate( GLenum sfactorRGB, GLenum dfactorRGB,
/**
* Set blend source/dest factors for one color buffer/target.
*/
void GLAPIENTRY
_mesa_BlendFunciARB(GLuint buf, GLenum sfactor, GLenum dfactor)
{
_mesa_BlendFuncSeparateiARB(buf, sfactor, dfactor, sfactor, dfactor);
}
-/**
- * Set separate blend source/dest factors for one color buffer/target.
- */
-void GLAPIENTRY
-_mesa_BlendFuncSeparateiARB(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
- GLenum sfactorA, GLenum dfactorA)
+static ALWAYS_INLINE void
+blend_func_separatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA, bool no_error)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_draw_buffers_blend) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendFunc[Separate]i()");
- return;
- }
+ if (!no_error) {
+ if (!ctx->Extensions.ARB_draw_buffers_blend) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendFunc[Separate]i()");
+ return;
+ }
- if (buf >= ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
- buf);
- return;
+ if (buf >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
+ buf);
+ return;
+ }
}
if (ctx->Color.Blend[buf].SrcRGB == sfactorRGB &&
ctx->Color.Blend[buf].DstRGB == dfactorRGB &&
ctx->Color.Blend[buf].SrcA == sfactorA &&
ctx->Color.Blend[buf].DstA == dfactorA)
return; /* no change */
- if (!validate_blend_factors(ctx, "glBlendFuncSeparatei",
- sfactorRGB, dfactorRGB,
- sfactorA, dfactorA)) {
+ if (!no_error && !validate_blend_factors(ctx, "glBlendFuncSeparatei",
+ sfactorRGB, dfactorRGB,
+ sfactorA, dfactorA)) {
return;
}
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.Blend[buf].SrcRGB = sfactorRGB;
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
update_uses_dual_src(ctx, buf);
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
}
/**
+ * Set separate blend source/dest factors for one color buffer/target.
+ */
+void GLAPIENTRY
+_mesa_BlendFuncSeparateiARB(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA)
+{
+ blend_func_separatei(buf, sfactorRGB, dfactorRGB, sfactorA, dfactorA,
+ false);
+}
+
+
+/**
* Return true if \p mode is a legal blending equation, excluding
* GL_KHR_blend_equation_advanced modes.
*/
static bool
legal_simple_blend_equation(const struct gl_context *ctx, GLenum mode)
{
switch (mode) {
case GL_FUNC_ADD:
case GL_FUNC_SUBTRACT:
case GL_FUNC_REVERSE_SUBTRACT:
--
2.9.3
More information about the mesa-dev
mailing list