00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027  
00028 
00029 
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    
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