• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3  Intel funded Tungsten Graphics 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 <keithw@vmware.com>
30   */
31 
32 
33 #include "brw_util.h"
34 #include "brw_defines.h"
35 #include "compiler/brw_eu_defines.h"
36 
brw_translate_blend_equation(GLenum mode)37 GLuint brw_translate_blend_equation( GLenum mode )
38 {
39    switch (mode) {
40    case GL_FUNC_ADD:
41       return BRW_BLENDFUNCTION_ADD;
42    case GL_MIN:
43       return BRW_BLENDFUNCTION_MIN;
44    case GL_MAX:
45       return BRW_BLENDFUNCTION_MAX;
46    case GL_FUNC_SUBTRACT:
47       return BRW_BLENDFUNCTION_SUBTRACT;
48    case GL_FUNC_REVERSE_SUBTRACT:
49       return BRW_BLENDFUNCTION_REVERSE_SUBTRACT;
50    default:
51       unreachable("not reached");
52    }
53 }
54 
brw_translate_blend_factor(GLenum factor)55 GLuint brw_translate_blend_factor( GLenum factor )
56 {
57    switch(factor) {
58    case GL_ZERO:
59       return BRW_BLENDFACTOR_ZERO;
60    case GL_SRC_ALPHA:
61       return BRW_BLENDFACTOR_SRC_ALPHA;
62    case GL_ONE:
63       return BRW_BLENDFACTOR_ONE;
64    case GL_SRC_COLOR:
65       return BRW_BLENDFACTOR_SRC_COLOR;
66    case GL_ONE_MINUS_SRC_COLOR:
67       return BRW_BLENDFACTOR_INV_SRC_COLOR;
68    case GL_DST_COLOR:
69       return BRW_BLENDFACTOR_DST_COLOR;
70    case GL_ONE_MINUS_DST_COLOR:
71       return BRW_BLENDFACTOR_INV_DST_COLOR;
72    case GL_ONE_MINUS_SRC_ALPHA:
73       return BRW_BLENDFACTOR_INV_SRC_ALPHA;
74    case GL_DST_ALPHA:
75       return BRW_BLENDFACTOR_DST_ALPHA;
76    case GL_ONE_MINUS_DST_ALPHA:
77       return BRW_BLENDFACTOR_INV_DST_ALPHA;
78    case GL_SRC_ALPHA_SATURATE:
79       return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
80    case GL_CONSTANT_COLOR:
81       return BRW_BLENDFACTOR_CONST_COLOR;
82    case GL_ONE_MINUS_CONSTANT_COLOR:
83       return BRW_BLENDFACTOR_INV_CONST_COLOR;
84    case GL_CONSTANT_ALPHA:
85       return BRW_BLENDFACTOR_CONST_ALPHA;
86    case GL_ONE_MINUS_CONSTANT_ALPHA:
87       return BRW_BLENDFACTOR_INV_CONST_ALPHA;
88 
89    case GL_SRC1_COLOR:
90       return BRW_BLENDFACTOR_SRC1_COLOR;
91    case GL_SRC1_ALPHA:
92       return BRW_BLENDFACTOR_SRC1_ALPHA;
93    case GL_ONE_MINUS_SRC1_COLOR:
94       return BRW_BLENDFACTOR_INV_SRC1_COLOR;
95    case GL_ONE_MINUS_SRC1_ALPHA:
96       return BRW_BLENDFACTOR_INV_SRC1_ALPHA;
97 
98    default:
99       unreachable("not reached");
100    }
101 }
102 
103 static const GLuint prim_to_hw_prim[GL_TRIANGLE_STRIP_ADJACENCY+1] = {
104    [GL_POINTS] =_3DPRIM_POINTLIST,
105    [GL_LINES] = _3DPRIM_LINELIST,
106    [GL_LINE_LOOP] = _3DPRIM_LINELOOP,
107    [GL_LINE_STRIP] = _3DPRIM_LINESTRIP,
108    [GL_TRIANGLES] = _3DPRIM_TRILIST,
109    [GL_TRIANGLE_STRIP] = _3DPRIM_TRISTRIP,
110    [GL_TRIANGLE_FAN] = _3DPRIM_TRIFAN,
111    [GL_QUADS] = _3DPRIM_QUADLIST,
112    [GL_QUAD_STRIP] = _3DPRIM_QUADSTRIP,
113    [GL_POLYGON] = _3DPRIM_POLYGON,
114    [GL_LINES_ADJACENCY] = _3DPRIM_LINELIST_ADJ,
115    [GL_LINE_STRIP_ADJACENCY] = _3DPRIM_LINESTRIP_ADJ,
116    [GL_TRIANGLES_ADJACENCY] = _3DPRIM_TRILIST_ADJ,
117    [GL_TRIANGLE_STRIP_ADJACENCY] = _3DPRIM_TRISTRIP_ADJ,
118 };
119 
120 uint32_t
get_hw_prim_for_gl_prim(int mode)121 get_hw_prim_for_gl_prim(int mode)
122 {
123    assert(mode < ARRAY_SIZE(prim_to_hw_prim));
124    return prim_to_hw_prim[mode];
125 }
126