diff options
author | Daniel Vetter <[email protected]> | 2011-03-11 20:21:00 +0100 |
---|---|---|
committer | Daniel Vetter <[email protected]> | 2011-03-12 20:32:29 +0100 |
commit | f0c56e2a23ec3a6ffa5aebe613a469e39601e7af (patch) | |
tree | a4e4ecf38fdc0a4b093d5a8730e182d31c821fb8 /src/gallium | |
parent | 06713a40798d97aa520b119731418ff16a92e4ba (diff) |
i915g: implement copy_region using u_blitter
Signed-off-by: Daniel Vetter <[email protected]>works
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/i915/i915_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_context.h | 23 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_state.c | 63 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_surface.c | 48 |
4 files changed, 128 insertions, 9 deletions
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index f1a14bc259e..5dbf0cfcbf1 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -170,6 +170,9 @@ i915_create_context(struct pipe_screen *screen, void *priv) draw_install_aaline_stage(i915->draw, &i915->base); draw_install_aapoint_stage(i915->draw, &i915->base); + /* 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); diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 62becbcccbf..51a364b042c 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -240,8 +240,6 @@ struct i915_context { struct i915_winsys_batchbuffer *batch; - struct blitter_context* blitter; - /** Vertex buffer */ struct i915_winsys_buffer *vbo; size_t vbo_offset; @@ -257,6 +255,26 @@ struct i915_context { int num_validation_buffers; struct util_slab_mempool transfer_pool; + + /** blitter/hw-clear */ + struct blitter_context* blitter; + + /** State tracking needed by u_blitter for save/restore. */ + void *saved_fs; + void (*saved_bind_fs_state)(struct pipe_context *pipe, void *shader); + void *saved_vs; + struct pipe_clip_state saved_clip; + struct i915_velems_state *saved_velems; + unsigned saved_nr_vertex_buffers; + struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS]; + unsigned saved_nr_samplers; + void *saved_samplers[PIPE_MAX_SAMPLERS]; + void (*saved_bind_sampler_states)(struct pipe_context *pipe, + unsigned num, void **sampler); + unsigned saved_nr_sampler_views; + struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS]; + void (*saved_set_sampler_views)(struct pipe_context *pipe, + unsigned num, struct pipe_sampler_view **views); }; /* A flag for each state_tracker state object: @@ -344,6 +362,7 @@ void i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *r * */ void i915_init_state_functions( struct i915_context *i915 ); +void i915_init_fixup_state_functions( struct i915_context *i915 ); void i915_init_flush_functions( struct i915_context *i915 ); void i915_init_string_functions( struct i915_context *i915 ); diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 4d134c1e163..1b57c5776f2 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -287,6 +287,17 @@ i915_create_sampler_state(struct pipe_context *pipe, return cso; } +static void i915_fixup_bind_sampler_states(struct pipe_context *pipe, + unsigned num, void **sampler) +{ + struct i915_context *i915 = i915_context(pipe); + + i915->saved_nr_samplers = num; + memcpy(&i915->saved_samplers, sampler, sizeof(void *) * num); + + i915->saved_bind_sampler_states(pipe, num, sampler); +} + static void i915_bind_sampler_states(struct pipe_context *pipe, unsigned num, void **sampler) { @@ -466,6 +477,17 @@ i915_create_fs_state(struct pipe_context *pipe, } static void +i915_fixup_bind_fs_state(struct pipe_context *pipe, void *shader) +{ + struct i915_context *i915 = i915_context(pipe); + draw_flush(i915->draw); + + i915->saved_fs = shader; + + i915->saved_bind_fs_state(pipe, shader); +} + +static void i915_bind_fs_state(struct pipe_context *pipe, void *shader) { struct i915_context *i915 = i915_context(pipe); @@ -505,6 +527,8 @@ static void i915_bind_vs_state(struct pipe_context *pipe, void *shader) { struct i915_context *i915 = i915_context(pipe); + i915->saved_vs = shader; + /* just pass-through to draw module */ draw_bind_vertex_shader(i915->draw, (struct draw_vertex_shader *) shader); @@ -571,6 +595,27 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, } +static void +i915_fixup_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) +{ + struct i915_context *i915 = i915_context(pipe); + int i; + + for (i = 0; i < num; i++) + pipe_sampler_view_reference(&i915->saved_sampler_views[i], + views[i]); + + for (i = num; i < i915->saved_nr_sampler_views; i++) + pipe_sampler_view_reference(&i915->saved_sampler_views[i], + NULL); + + i915->saved_nr_sampler_views = num; + + i915->saved_set_sampler_views(pipe, num, views); +} + static void i915_set_fragment_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) @@ -658,6 +703,8 @@ static void i915_set_clip_state( struct pipe_context *pipe, struct i915_context *i915 = i915_context(pipe); draw_flush(i915->draw); + i915->saved_clip = *clip; + draw_set_clip_state(i915->draw, clip); i915->dirty |= I915_NEW_CLIP; @@ -779,6 +826,9 @@ static void i915_set_vertex_buffers(struct pipe_context *pipe, struct draw_context *draw = i915->draw; int i; + util_copy_vertex_buffers(i915->saved_vertex_buffers, + &i915->saved_nr_vertex_buffers, + buffers, count); #if 0 /* XXX doesn't look like this is needed */ /* unmap old */ @@ -819,6 +869,8 @@ i915_bind_vertex_elements_state(struct pipe_context *pipe, struct i915_context *i915 = i915_context(pipe); struct i915_velems_state *i915_velems = (struct i915_velems_state *) velems; + i915->saved_velems = velems; + /* pass-through to draw module */ if (i915_velems) { draw_set_vertex_elements(i915->draw, @@ -897,3 +949,14 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.set_index_buffer = i915_set_index_buffer; i915->base.redefine_user_buffer = u_default_redefine_user_buffer; } + +void +i915_init_fixup_state_functions( struct i915_context *i915 ) +{ + i915->saved_bind_fs_state = i915->base.bind_fs_state; + i915->base.bind_fs_state = i915_fixup_bind_fs_state; + i915->saved_bind_sampler_states = i915->base.bind_fragment_sampler_states; + i915->base.bind_fragment_sampler_states = i915_fixup_bind_sampler_states; + i915->saved_set_sampler_views = i915->base.set_fragment_sampler_views; + i915->base.set_fragment_sampler_views = i915_fixup_set_fragment_sampler_views; +} diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 5dcb6c2ee7f..d02c420f6c2 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -43,6 +43,40 @@ */ static void +i915_surface_copy_render(struct pipe_context *pipe, + struct pipe_resource *dst, unsigned dst_level, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, unsigned src_level, + const struct pipe_box *src_box) +{ + struct i915_context *i915 = i915_context(pipe); + + 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_clip(i915->blitter, &i915->saved_clip); + 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); + + util_blitter_copy_region(i915->blitter, dst, dst_level, dstx, dsty, dstz, + src, src_level, src_box, TRUE); +} + +static void i915_clear_render_target_render(struct pipe_context *pipe, struct pipe_surface *dst, const float *rgba, @@ -112,11 +146,11 @@ i915_clear_depth_stencil_render(struct pipe_context *pipe, * do it higher up if required. */ static void -i915_surface_copy(struct pipe_context *pipe, - struct pipe_resource *dst, unsigned dst_level, - unsigned dstx, unsigned dsty, unsigned dstz, - struct pipe_resource *src, unsigned src_level, - const struct pipe_box *src_box) +i915_surface_copy_blitter(struct pipe_context *pipe, + struct pipe_resource *dst, unsigned dst_level, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, unsigned src_level, + const struct pipe_box *src_box) { struct i915_texture *dst_tex = i915_texture(dst); struct i915_texture *src_tex = i915_texture(src); @@ -150,7 +184,6 @@ i915_surface_copy(struct pipe_context *pipe, (short) src_box->width, (short) src_box->height ); } - static void i915_clear_render_target_blitter(struct pipe_context *pipe, struct pipe_surface *dst, @@ -262,11 +295,12 @@ i915_surface_destroy(struct pipe_context *ctx, void i915_init_surface_functions(struct i915_context *i915) { - i915->base.resource_copy_region = i915_surface_copy; if (i915_screen(i915->base.screen)->debug.use_blitter) { + i915->base.resource_copy_region = i915_surface_copy_blitter; i915->base.clear_render_target = i915_clear_render_target_blitter; i915->base.clear_depth_stencil = i915_clear_depth_stencil_blitter; } else { + i915->base.resource_copy_region = i915_surface_copy_render; i915->base.clear_render_target = i915_clear_render_target_render; i915->base.clear_depth_stencil = i915_clear_depth_stencil_render; } |