static void * svga_create_fs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { struct svga_context *svga = svga_context(pipe); struct svga_fragment_shader *fs; fs = CALLOC_STRUCT(svga_fragment_shader); if (!fs) return NULL; fs->base.tokens = tgsi_dup_tokens(templ->tokens); /* Collect basic info that we'll need later: */ tgsi_scan_shader(fs->base.tokens, &fs->base.info); fs->base.id = svga->debug.shader_id++; fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.info); svga_remap_generics(fs->generic_inputs, fs->generic_remap_table); fs->draw_shader = draw_create_fragment_shader(svga->swtnl.draw, templ); if (SVGA_DEBUG & DEBUG_TGSI || 0) { debug_printf("%s id: %u, inputs: %u, outputs: %u\n", __FUNCTION__, fs->base.id, fs->base.info.num_inputs, fs->base.info.num_outputs); } return fs; }
/** * Create a new fragment shader variant. */ static struct sp_fragment_shader_variant * create_fs_variant(struct softpipe_context *softpipe, struct sp_fragment_shader *fs, const struct sp_fragment_shader_variant_key *key) { struct sp_fragment_shader_variant *var; struct pipe_shader_state *curfs = &fs->shader; /* codegen, create variant object */ var = softpipe_create_fs_variant_exec(softpipe); if (var) { var->key = *key; #if DO_PSTIPPLE_IN_HELPER_MODULE if (key->polygon_stipple) { /* get new shader that implements polygon stippling */ var->tokens = util_pstipple_create_fragment_shader(curfs->tokens, &var->stipple_sampler_unit, 0, TGSI_FILE_INPUT); } else #endif { var->tokens = tgsi_dup_tokens(curfs->tokens); var->stipple_sampler_unit = 0; } tgsi_scan_shader(var->tokens, &var->info); /* See comments elsewhere about draw fragment shaders */ #if 0 /* draw's fs state */ var->draw_shader = draw_create_fragment_shader(softpipe->draw, &fs->shader); if (!var->draw_shader) { var->delete(var); FREE((void *) var->tokens); return NULL; } #endif /* insert variant into linked list */ var->next = fs->variants; fs->variants = var; }
static void * i915_create_fs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { struct i915_context *i915 = i915_context(pipe); struct i915_fragment_shader *ifs = CALLOC_STRUCT(i915_fragment_shader); if (!ifs) return NULL; ifs->draw_data = draw_create_fragment_shader(i915->draw, templ); ifs->state.tokens = tgsi_dup_tokens(templ->tokens); tgsi_scan_shader(templ->tokens, &ifs->info); /* The shader's compiled to i915 instructions here */ i915_translate_fragment_program(i915, ifs); return ifs; }
void nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) { struct nv30_context *nv30 = nv30_context(pipe); struct draw_context *draw = nv30->draw; struct pipe_transfer *transfer[PIPE_MAX_ATTRIBS] = {NULL}; struct pipe_transfer *transferi = NULL; int i; nv30_render_validate(nv30); if (nv30->draw_dirty & NV30_NEW_VIEWPORT) draw_set_viewport_states(draw, 0, 1, &nv30->viewport); if (nv30->draw_dirty & NV30_NEW_RASTERIZER) draw_set_rasterizer_state(draw, &nv30->rast->pipe, NULL); if (nv30->draw_dirty & NV30_NEW_CLIP) draw_set_clip_state(draw, &nv30->clip); if (nv30->draw_dirty & NV30_NEW_ARRAYS) { draw_set_vertex_buffers(draw, 0, nv30->num_vtxbufs, nv30->vtxbuf); draw_set_vertex_elements(draw, nv30->vertex->num_elements, nv30->vertex->pipe); } if (nv30->draw_dirty & NV30_NEW_FRAGPROG) { struct nv30_fragprog *fp = nv30->fragprog.program; if (!fp->draw) fp->draw = draw_create_fragment_shader(draw, &fp->pipe); draw_bind_fragment_shader(draw, fp->draw); } if (nv30->draw_dirty & NV30_NEW_VERTPROG) { struct nv30_vertprog *vp = nv30->vertprog.program; if (!vp->draw) vp->draw = draw_create_vertex_shader(draw, &vp->pipe); draw_bind_vertex_shader(draw, vp->draw); } if (nv30->draw_dirty & NV30_NEW_VERTCONST) { if (nv30->vertprog.constbuf) { void *map = nv04_resource(nv30->vertprog.constbuf)->data; draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, map, nv30->vertprog.constbuf_nr * 16); } else { draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, NULL, 0); } } for (i = 0; i < nv30->num_vtxbufs; i++) { const void *map = nv30->vtxbuf[i].user_buffer; if (!map) { if (nv30->vtxbuf[i].buffer) map = pipe_buffer_map(pipe, nv30->vtxbuf[i].buffer, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transfer[i]); } draw_set_mapped_vertex_buffer(draw, i, map, ~0); } if (info->indexed) { const void *map = nv30->idxbuf.user_buffer; if (!map) map = pipe_buffer_map(pipe, nv30->idxbuf.buffer, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transferi); draw_set_indexes(draw, (ubyte *) map + nv30->idxbuf.offset, nv30->idxbuf.index_size, ~0); } else { draw_set_indexes(draw, NULL, 0, 0); } draw_vbo(draw, info); draw_flush(draw); if (info->indexed && transferi) pipe_buffer_unmap(pipe, transferi); for (i = 0; i < nv30->num_vtxbufs; i++) if (transfer[i]) pipe_buffer_unmap(pipe, transfer[i]); nv30->draw_dirty = 0; nv30_state_release(nv30); }