sp_context.c File Reference

Include dependency graph for sp_context.c:

Go to the source code of this file.

Functions

void softpipe_map_surfaces (struct softpipe_context *sp)
 Map any drawing surfaces which aren't already mapped.
void softpipe_unmap_surfaces (struct softpipe_context *sp)
 Unmap any mapped drawing surfaces.
static void softpipe_destroy (struct pipe_context *pipe)
struct pipe_contextsoftpipe_create (struct pipe_screen *screen, struct pipe_winsys *pipe_winsys, void *unused)


Function Documentation

struct pipe_context* softpipe_create ( struct pipe_screen screen,
struct pipe_winsys pipe_winsys,
void *  unused 
) [read]

Definition at line 127 of file sp_context.c.

References softpipe_context::alpha_test, pipe_context::bind_blend_state, pipe_context::bind_depth_stencil_alpha_state, pipe_context::bind_fs_state, pipe_context::bind_rasterizer_state, pipe_context::bind_sampler_states, pipe_context::bind_vs_state, softpipe_context::blend, CALLOC_STRUCT, softpipe_context::cbuf_cache, pipe_context::clear, softpipe_context::colormask, softpipe_context::coverage, pipe_context::create_blend_state, pipe_context::create_depth_stencil_alpha_state, pipe_context::create_fs_state, pipe_context::create_rasterizer_state, pipe_context::create_sampler_state, pipe_context::create_vs_state, debug_get_bool_option(), pipe_context::delete_blend_state, pipe_context::delete_depth_stencil_alpha_state, pipe_context::delete_fs_state, pipe_context::delete_rasterizer_state, pipe_context::delete_sampler_state, pipe_context::delete_vs_state, softpipe_context::depth_test, pipe_context::destroy, softpipe_context::draw, pipe_context::draw_arrays, draw_create(), pipe_context::draw_elements, draw_install_aaline_stage(), draw_install_aapoint_stage(), draw_install_pstipple_stage(), pipe_context::draw_range_elements, draw_set_rasterize_stage(), softpipe_context::dump_fs, softpipe_context::earlyz, FALSE, pipe_context::flush, softpipe_context::no_rast, softpipe_context::occlusion, softpipe_context::output, softpipe_context::pipe, PIPE_MAX_COLOR_BUFS, PIPE_MAX_SAMPLERS, softpipe_context::polygon_stipple, softpipe_context::quad, pipe_context::screen, pipe_context::set_blend_color, pipe_context::set_clip_state, pipe_context::set_constant_buffer, pipe_context::set_edgeflags, pipe_context::set_framebuffer_state, pipe_context::set_polygon_stipple, pipe_context::set_sampler_textures, pipe_context::set_scissor_state, pipe_context::set_vertex_buffers, pipe_context::set_vertex_elements, pipe_context::set_viewport_state, softpipe_context::setup, softpipe_context::shade, softpipe_bind_blend_state(), softpipe_bind_depth_stencil_state(), softpipe_bind_fs_state(), softpipe_bind_rasterizer_state(), softpipe_bind_sampler_states(), softpipe_bind_vs_state(), softpipe_clear(), softpipe_create_blend_state(), softpipe_create_depth_stencil_state(), softpipe_create_fs_state(), softpipe_create_rasterizer_state(), softpipe_create_sampler_state(), softpipe_create_vs_state(), softpipe_delete_blend_state(), softpipe_delete_depth_stencil_state(), softpipe_delete_fs_state(), softpipe_delete_rasterizer_state(), softpipe_delete_sampler_state(), softpipe_delete_vs_state(), softpipe_destroy(), softpipe_draw_arrays(), softpipe_draw_elements(), softpipe_draw_range_elements(), softpipe_flush(), softpipe_init_query_funcs(), softpipe_init_texture_funcs(), softpipe_set_blend_color(), softpipe_set_clip_state(), softpipe_set_constant_buffer(), softpipe_set_edgeflags(), softpipe_set_framebuffer_state(), softpipe_set_polygon_stipple(), softpipe_set_sampler_textures(), softpipe_set_scissor_state(), softpipe_set_vertex_buffers(), softpipe_set_vertex_elements(), softpipe_set_viewport_state(), sp_create_tile_cache(), sp_draw_render_stage(), sp_init_surface_functions(), sp_init_vbuf(), SP_NUM_QUAD_THREADS, sp_quad_alpha_test_stage(), sp_quad_blend_stage(), sp_quad_colormask_stage(), sp_quad_coverage_stage(), sp_quad_depth_test_stage(), sp_quad_earlyz_stage(), sp_quad_occlusion_stage(), sp_quad_output_stage(), sp_quad_polygon_stipple_stage(), sp_quad_shade_stage(), sp_quad_stencil_test_stage(), softpipe_context::stencil_test, softpipe_context::tex_cache, TRUE, softpipe_context::use_sse, util_init_math(), pipe_context::winsys, and softpipe_context::zsbuf_cache.

