mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 05:38:16 +02:00
panfrost: Add an helper to retrieve the currently active shader state
Doing that improves readability and helps avoiding code duplication. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>
This commit is contained in:
parent
a0402f7960
commit
b28f4bb67c
3 changed files with 21 additions and 13 deletions
|
|
@ -357,7 +357,7 @@ bool
|
|||
panfrost_writes_point_size(struct panfrost_context *ctx)
|
||||
{
|
||||
assert(ctx->shader[PIPE_SHADER_VERTEX]);
|
||||
struct panfrost_shader_state *vs = &ctx->shader[PIPE_SHADER_VERTEX]->variants[ctx->shader[PIPE_SHADER_VERTEX]->active_variant];
|
||||
struct panfrost_shader_state *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
|
||||
|
||||
return vs->writes_point_size && ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.draw_mode == MALI_POINTS;
|
||||
}
|
||||
|
|
@ -719,15 +719,13 @@ static void
|
|||
panfrost_patch_shader_state(struct panfrost_context *ctx,
|
||||
enum pipe_shader_type stage)
|
||||
{
|
||||
struct panfrost_shader_variants *all = ctx->shader[stage];
|
||||
struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, stage);
|
||||
|
||||
if (!all) {
|
||||
if (!ss) {
|
||||
ctx->payloads[stage].postfix.shader = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
struct panfrost_shader_state *ss = &all->variants[all->active_variant];
|
||||
|
||||
ss->tripipe->texture_count = ctx->sampler_view_count[stage];
|
||||
ss->tripipe->sampler_count = ctx->sampler_count[stage];
|
||||
|
||||
|
|
@ -804,7 +802,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
|||
}
|
||||
|
||||
if (ctx->shader[PIPE_SHADER_FRAGMENT]) {
|
||||
struct panfrost_shader_state *variant = &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant];
|
||||
struct panfrost_shader_state *variant = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
|
||||
|
||||
panfrost_patch_shader_state(ctx, PIPE_SHADER_FRAGMENT);
|
||||
|
||||
|
|
@ -1160,12 +1158,11 @@ panfrost_queue_draw(struct panfrost_context *ctx)
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < PIPE_SHADER_TYPES; ++i) {
|
||||
struct panfrost_shader_variants *all = ctx->shader[i];
|
||||
struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, i);
|
||||
|
||||
if (!all)
|
||||
if (!ss)
|
||||
continue;
|
||||
|
||||
struct panfrost_shader_state *ss = &all->variants[all->active_variant];
|
||||
batch->stack_size = MAX2(batch->stack_size, ss->stack_size);
|
||||
}
|
||||
}
|
||||
|
|
@ -1553,8 +1550,7 @@ panfrost_bind_rasterizer_state(
|
|||
|
||||
/* Point sprites are emulated */
|
||||
|
||||
struct panfrost_shader_state *variant =
|
||||
ctx->shader[PIPE_SHADER_FRAGMENT] ? &ctx->shader[PIPE_SHADER_FRAGMENT]->variants[ctx->shader[PIPE_SHADER_FRAGMENT]->active_variant] : NULL;
|
||||
struct panfrost_shader_state *variant = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
|
||||
|
||||
if (ctx->rasterizer->base.sprite_coord_enable || (variant && variant->point_sprite_mask))
|
||||
ctx->base.bind_fs_state(&ctx->base, ctx->shader[PIPE_SHADER_FRAGMENT]);
|
||||
|
|
|
|||
|
|
@ -272,6 +272,18 @@ pan_context(struct pipe_context *pcontext)
|
|||
return (struct panfrost_context *) pcontext;
|
||||
}
|
||||
|
||||
static inline struct panfrost_shader_state *
|
||||
panfrost_get_shader_state(struct panfrost_context *ctx,
|
||||
enum pipe_shader_type st)
|
||||
{
|
||||
struct panfrost_shader_variants *all = ctx->shader[st];
|
||||
|
||||
if (!all)
|
||||
return NULL;
|
||||
|
||||
return &all->variants[all->active_variant];
|
||||
}
|
||||
|
||||
struct pipe_context *
|
||||
panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ panfrost_emit_varying_descriptor(
|
|||
{
|
||||
/* Load the shaders */
|
||||
|
||||
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 *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
|
||||
struct panfrost_shader_state *fs = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
|
||||
unsigned int num_gen_varyings = 0;
|
||||
|
||||
/* Allocate the varying descriptor */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue