brw_util.c

Go to the documentation of this file.
00001 /*
00002  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
00003  Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
00004  develop this 3D driver.
00005 
00006  Permission is hereby granted, free of charge, to any person obtaining
00007  a 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, sublicense, 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
00016  portions of the Software.
00017 
00018  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00021  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
00022  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00023  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00024  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025 
00026  **********************************************************************/
00027  /*
00028   * Authors:
00029   *   Keith Whitwell <keith@tungstengraphics.com>
00030   */
00031 
00032 
00033 #include "brw_util.h"
00034 #include "brw_defines.h"
00035 
00036 #include "pipe/p_defines.h"
00037 
00038 unsigned brw_count_bits( unsigned val )
00039 {
00040    unsigned i;
00041    for (i = 0; val ; val >>= 1)
00042       if (val & 1)
00043          i++;
00044    return i;
00045 }
00046 
00047 
00048 unsigned brw_translate_blend_equation( int mode )
00049 {
00050    switch (mode) {
00051    case PIPE_BLEND_ADD:
00052       return BRW_BLENDFUNCTION_ADD;
00053    case PIPE_BLEND_MIN:
00054       return BRW_BLENDFUNCTION_MIN;
00055    case PIPE_BLEND_MAX:
00056       return BRW_BLENDFUNCTION_MAX;
00057    case PIPE_BLEND_SUBTRACT:
00058       return BRW_BLENDFUNCTION_SUBTRACT;
00059    case PIPE_BLEND_REVERSE_SUBTRACT:
00060       return BRW_BLENDFUNCTION_REVERSE_SUBTRACT;
00061    default:
00062       assert(0);
00063       return BRW_BLENDFUNCTION_ADD;
00064    }
00065 }
00066 
00067 unsigned brw_translate_blend_factor( int factor )
00068 {
00069    switch(factor) {
00070    case PIPE_BLENDFACTOR_ZERO:
00071       return BRW_BLENDFACTOR_ZERO;
00072    case PIPE_BLENDFACTOR_SRC_ALPHA:
00073       return BRW_BLENDFACTOR_SRC_ALPHA;
00074    case PIPE_BLENDFACTOR_ONE:
00075       return BRW_BLENDFACTOR_ONE;
00076    case PIPE_BLENDFACTOR_SRC_COLOR:
00077       return BRW_BLENDFACTOR_SRC_COLOR;
00078    case PIPE_BLENDFACTOR_INV_SRC_COLOR:
00079       return BRW_BLENDFACTOR_INV_SRC_COLOR;
00080    case PIPE_BLENDFACTOR_DST_COLOR:
00081       return BRW_BLENDFACTOR_DST_COLOR;
00082    case PIPE_BLENDFACTOR_INV_DST_COLOR:
00083       return BRW_BLENDFACTOR_INV_DST_COLOR;
00084    case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
00085       return BRW_BLENDFACTOR_INV_SRC_ALPHA;
00086    case PIPE_BLENDFACTOR_DST_ALPHA:
00087       return BRW_BLENDFACTOR_DST_ALPHA;
00088    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
00089       return BRW_BLENDFACTOR_INV_DST_ALPHA;
00090    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
00091       return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
00092    case PIPE_BLENDFACTOR_CONST_COLOR:
00093       return BRW_BLENDFACTOR_CONST_COLOR;
00094    case PIPE_BLENDFACTOR_INV_CONST_COLOR:
00095       return BRW_BLENDFACTOR_INV_CONST_COLOR;
00096    case PIPE_BLENDFACTOR_CONST_ALPHA:
00097       return BRW_BLENDFACTOR_CONST_ALPHA;
00098    case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
00099       return BRW_BLENDFACTOR_INV_CONST_ALPHA;
00100    default:
00101       assert(0);
00102       return BRW_BLENDFACTOR_ZERO;
00103    }
00104 }

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