diff options
author | Chia-I Wu <[email protected]> | 2010-12-01 17:38:57 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-12-01 17:46:34 +0800 |
commit | 04f342b4170366e417aa0c414cc536337270d3ab (patch) | |
tree | a74be041b3e62d44211b146181f3b4d1fc8a7d97 /src | |
parent | f8e0dd246b26281d31d4f37799985e27368ba2f4 (diff) |
st/vega: Delay blend texture creation until needed.
It is used for more advanced blending or mask update. It might not be
ever needed for some applications.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/vega/mask.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shader.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.c | 76 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.h | 4 |
4 files changed, 32 insertions, 57 deletions
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index e3aec980b53..0a800b2c10a 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -316,9 +316,8 @@ static void mask_using_texture(struct pipe_sampler_view *sampler_view, views[0] = sampler_view; /* prepare our blend surface */ - vg_prepare_blend_surface_from_mask(ctx); samplers[1] = &ctx->mask.sampler; - views[1] = ctx->draw_buffer->blend_texture_view; + views[1] = vg_prepare_blend_surface_from_mask(ctx); fs = setup_mask_operation(operation); diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c index 483ff15098f..3d397f9ed4c 100644 --- a/src/gallium/state_trackers/vega/shader.c +++ b/src/gallium/state_trackers/vega/shader.c @@ -137,12 +137,8 @@ static VGint blend_bind_samplers(struct vg_context *ctx, bmode == VG_BLEND_SCREEN || bmode == VG_BLEND_DARKEN || bmode == VG_BLEND_LIGHTEN) { - struct st_framebuffer *stfb = ctx->draw_buffer; - - vg_prepare_blend_surface(ctx); - samplers[2] = &ctx->blend_sampler; - sampler_views[2] = stfb->blend_texture_view; + sampler_views[2] = vg_prepare_blend_surface(ctx); if (!samplers[0] || !sampler_views[0]) { samplers[0] = samplers[2]; diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 6ca80e70653..b7d59a559a2 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -406,7 +406,6 @@ void vg_validate_state(struct vg_context *ctx) /* TODO create as needed */ vg_context_update_alpha_mask_view(ctx, stfb->width, stfb->height); - vg_context_update_blend_texture_view(ctx, stfb->width, stfb->height); renderer_validate(ctx->renderer, ctx->state.dirty, ctx->draw_buffer, &ctx->state.vg); @@ -438,75 +437,56 @@ void vg_set_error(struct vg_context *ctx, ctx->_error = code; } -void vg_prepare_blend_surface(struct vg_context *ctx) +static void vg_prepare_blend_texture(struct vg_context *ctx, + struct pipe_sampler_view *src) +{ + struct st_framebuffer *stfb = ctx->draw_buffer; + struct pipe_surface *surf; + + vg_context_update_blend_texture_view(ctx, stfb->width, stfb->height); + + surf = ctx->pipe->screen->get_tex_surface(ctx->pipe->screen, + stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + if (surf) { + util_blit_pixels_tex(ctx->blit, + src, 0, 0, stfb->width, stfb->height, + surf, 0, 0, stfb->width, stfb->height, + 0.0, PIPE_TEX_MIPFILTER_NEAREST); + + pipe_surface_reference(&surf, NULL); + } +} + +struct pipe_sampler_view *vg_prepare_blend_surface(struct vg_context *ctx) { - struct pipe_surface *dest_surface = NULL; struct pipe_context *pipe = ctx->pipe; struct pipe_sampler_view *view; struct pipe_sampler_view view_templ; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; - /* first finish all pending rendering */ - vgFinish(); + vg_validate_state(ctx); u_sampler_view_default_template(&view_templ, strb->texture, strb->texture->format); view = pipe->create_sampler_view(pipe, strb->texture, &view_templ); - dest_surface = pipe->screen->get_tex_surface(pipe->screen, - stfb->blend_texture_view->texture, - 0, 0, 0, - PIPE_BIND_RENDER_TARGET); - util_blit_pixels_tex(ctx->blit, - view, - 0, 0, - strb->width, strb->height, - dest_surface, - 0, 0, - strb->width, strb->height, - 0.0, PIPE_TEX_MIPFILTER_NEAREST); - - if (dest_surface) - pipe_surface_reference(&dest_surface, NULL); - - /* make sure it's complete */ - vgFinish(); + vg_prepare_blend_texture(ctx, view); pipe_sampler_view_reference(&view, NULL); + + return stfb->blend_texture_view; } -void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) +struct pipe_sampler_view *vg_prepare_blend_surface_from_mask(struct vg_context *ctx) { - struct pipe_surface *dest_surface = NULL; - struct pipe_context *pipe = ctx->pipe; struct st_framebuffer *stfb = ctx->draw_buffer; - struct st_renderbuffer *strb = stfb->strb; vg_validate_state(ctx); - /* first finish all pending rendering */ - vgFinish(); - - dest_surface = pipe->screen->get_tex_surface(pipe->screen, - stfb->blend_texture_view->texture, - 0, 0, 0, - PIPE_BIND_RENDER_TARGET); - - util_blit_pixels_tex(ctx->blit, - stfb->alpha_mask_view, - 0, 0, - strb->width, strb->height, - dest_surface, - 0, 0, - strb->width, strb->height, - 0.0, PIPE_TEX_MIPFILTER_NEAREST); - - /* make sure it's complete */ - vgFinish(); + vg_prepare_blend_texture(ctx, stfb->alpha_mask_view); - if (dest_surface) - pipe_surface_reference(&dest_surface, NULL); + return stfb->blend_texture_view; } /** diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index 5d0bca33c52..32996f4678f 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -159,8 +159,8 @@ void vg_validate_state(struct vg_context *ctx); void vg_set_error(struct vg_context *ctx, VGErrorCode code); -void vg_prepare_blend_surface(struct vg_context *ctx); -void vg_prepare_blend_surface_from_mask(struct vg_context *ctx); +struct pipe_sampler_view *vg_prepare_blend_surface(struct vg_context *ctx); +struct pipe_sampler_view *vg_prepare_blend_surface_from_mask(struct vg_context *ctx); VGboolean vg_get_paint_matrix(struct vg_context *ctx, const struct matrix *paint_to_user, |