diff options
author | Marek Olšák <[email protected]> | 2012-09-13 00:34:01 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-09-30 18:57:56 +0200 |
commit | 6d2f59ce5494a9435b6b3d3faa1d94ba6caad100 (patch) | |
tree | 76c2f542c4f7b04eadaa71f1e5d87d42f9cb060a /src | |
parent | 2a309dc2b4e78c9e49d5b679cae5cf802b772469 (diff) |
i915g: implement blit
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/i915/i915_context.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_surface.c | 73 |
2 files changed, 61 insertions, 23 deletions
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 988d6591519..1f2ca848100 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -187,6 +187,13 @@ i915_create_context(struct pipe_screen *screen, void *priv) i915_init_resource_functions(i915); i915_init_query_functions(i915); + /* Create blitter. */ + i915->blitter = util_blitter_create(&i915->base); + assert(i915->blitter); + + /* must be done before installing Draw stages */ + util_blitter_cache_all_shaders(i915->blitter); + draw_install_aaline_stage(i915->draw, &i915->base); draw_install_aapoint_stage(i915->draw, &i915->base); draw_enable_point_sprites(i915->draw, TRUE); @@ -194,10 +201,6 @@ i915_create_context(struct pipe_screen *screen, void *priv) /* augmented draw pipeline clobbers state functions */ i915_init_fixup_state_functions(i915); - /* Create blitter last - calls state creation functions. */ - i915->blitter = util_blitter_create(&i915->base); - assert(i915->blitter); - i915->dirty = ~0; i915->hardware_dirty = ~0; i915->immediate_dirty = ~0; 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 @@ -44,6 +44,31 @@ */ 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, unsigned dstx, unsigned dsty, unsigned dstz, @@ -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); @@ -206,6 +213,33 @@ i915_surface_copy_blitter(struct pipe_context *pipe, } 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, const union pipe_color_union *color, @@ -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; } |