static void svga_set_polygon_stipple(struct pipe_context *pipe, const struct pipe_poly_stipple *stipple) { struct svga_context *svga = svga_context(pipe); /* release old texture */ pipe_resource_reference(&svga->polygon_stipple.texture, NULL); /* release old sampler view */ if (svga->polygon_stipple.sampler_view) { pipe->sampler_view_destroy(pipe, &svga->polygon_stipple.sampler_view->base); } /* create new stipple texture */ svga->polygon_stipple.texture = util_pstipple_create_stipple_texture(pipe, stipple->stipple); /* create new sampler view */ svga->polygon_stipple.sampler_view = (struct svga_pipe_sampler_view *) util_pstipple_create_sampler_view(pipe, svga->polygon_stipple.texture); /* allocate sampler state, if first time */ if (!svga->polygon_stipple.sampler) { svga->polygon_stipple.sampler = util_pstipple_create_sampler(pipe); } svga->dirty |= SVGA_NEW_STIPPLE; }
/** * Called by drivers that want to install this polygon stipple stage * into the draw module's pipeline. This will not be used if the * hardware has native support for polygon stipple. */ boolean draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe) { struct pstip_stage *pstip; pipe->draw = (void *) draw; /* * Create / install pgon stipple drawing / prim stage */ pstip = draw_pstip_stage( draw, pipe ); if (!pstip) goto fail; draw->pipeline.pstipple = &pstip->stage; /* save original driver functions */ pstip->driver_create_fs_state = pipe->create_fs_state; pstip->driver_bind_fs_state = pipe->bind_fs_state; pstip->driver_delete_fs_state = pipe->delete_fs_state; pstip->driver_bind_sampler_states = pipe->bind_sampler_states; pstip->driver_set_sampler_views = pipe->set_sampler_views; pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple; /* create special texture, sampler state */ pstip->texture = util_pstipple_create_stipple_texture(pipe, NULL); if (!pstip->texture) goto fail; pstip->sampler_view = util_pstipple_create_sampler_view(pipe, pstip->texture); if (!pstip->sampler_view) goto fail; pstip->sampler_cso = util_pstipple_create_sampler(pipe); if (!pstip->sampler_cso) goto fail; /* override the driver's functions */ pipe->create_fs_state = pstip_create_fs_state; pipe->bind_fs_state = pstip_bind_fs_state; pipe->delete_fs_state = pstip_delete_fs_state; pipe->bind_sampler_states = pstip_bind_sampler_states; pipe->set_sampler_views = pstip_set_sampler_views; pipe->set_polygon_stipple = pstip_set_polygon_stipple; return TRUE; fail: if (pstip) pstip->stage.destroy( &pstip->stage ); return FALSE; }
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; }