brw_vs.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_vs.h"
00035 #include "brw_util.h"
00036 #include "brw_state.h"
00037 
00038 
00039 static void do_vs_prog( struct brw_context *brw,
00040                         const struct brw_vertex_program *vp,
00041                         struct brw_vs_prog_key *key )
00042 {
00043    unsigned program_size;
00044    const unsigned *program;
00045    struct brw_vs_compile c;
00046 
00047    memset(&c, 0, sizeof(c));
00048    memcpy(&c.key, key, sizeof(*key));
00049 
00050    brw_init_compile(&c.func);
00051    c.vp = vp;
00052 
00053    c.prog_data.outputs_written = vp->info.num_outputs;
00054    c.prog_data.inputs_read = vp->info.num_inputs;
00055 
00056 #if 0
00057    if (c.key.copy_edgeflag) {
00058       c.prog_data.outputs_written |= 1<<VERT_RESULT_EDGE;
00059       c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
00060    }
00061 #endif
00062 
00063    /* Emit GEN4 code.
00064     */
00065    brw_vs_emit(&c);
00066 
00067    /* get the program
00068     */
00069    program = brw_get_program(&c.func, &program_size);
00070 
00071    /*
00072     */
00073    brw->vs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_VS_PROG],
00074                                               &c.key,
00075                                               sizeof(c.key),
00076                                               program,
00077                                               program_size,
00078                                               &c.prog_data,
00079                                               &brw->vs.prog_data);
00080 }
00081 
00082 
00083 static void brw_upload_vs_prog( struct brw_context *brw )
00084 {
00085    struct brw_vs_prog_key key;
00086    const struct brw_vertex_program *vp = brw->attribs.VertexProgram;
00087 
00088    assert(vp);
00089 
00090    memset(&key, 0, sizeof(key));
00091 
00092    /* Just upload the program verbatim for now.  Always send it all
00093     * the inputs it asks for, whether they are varying or not.
00094     */
00095    key.program_string_id = vp->id;
00096    key.nr_userclip = brw->attribs.Clip.nr;
00097    key.copy_edgeflag = (brw->attribs.Raster->fill_cw != PIPE_POLYGON_MODE_FILL ||
00098                         brw->attribs.Raster->fill_ccw != PIPE_POLYGON_MODE_FILL);
00099 
00100    /* Make an early check for the key.
00101     */
00102    if (brw_search_cache(&brw->cache[BRW_VS_PROG],
00103                         &key, sizeof(key),
00104                         &brw->vs.prog_data,
00105                         &brw->vs.prog_gs_offset))
00106        return;
00107 
00108    do_vs_prog(brw, vp, &key);
00109 }
00110 
00111 
00112 /* See brw_vs.c:
00113  */
00114 const struct brw_tracked_state brw_vs_prog = {
00115    .dirty = {
00116       .brw   = BRW_NEW_VS,
00117       .cache = 0
00118    },
00119    .update = brw_upload_vs_prog
00120 };

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