X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fpipe%2Ffailover%2Ffo_state.c;h=db3aea775655ca5d1e6fc6f83bc4703e525500b7;hb=daf5b0f41baa50951e7c2f9ea5cd90b119085a7f;hp=2357d7ef5cef5241f70eb217f0fdea929fd18c07;hpb=9780327c5d95586a88fce94d7b47342355ead118;p=mesa.git diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 2357d7ef5ce..db3aea77565 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -57,17 +57,43 @@ failover_set_alpha_test_state(struct pipe_context *pipe, } -static void +static void * +failover_create_blend_state( struct pipe_context *pipe, + const struct pipe_blend_state *blend ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_blend_state(pipe, blend); + state->hw_state = failover->hw->create_blend_state(pipe, blend); + + return state; +} + +static void failover_bind_blend_state( struct pipe_context *pipe, - const struct pipe_blend_state *blend ) + void *blend ) { struct failover_context *failover = failover_context(pipe); - failover->blend = blend; + failover->blend = (struct fo_state *)blend; failover->dirty |= FO_NEW_BLEND; failover->hw->bind_blend_state( failover->hw, blend ); } +static void +failover_delete_blend_state( struct pipe_context *pipe, + void *blend ) +{ + struct fo_state *state = (struct fo_state*)blend; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_blend_state(pipe, state->sw_state); + failover->hw->delete_blend_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); +} static void failover_set_blend_color( struct pipe_context *pipe, @@ -103,14 +129,14 @@ failover_set_clear_color_state( struct pipe_context *pipe, } static void -failover_set_depth_test_state(struct pipe_context *pipe, - const struct pipe_depth_state *depth) +failover_bind_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) { struct failover_context *failover = failover_context(pipe); - failover->depth_test = *depth; - failover->dirty |= FO_NEW_DEPTH_TEST; - failover->hw->set_depth_state( failover->hw, depth ); + failover->depth_stencil = depth_stencil; + failover->dirty |= FO_NEW_DEPTH_STENCIL; + failover->hw->bind_depth_stencil_state( failover->hw, depth_stencil ); } static void @@ -124,28 +150,82 @@ failover_set_framebuffer_state(struct pipe_context *pipe, failover->hw->set_framebuffer_state( failover->hw, framebuffer ); } + +static void * +failover_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_fs_state(pipe, templ); + state->hw_state = failover->hw->create_fs_state(pipe, templ); + + return state; +} + static void -failover_set_fs_state(struct pipe_context *pipe, - const struct pipe_shader_state *fs) +failover_bind_fs_state(struct pipe_context *pipe, + void *fs) { struct failover_context *failover = failover_context(pipe); - failover->fragment_shader = *fs; + failover->fragment_shader = (struct fo_state *)fs; failover->dirty |= FO_NEW_FRAGMENT_SHADER; - failover->hw->set_fs_state( failover->hw, fs ); + failover->hw->bind_fs_state(failover->hw, (struct pipe_shader_state *)fs); +} + +static void +failover_delete_fs_state(struct pipe_context *pipe, + void *fs) +{ + struct fo_state *state = (struct fo_state*)fs; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_fs_state(pipe, state->sw_state); + failover->hw->delete_fs_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); +} + +static void * +failover_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_vs_state(pipe, templ); + state->hw_state = failover->hw->create_vs_state(pipe, templ); + + return state; } static void -failover_set_vs_state(struct pipe_context *pipe, - const struct pipe_shader_state *vs) +failover_bind_vs_state(struct pipe_context *pipe, + void *vs) { struct failover_context *failover = failover_context(pipe); - failover->vertex_shader = *vs; + failover->vertex_shader = (struct fo_state*)vs; failover->dirty |= FO_NEW_VERTEX_SHADER; - failover->hw->set_vs_state( failover->hw, vs ); + failover->hw->bind_vs_state(failover->hw, vs); } +static void +failover_delete_vs_state(struct pipe_context *pipe, + void *vs) +{ + struct fo_state *state = (struct fo_state*)vs; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_vs_state(pipe, state->sw_state); + failover->hw->delete_vs_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); +} static void failover_set_polygon_stipple( struct pipe_context *pipe, @@ -158,17 +238,42 @@ failover_set_polygon_stipple( struct pipe_context *pipe, failover->hw->set_polygon_stipple( failover->hw, stipple ); } +static void * +failover_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + state->sw_state = failover->sw->create_rasterizer_state(pipe, templ); + state->hw_state = failover->hw->create_rasterizer_state(pipe, templ); -static void -failover_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) + return state; +} + +static void +failover_bind_rasterizer_state(struct pipe_context *pipe, + void *raster) +{ + struct failover_context *failover = failover_context(pipe); + + failover->rasterizer = (struct fo_state *)raster; + failover->dirty |= FO_NEW_RASTERIZER; + failover->hw->bind_rasterizer_state( failover->hw, raster ); +} + +static void +failover_delete_rasterizer_state(struct pipe_context *pipe, + void *raster) { + struct fo_state *state = (struct fo_state*)raster; struct failover_context *failover = failover_context(pipe); - failover->setup = *setup; - failover->dirty |= FO_NEW_SETUP; - failover->hw->set_setup_state( failover->hw, setup ); + failover->sw->delete_rasterizer_state(pipe, state->sw_state); + failover->hw->delete_rasterizer_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); } @@ -184,28 +289,16 @@ failover_set_scissor_state( struct pipe_context *pipe, } static void -failover_set_stencil_state(struct pipe_context *pipe, - const struct pipe_stencil_state *stencil) -{ - struct failover_context *failover = failover_context(pipe); - - failover->stencil = *stencil; - failover->dirty |= FO_NEW_STENCIL; - failover->hw->set_stencil_state( failover->hw, stencil ); -} - - -static void -failover_set_sampler_state(struct pipe_context *pipe, +failover_bind_sampler_state(struct pipe_context *pipe, unsigned unit, const struct pipe_sampler_state *sampler) { struct failover_context *failover = failover_context(pipe); - failover->sampler[unit] = *sampler; + failover->sampler[unit] = sampler; failover->dirty |= FO_NEW_SAMPLER; failover->dirty_sampler |= (1<hw->set_sampler_state( failover->hw, unit, sampler ); + failover->hw->bind_sampler_state( failover->hw, unit, sampler ); } @@ -266,21 +359,28 @@ failover_set_vertex_element(struct pipe_context *pipe, void failover_init_state_functions( struct failover_context *failover ) { + failover->pipe.create_blend_state = failover_create_blend_state; failover->pipe.bind_blend_state = failover_bind_blend_state; + failover->pipe.delete_blend_state = failover_delete_blend_state; + failover->pipe.bind_sampler_state = failover_bind_sampler_state; + failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; + failover->pipe.create_rasterizer_state = failover_create_rasterizer_state; + failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state; + failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state; + failover->pipe.create_fs_state = failover_create_fs_state; + failover->pipe.bind_fs_state = failover_bind_fs_state; + failover->pipe.delete_fs_state = failover_delete_fs_state; + failover->pipe.create_vs_state = failover_create_vs_state; + failover->pipe.bind_vs_state = failover_bind_vs_state; + failover->pipe.delete_vs_state = failover_delete_vs_state; failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_clip_state = failover_set_clip_state; failover->pipe.set_clear_color_state = failover_set_clear_color_state; - failover->pipe.set_depth_state = failover_set_depth_test_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; - failover->pipe.set_fs_state = failover_set_fs_state; - failover->pipe.set_vs_state = failover_set_vs_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; - failover->pipe.set_sampler_state = failover_set_sampler_state; failover->pipe.set_scissor_state = failover_set_scissor_state; - failover->pipe.set_setup_state = failover_set_setup_state; - failover->pipe.set_stencil_state = failover_set_stencil_state; failover->pipe.set_texture_state = failover_set_texture_state; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;