boolean svga_init_swtnl( struct svga_context *svga ) { struct svga_screen *screen = svga_screen(svga->pipe.screen); svga->swtnl.backend = svga_vbuf_render_create(svga); if(!svga->swtnl.backend) goto fail; /* * Create drawing context and plug our rendering stage into it. */ svga->swtnl.draw = draw_create(&svga->pipe); if (svga->swtnl.draw == NULL) goto fail; draw_set_rasterize_stage(svga->swtnl.draw, draw_vbuf_stage( svga->swtnl.draw, svga->swtnl.backend )); draw_set_render(svga->swtnl.draw, svga->swtnl.backend); svga->blitter = util_blitter_create(&svga->pipe); if (!svga->blitter) goto fail; /* must be done before installing Draw stages */ util_blitter_cache_all_shaders(svga->blitter); if (!screen->haveLineSmooth) draw_install_aaline_stage(svga->swtnl.draw, &svga->pipe); /* enable/disable line stipple stage depending on device caps */ draw_enable_line_stipple(svga->swtnl.draw, !screen->haveLineStipple); /* always install AA point stage */ draw_install_aapoint_stage(svga->swtnl.draw, &svga->pipe); /* Set wide line threshold above device limit (so we'll never really use it) */ draw_wide_line_threshold(svga->swtnl.draw, MAX2(screen->maxLineWidth, screen->maxLineWidthAA)); if (debug_get_bool_option("SVGA_SWTNL_FSE", FALSE)) draw_set_driver_clipping(svga->swtnl.draw, TRUE, TRUE, TRUE, FALSE); return TRUE; fail: if (svga->blitter) util_blitter_destroy(svga->blitter); if (svga->swtnl.backend) svga->swtnl.backend->destroy( svga->swtnl.backend ); if (svga->swtnl.draw) draw_destroy( svga->swtnl.draw ); return FALSE; }
/** * Initialize the post-transform vertex buffer information for the given * context. */ void sp_init_vbuf(struct softpipe_context *sp) { assert(sp->draw); sp->vbuf_render = CALLOC_STRUCT(softpipe_vbuf_render); sp->vbuf_render->base.max_indices = SP_MAX_VBUF_INDEXES; sp->vbuf_render->base.max_vertex_buffer_bytes = SP_MAX_VBUF_SIZE; sp->vbuf_render->base.get_vertex_info = sp_vbuf_get_vertex_info; sp->vbuf_render->base.allocate_vertices = sp_vbuf_allocate_vertices; sp->vbuf_render->base.map_vertices = sp_vbuf_map_vertices; sp->vbuf_render->base.unmap_vertices = sp_vbuf_unmap_vertices; sp->vbuf_render->base.set_primitive = sp_vbuf_set_primitive; sp->vbuf_render->base.draw = sp_vbuf_draw; sp->vbuf_render->base.draw_arrays = sp_vbuf_draw_arrays; sp->vbuf_render->base.release_vertices = sp_vbuf_release_vertices; sp->vbuf_render->base.destroy = sp_vbuf_destroy; sp->vbuf_render->softpipe = sp; sp->vbuf = draw_vbuf_stage(sp->draw, &sp->vbuf_render->base); draw_set_rasterize_stage(sp->draw, sp->vbuf); draw_set_render(sp->draw, &sp->vbuf_render->base); }
void nv30_draw_init(struct pipe_context *pipe) { struct nv30_context *nv30 = nv30_context(pipe); struct vbuf_render *render; struct draw_context *draw; struct draw_stage *stage; draw = draw_create(pipe); if (!draw) return; render = nv30_render_create(nv30); if (!render) { draw_destroy(draw); return; } stage = draw_vbuf_stage(draw, render); if (!stage) { render->destroy(render); draw_destroy(draw); return; } draw_set_render(draw, render); draw_set_rasterize_stage(draw, stage); draw_wide_line_threshold(draw, 10000000.f); draw_wide_point_threshold(draw, 10000000.f); draw_wide_point_sprites(draw, TRUE); nv30->draw = draw; }
/** * Create a new primitive tiling engine. Plug it into the backend of * the draw module. Currently also creates a rasterizer to use with * it. */ struct lp_setup_context * lp_setup_create( struct pipe_context *pipe, struct draw_context *draw ) { struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen); struct lp_setup_context *setup; unsigned i; setup = CALLOC_STRUCT(lp_setup_context); if (!setup) { goto no_setup; } lp_setup_init_vbuf(setup); /* Used only in update_state(): */ setup->pipe = pipe; setup->num_threads = screen->num_threads; setup->vbuf = draw_vbuf_stage(draw, &setup->base); if (!setup->vbuf) { goto no_vbuf; } draw_set_rasterize_stage(draw, setup->vbuf); draw_set_render(draw, &setup->base); /* create some empty scenes */ for (i = 0; i < MAX_SCENES; i++) { setup->scenes[i] = lp_scene_create( pipe ); if (!setup->scenes[i]) { goto no_scenes; } } setup->triangle = first_triangle; setup->line = first_line; setup->point = first_point; setup->dirty = ~0; return setup; no_scenes: for (i = 0; i < MAX_SCENES; i++) { if (setup->scenes[i]) { lp_scene_destroy(setup->scenes[i]); } } setup->vbuf->destroy(setup->vbuf); no_vbuf: FREE(setup); no_setup: return NULL; }
boolean svga_init_swtnl( struct svga_context *svga ) { svga->swtnl.backend = svga_vbuf_render_create(svga); if(!svga->swtnl.backend) goto fail; /* * Create drawing context and plug our rendering stage into it. */ svga->swtnl.draw = draw_create(&svga->pipe); if (svga->swtnl.draw == NULL) goto fail; draw_set_rasterize_stage(svga->swtnl.draw, draw_vbuf_stage( svga->swtnl.draw, svga->swtnl.backend )); draw_set_render(svga->swtnl.draw, svga->swtnl.backend); svga->blitter = util_blitter_create(&svga->pipe); if (!svga->blitter) goto fail; /* must be done before installing Draw stages */ util_blitter_cache_all_shaders(svga->blitter); draw_install_aaline_stage(svga->swtnl.draw, &svga->pipe); draw_install_aapoint_stage(svga->swtnl.draw, &svga->pipe); draw_install_pstipple_stage(svga->swtnl.draw, &svga->pipe); if (debug_get_bool_option("SVGA_SWTNL_FSE", FALSE)) draw_set_driver_clipping(svga->swtnl.draw, TRUE, TRUE, TRUE); return TRUE; fail: if (svga->blitter) util_blitter_destroy(svga->blitter); if (svga->swtnl.backend) svga->swtnl.backend->destroy( svga->swtnl.backend ); if (svga->swtnl.draw) draw_destroy( svga->swtnl.draw ); return FALSE; }
/** * Create a new primitive vbuf/render stage. */ struct draw_stage *i915_draw_vbuf_stage(struct i915_context *i915) { struct vbuf_render *render; struct draw_stage *stage; render = i915_vbuf_render_create(i915); if(!render) return NULL; stage = draw_vbuf_stage(i915->draw, render); if(!stage) { render->destroy(render); return NULL; } /** TODO JB: this shouldn't be here */ draw_set_render(i915->draw, render); return stage; }
struct draw_stage* r300_draw_stage(struct r300_context* r300) { struct vbuf_render* render; struct draw_stage* stage; render = r300_render_create(r300); if (!render) { return NULL; } stage = draw_vbuf_stage(r300->draw, render); if (!stage) { render->destroy(render); return NULL; } draw_set_render(r300->draw, render); return stage; }
struct pipe_context * softpipe_create_context( struct pipe_screen *screen, void *priv ) { struct softpipe_screen *sp_screen = softpipe_screen(screen); struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context); uint i, sh; util_init_math(); softpipe->dump_fs = debug_get_bool_option( "SOFTPIPE_DUMP_FS", FALSE ); softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE ); softpipe->pipe.screen = screen; softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.priv = priv; /* state setters */ softpipe_init_blend_funcs(&softpipe->pipe); softpipe_init_clip_funcs(&softpipe->pipe); softpipe_init_query_funcs( softpipe ); softpipe_init_rasterizer_funcs(&softpipe->pipe); softpipe_init_sampler_funcs(&softpipe->pipe); softpipe_init_shader_funcs(&softpipe->pipe); softpipe_init_streamout_funcs(&softpipe->pipe); softpipe_init_texture_funcs( &softpipe->pipe ); softpipe_init_vertex_funcs(&softpipe->pipe); softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.draw_vbo = softpipe_draw_vbo; softpipe->pipe.clear = softpipe_clear; softpipe->pipe.flush = softpipe_flush_wrapped; softpipe->pipe.render_condition = softpipe_render_condition; softpipe->pipe.create_video_decoder = vl_create_decoder; softpipe->pipe.create_video_buffer = vl_video_buffer_create; /* * Alloc caches for accessing drawing surfaces and textures. * Must be before quad stage setup! */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) softpipe->cbuf_cache[i] = sp_create_tile_cache( &softpipe->pipe ); softpipe->zsbuf_cache = sp_create_tile_cache( &softpipe->pipe ); /* Allocate texture caches */ for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) { for (i = 0; i < Elements(softpipe->tex_cache[0]); i++) { softpipe->tex_cache[sh][i] = sp_create_tex_tile_cache(&softpipe->pipe); if (!softpipe->tex_cache[sh][i]) goto fail; } } softpipe->fs_machine = tgsi_exec_machine_create(); /* setup quad rendering stages */ softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe); softpipe->quad.blend = sp_quad_blend_stage(softpipe); softpipe->quad.pstipple = sp_quad_polygon_stipple_stage(softpipe); /* * Create drawing context and plug our rendering stage into it. */ if (sp_screen->use_llvm) softpipe->draw = draw_create(&softpipe->pipe); else softpipe->draw = draw_create_no_llvm(&softpipe->pipe); if (!softpipe->draw) goto fail; draw_texture_samplers(softpipe->draw, PIPE_SHADER_VERTEX, PIPE_MAX_SAMPLERS, (struct tgsi_sampler **) softpipe->tgsi.samplers_list[PIPE_SHADER_VERTEX]); draw_texture_samplers(softpipe->draw, PIPE_SHADER_GEOMETRY, PIPE_MAX_SAMPLERS, (struct tgsi_sampler **) softpipe->tgsi.samplers_list[PIPE_SHADER_GEOMETRY]); if (debug_get_bool_option( "SOFTPIPE_NO_RAST", FALSE )) softpipe->no_rast = TRUE; softpipe->vbuf_backend = sp_create_vbuf_backend(softpipe); if (!softpipe->vbuf_backend) goto fail; softpipe->vbuf = draw_vbuf_stage(softpipe->draw, softpipe->vbuf_backend); if (!softpipe->vbuf) goto fail; draw_set_rasterize_stage(softpipe->draw, softpipe->vbuf); draw_set_render(softpipe->draw, softpipe->vbuf_backend); /* plug in AA line/point stages */ draw_install_aaline_stage(softpipe->draw, &softpipe->pipe); draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe); /* Do polygon stipple w/ texture map + frag prog? */ #if DO_PSTIPPLE_IN_DRAW_MODULE draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe); #endif draw_wide_point_sprites(softpipe->draw, TRUE); sp_init_surface_functions(softpipe); #if DO_PSTIPPLE_IN_HELPER_MODULE /* create the polgon stipple sampler */ softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe); #endif return &softpipe->pipe; fail: softpipe_destroy(&softpipe->pipe); return NULL; }
struct pipe_context * softpipe_create_context( struct pipe_screen *screen, void *priv ) { struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context); uint i; util_init_math(); #ifdef PIPE_ARCH_X86 softpipe->use_sse = !debug_get_bool_option( "GALLIUM_NOSSE", FALSE ); #else softpipe->use_sse = FALSE; #endif softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE ); softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE ); softpipe->pipe.winsys = screen->winsys; softpipe->pipe.screen = screen; softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.priv = priv; /* state setters */ softpipe->pipe.create_blend_state = softpipe_create_blend_state; softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; softpipe->pipe.create_sampler_state = softpipe_create_sampler_state; softpipe->pipe.bind_fragment_sampler_states = softpipe_bind_sampler_states; softpipe->pipe.bind_vertex_sampler_states = softpipe_bind_vertex_sampler_states; softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state; softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state; softpipe->pipe.bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state; softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state; softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; softpipe->pipe.create_fs_state = softpipe_create_fs_state; softpipe->pipe.bind_fs_state = softpipe_bind_fs_state; softpipe->pipe.delete_fs_state = softpipe_delete_fs_state; softpipe->pipe.create_vs_state = softpipe_create_vs_state; softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; softpipe->pipe.delete_vs_state = softpipe_delete_vs_state; softpipe->pipe.create_gs_state = softpipe_create_gs_state; softpipe->pipe.bind_gs_state = softpipe_bind_gs_state; softpipe->pipe.delete_gs_state = softpipe_delete_gs_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; softpipe->pipe.set_fragment_sampler_textures = softpipe_set_sampler_textures; softpipe->pipe.set_vertex_sampler_textures = softpipe_set_vertex_sampler_textures; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers; softpipe->pipe.set_vertex_elements = softpipe_set_vertex_elements; softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; softpipe->pipe.draw_range_elements = softpipe_draw_range_elements; softpipe->pipe.draw_arrays_instanced = softpipe_draw_arrays_instanced; softpipe->pipe.draw_elements_instanced = softpipe_draw_elements_instanced; softpipe->pipe.clear = softpipe_clear; softpipe->pipe.flush = softpipe_flush; softpipe->pipe.is_texture_referenced = softpipe_is_texture_referenced; softpipe->pipe.is_buffer_referenced = softpipe_is_buffer_referenced; softpipe_init_query_funcs( softpipe ); softpipe->pipe.render_condition = softpipe_render_condition; /* * Alloc caches for accessing drawing surfaces and textures. * Must be before quad stage setup! */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) softpipe->cbuf_cache[i] = sp_create_tile_cache( screen ); softpipe->zsbuf_cache = sp_create_tile_cache( screen ); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) softpipe->tex_cache[i] = sp_create_tex_tile_cache( screen ); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache(screen); } /* setup quad rendering stages */ softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe); softpipe->quad.blend = sp_quad_blend_stage(softpipe); /* * Create drawing context and plug our rendering stage into it. */ softpipe->draw = draw_create(&softpipe->pipe); if (!softpipe->draw) goto fail; draw_texture_samplers(softpipe->draw, PIPE_MAX_VERTEX_SAMPLERS, (struct tgsi_sampler **) softpipe->tgsi.vert_samplers_list); if (debug_get_bool_option( "SP_NO_RAST", FALSE )) softpipe->no_rast = TRUE; softpipe->vbuf_backend = sp_create_vbuf_backend(softpipe); if (!softpipe->vbuf_backend) goto fail; softpipe->vbuf = draw_vbuf_stage(softpipe->draw, softpipe->vbuf_backend); if (!softpipe->vbuf) goto fail; draw_set_rasterize_stage(softpipe->draw, softpipe->vbuf); draw_set_render(softpipe->draw, softpipe->vbuf_backend); /* plug in AA line/point stages */ draw_install_aaline_stage(softpipe->draw, &softpipe->pipe); draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe); /* Do polygon stipple w/ texture map + frag prog? */ draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe); sp_init_surface_functions(softpipe); return &softpipe->pipe; fail: softpipe_destroy(&softpipe->pipe); return NULL; }