19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/*
29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp.  2006.  All Rights Reserved.
39f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver.
59f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
69f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Permission is hereby granted, free of charge, to any person obtaining
79f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt a copy of this software and associated documentation files (the
89f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt "Software"), to deal in the Software without restriction, including
99f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt without limitation the rights to use, copy, modify, merge, publish,
109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt distribute, sublicense, and/or sell copies of the Software, and to
119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt permit persons to whom the Software is furnished to do so, subject to
129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt the following conditions:
139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt The above copyright notice and this permission notice (including the
159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt next paragraph) shall be included in all copies or substantial
169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt portions of the Software.
179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/
279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /*
289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  * Authors:
299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  *   Keith Whitwell <keith@tungstengraphics.com>
309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  */
319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
339846b0627149e221c9fbd7c3379e33fb68e68511Vinson Lee#include <assert.h>
349846b0627149e221c9fbd7c3379e33fb68e68511Vinson Lee
35ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h"
36ec2b92f98c2e7f161521b447cc1d9a36bce3707cBrian Paul#include "program/prog_parameter.h"
37064ae479a770bf434958d673baf6f7530f642697Brian#include "brw_util.h"
389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_defines.h"
399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
409f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtGLuint brw_translate_blend_equation( GLenum mode )
419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   switch (mode) {
439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_FUNC_ADD:
449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_ADD;
459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_MIN:
469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_MIN;
479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_MAX:
489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_MAX;
499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_FUNC_SUBTRACT:
509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_SUBTRACT;
519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_FUNC_REVERSE_SUBTRACT:
529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_REVERSE_SUBTRACT;
539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   default:
549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      assert(0);
559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFUNCTION_ADD;
569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   }
579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
599f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtGLuint brw_translate_blend_factor( GLenum factor )
609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   switch(factor) {
629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ZERO:
639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_ZERO;
649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_SRC_ALPHA:
659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_SRC_ALPHA;
669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE:
679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_ONE;
689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_SRC_COLOR:
699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_SRC_COLOR;
709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_SRC_COLOR:
719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_SRC_COLOR;
729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_DST_COLOR:
739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_DST_COLOR;
749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_DST_COLOR:
759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_DST_COLOR;
769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_SRC_ALPHA:
779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_SRC_ALPHA;
789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_DST_ALPHA:
799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_DST_ALPHA;
809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_DST_ALPHA:
819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_DST_ALPHA;
829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_SRC_ALPHA_SATURATE:
839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_CONSTANT_COLOR:
859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_CONST_COLOR;
869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_CONSTANT_COLOR:
879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_CONST_COLOR;
889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_CONSTANT_ALPHA:
899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_CONST_ALPHA;
909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case GL_ONE_MINUS_CONSTANT_ALPHA:
919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_INV_CONST_ALPHA;
9229362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt
9329362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt   case GL_SRC1_COLOR:
9429362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt      return BRW_BLENDFACTOR_SRC1_COLOR;
9529362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt   case GL_SRC1_ALPHA:
9629362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt      return BRW_BLENDFACTOR_SRC1_ALPHA;
9729362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt   case GL_ONE_MINUS_SRC1_COLOR:
9829362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt      return BRW_BLENDFACTOR_INV_SRC1_COLOR;
9929362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt   case GL_ONE_MINUS_SRC1_ALPHA:
10029362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt      return BRW_BLENDFACTOR_INV_SRC1_ALPHA;
10129362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt
1029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   default:
1039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      assert(0);
1049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return BRW_BLENDFACTOR_ZERO;
1059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   }
1069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
107