brw_context.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_draw.h"
00036 #include "brw_vs.h"
00037 #include "brw_tex_layout.h"
00038 #include "brw_winsys.h"
00039 
00040 #include "pipe/p_winsys.h"
00041 #include "pipe/p_context.h"
00042 #include "util/u_memory.h"
00043 #include "pipe/p_screen.h"
00044 
00045 
00046 #ifndef BRW_DEBUG
00047 int BRW_DEBUG = (0);
00048 #endif
00049 
00050 
00051 static void brw_destroy(struct pipe_context *pipe)
00052 {
00053    struct brw_context *brw = brw_context(pipe);
00054 
00055    if(brw->winsys->destroy)
00056       brw->winsys->destroy(brw->winsys);
00057    
00058    FREE(brw);
00059 }
00060 
00061 
00062 static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
00063                       unsigned clearValue)
00064 {
00065    int x, y, w, h;
00066    /* FIXME: corny... */
00067 
00068    x = 0;
00069    y = 0;
00070    w = ps->width;
00071    h = ps->height;
00072 
00073    pipe->surface_fill(pipe, ps, x, y, w, h, clearValue);
00074 }
00075 
00076 
00077 struct pipe_context *brw_create(struct pipe_screen *screen,
00078                                 struct brw_winsys *brw_winsys,
00079                                 unsigned pci_id)
00080 {
00081    struct brw_context *brw;
00082 
00083    debug_printf("%s: creating brw_context with pci id 0x%x\n",
00084                 __FUNCTION__, pci_id);
00085 
00086    brw = CALLOC_STRUCT(brw_context);
00087    if (brw == NULL)
00088       return NULL;
00089 
00090    brw->winsys = brw_winsys;
00091    brw->pipe.winsys = screen->winsys;
00092    brw->pipe.screen = screen;
00093 
00094    brw->pipe.destroy = brw_destroy;
00095    brw->pipe.clear = brw_clear;
00096 
00097    brw_init_surface_functions(brw);
00098    brw_init_texture_functions(brw);
00099    brw_init_state_functions(brw);
00100    brw_init_flush_functions(brw);
00101    brw_init_draw_functions( brw );
00102 
00103 
00104    brw_init_state( brw );
00105 
00106    brw->pci_id = pci_id;
00107    brw->dirty = ~0;
00108    brw->hardware_dirty = ~0;
00109 
00110    memset(&brw->wm.bind, ~0, sizeof(brw->wm.bind));
00111 
00112    return &brw->pipe;
00113 }
00114 

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