diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-31 14:13:30 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-01 16:23:03 -0700 |
commit | ac6aa93f9e500acf7abda3d8e826f4d207e5c1b8 (patch) | |
tree | 3a23943e20b754f4487a8c66ef0ad36fe782449e /src/gallium/drivers | |
parent | 4b93152c29356382acfefaf66a466faca516cec0 (diff) |
panfrost: Unify ctx->vs and ctx->fs
It's a little verbose, but this way we can support other shader stages
without too much contortion.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blit.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 6 |
3 files changed, 21 insertions, 25 deletions
diff --git a/src/gallium/drivers/panfrost/pan_blit.c b/src/gallium/drivers/panfrost/pan_blit.c index 35c8507eb8d..461bd8eec35 100644 --- a/src/gallium/drivers/panfrost/pan_blit.c +++ b/src/gallium/drivers/panfrost/pan_blit.c @@ -38,11 +38,11 @@ panfrost_blitter_save( util_blitter_save_vertex_buffer_slot(blitter, ctx->vertex_buffers); util_blitter_save_vertex_elements(blitter, ctx->vertex); - util_blitter_save_vertex_shader(blitter, ctx->vs); + util_blitter_save_vertex_shader(blitter, ctx->shader[PIPE_SHADER_VERTEX]); util_blitter_save_rasterizer(blitter, ctx->rasterizer); util_blitter_save_viewport(blitter, &ctx->pipe_viewport); util_blitter_save_scissor(blitter, &ctx->scissor); - util_blitter_save_fragment_shader(blitter, ctx->fs); + util_blitter_save_fragment_shader(blitter, ctx->shader[PIPE_SHADER_FRAGMENT]); util_blitter_save_blend(blitter, ctx->blend); util_blitter_save_depth_stencil_alpha(blitter, ctx->depth_stencil); util_blitter_save_stencil_ref(blitter, &ctx->stencil_ref); diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index b6c78340222..b5e50854502 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -528,8 +528,8 @@ panfrost_emit_varying_descriptor( { /* Load the shaders */ - struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant]; - struct panfrost_shader_state *fs = &ctx->fs->variants[ctx->fs->active_variant]; + struct panfrost_shader_state *vs = &ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant]; + struct panfrost_shader_state *fs = &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant]; unsigned int num_gen_varyings = 0; /* Allocate the varying descriptor */ @@ -656,8 +656,8 @@ panfrost_vertex_buffer_address(struct panfrost_context *ctx, unsigned i) static bool panfrost_writes_point_size(struct panfrost_context *ctx) { - assert(ctx->vs); - struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant]; + assert(ctx->shader[PIPE_SHADER_VERTEX]); + struct panfrost_shader_state *vs = &ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant]; return vs->writes_point_size && ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.draw_mode == MALI_POINTS; } @@ -1049,9 +1049,9 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) * uploads */ ctx->dirty |= PAN_DIRTY_VS; if (ctx->dirty & PAN_DIRTY_VS) { - assert(ctx->vs); + assert(ctx->shader[PIPE_SHADER_VERTEX]); - struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant]; + struct panfrost_shader_state *vs = &ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant]; ctx->payloads[PIPE_SHADER_VERTEX].postfix._shader_upper = panfrost_patch_shader_state(ctx, vs, PIPE_SHADER_VERTEX, true) >> 4; @@ -1069,12 +1069,12 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) } /* TODO: Maybe dirty track FS, maybe not. For now, it's transient. */ - if (ctx->fs) + if (ctx->shader[PIPE_SHADER_FRAGMENT]) ctx->dirty |= PAN_DIRTY_FS; if (ctx->dirty & PAN_DIRTY_FS) { - assert(ctx->fs); - struct panfrost_shader_state *variant = &ctx->fs->variants[ctx->fs->active_variant]; + assert(ctx->shader[PIPE_SHADER_FRAGMENT]); + struct panfrost_shader_state *variant = &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant]; panfrost_patch_shader_state(ctx, variant, PIPE_SHADER_FRAGMENT, false); @@ -1256,8 +1256,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) for (int i = 0; i <= PIPE_SHADER_FRAGMENT; ++i) { struct panfrost_constant_buffer *buf = &ctx->constant_buffer[i]; - struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant]; - struct panfrost_shader_state *fs = &ctx->fs->variants[ctx->fs->active_variant]; + struct panfrost_shader_state *vs = &ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant]; + struct panfrost_shader_state *fs = &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant]; struct panfrost_shader_state *ss = (i == PIPE_SHADER_FRAGMENT) ? fs : vs; /* Uniforms are implicitly UBO #0 */ @@ -1285,11 +1285,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) switch (i) { case PIPE_SHADER_VERTEX: - uniform_count = ctx->vs->variants[ctx->vs->active_variant].uniform_count; + uniform_count = ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant].uniform_count; break; case PIPE_SHADER_FRAGMENT: - uniform_count = ctx->fs->variants[ctx->fs->active_variant].uniform_count; + uniform_count = ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant].uniform_count; break; default: @@ -1856,10 +1856,10 @@ panfrost_bind_rasterizer_state( /* Point sprites are emulated */ struct panfrost_shader_state *variant = - ctx->fs ? &ctx->fs->variants[ctx->fs->active_variant] : NULL; + ctx->shader[PIPE_SHADER_FRAGMENT] ? &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant] : NULL; if (ctx->rasterizer->base.sprite_coord_enable || (variant && variant->point_sprite_mask)) - ctx->base.bind_fs_state(&ctx->base, ctx->fs); + ctx->base.bind_fs_state(&ctx->base, ctx->shader[PIPE_SHADER_FRAGMENT]); } static void * @@ -2061,11 +2061,11 @@ panfrost_bind_shader_state( struct panfrost_context *ctx = pan_context(pctx); if (type == PIPE_SHADER_FRAGMENT) { - ctx->fs = hwcso; + ctx->shader[PIPE_SHADER_FRAGMENT] = hwcso; ctx->dirty |= PAN_DIRTY_FS; } else { assert(type == PIPE_SHADER_VERTEX); - ctx->vs = hwcso; + ctx->shader[PIPE_SHADER_VERTEX] = hwcso; ctx->dirty |= PAN_DIRTY_VS; } @@ -2429,7 +2429,7 @@ panfrost_bind_depth_stencil_state(struct pipe_context *pipe, if (depth_stencil->alpha.enabled) { /* We need to trigger a new shader (maybe) */ - ctx->base.bind_fs_state(&ctx->base, ctx->fs); + ctx->base.bind_fs_state(&ctx->base, ctx->shader[PIPE_SHADER_FRAGMENT]); } /* Stencil state */ diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 22fa431c8c7..eefd9eff43f 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -144,12 +144,8 @@ struct panfrost_context { struct panfrost_constant_buffer constant_buffer[PIPE_SHADER_TYPES]; - /* CSOs */ struct panfrost_rasterizer *rasterizer; - - struct panfrost_shader_variants *vs; - struct panfrost_shader_variants *fs; - + struct panfrost_shader_variants *shader[PIPE_SHADER_TYPES]; struct panfrost_vertex_state *vertex; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; |