radeonsi: move handling of DBG_NO_OPT_VARIANT into si_shader_selector_key
[mesa.git] / src / gallium / drivers / rbug / rbug_context.c
index 3c2dc698e42f606239edc198779171203a3a6d65..e1f3c4f28447aa768c553591770eac38fd4cb9be 100644 (file)
@@ -46,10 +46,10 @@ rbug_destroy(struct pipe_context *_pipe)
 
    rbug_screen_remove_from_list(rb_screen, contexts, rb_pipe);
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->destroy(pipe);
    rb_pipe->pipe = NULL;
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    FREE(rb_pipe);
 }
@@ -108,7 +108,7 @@ rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag)
    /* wait for rbug to clear the blocked flag */
    while (rb_pipe->draw_blocked & flag) {
       rb_pipe->draw_blocked |= flag;
-      pipe_condvar_wait(rb_pipe->draw_cond, rb_pipe->draw_mutex);
+      cnd_wait(&rb_pipe->draw_cond, &rb_pipe->draw_mutex);
    }
 
 }
@@ -119,19 +119,19 @@ rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info)
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->draw_mutex);
+   mtx_lock(&rb_pipe->draw_mutex);
    rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE);
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    /* XXX loop over PIPE_SHADER_x here */
    if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) &&
        !(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) &&
        !(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled))
       pipe->draw_vbo(pipe, info);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER);
-   pipe_mutex_unlock(rb_pipe->draw_mutex);
+   mtx_unlock(&rb_pipe->draw_mutex);
 }
 
 static struct pipe_query *
@@ -143,11 +143,11 @@ rbug_create_query(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    struct pipe_query *query;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    query = pipe->create_query(pipe,
                               query_type,
                               index);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
    return query;
 }
 
