diff options
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/xa/xa_composite.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/xa/xa_context.c | 50 | ||||
-rw-r--r-- | src/gallium/state_trackers/xa/xa_priv.h | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/xa/xa_tracker.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/xa/xa_yuv.c | 43 |
5 files changed, 65 insertions, 63 deletions
diff --git a/src/gallium/state_trackers/xa/xa_composite.c b/src/gallium/state_trackers/xa/xa_composite.c index 347fe0cd379..1a35d0996bd 100644 --- a/src/gallium/state_trackers/xa/xa_composite.c +++ b/src/gallium/state_trackers/xa/xa_composite.c @@ -365,7 +365,7 @@ bind_shaders(struct xa_context *ctx, const struct xa_composite *comp) fs_traits |= picture_format_fixups(mask_pic, 1); } - if (ctx->dst->srf->format == PIPE_FORMAT_L8_UNORM) + if (ctx->srf->format == PIPE_FORMAT_L8_UNORM) fs_traits |= FS_DST_LUMINANCE; shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits); @@ -455,14 +455,13 @@ xa_composite_prepare(struct xa_context *ctx, struct xa_surface *dst_srf = comp->dst->srf; int ret; - ret = xa_surface_psurf_create(ctx, dst_srf); + ret = xa_ctx_srf_create(ctx, dst_srf); if (ret != XA_ERR_NONE) return ret; ctx->dst = dst_srf; - renderer_bind_destination(ctx, dst_srf->srf, - dst_srf->srf->width, - dst_srf->srf->height); + renderer_bind_destination(ctx, ctx->srf, ctx->srf->width, + ctx->srf->height); ret = bind_composite_blend_state(ctx, comp); if (ret != XA_ERR_NONE) @@ -479,7 +478,7 @@ xa_composite_prepare(struct xa_context *ctx, ctx->comp = comp; } - xa_surface_psurf_destroy(dst_srf); + xa_ctx_srf_destroy(ctx); return XA_ERR_NONE; } @@ -514,7 +513,7 @@ xa_composite_done(struct xa_context *ctx) ctx->comp = NULL; ctx->has_solid_color = FALSE; - ctx->num_bound_samplers = 0; + xa_ctx_sampler_views_destroy(ctx); } static const struct xa_composite_allocation a = { diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c index 118a390a14a..1e7a20ad485 100644 --- a/src/gallium/state_trackers/xa/xa_context.c +++ b/src/gallium/state_trackers/xa/xa_context.c @@ -72,6 +72,8 @@ xa_context_destroy(struct xa_context *r) r->shaders = NULL; } + xa_ctx_sampler_views_destroy(r); + if (r->cso) { cso_release_all(r->cso); cso_destroy_context(r->cso); @@ -136,6 +138,9 @@ xa_surface_map(struct xa_context *ctx, unsigned int transfer_direction = 0; struct pipe_context *pipe = ctx->pipe; + /* + * A surface may only have a single map. + */ if (srf->transfer) return NULL; @@ -174,12 +179,12 @@ xa_surface_unmap(struct xa_surface *srf) } int -xa_surface_psurf_create(struct xa_context *ctx, struct xa_surface *dst) +xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst) { struct pipe_screen *screen = ctx->pipe->screen; struct pipe_surface srf_templ; - if (dst->srf) + if (ctx->srf) return -XA_ERR_INVAL; if (!screen->is_format_supported(screen, dst->tex->format, @@ -189,37 +194,38 @@ xa_surface_psurf_create(struct xa_context *ctx, struct xa_surface *dst) u_surface_default_template(&srf_templ, dst->tex, PIPE_BIND_RENDER_TARGET); - dst->srf = ctx->pipe->create_surface(ctx->pipe, dst->tex, &srf_templ); - if (!dst->srf) + ctx->srf = ctx->pipe->create_surface(ctx->pipe, dst->tex, &srf_templ); + if (!ctx->srf) return -XA_ERR_NORES; return XA_ERR_NONE; } void -xa_surface_psurf_destroy(struct xa_surface *dst) +xa_ctx_srf_destroy(struct xa_context *ctx) { - pipe_surface_reference(&dst->srf, NULL); + pipe_surface_reference(&ctx->srf, NULL); } int xa_copy_prepare(struct xa_context *ctx, struct xa_surface *dst, struct xa_surface *src) { - if (src == dst || dst->srf != NULL) + if (src == dst || ctx->srf != NULL) return -XA_ERR_INVAL; if (src->tex->format != dst->tex->format) { - int ret = xa_surface_psurf_create(ctx, dst); + int ret = xa_ctx_srf_create(ctx, dst); if (ret != XA_ERR_NONE) return ret; - renderer_copy_prepare(ctx, dst->srf, src->tex); + renderer_copy_prepare(ctx, ctx->srf, src->tex); ctx->simple_copy = 0; } else ctx->simple_copy = 1; ctx->src = src; ctx->dst = dst; + xa_ctx_srf_destroy(ctx); return 0; } @@ -238,7 +244,8 @@ xa_copy(struct xa_context *ctx, 0, &src_box); } else renderer_copy(ctx, dx, dy, sx, sy, width, height, - (float) width, (float) height); + (float) ctx->src->tex->width0, + (float) ctx->src->tex->height0); } void @@ -247,7 +254,6 @@ xa_copy_done(struct xa_context *ctx) if (!ctx->simple_copy) { renderer_draw_flush(ctx); ctx->pipe->flush(ctx->pipe, &ctx->last_fence); - xa_surface_psurf_destroy(ctx->dst); } else ctx->pipe->flush(ctx->pipe, &ctx->last_fence); } @@ -278,19 +284,19 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst, int width, height; int ret; - ret = xa_surface_psurf_create(ctx, dst); + ret = xa_ctx_srf_create(ctx, dst); if (ret != XA_ERR_NONE) return ret; - if (dst->srf->format == PIPE_FORMAT_L8_UNORM) + if (ctx->srf->format == PIPE_FORMAT_L8_UNORM) xa_pixel_to_float4_a8(fg, ctx->solid_color); else xa_pixel_to_float4(fg, ctx->solid_color); ctx->has_solid_color = 1; ctx->dst = dst; - width = dst->srf->width; - height = dst->srf->height; + width = ctx->srf->width; + height = ctx->srf->height; #if 0 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", @@ -303,7 +309,7 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst, vs_traits = VS_SOLID_FILL; fs_traits = FS_SOLID_FILL; - renderer_bind_destination(ctx, dst->srf, width, height); + renderer_bind_destination(ctx, ctx->srf, width, height); bind_solid_blend_state(ctx); cso_set_samplers(ctx->cso, 0, NULL); cso_set_fragment_sampler_views(ctx->cso, 0, NULL); @@ -314,7 +320,7 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst, renderer_begin_solid(ctx); - xa_surface_psurf_destroy(dst); + xa_ctx_srf_destroy(ctx); return XA_ERR_NONE; } @@ -387,3 +393,13 @@ xa_fence_destroy(struct xa_fence *fence) free(fence); } + +void +xa_ctx_sampler_views_destroy(struct xa_context *ctx) +{ + int i; + + for (i = 0; i < ctx->num_bound_samplers; ++i) + pipe_sampler_view_reference(&ctx->bound_sampler_views[i], NULL); + ctx->num_bound_samplers = 0; +} diff --git a/src/gallium/state_trackers/xa/xa_priv.h b/src/gallium/state_trackers/xa/xa_priv.h index e8f67a12276..a281c907f88 100644 --- a/src/gallium/state_trackers/xa/xa_priv.h +++ b/src/gallium/state_trackers/xa/xa_priv.h @@ -56,11 +56,9 @@ struct xa_surface { struct pipe_resource template; struct xa_tracker *xa; struct pipe_resource *tex; - struct pipe_surface *srf; - struct pipe_sampler_view *view; + struct pipe_transfer *transfer; unsigned int flags; struct xa_format_descriptor fdesc; - struct pipe_transfer *transfer; struct pipe_context *mapping_pipe; }; @@ -97,6 +95,8 @@ struct xa_context { struct pipe_fence_handle *last_fence; struct xa_surface *src; struct xa_surface *dst; + struct pipe_surface *srf; + int simple_copy; int has_solid_color; @@ -200,10 +200,13 @@ struct xa_shader xa_shaders_get(struct xa_shaders *shaders, * xa_context.c */ extern int -xa_surface_psurf_create(struct xa_context *ctx, struct xa_surface *dst); +xa_ctx_srf_create(struct xa_context *ctx, struct xa_surface *dst); + +extern void +xa_ctx_srf_destroy(struct xa_context *ctx); extern void -xa_surface_psurf_destroy(struct xa_surface *dst); +xa_ctx_sampler_views_destroy(struct xa_context *ctx); /* * xa_renderer.c diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c index 50922d38378..01879ff6da0 100644 --- a/src/gallium/state_trackers/xa/xa_tracker.c +++ b/src/gallium/state_trackers/xa/xa_tracker.c @@ -314,7 +314,6 @@ xa_surface_create(struct xa_tracker *xa, if (!srf->tex) goto out_no_tex; - srf->srf = NULL; srf->xa = xa; srf->flags = flags; srf->fdesc = fdesc; @@ -341,8 +340,10 @@ xa_surface_redefine(struct xa_surface *srf, struct xa_tracker *xa = srf->xa; int save_width; int save_height; + unsigned int save_format; struct xa_format_descriptor fdesc; + if (xa_format == xa_format_unknown) fdesc = xa_get_format_stype_depth(xa, stype, depth); else @@ -373,19 +374,20 @@ xa_surface_redefine(struct xa_surface *srf, save_width = template->width0; save_height = template->height0; + save_format = template->format; template->width0 = width; template->height0 = height; + template->format = fdesc.format; texture = xa->screen->resource_create(xa->screen, template); if (!texture) { template->width0 = save_width; template->height0 = save_height; + template->format = save_format; return -XA_ERR_NORES; } - pipe_surface_reference(&srf->srf, NULL); - if (copy_contents) { struct pipe_context *pipe = xa->default_ctx->pipe; @@ -407,7 +409,6 @@ xa_surface_redefine(struct xa_surface *srf, void xa_surface_destroy(struct xa_surface *srf) { - pipe_surface_reference(&srf->srf, NULL); pipe_resource_reference(&srf->tex, NULL); free(srf); } diff --git a/src/gallium/state_trackers/xa/xa_yuv.c b/src/gallium/state_trackers/xa/xa_yuv.c index 66cbc5393b5..a5a4010e524 100644 --- a/src/gallium/state_trackers/xa/xa_yuv.c +++ b/src/gallium/state_trackers/xa/xa_yuv.c @@ -71,7 +71,6 @@ xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[]) { struct pipe_sampler_state *samplers[3]; struct pipe_sampler_state sampler; - struct pipe_sampler_view *views[3]; struct pipe_sampler_view view_templ; unsigned int i; @@ -86,19 +85,15 @@ xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[]) for (i = 0; i < 3; ++i) { samplers[i] = &sampler; - if (!yuv[i]->view) { - u_sampler_view_default_template(&view_templ, - yuv[i]->tex, yuv[i]->tex->format); - - yuv[i]->view = r->pipe->create_sampler_view(r->pipe, - yuv[i]->tex, - &view_templ); - } - views[i] = yuv[i]->view; - } + u_sampler_view_default_template(&view_templ, yuv[i]->tex, + yuv[i]->tex->format); + r->bound_sampler_views[i] = + r->pipe->create_sampler_view(r->pipe, yuv[i]->tex, &view_templ); + } + r->num_bound_samplers = 3; cso_set_samplers(r->cso, 3, (const struct pipe_sampler_state **)samplers); - cso_set_fragment_sampler_views(r->cso, 3, views); + cso_set_fragment_sampler_views(r->cso, 3, r->bound_sampler_views); } static void @@ -110,16 +105,6 @@ xa_yuv_fs_constants(struct xa_context *r, const float conversion_matrix[]) conversion_matrix, param_bytes); } -static void -xa_yuv_destroy_sampler_views(struct xa_surface *yuv[]) -{ - unsigned int i; - - for (i = 0; i < 3; ++i) { - pipe_sampler_view_reference(&yuv[i]->view, NULL); - } -} - extern int xa_yuv_planar_blit(struct xa_context *r, int src_x, @@ -137,18 +122,16 @@ xa_yuv_planar_blit(struct xa_context *r, { float scale_x; float scale_y; - struct pipe_surface srf_templ; + int ret; if (dst_w == 0 || dst_h == 0) return XA_ERR_NONE; - memset(&srf_templ, 0, sizeof(srf_templ)); - u_surface_default_template(&srf_templ, dst->tex, PIPE_BIND_RENDER_TARGET); - dst->srf = r->pipe->create_surface(r->pipe, dst->tex, &srf_templ); - if (!dst->srf) + ret = xa_ctx_srf_create(r, dst); + if (ret != XA_ERR_NONE) return -XA_ERR_NORES; - renderer_bind_destination(r, dst->srf, dst->srf->width, dst->srf->height); + renderer_bind_destination(r, r->srf, r->srf->width, r->srf->height); xa_yuv_bind_blend_state(r); xa_yuv_bind_shaders(r); xa_yuv_bind_samplers(r, yuv); @@ -172,8 +155,8 @@ xa_yuv_planar_blit(struct xa_context *r, r->pipe->flush(r->pipe, &r->last_fence); - xa_yuv_destroy_sampler_views(yuv); - pipe_surface_reference(&dst->srf, NULL); + xa_ctx_sampler_views_destroy(r); + xa_ctx_srf_destroy(r); return XA_ERR_NONE; } |