Module: Mesa
Branch: main
Commit: 7da5b8dac09b5bca4db7b9e7d09759340c4ed972
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7da5b8dac09b5bca4db7b9e7d09759340c4ed972

Author: Marek Olšák <[email protected]>
Date:   Thu Dec  7 16:06:40 2023 -0500

cso: do cso_context inheritance how we do it elsewhere

Currently, we have:
- cso_context_base is the base class, but cso_context is passed to functions
- cso_context is the derived class

Change:
- cso_context to become the base class, and is passed to functions
- cso_context_priv to become the derived class.

mesa/main will need to access the base class directly.

Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26619>

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 218 +++++++++++++++-----------
 src/gallium/auxiliary/cso_cache/cso_context.h |  14 +-
 2 files changed, 131 insertions(+), 101 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 11d6e506ade..fd24be07d2d 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -62,8 +62,8 @@ struct sampler_info
 
 
 
-struct cso_context {
-   struct cso_context_base base;
+struct cso_context_priv {
+   struct cso_context base;
 
    struct u_vbuf *vbuf;
    struct u_vbuf *vbuf_current;
@@ -126,7 +126,7 @@ struct cso_context {
 
 
 static inline bool
-delete_cso(struct cso_context *ctx,
+delete_cso(struct cso_context_priv *ctx,
            void *state, enum cso_cache_type type)
 {
    switch (type) {
@@ -166,7 +166,7 @@ static inline void
 sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
               int max_size, void *user_data)
 {
-   struct cso_context *ctx = (struct cso_context *)user_data;
+   struct cso_context_priv *ctx = (struct cso_context_priv *)user_data;
    /* if we're approach the maximum size, remove fourth of the entries
     * otherwise every subsequent call will go through the same */
    const int hash_size = cso_hash_size(hash);
@@ -241,7 +241,7 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type 
type,
 
 
 static void
-cso_init_vbuf(struct cso_context *cso, unsigned flags)
+cso_init_vbuf(struct cso_context_priv *cso, unsigned flags)
 {
    struct u_vbuf_caps caps;
    bool uses_user_vertex_buffers = !(flags & CSO_NO_USER_VERTEX_BUFFERS);
@@ -279,7 +279,7 @@ cso_draw_vbo_default(struct pipe_context *pipe,
 struct cso_context *
 cso_create_context(struct pipe_context *pipe, unsigned flags)
 {
-   struct cso_context *ctx = CALLOC_STRUCT(cso_context);
+   struct cso_context_priv *ctx = CALLOC_STRUCT(cso_context_priv);
    if (!ctx)
       return NULL;
 
@@ -347,13 +347,14 @@ cso_create_context(struct pipe_context *pipe, unsigned 
flags)
                                      PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
 
    ctx->max_sampler_seen = -1;
-   return ctx;
+   return &ctx->base;
 }
 
 
 void
-cso_unbind_context(struct cso_context *ctx)
+cso_unbind_context(struct cso_context *cso)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    unsigned i;
 
    bool dumping = trace_dumping_enabled_locked();
@@ -466,8 +467,8 @@ cso_unbind_context(struct cso_context *ctx)
 
    memset(&ctx->samplers, 0, sizeof(ctx->samplers));
    memset(&ctx->nr_so_targets, 0,
-          offsetof(struct cso_context, cache)
-          - offsetof(struct cso_context, nr_so_targets));
+          offsetof(struct cso_context_priv, cache)
+          - offsetof(struct cso_context_priv, nr_so_targets));
    ctx->sample_mask = ~0;
    /*
     * If the cso context is reused (with the same pipe context),
@@ -485,9 +486,11 @@ cso_unbind_context(struct cso_context *ctx)
  * Free the CSO context.
  */
 void
-cso_destroy_context(struct cso_context *ctx)
+cso_destroy_context(struct cso_context *cso)
 {
-   cso_unbind_context(ctx);
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
+   cso_unbind_context(cso);
    cso_cache_delete(&ctx->cache);
 
    if (ctx->vbuf)
@@ -512,9 +515,10 @@ cso_destroy_context(struct cso_context *ctx)
  */
 
 enum pipe_error
-cso_set_blend(struct cso_context *ctx,
+cso_set_blend(struct cso_context *cso,
               const struct pipe_blend_state *templ)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    unsigned key_size, hash_key;
    struct cso_hash_iter iter;
    void *handle;
@@ -564,7 +568,7 @@ cso_set_blend(struct cso_context *ctx,
 
 
 static void
-cso_save_blend(struct cso_context *ctx)
+cso_save_blend(struct cso_context_priv *ctx)
 {
    assert(!ctx->blend_saved);
    ctx->blend_saved = ctx->blend;
@@ -572,7 +576,7 @@ cso_save_blend(struct cso_context *ctx)
 
 
 static void
-cso_restore_blend(struct cso_context *ctx)
+cso_restore_blend(struct cso_context_priv *ctx)
 {
    if (ctx->blend != ctx->blend_saved) {
       ctx->blend = ctx->blend_saved;
@@ -583,9 +587,10 @@ cso_restore_blend(struct cso_context *ctx)
 
 
 enum pipe_error
-cso_set_depth_stencil_alpha(struct cso_context *ctx,
+cso_set_depth_stencil_alpha(struct cso_context *cso,
                             const struct pipe_depth_stencil_alpha_state *templ)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    const unsigned key_size = sizeof(struct pipe_depth_stencil_alpha_state);
    const unsigned hash_key = cso_construct_key(templ, key_size);
    struct cso_hash_iter iter = cso_find_state_template(&ctx->cache,
@@ -626,7 +631,7 @@ cso_set_depth_stencil_alpha(struct cso_context *ctx,
 
 
 static void
-cso_save_depth_stencil_alpha(struct cso_context *ctx)
+cso_save_depth_stencil_alpha(struct cso_context_priv *ctx)
 {
    assert(!ctx->depth_stencil_saved);
    ctx->depth_stencil_saved = ctx->depth_stencil;
@@ -634,7 +639,7 @@ cso_save_depth_stencil_alpha(struct cso_context *ctx)
 
 
 static void
-cso_restore_depth_stencil_alpha(struct cso_context *ctx)
+cso_restore_depth_stencil_alpha(struct cso_context_priv *ctx)
 {
    if (ctx->depth_stencil != ctx->depth_stencil_saved) {
       ctx->depth_stencil = ctx->depth_stencil_saved;
@@ -646,9 +651,10 @@ cso_restore_depth_stencil_alpha(struct cso_context *ctx)
 
 
 enum pipe_error
-cso_set_rasterizer(struct cso_context *ctx,
+cso_set_rasterizer(struct cso_context *cso,
                    const struct pipe_rasterizer_state *templ)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    const unsigned key_size = sizeof(struct pipe_rasterizer_state);
    const unsigned hash_key = cso_construct_key(templ, key_size);
    struct cso_hash_iter iter = cso_find_state_template(&ctx->cache,
@@ -693,7 +699,7 @@ cso_set_rasterizer(struct cso_context *ctx,
 
 
 static void
-cso_save_rasterizer(struct cso_context *ctx)
+cso_save_rasterizer(struct cso_context_priv *ctx)
 {
    assert(!ctx->rasterizer_saved);
    ctx->rasterizer_saved = ctx->rasterizer;
@@ -702,7 +708,7 @@ cso_save_rasterizer(struct cso_context *ctx)
 
 
 static void
-cso_restore_rasterizer(struct cso_context *ctx)
+cso_restore_rasterizer(struct cso_context_priv *ctx)
 {
    if (ctx->rasterizer != ctx->rasterizer_saved) {
       ctx->rasterizer = ctx->rasterizer_saved;
@@ -716,8 +722,10 @@ cso_restore_rasterizer(struct cso_context *ctx)
 
 
 void
-cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_fragment_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (ctx->fragment_shader != handle) {
       ctx->fragment_shader = handle;
       ctx->base.pipe->bind_fs_state(ctx->base.pipe, handle);
@@ -726,7 +734,7 @@ cso_set_fragment_shader_handle(struct cso_context *ctx, 
void *handle)
 
 
 static void
-cso_save_fragment_shader(struct cso_context *ctx)
+cso_save_fragment_shader(struct cso_context_priv *ctx)
 {
    assert(!ctx->fragment_shader_saved);
    ctx->fragment_shader_saved = ctx->fragment_shader;
@@ -734,7 +742,7 @@ cso_save_fragment_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_fragment_shader(struct cso_context *ctx)
+cso_restore_fragment_shader(struct cso_context_priv *ctx)
 {
    if (ctx->fragment_shader_saved != ctx->fragment_shader) {
       ctx->base.pipe->bind_fs_state(ctx->base.pipe, 
ctx->fragment_shader_saved);
@@ -745,8 +753,10 @@ cso_restore_fragment_shader(struct cso_context *ctx)
 
 
 void
-cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_vertex_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (ctx->vertex_shader != handle) {
       ctx->vertex_shader = handle;
       ctx->base.pipe->bind_vs_state(ctx->base.pipe, handle);
@@ -755,7 +765,7 @@ cso_set_vertex_shader_handle(struct cso_context *ctx, void 
*handle)
 
 
 static void
-cso_save_vertex_shader(struct cso_context *ctx)
+cso_save_vertex_shader(struct cso_context_priv *ctx)
 {
    assert(!ctx->vertex_shader_saved);
    ctx->vertex_shader_saved = ctx->vertex_shader;
@@ -763,7 +773,7 @@ cso_save_vertex_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_vertex_shader(struct cso_context *ctx)
+cso_restore_vertex_shader(struct cso_context_priv *ctx)
 {
    if (ctx->vertex_shader_saved != ctx->vertex_shader) {
       ctx->base.pipe->bind_vs_state(ctx->base.pipe, ctx->vertex_shader_saved);
@@ -774,9 +784,11 @@ cso_restore_vertex_shader(struct cso_context *ctx)
 
 
 void
-cso_set_framebuffer(struct cso_context *ctx,
+cso_set_framebuffer(struct cso_context *cso,
                     const struct pipe_framebuffer_state *fb)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (memcmp(&ctx->fb, fb, sizeof(*fb)) != 0) {
       util_copy_framebuffer_state(&ctx->fb, fb);
       ctx->base.pipe->set_framebuffer_state(ctx->base.pipe, fb);
@@ -785,14 +797,14 @@ cso_set_framebuffer(struct cso_context *ctx,
 
 
 static void
-cso_save_framebuffer(struct cso_context *ctx)
+cso_save_framebuffer(struct cso_context_priv *ctx)
 {
    util_copy_framebuffer_state(&ctx->fb_saved, &ctx->fb);
 }
 
 
 static void
-cso_restore_framebuffer(struct cso_context *ctx)
+cso_restore_framebuffer(struct cso_context_priv *ctx)
 {
    if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) {
       util_copy_framebuffer_state(&ctx->fb, &ctx->fb_saved);
@@ -803,9 +815,11 @@ cso_restore_framebuffer(struct cso_context *ctx)
 
 
 void
-cso_set_viewport(struct cso_context *ctx,
+cso_set_viewport(struct cso_context *cso,
                  const struct pipe_viewport_state *vp)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (memcmp(&ctx->vp, vp, sizeof(*vp))) {
       ctx->vp = *vp;
       ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, vp);
@@ -837,14 +851,14 @@ cso_set_viewport_dims(struct cso_context *ctx,
 
 
 static void
-cso_save_viewport(struct cso_context *ctx)
+cso_save_viewport(struct cso_context_priv *ctx)
 {
    ctx->vp_saved = ctx->vp;
 }
 
 
 static void
-cso_restore_viewport(struct cso_context *ctx)
+cso_restore_viewport(struct cso_context_priv *ctx)
 {
    if (memcmp(&ctx->vp, &ctx->vp_saved, sizeof(ctx->vp))) {
       ctx->vp = ctx->vp_saved;
@@ -854,8 +868,10 @@ cso_restore_viewport(struct cso_context *ctx)
 
 
 void
-cso_set_sample_mask(struct cso_context *ctx, unsigned sample_mask)
+cso_set_sample_mask(struct cso_context *cso, unsigned sample_mask)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (ctx->sample_mask != sample_mask) {
       ctx->sample_mask = sample_mask;
       ctx->base.pipe->set_sample_mask(ctx->base.pipe, sample_mask);
@@ -864,22 +880,24 @@ cso_set_sample_mask(struct cso_context *ctx, unsigned 
sample_mask)
 
 
 static void
-cso_save_sample_mask(struct cso_context *ctx)
+cso_save_sample_mask(struct cso_context_priv *ctx)
 {
    ctx->sample_mask_saved = ctx->sample_mask;
 }
 
 
 static void
-cso_restore_sample_mask(struct cso_context *ctx)
+cso_restore_sample_mask(struct cso_context_priv *ctx)
 {
-   cso_set_sample_mask(ctx, ctx->sample_mask_saved);
+   cso_set_sample_mask(&ctx->base, ctx->sample_mask_saved);
 }
 
 
 void
-cso_set_min_samples(struct cso_context *ctx, unsigned min_samples)
+cso_set_min_samples(struct cso_context *cso, unsigned min_samples)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (ctx->min_samples != min_samples && ctx->base.pipe->set_min_samples) {
       ctx->min_samples = min_samples;
       ctx->base.pipe->set_min_samples(ctx->base.pipe, min_samples);
@@ -888,23 +906,25 @@ cso_set_min_samples(struct cso_context *ctx, unsigned 
min_samples)
 
 
 static void
-cso_save_min_samples(struct cso_context *ctx)
+cso_save_min_samples(struct cso_context_priv *ctx)
 {
    ctx->min_samples_saved = ctx->min_samples;
 }
 
 
 static void
-cso_restore_min_samples(struct cso_context *ctx)
+cso_restore_min_samples(struct cso_context_priv *ctx)
 {
-   cso_set_min_samples(ctx, ctx->min_samples_saved);
+   cso_set_min_samples(&ctx->base, ctx->min_samples_saved);
 }
 
 
 void
-cso_set_stencil_ref(struct cso_context *ctx,
+cso_set_stencil_ref(struct cso_context *cso,
                     const struct pipe_stencil_ref sr)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    if (memcmp(&ctx->stencil_ref, &sr, sizeof(ctx->stencil_ref))) {
       ctx->stencil_ref = sr;
       ctx->base.pipe->set_stencil_ref(ctx->base.pipe, sr);
@@ -913,14 +933,14 @@ cso_set_stencil_ref(struct cso_context *ctx,
 
 
 static void
-cso_save_stencil_ref(struct cso_context *ctx)
+cso_save_stencil_ref(struct cso_context_priv *ctx)
 {
    ctx->stencil_ref_saved = ctx->stencil_ref;
 }
 
 
 static void
-cso_restore_stencil_ref(struct cso_context *ctx)
+cso_restore_stencil_ref(struct cso_context_priv *ctx)
 {
    if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved,
               sizeof(ctx->stencil_ref))) {
@@ -931,11 +951,12 @@ cso_restore_stencil_ref(struct cso_context *ctx)
 
 
 void
-cso_set_render_condition(struct cso_context *ctx,
+cso_set_render_condition(struct cso_context *cso,
                          struct pipe_query *query,
                          bool condition,
                          enum pipe_render_cond_flag mode)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct pipe_context *pipe = ctx->base.pipe;
 
    if (ctx->render_condition != query ||
@@ -950,7 +971,7 @@ cso_set_render_condition(struct cso_context *ctx,
 
 
 static void
-cso_save_render_condition(struct cso_context *ctx)
+cso_save_render_condition(struct cso_context_priv *ctx)
 {
    ctx->render_condition_saved = ctx->render_condition;
    ctx->render_condition_cond_saved = ctx->render_condition_cond;
@@ -959,17 +980,18 @@ cso_save_render_condition(struct cso_context *ctx)
 
 
 static void
-cso_restore_render_condition(struct cso_context *ctx)
+cso_restore_render_condition(struct cso_context_priv *ctx)
 {
-   cso_set_render_condition(ctx, ctx->render_condition_saved,
+   cso_set_render_condition(&ctx->base, ctx->render_condition_saved,
                             ctx->render_condition_cond_saved,
                             ctx->render_condition_mode_saved);
 }
 
 
 void
-cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_geometry_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    assert(ctx->has_geometry_shader || !handle);
 
    if (ctx->has_geometry_shader && ctx->geometry_shader != handle) {
@@ -980,7 +1002,7 @@ cso_set_geometry_shader_handle(struct cso_context *ctx, 
void *handle)
 
 
 static void
-cso_save_geometry_shader(struct cso_context *ctx)
+cso_save_geometry_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_geometry_shader) {
       return;
@@ -992,7 +1014,7 @@ cso_save_geometry_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_geometry_shader(struct cso_context *ctx)
+cso_restore_geometry_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_geometry_shader) {
       return;
@@ -1007,8 +1029,9 @@ cso_restore_geometry_shader(struct cso_context *ctx)
 
 
 void
-cso_set_tessctrl_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_tessctrl_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    assert(ctx->has_tessellation || !handle);
 
    if (ctx->has_tessellation && ctx->tessctrl_shader != handle) {
@@ -1019,7 +1042,7 @@ cso_set_tessctrl_shader_handle(struct cso_context *ctx, 
void *handle)
 
 
 static void
-cso_save_tessctrl_shader(struct cso_context *ctx)
+cso_save_tessctrl_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -1031,7 +1054,7 @@ cso_save_tessctrl_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_tessctrl_shader(struct cso_context *ctx)
+cso_restore_tessctrl_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -1046,8 +1069,10 @@ cso_restore_tessctrl_shader(struct cso_context *ctx)
 
 
 void
-cso_set_tesseval_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_tesseval_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    assert(ctx->has_tessellation || !handle);
 
    if (ctx->has_tessellation && ctx->tesseval_shader != handle) {
@@ -1058,7 +1083,7 @@ cso_set_tesseval_shader_handle(struct cso_context *ctx, 
void *handle)
 
 
 static void
-cso_save_tesseval_shader(struct cso_context *ctx)
+cso_save_tesseval_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -1070,7 +1095,7 @@ cso_save_tesseval_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_tesseval_shader(struct cso_context *ctx)
+cso_restore_tesseval_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -1085,8 +1110,9 @@ cso_restore_tesseval_shader(struct cso_context *ctx)
 
 
 void
-cso_set_compute_shader_handle(struct cso_context *ctx, void *handle)
+cso_set_compute_shader_handle(struct cso_context *cso, void *handle)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    assert(ctx->has_compute_shader || !handle);
 
    if (ctx->has_compute_shader && ctx->compute_shader != handle) {
@@ -1097,7 +1123,7 @@ cso_set_compute_shader_handle(struct cso_context *ctx, 
void *handle)
 
 
 static void
-cso_save_compute_shader(struct cso_context *ctx)
+cso_save_compute_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_compute_shader) {
       return;
@@ -1109,7 +1135,7 @@ cso_save_compute_shader(struct cso_context *ctx)
 
 
 static void
-cso_restore_compute_shader(struct cso_context *ctx)
+cso_restore_compute_shader(struct cso_context_priv *ctx)
 {
    if (!ctx->has_compute_shader) {
       return;
@@ -1124,7 +1150,7 @@ cso_restore_compute_shader(struct cso_context *ctx)
 
 
 static void
-cso_save_compute_samplers(struct cso_context *ctx)
+cso_save_compute_samplers(struct cso_context_priv *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_COMPUTE];
    struct sampler_info *saved = &ctx->compute_samplers_saved;
@@ -1136,7 +1162,7 @@ cso_save_compute_samplers(struct cso_context *ctx)
 
 
 static void
-cso_restore_compute_samplers(struct cso_context *ctx)
+cso_restore_compute_samplers(struct cso_context_priv *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_COMPUTE];
    struct sampler_info *saved = &ctx->compute_samplers_saved;
@@ -1152,12 +1178,12 @@ cso_restore_compute_samplers(struct cso_context *ctx)
       }
    }
 
-   cso_single_sampler_done(ctx, PIPE_SHADER_COMPUTE);
+   cso_single_sampler_done(&ctx->base, PIPE_SHADER_COMPUTE);
 }
 
 
 static void
-cso_set_vertex_elements_direct(struct cso_context *ctx,
+cso_set_vertex_elements_direct(struct cso_context_priv *ctx,
                                const struct cso_velems_state *velems)
 {
    /* Need to include the count into the stored state data too.
@@ -1208,9 +1234,10 @@ cso_set_vertex_elements_direct(struct cso_context *ctx,
 
 
 enum pipe_error
-cso_set_vertex_elements(struct cso_context *ctx,
+cso_set_vertex_elements(struct cso_context *cso,
                         const struct cso_velems_state *velems)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct u_vbuf *vbuf = ctx->vbuf_current;
 
    if (vbuf) {
@@ -1224,7 +1251,7 @@ cso_set_vertex_elements(struct cso_context *ctx,
 
 
 static void
-cso_save_vertex_elements(struct cso_context *ctx)
+cso_save_vertex_elements(struct cso_context_priv *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf_current;
 
@@ -1239,7 +1266,7 @@ cso_save_vertex_elements(struct cso_context *ctx)
 
 
 static void
-cso_restore_vertex_elements(struct cso_context *ctx)
+cso_restore_vertex_elements(struct cso_context_priv *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf_current;
 
@@ -1258,12 +1285,13 @@ cso_restore_vertex_elements(struct cso_context *ctx)
 /* vertex buffers */
 
 void
-cso_set_vertex_buffers(struct cso_context *ctx,
+cso_set_vertex_buffers(struct cso_context *cso,
                        unsigned count,
                        unsigned unbind_trailing_count,
                        bool take_ownership,
                        const struct pipe_vertex_buffer *buffers)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct u_vbuf *vbuf = ctx->vbuf_current;
 
    if (!count && !unbind_trailing_count)
@@ -1294,7 +1322,7 @@ cso_set_vertex_buffers(struct cso_context *ctx,
  * u_vbuf, not both.
  */
 void
-cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
+cso_set_vertex_buffers_and_elements(struct cso_context *cso,
                                     const struct cso_velems_state *velems,
                                     unsigned vb_count,
                                     unsigned unbind_trailing_vb_count,
@@ -1302,6 +1330,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context 
*ctx,
                                     bool uses_user_vertex_buffers,
                                     const struct pipe_vertex_buffer *vbuffers)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct u_vbuf *vbuf = ctx->vbuf;
    struct pipe_context *pipe = ctx->base.pipe;
 
@@ -1352,7 +1381,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context 
*ctx,
 
 
 ALWAYS_INLINE static struct cso_sampler *
-set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
+set_sampler(struct cso_context_priv *ctx, enum pipe_shader_type shader_stage,
             unsigned idx, const struct pipe_sampler_state *templ,
             size_t key_size)
 {
@@ -1385,7 +1414,7 @@ set_sampler(struct cso_context *ctx, enum 
pipe_shader_type shader_stage,
 
 
 ALWAYS_INLINE static bool
-cso_set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
+cso_set_sampler(struct cso_context_priv *ctx, enum pipe_shader_type 
shader_stage,
                 unsigned idx, const struct pipe_sampler_state *templ,
                 size_t size)
 {
@@ -1397,9 +1426,11 @@ cso_set_sampler(struct cso_context *ctx, enum 
pipe_shader_type shader_stage,
 
 
 void
-cso_single_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
+cso_single_sampler(struct cso_context *cso, enum pipe_shader_type shader_stage,
                    unsigned idx, const struct pipe_sampler_state *templ)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
+
    /* The reasons both blocks are duplicated is that we want the size parameter
     * to be a constant expression to inline and unroll memcmp and hash key
     * computations.
@@ -1420,9 +1451,10 @@ cso_single_sampler(struct cso_context *ctx, enum 
pipe_shader_type shader_stage,
  * Send staged sampler state to the driver.
  */
 void
-cso_single_sampler_done(struct cso_context *ctx,
+cso_single_sampler_done(struct cso_context *cso,
                         enum pipe_shader_type shader_stage)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct sampler_info *info = &ctx->samplers[shader_stage];
 
    if (ctx->max_sampler_seen == -1)
@@ -1436,7 +1468,7 @@ cso_single_sampler_done(struct cso_context *ctx,
 
 
 ALWAYS_INLINE static int
-set_samplers(struct cso_context *ctx,
+set_samplers(struct cso_context_priv *ctx,
              enum pipe_shader_type shader_stage,
              unsigned nr,
              const struct pipe_sampler_state **templates,
@@ -1484,11 +1516,12 @@ set_samplers(struct cso_context *ctx,
  * as possible.
  */
 void
-cso_set_samplers(struct cso_context *ctx,
+cso_set_samplers(struct cso_context *cso,
                  enum pipe_shader_type shader_stage,
                  unsigned nr,
                  const struct pipe_sampler_state **templates)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    int last;
 
    /* ensure sampler size is a constant for memcmp */
@@ -1501,12 +1534,12 @@ cso_set_samplers(struct cso_context *ctx,
    }
 
    ctx->max_sampler_seen = MAX2(ctx->max_sampler_seen, last);
-   cso_single_sampler_done(ctx, shader_stage);
+   cso_single_sampler_done(&ctx->base, shader_stage);
 }
 
 
 static void
-cso_save_fragment_samplers(struct cso_context *ctx)
+cso_save_fragment_samplers(struct cso_context_priv *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
    struct sampler_info *saved = &ctx->fragment_samplers_saved;
@@ -1518,7 +1551,7 @@ cso_save_fragment_samplers(struct cso_context *ctx)
 
 
 static void
-cso_restore_fragment_samplers(struct cso_context *ctx)
+cso_restore_fragment_samplers(struct cso_context_priv *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
    struct sampler_info *saved = &ctx->fragment_samplers_saved;
@@ -1534,16 +1567,17 @@ cso_restore_fragment_samplers(struct cso_context *ctx)
       }
    }
 
-   cso_single_sampler_done(ctx, PIPE_SHADER_FRAGMENT);
+   cso_single_sampler_done(&ctx->base, PIPE_SHADER_FRAGMENT);
 }
 
 
 void
-cso_set_stream_outputs(struct cso_context *ctx,
+cso_set_stream_outputs(struct cso_context *cso,
                        unsigned num_targets,
                        struct pipe_stream_output_target **targets,
                        const unsigned *offsets)
 {
+   struct cso_context_priv *ctx = (struct cso_context_priv *)cso;
    struct pipe_context *pipe = ctx->base.pipe;
    unsigned i;
 
@@ -1573,7 +1607,7 @@ cso_set_stream_outputs(struct cso_context *ctx,
 
 
 static void
-cso_save_stream_outputs(struct cso_context *ctx)
+cso_save_stream_outputs(struct cso_context_priv *ctx)
 {
    if (!ctx->has_streamout) {
       return;
@@ -1589,7 +1623,7 @@ cso_save_stream_outputs(struct cso_context *ctx)
 
 
 static void
-cso_restore_stream_outputs(struct cso_context *ctx)
+cso_restore_stream_outputs(struct cso_context_priv *ctx)
 {
    struct pipe_context *pipe = ctx->base.pipe;
    unsigned i;
@@ -1630,8 +1664,9 @@ cso_restore_stream_outputs(struct cso_context *ctx)
  * of CSO_BIT_x flags.
  */
 void
-cso_save_state(struct cso_context *cso, unsigned state_mask)
+cso_save_state(struct cso_context *ctx, unsigned state_mask)
 {
+   struct cso_context_priv *cso = (struct cso_context_priv *)ctx;
    assert(cso->saved_state == 0);
 
    cso->saved_state = state_mask;
@@ -1679,8 +1714,9 @@ cso_save_state(struct cso_context *cso, unsigned 
state_mask)
  * Restore the state which was saved by cso_save_state().
  */
 void
-cso_restore_state(struct cso_context *cso, unsigned unbind)
+cso_restore_state(struct cso_context *ctx, unsigned unbind)
 {
+   struct cso_context_priv *cso = (struct cso_context_priv *)ctx;
    unsigned state_mask = cso->saved_state;
 
    assert(state_mask);
@@ -1745,8 +1781,9 @@ cso_restore_state(struct cso_context *cso, unsigned 
unbind)
  * of CSO_BIT_COMPUTE_x flags.
  */
 void
-cso_save_compute_state(struct cso_context *cso, unsigned state_mask)
+cso_save_compute_state(struct cso_context *ctx, unsigned state_mask)
 {
+   struct cso_context_priv *cso = (struct cso_context_priv *)ctx;
    assert(cso->saved_compute_state == 0);
 
    cso->saved_compute_state = state_mask;
@@ -1763,8 +1800,9 @@ cso_save_compute_state(struct cso_context *cso, unsigned 
state_mask)
  * Restore the state which was saved by cso_save_compute_state().
  */
 void
-cso_restore_compute_state(struct cso_context *cso)
+cso_restore_compute_state(struct cso_context *ctx)
 {
+   struct cso_context_priv *cso = (struct cso_context_priv *)ctx;
    unsigned state_mask = cso->saved_compute_state;
 
    assert(state_mask);
@@ -1783,7 +1821,7 @@ cso_restore_compute_state(struct cso_context *cso)
 /* drawing */
 
 void
-cso_draw_arrays(struct cso_context *cso, unsigned mode, unsigned start, 
unsigned count)
+cso_draw_arrays(struct cso_context *ctx, unsigned mode, unsigned start, 
unsigned count)
 {
    struct pipe_draw_info info;
    struct pipe_draw_start_count_bias draw;
@@ -1799,12 +1837,12 @@ cso_draw_arrays(struct cso_context *cso, unsigned mode, 
unsigned start, unsigned
    draw.count = count;
    draw.index_bias = 0;
 
-   cso_draw_vbo(cso, &info, 0, NULL, &draw, 1);
+   cso_draw_vbo(ctx, &info, 0, NULL, &draw, 1);
 }
 
 
 void
-cso_draw_arrays_instanced(struct cso_context *cso, unsigned mode,
+cso_draw_arrays_instanced(struct cso_context *ctx, unsigned mode,
                           unsigned start, unsigned count,
                           unsigned start_instance, unsigned instance_count)
 {
@@ -1824,5 +1862,5 @@ cso_draw_arrays_instanced(struct cso_context *cso, 
unsigned mode,
    draw.count = count;
    draw.index_bias = 0;
 
-   cso_draw_vbo(cso, &info, 0, NULL, &draw, 1);
+   cso_draw_vbo(ctx, &info, 0, NULL, &draw, 1);
 }
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index 56e79236057..1a150ff9fd4 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -39,10 +39,7 @@
 extern "C" {
 #endif
 
-struct cso_context;
-struct u_vbuf;
-
-struct cso_context_base {
+struct cso_context {
    struct pipe_context *pipe;
 
    /* This is equal to either pipe_context::draw_vbo or u_vbuf_draw_vbo. */
@@ -231,9 +228,7 @@ cso_draw_arrays(struct cso_context *cso, unsigned mode, 
unsigned start, unsigned
 static inline struct pipe_context *
 cso_get_pipe_context(struct cso_context *cso)
 {
-   struct cso_context_base *cso_base = (struct cso_context_base *)cso;
-
-   return cso_base->pipe;
+   return cso->pipe;
 }
 
 static ALWAYS_INLINE void
@@ -257,10 +252,7 @@ cso_draw_vbo(struct cso_context *cso,
    /* Indirect only uses indirect->draw_count, not num_draws. */
    assert(!indirect || num_draws == 1);
 
-   struct cso_context_base *cso_base = (struct cso_context_base *)cso;
-
-   cso_base->draw_vbo(cso_base->pipe, info, drawid_offset, indirect, draws,
-                      num_draws);
+   cso->draw_vbo(cso->pipe, info, drawid_offset, indirect, draws, num_draws);
 }
 
 #ifdef __cplusplus

Reply via email to