• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3  Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4  develop this 3D driver.
5 
6  Permission is hereby granted, free of charge, to any person obtaining
7  a copy of this software and associated documentation files (the
8  "Software"), to deal in the Software without restriction, including
9  without limitation the rights to use, copy, modify, merge, publish,
10  distribute, sublicense, and/or sell copies of the Software, and to
11  permit persons to whom the Software is furnished to do so, subject to
12  the following conditions:
13 
14  The above copyright notice and this permission notice (including the
15  next paragraph) shall be included in all copies or substantial
16  portions of the Software.
17 
18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 
26  **********************************************************************/
27  /*
28   * Authors:
29   *   Keith Whitwell <keith@tungstengraphics.com>
30   */
31 
32 
33 #include <assert.h>
34 
35 #include "main/mtypes.h"
36 #include "program/prog_parameter.h"
37 #include "brw_util.h"
38 #include "brw_defines.h"
39 
brw_translate_blend_equation(GLenum mode)40 GLuint brw_translate_blend_equation( GLenum mode )
41 {
42    switch (mode) {
43    case GL_FUNC_ADD:
44       return BRW_BLENDFUNCTION_ADD;
45    case GL_MIN:
46       return BRW_BLENDFUNCTION_MIN;
47    case GL_MAX:
48       return BRW_BLENDFUNCTION_MAX;
49    case GL_FUNC_SUBTRACT:
50       return BRW_BLENDFUNCTION_SUBTRACT;
51    case GL_FUNC_REVERSE_SUBTRACT:
52       return BRW_BLENDFUNCTION_REVERSE_SUBTRACT;
53    default:
54       assert(0);
55       return BRW_BLENDFUNCTION_ADD;
56    }
57 }
58 
brw_translate_blend_factor(GLenum factor)59 GLuint brw_translate_blend_factor( GLenum factor )
60 {
61    switch(factor) {
62    case GL_ZERO:
63       return BRW_BLENDFACTOR_ZERO;
64    case GL_SRC_ALPHA:
65       return BRW_BLENDFACTOR_SRC_ALPHA;
66    case GL_ONE:
67       return BRW_BLENDFACTOR_ONE;
68    case GL_SRC_COLOR:
69       return BRW_BLENDFACTOR_SRC_COLOR;
70    case GL_ONE_MINUS_SRC_COLOR:
71       return BRW_BLENDFACTOR_INV_SRC_COLOR;
72    case GL_DST_COLOR:
73       return BRW_BLENDFACTOR_DST_COLOR;
74    case GL_ONE_MINUS_DST_COLOR:
75       return BRW_BLENDFACTOR_INV_DST_COLOR;
76    case GL_ONE_MINUS_SRC_ALPHA:
77       return BRW_BLENDFACTOR_INV_SRC_ALPHA;
78    case GL_DST_ALPHA:
79       return BRW_BLENDFACTOR_DST_ALPHA;
80    case GL_ONE_MINUS_DST_ALPHA:
81       return BRW_BLENDFACTOR_INV_DST_ALPHA;
82    case GL_SRC_ALPHA_SATURATE:
83       return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
84    case GL_CONSTANT_COLOR:
85       return BRW_BLENDFACTOR_CONST_COLOR;
86    case GL_ONE_MINUS_CONSTANT_COLOR:
87       return BRW_BLENDFACTOR_INV_CONST_COLOR;
88    case GL_CONSTANT_ALPHA:
89       return BRW_BLENDFACTOR_CONST_ALPHA;
90    case GL_ONE_MINUS_CONSTANT_ALPHA:
91       return BRW_BLENDFACTOR_INV_CONST_ALPHA;
92 
93    case GL_SRC1_COLOR:
94       return BRW_BLENDFACTOR_SRC1_COLOR;
95    case GL_SRC1_ALPHA:
96       return BRW_BLENDFACTOR_SRC1_ALPHA;
97    case GL_ONE_MINUS_SRC1_COLOR:
98       return BRW_BLENDFACTOR_INV_SRC1_COLOR;
99    case GL_ONE_MINUS_SRC1_ALPHA:
100       return BRW_BLENDFACTOR_INV_SRC1_ALPHA;
101 
102    default:
103       assert(0);
104       return BRW_BLENDFACTOR_ZERO;
105    }
106 }
107