Lines Matching refs:ctx
38 xa_context_flush(struct xa_context *ctx)
40 if (ctx->last_fence) {
41 struct pipe_screen *screen = ctx->xa->screen;
42 screen->fence_reference(screen, &ctx->last_fence, NULL);
44 ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0);
56 struct xa_context *ctx = calloc(1, sizeof(*ctx));
58 ctx->xa = xa;
59 ctx->pipe = xa->screen->context_create(xa->screen, NULL, 0);
60 ctx->cso = cso_create_context(ctx->pipe, 0);
61 ctx->shaders = xa_shaders_create(ctx);
62 renderer_init_state(ctx);
64 return ctx;
98 xa_surface_dma(struct xa_context *ctx,
108 struct pipe_context *pipe = ctx->pipe;
137 xa_surface_map(struct xa_context *ctx,
142 struct pipe_context *pipe = ctx->pipe;
189 xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst)
191 struct pipe_screen *screen = ctx->pipe->screen;
197 if (ctx->srf) {
198 if (ctx->srf->texture == dst->tex)
201 pipe_surface_reference(&ctx->srf, NULL);
210 ctx->srf = ctx->pipe->create_surface(ctx->pipe, dst->tex, &srf_templ);
211 if (!ctx->srf)
218 xa_ctx_srf_destroy(struct xa_context *ctx)
227 xa_copy_prepare(struct xa_context *ctx,
234 int ret = xa_ctx_srf_create(ctx, dst);
237 renderer_copy_prepare(ctx, ctx->srf, src->tex,
240 ctx->simple_copy = 0;
242 ctx->simple_copy = 1;
244 ctx->src = src;
245 ctx->dst = dst;
246 xa_ctx_srf_destroy(ctx);
252 xa_copy(struct xa_context *ctx,
257 xa_scissor_update(ctx, dx, dy, dx + width, dy + height);
259 if (ctx->simple_copy) {
261 ctx->pipe->resource_copy_region(ctx->pipe,
262 ctx->dst->tex, 0, dx, dy, 0,
263 ctx->src->tex,
266 renderer_copy(ctx, dx, dy, sx, sy, width, height,
267 (float) ctx->src->tex->width0,
268 (float) ctx->src->tex->height0);
272 xa_copy_done(struct xa_context *ctx)
274 if (!ctx->simple_copy) {
275 renderer_draw_flush(ctx);
280 bind_solid_blend_state(struct xa_context *ctx)
293 cso_set_blend(ctx->cso, &blend);
297 xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
304 ret = xa_ctx_srf_create(ctx, dst);
308 if (ctx->srf->format == PIPE_FORMAT_L8_UNORM)
309 xa_pixel_to_float4_a8(fg, ctx->solid_color);
311 xa_pixel_to_float4(fg, ctx->solid_color);
312 ctx->has_solid_src = 1;
314 ctx->dst = dst;
327 renderer_bind_destination(ctx, ctx->srf);
328 bind_solid_blend_state(ctx);
329 cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, 0, NULL);
330 ctx->pipe->set_sampler_views(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, 0,
333 shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits);
334 cso_set_vertex_shader_handle(ctx->cso, shader.vs);
335 cso_set_fragment_shader_handle(ctx->cso, shader.fs);
337 renderer_begin_solid(ctx);
339 xa_ctx_srf_destroy(ctx);
344 xa_solid(struct xa_context *ctx, int x, int y, int width, int height)
346 xa_scissor_update(ctx, x, y, x + width, y + height);
347 renderer_solid(ctx, x, y, x + width, y + height);
351 xa_solid_done(struct xa_context *ctx)
353 renderer_draw_flush(ctx);
354 ctx->comp = NULL;
355 ctx->has_solid_src = FALSE;
356 ctx->num_bound_samplers = 0;
360 xa_fence_get(struct xa_context *ctx)
363 struct pipe_screen *screen = ctx->xa->screen;
368 fence->xa = ctx->xa;
370 if (ctx->last_fence == NULL)
373 screen->fence_reference(screen, &fence->pipe_fence, ctx->last_fence);
413 xa_ctx_sampler_views_destroy(struct xa_context *ctx)
417 for (i = 0; i < ctx->num_bound_samplers; ++i)
418 pipe_sampler_view_reference(&ctx->bound_sampler_views[i], NULL);
419 ctx->num_bound_samplers = 0;