diff options
author | Michal Krol <[email protected]> | 2010-02-23 16:09:10 +0100 |
---|---|---|
committer | Michal Krol <[email protected]> | 2010-02-23 16:09:10 +0100 |
commit | 9187b25a15145933ca014556e109b17ecf38ece4 (patch) | |
tree | b0520024b3787537d30438bc782720226c8e9367 /src/gallium/drivers/failover/fo_state.c | |
parent | f6106566081978f663cf08e54bb8908cb58a5316 (diff) |
failover: Fix after sampler view changes.
Diffstat (limited to 'src/gallium/drivers/failover/fo_state.c')
-rw-r--r-- | src/gallium/drivers/failover/fo_state.c | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index b16f2197f11..d0c2f1474ae 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -404,30 +404,66 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler) } +static struct pipe_sampler_view * +failover_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view)); + struct failover_context *failover = failover_context(pipe); + + view->sw = failover->sw->create_sampler_view(failover->sw, texture, templ); + view->hw = failover->hw->create_sampler_view(failover->hw, texture, templ); + + view->base = *templ; + view->base.reference.count = 1; + view->base.texture = NULL; + pipe_texture_reference(&view->base.texture, texture); + view->base.context = pipe; + + return &view->base; +} + +static void +failover_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)view; + struct failover_context *failover = failover_context(pipe); + + failover->sw->sampler_view_destroy(failover->sw, fo_view->sw); + failover->hw->sampler_view_destroy(failover->hw, fo_view->hw); + + pipe_texture_reference(&fo_view->base.texture, NULL); + free(fo_view); +} + static void failover_set_fragment_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); + struct pipe_sampler_view *hw_views[PIPE_MAX_SAMPLERS]; uint i; assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == failover->num_sampler_views && - !memcmp(failover->sampler_views, views, num * sizeof(struct pipe_sampler_view *))) + if (num == failover->num_fragment_sampler_views && + !memcmp(failover->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; - for (i = 0; i < num; i++) - pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], - views[i]); - for (i = num; i < failover->num_sampler_views; i++) - pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], - NULL); - failover->dirty |= FO_NEW_TEXTURE; - failover->num_sampler_views = num; - failover->sw->set_fragment_sampler_views( failover->sw, num, views ); - failover->hw->set_fragment_sampler_views( failover->hw, num, views ); + for (i = 0; i < num; i++) { + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i]; + + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], views[i]); + hw_views[i] = fo_view->hw; + } + for (i = num; i < failover->num_fragment_sampler_views; i++) + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], NULL); + failover->dirty |= FO_NEW_SAMPLER_VIEW; + failover->num_fragment_sampler_views = num; + failover->hw->set_fragment_sampler_views(failover->hw, num, hw_views); } @@ -437,6 +473,7 @@ failover_set_vertex_sampler_views(struct pipe_context *pipe, struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); + struct pipe_sampler_view *hw_views[PIPE_MAX_VERTEX_SAMPLERS]; uint i; assert(num <= PIPE_MAX_VERTEX_SAMPLERS); @@ -447,17 +484,16 @@ failover_set_vertex_sampler_views(struct pipe_context *pipe, return; } for (i = 0; i < num; i++) { - pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], - views[i]); - } - for (i = num; i < failover->num_vertex_sampler_views; i++) { - pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], - NULL); + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i]; + + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], views[i]); + hw_views[i] = fo_view->hw; } - failover->dirty |= FO_NEW_TEXTURE; + for (i = num; i < failover->num_vertex_sampler_views; i++) + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], NULL); + failover->dirty |= FO_NEW_SAMPLER_VIEW; failover->num_vertex_sampler_views = num; - failover->sw->set_vertex_sampler_views(failover->sw, num, views); - failover->hw->set_vertex_sampler_views(failover->hw, num, views); + failover->hw->set_vertex_sampler_views(failover->hw, num, hw_views); } @@ -556,4 +592,6 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_vertex_buffers = failover_set_vertex_buffers; failover->pipe.set_vertex_elements = failover_set_vertex_elements; failover->pipe.set_constant_buffer = failover_set_constant_buffer; + failover->pipe.create_sampler_view = failover_create_sampler_view; + failover->pipe.sampler_view_destroy = failover_sampler_view_destroy; } |