struct vg_context * vg_create_context(struct pipe_context *pipe, const void *visual, struct vg_context *share) { struct vg_context *ctx; ctx = CALLOC_STRUCT(vg_context); ctx->pipe = pipe; if (!choose_depth_stencil_format(ctx)) { FREE(ctx); return NULL; } ctx->dispatch = api_create_dispatch(); vg_init_state(&ctx->state.vg); ctx->state.dirty = ALL_DIRTY; ctx->cso_context = cso_create_context(pipe); ctx->default_paint = paint_create(ctx); ctx->state.vg.stroke_paint = ctx->default_paint; ctx->state.vg.fill_paint = ctx->default_paint; ctx->mask.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->mask.sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->mask.sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->mask.sampler.normalized_coords = 0; ctx->blend_sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->blend_sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.normalized_coords = 0; vg_set_error(ctx, VG_NO_ERROR); ctx->owned_objects[VG_OBJECT_PAINT] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_IMAGE] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_MASK] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_FONT] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_PATH] = cso_hash_create(); ctx->renderer = renderer_create(ctx); ctx->sc = shaders_cache_create(ctx); ctx->shader = shader_create(ctx); ctx->blit = util_create_blit(ctx->pipe, ctx->cso_context); return ctx; }
void st_init_blit(struct st_context *st) { st->blit = util_create_blit(st->pipe, st->cso_context); }
/** Initialize the post-processing queue. */ struct pp_queue_t * pp_init(struct pipe_context *pipe, const unsigned int *enabled, struct cso_context *cso) { unsigned int curpos = 0, i, tmp_req = 0; struct pp_queue_t *ppq; pp_func *tmp_q; pp_debug("Initializing the post-processing queue.\n"); /* How many filters were requested? */ for (i = 0; i < PP_FILTERS; i++) { if (enabled[i]) curpos++; } if (!curpos) return NULL; ppq = CALLOC(1, sizeof(struct pp_queue_t)); tmp_q = CALLOC(curpos, sizeof(pp_func)); ppq->shaders = CALLOC(curpos, sizeof(void *)); ppq->verts = CALLOC(curpos, sizeof(unsigned int)); if (!tmp_q || !ppq || !ppq->shaders || !ppq->verts) goto error; ppq->p = pp_init_prog(ppq, pipe, cso); if (!ppq->p) goto error; /* Add the enabled filters to the queue, in order */ curpos = 0; ppq->pp_queue = tmp_q; for (i = 0; i < PP_FILTERS; i++) { if (enabled[i]) { ppq->pp_queue[curpos] = pp_filters[i].main; tmp_req = MAX2(tmp_req, pp_filters[i].inner_tmps); if (pp_filters[i].shaders) { ppq->shaders[curpos] = CALLOC(pp_filters[i].shaders + 1, sizeof(void *)); ppq->verts[curpos] = pp_filters[i].verts; if (!ppq->shaders[curpos]) goto error; } pp_filters[i].init(ppq, curpos, enabled[i]); curpos++; } } ppq->p->blitctx = util_create_blit(ppq->p->pipe, cso); if (!ppq->p->blitctx) goto error; ppq->n_filters = curpos; ppq->n_tmp = (curpos > 2 ? 2 : 1); ppq->n_inner_tmp = tmp_req; ppq->fbos_init = false; for (i = 0; i < curpos; i++) ppq->shaders[i][0] = ppq->p->passvs; pp_debug("Queue successfully allocated. %u filter(s).\n", curpos); return ppq; error: pp_debug("Error setting up pp\n"); if (ppq) FREE(ppq->p); FREE(ppq); FREE(tmp_q); return NULL; }
struct vg_context * vg_create_context(struct pipe_context *pipe, const void *visual, struct vg_context *share) { struct vg_context *ctx; unsigned i; ctx = CALLOC_STRUCT(vg_context); ctx->pipe = pipe; if (!choose_depth_stencil_format(ctx)) { FREE(ctx); return NULL; } ctx->dispatch = api_create_dispatch(); vg_init_state(&ctx->state.vg); ctx->state.dirty = ALL_DIRTY; ctx->cso_context = cso_create_context(pipe); init_clear(ctx); ctx->default_paint = paint_create(ctx); ctx->state.vg.stroke_paint = ctx->default_paint; ctx->state.vg.fill_paint = ctx->default_paint; ctx->mask.sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->mask.sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->mask.sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->mask.sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->mask.sampler.normalized_coords = 0; ctx->blend_sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; ctx->blend_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; ctx->blend_sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.normalized_coords = 0; for (i = 0; i < 2; i++) { ctx->velems[i].src_offset = i * 4 * sizeof(float); ctx->velems[i].instance_divisor = 0; ctx->velems[i].vertex_buffer_index = 0; ctx->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; } vg_set_error(ctx, VG_NO_ERROR); ctx->owned_objects[VG_OBJECT_PAINT] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_IMAGE] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_MASK] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_FONT] = cso_hash_create(); ctx->owned_objects[VG_OBJECT_PATH] = cso_hash_create(); ctx->renderer = renderer_create(ctx); ctx->sc = shaders_cache_create(ctx); ctx->shader = shader_create(ctx); ctx->blit = util_create_blit(ctx->pipe, ctx->cso_context); return ctx; }