00130 {
00131    struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
00132    uint i;
00133 
00134    util_init_math();
00135 
00136 #ifdef PIPE_ARCH_X86
00137    softpipe->use_sse = !debug_get_bool_option( "GALLIUM_NOSSE", FALSE );
00138 #else
00139    softpipe->use_sse = FALSE;
00140 #endif
00141 
00142    softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE );
00143 
00144    softpipe->pipe.winsys = pipe_winsys;
00145    softpipe->pipe.screen = screen;
00146    softpipe->pipe.destroy = softpipe_destroy;
00147 
00148    /* state setters */
00149    softpipe->pipe.create_blend_state = softpipe_create_blend_state;
00150    softpipe->pipe.bind_blend_state   = softpipe_bind_blend_state;
00151    softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
00152 
00153    softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
00154    softpipe->pipe.bind_sampler_states  = softpipe_bind_sampler_states;
00155    softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
00156 
00157    softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;
00158    softpipe->pipe.bind_depth_stencil_alpha_state   = softpipe_bind_depth_stencil_state;
00159    softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state;
00160 
00161    softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
00162    softpipe->pipe.bind_rasterizer_state   = softpipe_bind_rasterizer_state;
00163    softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state;
00164 
00165    softpipe->pipe.create_fs_state = softpipe_create_fs_state;
00166    softpipe->pipe.bind_fs_state   = softpipe_bind_fs_state;
00167    softpipe->pipe.delete_fs_state = softpipe_delete_fs_state;
00168 
00169    softpipe->pipe.create_vs_state = softpipe_create_vs_state;
00170    softpipe->pipe.bind_vs_state   = softpipe_bind_vs_state;
00171    softpipe->pipe.delete_vs_state = softpipe_delete_vs_state;
00172 
00173    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
00174    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
00175    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
00176    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
00177    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
00178    softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
00179    softpipe->pipe.set_sampler_textures = softpipe_set_sampler_textures;
00180    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
00181 
00182    softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers;
00183    softpipe->pipe.set_vertex_elements = softpipe_set_vertex_elements;
00184 
00185    softpipe->pipe.draw_arrays = softpipe_draw_arrays;
00186    softpipe->pipe.draw_elements = softpipe_draw_elements;
00187    softpipe->pipe.draw_range_elements = softpipe_draw_range_elements;
00188    softpipe->pipe.set_edgeflags = softpipe_set_edgeflags;
00189 
00190 
00191    softpipe->pipe.clear = softpipe_clear;
00192    softpipe->pipe.flush = softpipe_flush;
00193 
00194    softpipe_init_query_funcs( softpipe );
00195    softpipe_init_texture_funcs( softpipe );
00196 
00197    /*
00198     * Alloc caches for accessing drawing surfaces and textures.
00199     * Must be before quad stage setup!
00200     */
00201    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
00202       softpipe->cbuf_cache[i] = sp_create_tile_cache( screen );
00203    softpipe->zsbuf_cache = sp_create_tile_cache( screen );
00204 
00205    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
00206       softpipe->tex_cache[i] = sp_create_tile_cache( screen );
00207 
00208 
00209    /* setup quad rendering stages */
00210    for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
00211       softpipe->quad[i].polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
00212       softpipe->quad[i].earlyz = sp_quad_earlyz_stage(softpipe);
00213       softpipe->quad[i].shade = sp_quad_shade_stage(softpipe);
00214       softpipe->quad[i].alpha_test = sp_quad_alpha_test_stage(softpipe);
00215       softpipe->quad[i].depth_test = sp_quad_depth_test_stage(softpipe);
00216       softpipe->quad[i].stencil_test = sp_quad_stencil_test_stage(softpipe);
00217       softpipe->quad[i].occlusion = sp_quad_occlusion_stage(softpipe);
00218       softpipe->quad[i].coverage = sp_quad_coverage_stage(softpipe);
00219       softpipe->quad[i].blend = sp_quad_blend_stage(softpipe);
00220       softpipe->quad[i].colormask = sp_quad_colormask_stage(softpipe);
00221       softpipe->quad[i].output = sp_quad_output_stage(softpipe);
00222    }
00223 
00224    /*
00225     * Create drawing context and plug our rendering stage into it.
00226     */
00227    softpipe->draw = draw_create();
00228    if (!softpipe->draw) 
00229       goto fail;
00230 
00231    softpipe->setup = sp_draw_render_stage(softpipe);
00232    if (!softpipe->setup)
00233       goto fail;
00234 
00235    if (debug_get_bool_option( "SP_NO_RAST", FALSE ))
00236       softpipe->no_rast = TRUE;
00237 
00238    if (debug_get_bool_option( "SP_NO_VBUF", FALSE )) {
00239       /* Deprecated path -- vbuf is the intended interface to the draw module:
00240        */
00241       draw_set_rasterize_stage(softpipe->draw, softpipe->setup);
00242    }
00243    else {
00244       sp_init_vbuf(softpipe);
00245    }
00246 
00247    /* plug in AA line/point stages */
00248    draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
00249    draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
00250 
00251 #if USE_DRAW_STAGE_PSTIPPLE
00252    /* Do polygon stipple w/ texture map + frag prog? */
00253    draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
00254 #endif
00255 
00256    sp_init_surface_functions(softpipe);
00257 
00258    return &softpipe->pipe;
00259 
00260  fail:
00261    softpipe_destroy(&softpipe->pipe);
00262    return NULL;
00263 }

