mesa/es: Validate blend function enums in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 02:52:53 +0000 (19:52 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 29 Aug 2012 22:09:34 +0000 (15:09 -0700)
v2: Add proper core-profile filtering.

v3: Allow GL_SRC_ALPHA_SATURATE as a destination factor in GLES3.  Based
on review feedback from Eric Anholt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/APIspec.xml
src/mesa/main/blend.c

index 44dcd21007892f09b93296cfbc8ecff8d3e0bb5b..34e41b49e17670e26d8787383ac8e88e511742a2 100644 (file)
                <param name="sfactor" type="GLenum"/>
                <param name="dfactor" type="GLenum"/>
        </proto>
-
-       <desc name="sfactor">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-               <value name="GL_SRC_ALPHA_SATURATE"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
-
-       <desc name="dfactor">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
 </template>
 
 <template name="LogicOp">
                <param name="srcAlpha" type="GLenum"/>
                <param name="dstAlpha" type="GLenum"/>
        </proto>
-
-       <desc name="srcRGB">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-               <value name="GL_SRC_ALPHA_SATURATE"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
-
-       <desc name="dstRGB">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
-
-       <desc name="srcAlpha">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-               <value name="GL_SRC_ALPHA_SATURATE"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
-
-       <desc name="dstAlpha">
-               <value name="GL_ZERO"/>
-               <value name="GL_ONE"/>
-               <value name="GL_SRC_COLOR"/>
-               <value name="GL_ONE_MINUS_SRC_COLOR"/>
-               <value name="GL_SRC_ALPHA"/>
-               <value name="GL_ONE_MINUS_SRC_ALPHA"/>
-               <value name="GL_DST_ALPHA"/>
-               <value name="GL_ONE_MINUS_DST_ALPHA"/>
-               <value name="GL_DST_COLOR"/>
-               <value name="GL_ONE_MINUS_DST_COLOR"/>
-
-               <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
-               <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
-               <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
-       </desc>
 </template>
 
 <template name="PointParameter">
index 5bc40a028bd18901800548222451fa4ef019803d..de871a92a39eac3cfa9ceb2b4590121db688f6e9 100644 (file)
@@ -58,16 +58,18 @@ legal_src_factor(const struct gl_context *ctx, GLenum factor)
    case GL_DST_ALPHA:
    case GL_ONE_MINUS_DST_ALPHA:
    case GL_SRC_ALPHA_SATURATE:
+      return GL_TRUE;
    case GL_CONSTANT_COLOR:
    case GL_ONE_MINUS_CONSTANT_COLOR:
    case GL_CONSTANT_ALPHA:
    case GL_ONE_MINUS_CONSTANT_ALPHA:
-      return GL_TRUE;
+      return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
    case GL_SRC1_COLOR:
    case GL_SRC1_ALPHA:
    case GL_ONE_MINUS_SRC1_COLOR:
    case GL_ONE_MINUS_SRC1_ALPHA:
-      return ctx->Extensions.ARB_blend_func_extended;
+      return _mesa_is_desktop_gl(ctx)
+         && ctx->Extensions.ARB_blend_func_extended;
    default:
       return GL_FALSE;
    }
@@ -93,17 +95,22 @@ legal_dst_factor(const struct gl_context *ctx, GLenum factor)
    case GL_ONE_MINUS_SRC_ALPHA:
    case GL_DST_ALPHA:
    case GL_ONE_MINUS_DST_ALPHA:
+      return GL_TRUE;
    case GL_CONSTANT_COLOR:
    case GL_ONE_MINUS_CONSTANT_COLOR:
    case GL_CONSTANT_ALPHA:
    case GL_ONE_MINUS_CONSTANT_ALPHA:
-      return GL_TRUE;
+      return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
    case GL_SRC_ALPHA_SATURATE:
+      return (_mesa_is_desktop_gl(ctx)
+              && ctx->Extensions.ARB_blend_func_extended)
+         || _mesa_is_gles3(ctx);
    case GL_SRC1_COLOR:
    case GL_SRC1_ALPHA:
    case GL_ONE_MINUS_SRC1_COLOR:
    case GL_ONE_MINUS_SRC1_ALPHA:
-      return ctx->Extensions.ARB_blend_func_extended;
+      return _mesa_is_desktop_gl(ctx)
+         && ctx->Extensions.ARB_blend_func_extended;
    default:
       return GL_FALSE;
    }