@@ -158,10 +158,10 @@ rbug_destroy_query(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->destroy_query(pipe,
                        query);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static boolean
@@ -172,9 +172,9 @@ rbug_begin_query(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    boolean ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->begin_query(pipe, query);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
    return ret;
 }
 
@@ -186,10 +186,10 @@ rbug_end_query(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    bool ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->end_query(pipe,
                          query);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -204,12 +204,12 @@ rbug_get_query_result(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    boolean ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->get_query_result(pipe,
                                 query,
                                 wait,
                                 result);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -220,9 +220,9 @@ rbug_set_active_query_state(struct pipe_context *_pipe, boolean enable)
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_active_query_state(pipe, enable);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -233,10 +233,10 @@ rbug_create_blend_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->create_blend_state(pipe,
                                   blend);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -248,10 +248,10 @@ rbug_bind_blend_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->bind_blend_state(pipe,
                           blend);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -261,10 +261,10 @@ rbug_delete_blend_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->delete_blend_state(pipe,
                             blend);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -275,25 +275,26 @@ rbug_create_sampler_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->create_sampler_state(pipe,
                                     sampler);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
 
 static void
-rbug_bind_sampler_states(struct pipe_context *_pipe, unsigned shader,
+rbug_bind_sampler_states(struct pipe_context *_pipe,
+                         enum pipe_shader_type shader,
                          unsigned start, unsigned count,
                          void **samplers)
 {
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->bind_sampler_states(pipe, shader, start, count, samplers);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -303,10 +304,10 @@ rbug_delete_sampler_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->delete_sampler_state(pipe,
                               sampler);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -317,10 +318,10 @@ rbug_create_rasterizer_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->create_rasterizer_state(pipe,
                                        rasterizer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -332,10 +333,10 @@ rbug_bind_rasterizer_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->bind_rasterizer_state(pipe,
                                rasterizer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -345,10 +346,10 @@ rbug_delete_rasterizer_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->delete_rasterizer_state(pipe,
                                  rasterizer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -359,10 +360,10 @@ rbug_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->create_depth_stencil_alpha_state(pipe,
                                                 depth_stencil_alpha);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -374,10 +375,10 @@ rbug_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->bind_depth_stencil_alpha_state(pipe,
                                         depth_stencil_alpha);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -387,10 +388,10 @@ rbug_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->delete_depth_stencil_alpha_state(pipe,
                                           depth_stencil_alpha);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -401,9 +402,9 @@ rbug_create_fs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *result;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    result = pipe->create_fs_state(pipe, state);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    if (!result)
       return NULL;
@@ -419,14 +420,14 @@ rbug_bind_fs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *fs;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    fs = rbug_shader_unwrap(_fs);
    rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] = rbug_shader(_fs);
    pipe->bind_fs_state(pipe,
                        fs);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -436,9 +437,9 @@ rbug_delete_fs_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct rbug_shader *rb_shader = rbug_shader(_fs);
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    rbug_shader_destroy(rb_pipe, rb_shader);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -449,9 +450,9 @@ rbug_create_vs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *result;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    result = pipe->create_vs_state(pipe, state);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    if (!result)
       return NULL;
@@ -467,14 +468,14 @@ rbug_bind_vs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *vs;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    vs = rbug_shader_unwrap(_vs);
    rb_pipe->curr.shader[PIPE_SHADER_VERTEX] = rbug_shader(_vs);
    pipe->bind_vs_state(pipe,
                        vs);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -484,9 +485,9 @@ rbug_delete_vs_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct rbug_shader *rb_shader = rbug_shader(_vs);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
    rbug_shader_destroy(rb_pipe, rb_shader);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -497,9 +498,9 @@ rbug_create_gs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *result;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    result = pipe->create_gs_state(pipe, state);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    if (!result)
       return NULL;
@@ -515,14 +516,14 @@ rbug_bind_gs_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *gs;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    gs = rbug_shader_unwrap(_gs);
    rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] = rbug_shader(_gs);
    pipe->bind_gs_state(pipe,
                        gs);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -532,9 +533,9 @@ rbug_delete_gs_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct rbug_shader *rb_shader = rbug_shader(_gs);
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    rbug_shader_destroy(rb_pipe, rb_shader);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void *
@@ -546,11 +547,11 @@ rbug_create_vertex_elements_state(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    void *ret;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    ret = pipe->create_vertex_elements_state(pipe,
                                              num_elements,
                                              vertex_elements);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    return ret;
 }
@@ -562,10 +563,10 @@ rbug_bind_vertex_elements_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->bind_vertex_elements_state(pipe,
                                     velems);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -575,10 +576,10 @@ rbug_delete_vertex_elements_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->delete_vertex_elements_state(pipe,
                                       velems);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -588,10 +589,10 @@ rbug_set_blend_color(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_blend_color(pipe,
                          blend_color);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -601,10 +602,10 @@ rbug_set_stencil_ref(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_stencil_ref(pipe,
                          stencil_ref);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -614,15 +615,15 @@ rbug_set_clip_state(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_clip_state(pipe,
                         clip);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
 rbug_set_constant_buffer(struct pipe_context *_pipe,
-                         uint shader,
+                         enum pipe_shader_type shader,
                          uint index,
                          const struct pipe_constant_buffer *_cb)
 {
@@ -636,12 +637,12 @@ rbug_set_constant_buffer(struct pipe_context *_pipe,
       cb.buffer = rbug_resource_unwrap(_cb->buffer);
    }
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_constant_buffer(pipe,
                              shader,
                              index,
                              _cb ? &cb : NULL);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -655,7 +656,7 @@ rbug_set_framebuffer_state(struct pipe_context *_pipe,
    unsigned i;
 
    /* must protect curr status */
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    rb_pipe->curr.nr_cbufs = 0;
    memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs));
@@ -680,7 +681,7 @@ rbug_set_framebuffer_state(struct pipe_context *_pipe,
    pipe->set_framebuffer_state(pipe,
                                state);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -690,10 +691,10 @@ rbug_set_polygon_stipple(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_polygon_stipple(pipe,
                              poly_stipple);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -705,9 +706,9 @@ rbug_set_scissor_states(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_scissor_states(pipe, start_slot, num_scissors, scissor);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -719,14 +720,14 @@ rbug_set_viewport_states(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_viewport_states(pipe, start_slot, num_viewports, viewport);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
 rbug_set_sampler_views(struct pipe_context *_pipe,
-                       unsigned shader,
+                       enum pipe_shader_type shader,
                        unsigned start,
                        unsigned num,
                        struct pipe_sampler_view **_views)
@@ -740,7 +741,7 @@ rbug_set_sampler_views(struct pipe_context *_pipe,
    assert(start == 0); /* XXX fix */
 
    /* must protect curr status */
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    rb_pipe->curr.num_views[shader] = 0;
    memset(rb_pipe->curr.views[shader], 0, sizeof(rb_pipe->curr.views[shader]));
@@ -759,7 +760,7 @@ rbug_set_sampler_views(struct pipe_context *_pipe,
 
    pipe->set_sampler_views(pipe, shader, start, num, views);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -773,12 +774,15 @@ rbug_set_vertex_buffers(struct pipe_context *_pipe,
    struct pipe_vertex_buffer *buffers = NULL;
    unsigned i;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
 
    if (num_buffers && _buffers) {
       memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
-      for (i = 0; i < num_buffers; i++)
-         unwrapped_buffers[i].buffer = rbug_resource_unwrap(_buffers[i].buffer);
+      for (i = 0; i < num_buffers; i++) {
+         if (!_buffers[i].is_user_buffer)
+            unwrapped_buffers[i].buffer.resource =
+               rbug_resource_unwrap(_buffers[i].buffer.resource);
+      }
       buffers = unwrapped_buffers;
    }
 
@@ -786,26 +790,7 @@ rbug_set_vertex_buffers(struct pipe_context *_pipe,
                             num_buffers,
                             buffers);
 
-   pipe_mutex_unlock(rb_pipe->call_mutex);
-}
-
-static void
-rbug_set_index_buffer(struct pipe_context *_pipe,
-                      const struct pipe_index_buffer *_ib)
-{
-   struct rbug_context *rb_pipe = rbug_context(_pipe);
-   struct pipe_context *pipe = rb_pipe->pipe;
-   struct pipe_index_buffer unwrapped_ib, *ib = NULL;
-
-   if (_ib) {
-      unwrapped_ib = *_ib;
-      unwrapped_ib.buffer = rbug_resource_unwrap(_ib->buffer);
-      ib = &unwrapped_ib;
-   }
-
-   pipe_mutex_lock(rb_pipe->call_mutex);
-   pipe->set_index_buffer(pipe, ib);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -815,9 +800,9 @@ rbug_set_sample_mask(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_sample_mask(pipe, sample_mask);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static struct pipe_stream_output_target *
@@ -830,10 +815,10 @@ rbug_create_stream_output_target(struct pipe_context *_pipe,
    struct pipe_resource *res = rbug_resource_unwrap(_res);
    struct pipe_stream_output_target *target;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    target = pipe->create_stream_output_target(pipe, res, buffer_offset,
                                               buffer_size);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
    return target;
 }
 
@@ -844,9 +829,9 @@ rbug_stream_output_target_destroy(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->stream_output_target_destroy(pipe, target);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -858,9 +843,9 @@ rbug_set_stream_output_targets(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->set_stream_output_targets(pipe, num_targets, targets, offsets);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -881,7 +866,7 @@ rbug_resource_copy_region(struct pipe_context *_pipe,
    struct pipe_resource *dst = rb_resource_dst->resource;
    struct pipe_resource *src = rb_resource_src->resource;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->resource_copy_region(pipe,
                               dst,
                               dst_level,
@@ -891,7 +876,7 @@ rbug_resource_copy_region(struct pipe_context *_pipe,
                               src,
                               src_level,
                               src_box);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -909,9 +894,9 @@ rbug_blit(struct pipe_context *_pipe, const struct pipe_blit_info *_blit_info)
    blit_info.dst.resource = dst;
    blit_info.src.resource = src;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->blit(pipe, &blit_info);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -923,9 +908,9 @@ rbug_flush_resource(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    struct pipe_resource *res = rb_resource_res->resource;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->flush_resource(pipe, res);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -938,13 +923,13 @@ rbug_clear(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->clear(pipe,
                buffers,
                color,
                depth,
                stencil);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -960,7 +945,7 @@ rbug_clear_render_target(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    struct pipe_surface *dst = rb_surface_dst->surface;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->clear_render_target(pipe,
                              dst,
                              color,
@@ -969,7 +954,7 @@ rbug_clear_render_target(struct pipe_context *_pipe,
                              width,
                              height,
                              render_condition_enabled);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -987,7 +972,7 @@ rbug_clear_depth_stencil(struct pipe_context *_pipe,
    struct pipe_context *pipe = rb_pipe->pipe;
    struct pipe_surface *dst = rb_surface_dst->surface;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->clear_depth_stencil(pipe,
                              dst,
                              clear_flags,
@@ -998,7 +983,7 @@ rbug_clear_depth_stencil(struct pipe_context *_pipe,
                              width,
                              height,
                              render_condition_enabled);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static void
@@ -1009,9 +994,9 @@ rbug_flush(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    pipe->flush(pipe, fence, flags);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 static struct pipe_sampler_view *
@@ -1025,11 +1010,11 @@ rbug_context_create_sampler_view(struct pipe_context *_pipe,
    struct pipe_resource *resource = rb_resource->resource;
    struct pipe_sampler_view *result;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    result = pipe->create_sampler_view(pipe,
                                       resource,
                                       templ);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    if (result)
       return rbug_sampler_view_create(rb_pipe, rb_resource, result);
@@ -1055,11 +1040,11 @@ rbug_context_create_surface(struct pipe_context *_pipe,
    struct pipe_resource *resource = rb_resource->resource;
    struct pipe_surface *result;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    result = pipe->create_surface(pipe,
                                  resource,
                                  surf_tmpl);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    if (result)
       return rbug_surface_create(rb_pipe, rb_resource, result);
@@ -1073,10 +1058,10 @@ rbug_context_surface_destroy(struct pipe_context *_pipe,
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct rbug_surface *rb_surface = rbug_surface(_surface);
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    rbug_surface_destroy(rb_pipe,
                         rb_surface);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 
@@ -1096,13 +1081,13 @@ rbug_context_transfer_map(struct pipe_context *_context,
    struct pipe_transfer *result;
    void *map;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    map = context->transfer_map(context,
                                resource,
                                level,
                                usage,
                                box, &result);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 
    *transfer = rbug_transfer_create(rb_pipe, rb_resource, result);
    return *transfer ? map : NULL;
@@ -1118,11 +1103,11 @@ rbug_context_transfer_flush_region(struct pipe_context *_context,
    struct pipe_context *context = rb_pipe->pipe;
    struct pipe_transfer *transfer = rb_transfer->transfer;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    context->transfer_flush_region(context,
                                   transfer,
                                   box);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 
@@ -1135,12 +1120,12 @@ rbug_context_transfer_unmap(struct pipe_context *_context,
    struct pipe_context *context = rb_pipe->pipe;
    struct pipe_transfer *transfer = rb_transfer->transfer;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    context->transfer_unmap(context,
                            transfer);
    rbug_transfer_destroy(rb_pipe,
                          rb_transfer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 
@@ -1155,9 +1140,9 @@ rbug_context_buffer_subdata(struct pipe_context *_context,
    struct pipe_context *context = rb_pipe->pipe;
    struct pipe_resource *resource = rb_resource->resource;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    context->buffer_subdata(context, resource, usage, offset, size, data);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 
@@ -1176,7 +1161,7 @@ rbug_context_texture_subdata(struct pipe_context *_context,
    struct pipe_context *context = rb_pipe->pipe;
    struct pipe_resource *resource = rb_resource->resource;
 
-   pipe_mutex_lock(rb_pipe->call_mutex);
+   mtx_lock(&rb_pipe->call_mutex);
    context->texture_subdata(context,
                             resource,
                             level,
@@ -1185,7 +1170,7 @@ rbug_context_texture_subdata(struct pipe_context *_context,
                             data,
                             stride,
                             layer_stride);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
+   mtx_unlock(&rb_pipe->call_mutex);
 }
 
 
@@ -1202,15 +1187,17 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    if (!rb_pipe)
       return NULL;
 
-   pipe_mutex_init(rb_pipe->draw_mutex);
-   pipe_condvar_init(rb_pipe->draw_cond);
-   pipe_mutex_init(rb_pipe->call_mutex);
-   pipe_mutex_init(rb_pipe->list_mutex);
+   (void) mtx_init(&rb_pipe->draw_mutex, mtx_plain);
+   cnd_init(&rb_pipe->draw_cond);
+   (void) mtx_init(&rb_pipe->call_mutex, mtx_plain);
+   (void) mtx_init(&rb_pipe->list_mutex, mtx_plain);
    make_empty_list(&rb_pipe->shaders);
 
    rb_pipe->base.screen = _screen;
    rb_pipe->base.priv = pipe->priv; /* expose wrapped data */
    rb_pipe->base.draw = NULL;
+   rb_pipe->base.stream_uploader = pipe->stream_uploader;
+   rb_pipe->base.const_uploader = pipe->const_uploader;
 
    rb_pipe->base.destroy = rbug_destroy;
    rb_pipe->base.draw_vbo = rbug_draw_vbo;
@@ -1254,7 +1241,6 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    rb_pipe->base.set_viewport_states = rbug_set_viewport_states;
    rb_pipe->base.set_sampler_views = rbug_set_sampler_views;
    rb_pipe->base.set_vertex_buffers = rbug_set_vertex_buffers;
-   rb_pipe->base.set_index_buffer = rbug_set_index_buffer;
    rb_pipe->base.set_sample_mask = rbug_set_sample_mask;
    rb_pipe->base.create_stream_output_target = rbug_create_stream_output_target;
    rb_pipe->base.stream_output_target_destroy = rbug_stream_output_target_destroy;