brw_eu.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_context.h"
00034 #include "brw_defines.h"
00035 #include "brw_eu.h"
00036 
00037 
00038 
00039 /* How does predicate control work when execution_size != 8?  Do I
00040  * need to test/set for 0xffff when execution_size is 16?
00041  */
00042 void brw_set_predicate_control_flag_value( struct brw_compile *p, unsigned value )
00043 {
00044    p->current->header.predicate_control = BRW_PREDICATE_NONE;
00045 
00046    if (value != 0xff) {
00047       if (value != p->flag_value) {
00048          brw_push_insn_state(p);
00049          brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
00050          p->flag_value = value;
00051          brw_pop_insn_state(p);
00052       }
00053 
00054       p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
00055    }   
00056 }
00057 
00058 void brw_set_predicate_control( struct brw_compile *p, unsigned pc )
00059 {
00060    p->current->header.predicate_control = pc;
00061 }
00062 
00063 void brw_set_conditionalmod( struct brw_compile *p, unsigned conditional )
00064 {
00065    p->current->header.destreg__conditonalmod = conditional;
00066 }
00067 
00068 void brw_set_access_mode( struct brw_compile *p, unsigned access_mode )
00069 {
00070    p->current->header.access_mode = access_mode;
00071 }
00072 
00073 void brw_set_compression_control( struct brw_compile *p, boolean compression_control )
00074 {
00075    p->current->header.compression_control = compression_control;
00076 }
00077 
00078 void brw_set_mask_control( struct brw_compile *p, unsigned value )
00079 {
00080    p->current->header.mask_control = value;
00081 }
00082 
00083 void brw_set_saturate( struct brw_compile *p, unsigned value )
00084 {
00085    p->current->header.saturate = value;
00086 }
00087 
00088 void brw_push_insn_state( struct brw_compile *p )
00089 {
00090    assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
00091    memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
00092    p->current++;   
00093 }
00094 
00095 void brw_pop_insn_state( struct brw_compile *p )
00096 {
00097    assert(p->current != p->stack);
00098    p->current--;
00099 }
00100 
00101 
00102 /***********************************************************************
00103  */
00104 void brw_init_compile( struct brw_compile *p )
00105 {
00106    p->nr_insn = 0;
00107    p->current = p->stack;
00108    memset(p->current, 0, sizeof(p->current[0]));
00109 
00110    /* Some defaults?
00111     */
00112    brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
00113    brw_set_saturate(p, 0);
00114    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
00115    brw_set_predicate_control_flag_value(p, 0xff); 
00116 }
00117 
00118 
00119 const unsigned *brw_get_program( struct brw_compile *p,
00120                                unsigned *sz )
00121 {
00122    unsigned i;
00123 
00124    for (i = 0; i < 8; i++)
00125       brw_NOP(p);
00126 
00127    *sz = p->nr_insn * sizeof(struct brw_instruction);
00128    return (const unsigned *)p->store;
00129 }
00130 

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