From 6d2f59ce5494a9435b6b3d3faa1d94ba6caad100 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Thu, 13 Sep 2012 00:34:01 +0200 Subject: i915g: implement blit Reviewed-by: Brian Paul --- src/gallium/drivers/i915/i915_surface.c | 73 ++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 19 deletions(-) (limited to 'src/gallium/drivers/i915/i915_surface.c') diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 99837fe7658..4bb5f4800cf 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -43,6 +43,31 @@ * surface functions using the render engine */ +static void +i915_util_blitter_save_states(struct i915_context *i915) +{ + util_blitter_save_blend(i915->blitter, (void *)i915->blend); + util_blitter_save_depth_stencil_alpha(i915->blitter, (void *)i915->depth_stencil); + util_blitter_save_stencil_ref(i915->blitter, &i915->stencil_ref); + util_blitter_save_rasterizer(i915->blitter, (void *)i915->rasterizer); + util_blitter_save_fragment_shader(i915->blitter, i915->saved_fs); + util_blitter_save_vertex_shader(i915->blitter, i915->saved_vs); + util_blitter_save_viewport(i915->blitter, &i915->viewport); + util_blitter_save_scissor(i915->blitter, &i915->scissor); + util_blitter_save_vertex_elements(i915->blitter, i915->saved_velems); + util_blitter_save_vertex_buffers(i915->blitter, i915->saved_nr_vertex_buffers, + i915->saved_vertex_buffers); + + util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); + + util_blitter_save_fragment_sampler_states(i915->blitter, + i915->saved_nr_samplers, + i915->saved_samplers); + util_blitter_save_fragment_sampler_views(i915->blitter, + i915->saved_nr_sampler_views, + i915->saved_sampler_views); +} + static void i915_surface_copy_render(struct pipe_context *pipe, struct pipe_resource *dst, unsigned dst_level, @@ -66,25 +91,7 @@ i915_surface_copy_render(struct pipe_context *pipe, return; } - util_blitter_save_blend(i915->blitter, (void *)i915->blend); - util_blitter_save_depth_stencil_alpha(i915->blitter, (void *)i915->depth_stencil); - util_blitter_save_stencil_ref(i915->blitter, &i915->stencil_ref); - util_blitter_save_rasterizer(i915->blitter, (void *)i915->rasterizer); - util_blitter_save_fragment_shader(i915->blitter, i915->saved_fs); - util_blitter_save_vertex_shader(i915->blitter, i915->saved_vs); - util_blitter_save_viewport(i915->blitter, &i915->viewport); - util_blitter_save_vertex_elements(i915->blitter, i915->saved_velems); - util_blitter_save_vertex_buffers(i915->blitter, i915->saved_nr_vertex_buffers, - i915->saved_vertex_buffers); - - util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); - - util_blitter_save_fragment_sampler_states(i915->blitter, - i915->saved_nr_samplers, - i915->saved_samplers); - util_blitter_save_fragment_sampler_views(i915->blitter, - i915->saved_nr_sampler_views, - i915->saved_sampler_views); + i915_util_blitter_save_states(i915); util_blitter_copy_texture(i915->blitter, dst, dst_level, dstx, dsty, dstz, src, src_level, src_box, PIPE_MASK_RGBAZS, TRUE); @@ -205,6 +212,33 @@ i915_surface_copy_blitter(struct pipe_context *pipe, (short) src_box->width, (short) src_box->height ); } +static void +i915_blit(struct pipe_context *pipe, const struct pipe_blit_info *blit_info) +{ + struct i915_context *i915 = i915_context(pipe); + struct pipe_blit_info info = *blit_info; + + if (util_try_blit_via_copy_region(pipe, &info)) { + return; /* done */ + } + + if (info.mask & PIPE_MASK_S) { + debug_printf("i915: cannot blit stencil, skipping\n"); + info.mask &= ~PIPE_MASK_S; + } + + if (!util_blitter_is_blit_supported(i915->blitter, &info)) { + debug_printf("i915: blit unsupported %s -> %s\n", + util_format_short_name(info.src.resource->format), + util_format_short_name(info.dst.resource->format)); + return; + } + + i915_util_blitter_save_states(i915); + + util_blitter_blit(i915->blitter, &info); +} + static void i915_clear_render_target_blitter(struct pipe_context *pipe, struct pipe_surface *dst, @@ -325,6 +359,7 @@ i915_init_surface_functions(struct i915_context *i915) i915->base.clear_render_target = i915_clear_render_target_render; i915->base.clear_depth_stencil = i915_clear_depth_stencil_render; } + i915->base.blit = i915_blit; i915->base.create_surface = i915_create_surface; i915->base.surface_destroy = i915_surface_destroy; } -- cgit v1.2.3