Squashed commit of the following:
[mesa.git] / src / gallium / drivers / failover / fo_state.c
index d0c2f1474aecf01640761413023ee9272179af5b..b682ce6750e2bb797b90fb23a60ee3b4ecffca3b 100644 (file)
@@ -255,9 +255,52 @@ failover_delete_vs_state(struct pipe_context *pipe,
    free(state);
 }
 
+
+
+static void *
+failover_create_vertex_elements_state( struct pipe_context *pipe,
+                                       unsigned count,
+                                       const struct pipe_vertex_element *velems )
+{
+   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct failover_context *failover = failover_context(pipe);
+
+   state->sw_state = failover->sw->create_vertex_elements_state(failover->sw, count, velems);
+   state->hw_state = failover->hw->create_vertex_elements_state(failover->hw, count, velems);
+
+   return state;
+}
+
+static void
+failover_bind_vertex_elements_state(struct pipe_context *pipe,
+                                    void *velems )
+{
+   struct failover_context *failover = failover_context(pipe);
+   struct fo_state *state = (struct fo_state*)velems;
+
+   failover->vertex_elements = state;
+   failover->dirty |= FO_NEW_VERTEX_ELEMENT;
+   failover->sw->bind_vertex_elements_state( failover->sw, velems );
+   failover->hw->bind_vertex_elements_state( failover->hw, velems );
+}
+
+static void
+failover_delete_vertex_elements_state( struct pipe_context *pipe,
+                                       void *velems )
+{
+   struct fo_state *state = (struct fo_state*)velems;
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sw->delete_vertex_elements_state(failover->sw, state->sw_state);
+   failover->hw->delete_vertex_elements_state(failover->hw, state->hw_state);
+   state->sw_state = 0;
+   state->hw_state = 0;
+   free(state);
+}
+
 static void 
 failover_set_polygon_stipple( struct pipe_context *pipe,
-                             const struct pipe_poly_stipple *stipple )
+                              const struct pipe_poly_stipple *stipple )
 {
    struct failover_context *failover = failover_context(pipe);
 
@@ -406,7 +449,7 @@ 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,
+                             struct pipe_resource *texture,
                              const struct pipe_sampler_view *templ)
 {
    struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view));
@@ -418,7 +461,7 @@ failover_create_sampler_view(struct pipe_context *pipe,
    view->base = *templ;
    view->base.reference.count = 1;
    view->base.texture = NULL;
-   pipe_texture_reference(&view->base.texture, texture);
+   pipe_resource_reference(&view->base.texture, texture);
    view->base.context = pipe;
 
    return &view->base;
@@ -434,7 +477,7 @@ failover_sampler_view_destroy(struct pipe_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);
+   pipe_resource_reference(&fo_view->base.texture, NULL);
    free(fo_view);
 }
 
@@ -526,34 +569,18 @@ failover_set_vertex_buffers(struct pipe_context *pipe,
 }
 
 
-static void
-failover_set_vertex_elements(struct pipe_context *pipe,
-                             unsigned count,
-                             const struct pipe_vertex_element *vertex_elements)
-{
-   struct failover_context *failover = failover_context(pipe);
-
-   memcpy(failover->vertex_elements, vertex_elements,
-          count * sizeof(vertex_elements[0]));
-
-   failover->dirty |= FO_NEW_VERTEX_ELEMENT;
-   failover->num_vertex_elements = count;
-   failover->sw->set_vertex_elements( failover->sw, count, vertex_elements );
-   failover->hw->set_vertex_elements( failover->hw, count, vertex_elements );
-}
-
 void
 failover_set_constant_buffer(struct pipe_context *pipe,
                              uint shader, uint index,
-                             struct pipe_buffer *buf)
+                             struct pipe_resource *res)
 {
    struct failover_context *failover = failover_context(pipe);
 
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
-   failover->sw->set_constant_buffer(failover->sw, shader, index, buf);
-   failover->hw->set_constant_buffer(failover->hw, shader, index, buf);
+   failover->sw->set_constant_buffer(failover->sw, shader, index, res);
+   failover->hw->set_constant_buffer(failover->hw, shader, index, res);
 }
 
 
@@ -579,6 +606,9 @@ failover_init_state_functions( struct failover_context *failover )
    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.create_vertex_elements_state = failover_create_vertex_elements_state;
+   failover->pipe.bind_vertex_elements_state = failover_bind_vertex_elements_state;
+   failover->pipe.delete_vertex_elements_state = failover_delete_vertex_elements_state;
 
    failover->pipe.set_blend_color = failover_set_blend_color;
    failover->pipe.set_stencil_ref = failover_set_stencil_ref;
@@ -590,7 +620,6 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.set_vertex_sampler_views = failover_set_vertex_sampler_views;
    failover->pipe.set_viewport_state = failover_set_viewport_state;
    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;