i915_state_inlines.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 #ifndef I915_STATE_INLINES_H
00029 #define I915_STATE_INLINES_H
00030 
00031 #include "pipe/p_compiler.h"
00032 #include "pipe/p_defines.h"
00033 #include "i915_reg.h"
00034 
00035 
00036 static INLINE unsigned
00037 i915_translate_compare_func(unsigned func)
00038 {
00039    switch (func) {
00040    case PIPE_FUNC_NEVER:
00041       return COMPAREFUNC_NEVER;
00042    case PIPE_FUNC_LESS:
00043       return COMPAREFUNC_LESS;
00044    case PIPE_FUNC_LEQUAL:
00045       return COMPAREFUNC_LEQUAL;
00046    case PIPE_FUNC_GREATER:
00047       return COMPAREFUNC_GREATER;
00048    case PIPE_FUNC_GEQUAL:
00049       return COMPAREFUNC_GEQUAL;
00050    case PIPE_FUNC_NOTEQUAL:
00051       return COMPAREFUNC_NOTEQUAL;
00052    case PIPE_FUNC_EQUAL:
00053       return COMPAREFUNC_EQUAL;
00054    case PIPE_FUNC_ALWAYS:
00055       return COMPAREFUNC_ALWAYS;
00056    default:
00057       return COMPAREFUNC_ALWAYS;
00058    }
00059 }
00060 
00061 static INLINE unsigned
00062 i915_translate_stencil_op(unsigned op)
00063 {
00064    switch (op) {
00065    case PIPE_STENCIL_OP_KEEP:
00066       return STENCILOP_KEEP;
00067    case PIPE_STENCIL_OP_ZERO:
00068       return STENCILOP_ZERO;
00069    case PIPE_STENCIL_OP_REPLACE:
00070       return STENCILOP_REPLACE;
00071    case PIPE_STENCIL_OP_INCR:
00072       return STENCILOP_INCRSAT;
00073    case PIPE_STENCIL_OP_DECR:
00074       return STENCILOP_DECRSAT;
00075    case PIPE_STENCIL_OP_INCR_WRAP:
00076       return STENCILOP_INCR;
00077    case PIPE_STENCIL_OP_DECR_WRAP:
00078       return STENCILOP_DECR;
00079    case PIPE_STENCIL_OP_INVERT:
00080       return STENCILOP_INVERT;
00081    default:
00082       return STENCILOP_ZERO;
00083    }
00084 }
00085 
00086 static INLINE unsigned
00087 i915_translate_blend_factor(unsigned factor)
00088 {
00089    switch (factor) {
00090    case PIPE_BLENDFACTOR_ZERO:
00091       return BLENDFACT_ZERO;
00092    case PIPE_BLENDFACTOR_SRC_ALPHA:
00093       return BLENDFACT_SRC_ALPHA;
00094    case PIPE_BLENDFACTOR_ONE:
00095       return BLENDFACT_ONE;
00096    case PIPE_BLENDFACTOR_SRC_COLOR:
00097       return BLENDFACT_SRC_COLR;
00098    case PIPE_BLENDFACTOR_INV_SRC_COLOR:
00099       return BLENDFACT_INV_SRC_COLR;
00100    case PIPE_BLENDFACTOR_DST_COLOR:
00101       return BLENDFACT_DST_COLR;
00102    case PIPE_BLENDFACTOR_INV_DST_COLOR:
00103       return BLENDFACT_INV_DST_COLR;
00104    case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
00105       return BLENDFACT_INV_SRC_ALPHA;
00106    case PIPE_BLENDFACTOR_DST_ALPHA:
00107       return BLENDFACT_DST_ALPHA;
00108    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
00109       return BLENDFACT_INV_DST_ALPHA;
00110    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
00111       return BLENDFACT_SRC_ALPHA_SATURATE;
00112    case PIPE_BLENDFACTOR_CONST_COLOR:
00113       return BLENDFACT_CONST_COLOR;
00114    case PIPE_BLENDFACTOR_INV_CONST_COLOR:
00115       return BLENDFACT_INV_CONST_COLOR;
00116    case PIPE_BLENDFACTOR_CONST_ALPHA:
00117       return BLENDFACT_CONST_ALPHA;
00118    case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
00119       return BLENDFACT_INV_CONST_ALPHA;
00120    default:
00121       return BLENDFACT_ZERO;
00122    }
00123 }
00124 
00125 static INLINE unsigned
00126 i915_translate_blend_func(unsigned mode)
00127 {
00128    switch (mode) {
00129    case PIPE_BLEND_ADD:
00130       return BLENDFUNC_ADD;
00131    case PIPE_BLEND_MIN:
00132       return BLENDFUNC_MIN;
00133    case PIPE_BLEND_MAX:
00134       return BLENDFUNC_MAX;
00135    case PIPE_BLEND_SUBTRACT:
00136       return BLENDFUNC_SUBTRACT;
00137    case PIPE_BLEND_REVERSE_SUBTRACT:
00138       return BLENDFUNC_REVERSE_SUBTRACT;
00139    default:
00140       return 0;
00141    }
00142 }
00143 
00144 
00145 static INLINE unsigned
00146 i915_translate_logic_op(unsigned opcode)
00147 {
00148    switch (opcode) {
00149    case PIPE_LOGICOP_CLEAR:
00150       return LOGICOP_CLEAR;
00151    case PIPE_LOGICOP_AND:
00152       return LOGICOP_AND;
00153    case PIPE_LOGICOP_AND_REVERSE:
00154       return LOGICOP_AND_RVRSE;
00155    case PIPE_LOGICOP_COPY:
00156       return LOGICOP_COPY;
00157    case PIPE_LOGICOP_COPY_INVERTED:
00158       return LOGICOP_COPY_INV;
00159    case PIPE_LOGICOP_AND_INVERTED:
00160       return LOGICOP_AND_INV;
00161    case PIPE_LOGICOP_NOOP:
00162       return LOGICOP_NOOP;
00163    case PIPE_LOGICOP_XOR:
00164       return LOGICOP_XOR;
00165    case PIPE_LOGICOP_OR:
00166       return LOGICOP_OR;
00167    case PIPE_LOGICOP_OR_INVERTED:
00168       return LOGICOP_OR_INV;
00169    case PIPE_LOGICOP_NOR:
00170       return LOGICOP_NOR;
00171    case PIPE_LOGICOP_EQUIV:
00172       return LOGICOP_EQUIV;
00173    case PIPE_LOGICOP_INVERT:
00174       return LOGICOP_INV;
00175    case PIPE_LOGICOP_OR_REVERSE:
00176       return LOGICOP_OR_RVRSE;
00177    case PIPE_LOGICOP_NAND:
00178       return LOGICOP_NAND;
00179    case PIPE_LOGICOP_SET:
00180       return LOGICOP_SET;
00181    default:
00182       return LOGICOP_SET;
00183    }
00184 }
00185 
00186 
00187 
00188 static INLINE boolean i915_validate_vertices( unsigned hw_prim, unsigned nr )
00189 {
00190    boolean ok;
00191 
00192    switch (hw_prim) {
00193    case PRIM3D_POINTLIST:
00194       ok = (nr >= 1);
00195       assert(ok);
00196       break;
00197    case PRIM3D_LINELIST:
00198       ok = (nr >= 2) && (nr % 2) == 0;
00199       assert(ok);
00200       break;
00201    case PRIM3D_LINESTRIP:
00202       ok = (nr >= 2);
00203       assert(ok);
00204       break;
00205    case PRIM3D_TRILIST:
00206       ok = (nr >= 3) && (nr % 3) == 0;
00207       assert(ok);
00208       break;
00209    case PRIM3D_TRISTRIP:
00210       ok = (nr >= 3);
00211       assert(ok);
00212       break;
00213    case PRIM3D_TRIFAN:
00214       ok = (nr >= 3);
00215       assert(ok);
00216       break;
00217    case PRIM3D_POLY:
00218       ok = (nr >= 3);
00219       assert(ok);
00220       break;
00221    default:
00222       assert(0);
00223       ok = 0;
00224       break;
00225    }
00226 
00227    return ok;
00228 }
00229 
00230 #endif

Generated on Tue Sep 29 06:25:16 2009 for Gallium3D by  doxygen 1.5.4