static void softpipe_destroy ( struct pipe_context pipe  )  [static]

Definition at line 86 of file sp_context.c.

References softpipe_context::alpha_test, softpipe_context::blend, pipe_constant_buffer::buffer, softpipe_context::cbuf_cache, softpipe_context::colormask, softpipe_context::constants, softpipe_context::coverage, softpipe_context::depth_test, quad_stage::destroy, softpipe_context::draw, draw_destroy(), softpipe_context::earlyz, Elements, FREE, softpipe_context::occlusion, softpipe_context::output, PIPE_MAX_COLOR_BUFS, PIPE_MAX_SAMPLERS, softpipe_context::polygon_stipple, softpipe_context::quad, softpipe_context::shade, softpipe_context(), sp_destroy_tile_cache(), SP_NUM_QUAD_THREADS, softpipe_context::stencil_test, softpipe_context::tex_cache, pipe_context::winsys, winsys_buffer_reference(), and softpipe_context::zsbuf_cache.

00087 {
00088    struct softpipe_context *softpipe = softpipe_context( pipe );
00089    struct pipe_winsys *ws = pipe->winsys;
00090    uint i;
00091 
00092    if (softpipe->draw)
00093       draw_destroy( softpipe->draw );
00094 
00095    for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
00096       softpipe->quad[i].polygon_stipple->destroy( softpipe->quad[i].polygon_stipple );
00097       softpipe->quad[i].earlyz->destroy( softpipe->quad[i].earlyz );
00098       softpipe->quad[i].shade->destroy( softpipe->quad[i].shade );
00099       softpipe->quad[i].alpha_test->destroy( softpipe->quad[i].alpha_test );
00100       softpipe->quad[i].depth_test->destroy( softpipe->quad[i].depth_test );
00101       softpipe->quad[i].stencil_test->destroy( softpipe->quad[i].stencil_test );
00102       softpipe->quad[i].occlusion->destroy( softpipe->quad[i].occlusion );
00103       softpipe->quad[i].coverage->destroy( softpipe->quad[i].coverage );
00104       softpipe->quad[i].blend->destroy( softpipe->quad[i].blend );
00105       softpipe->quad[i].colormask->destroy( softpipe->quad[i].colormask );
00106       softpipe->quad[i].output->destroy( softpipe->quad[i].output );
00107    }
00108 
00109    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
00110       sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
00111    sp_destroy_tile_cache(softpipe->zsbuf_cache);
00112 
00113    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
00114       sp_destroy_tile_cache(softpipe->tex_cache[i]);
00115 
00116    for (i = 0; i < Elements(softpipe->constants); i++) {
00117       if (softpipe->constants[i].buffer) {
00118          winsys_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
00119       }
00120    }
00121 
00122    FREE( softpipe );
00123 }

void softpipe_map_surfaces ( struct softpipe_context sp  ) 

Map any drawing surfaces which aren't already mapped.

Definition at line 55 of file sp_context.c.

References softpipe_context::cbuf_cache, softpipe_context::framebuffer, pipe_framebuffer_state::num_cbufs, sp_tile_cache_map_surfaces(), and softpipe_context::zsbuf_cache.

00056 {
00057    unsigned i;
00058 
00059    for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
00060       sp_tile_cache_map_surfaces(sp->cbuf_cache[i]);
00061    }
00062 
00063    sp_tile_cache_map_surfaces(sp->zsbuf_cache);
00064 }

void softpipe_unmap_surfaces ( struct softpipe_context sp  ) 

Unmap any mapped drawing surfaces.

Definition at line 71 of file sp_context.c.

References softpipe_context::cbuf_cache, softpipe_context::framebuffer, pipe_framebuffer_state::num_cbufs, sp_flush_tile_cache(), sp_tile_cache_unmap_surfaces(), and softpipe_context::zsbuf_cache.

00072 {
00073    uint i;
00074 
00075    for (i = 0; i < sp->framebuffer.num_cbufs; i++)
00076       sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
00077    sp_flush_tile_cache(sp, sp->zsbuf_cache);
00078 
00079    for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
00080       sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]);
00081    }
00082    sp_tile_cache_unmap_surfaces(sp->zsbuf_cache);
00083 }


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