mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 11:28:05 +02:00
panfrost: DRY between shader stage setup
Just a little spring cleanup, extending UBOs to vertex shaders in the process. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
5e2c3d40bd
commit
b670becb1e
1 changed files with 36 additions and 19 deletions
|
|
@ -1030,6 +1030,26 @@ panfrost_ubo_count(struct panfrost_context *ctx, enum pipe_shader_type stage)
|
||||||
return 32 - __builtin_clz(mask);
|
return 32 - __builtin_clz(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fixes up a shader state with current state, returning a GPU address to the
|
||||||
|
* patched shader */
|
||||||
|
|
||||||
|
static mali_ptr
|
||||||
|
panfrost_patch_shader_state(
|
||||||
|
struct panfrost_context *ctx,
|
||||||
|
struct panfrost_shader_state *ss,
|
||||||
|
enum pipe_shader_type stage)
|
||||||
|
{
|
||||||
|
ss->tripipe->texture_count = ctx->sampler_view_count[stage];
|
||||||
|
ss->tripipe->sampler_count = ctx->sampler_count[stage];
|
||||||
|
|
||||||
|
ss->tripipe->midgard1.flags = 0x220;
|
||||||
|
|
||||||
|
unsigned ubo_count = panfrost_ubo_count(ctx, stage);
|
||||||
|
ss->tripipe->midgard1.uniform_buffer_count = ubo_count;
|
||||||
|
|
||||||
|
return ss->tripipe_gpu;
|
||||||
|
}
|
||||||
|
|
||||||
/* Go through dirty flags and actualise them in the cmdstream. */
|
/* Go through dirty flags and actualise them in the cmdstream. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1063,16 +1083,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
|
|
||||||
struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant];
|
struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant];
|
||||||
|
|
||||||
/* Late shader descriptor assignments */
|
ctx->payload_vertex.postfix._shader_upper =
|
||||||
|
panfrost_patch_shader_state(ctx, vs, PIPE_SHADER_VERTEX) >> 4;
|
||||||
vs->tripipe->texture_count = ctx->sampler_view_count[PIPE_SHADER_VERTEX];
|
|
||||||
vs->tripipe->sampler_count = ctx->sampler_count[PIPE_SHADER_VERTEX];
|
|
||||||
|
|
||||||
/* Who knows */
|
|
||||||
vs->tripipe->midgard1.flags = 0x220;
|
|
||||||
vs->tripipe->midgard1.uniform_buffer_count = 1;
|
|
||||||
|
|
||||||
ctx->payload_vertex.postfix._shader_upper = vs->tripipe_gpu >> 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->dirty & (PAN_DIRTY_RASTERIZER | PAN_DIRTY_VS)) {
|
if (ctx->dirty & (PAN_DIRTY_RASTERIZER | PAN_DIRTY_VS)) {
|
||||||
|
|
@ -1094,13 +1106,20 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
assert(ctx->fs);
|
assert(ctx->fs);
|
||||||
struct panfrost_shader_state *variant = &ctx->fs->variants[ctx->fs->active_variant];
|
struct panfrost_shader_state *variant = &ctx->fs->variants[ctx->fs->active_variant];
|
||||||
|
|
||||||
|
panfrost_patch_shader_state(ctx, variant, PIPE_SHADER_FRAGMENT);
|
||||||
|
|
||||||
#define COPY(name) ctx->fragment_shader_core.name = variant->tripipe->name
|
#define COPY(name) ctx->fragment_shader_core.name = variant->tripipe->name
|
||||||
|
|
||||||
COPY(shader);
|
COPY(shader);
|
||||||
COPY(attribute_count);
|
COPY(attribute_count);
|
||||||
COPY(varying_count);
|
COPY(varying_count);
|
||||||
|
COPY(texture_count);
|
||||||
|
COPY(sampler_count);
|
||||||
|
COPY(sampler_count);
|
||||||
COPY(midgard1.uniform_count);
|
COPY(midgard1.uniform_count);
|
||||||
|
COPY(midgard1.uniform_buffer_count);
|
||||||
COPY(midgard1.work_count);
|
COPY(midgard1.work_count);
|
||||||
|
COPY(midgard1.flags);
|
||||||
COPY(midgard1.unknown2);
|
COPY(midgard1.unknown2);
|
||||||
|
|
||||||
#undef COPY
|
#undef COPY
|
||||||
|
|
@ -1109,11 +1128,14 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
if (ctx->blend->has_blend_shader)
|
if (ctx->blend->has_blend_shader)
|
||||||
ctx->fragment_shader_core.midgard1.work_count = /*MAX2(ctx->fragment_shader_core.midgard1.work_count, ctx->blend->blend_work_count)*/16;
|
ctx->fragment_shader_core.midgard1.work_count = /*MAX2(ctx->fragment_shader_core.midgard1.work_count, ctx->blend->blend_work_count)*/16;
|
||||||
|
|
||||||
unsigned ubo_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT);
|
|
||||||
ctx->fragment_shader_core.midgard1.uniform_buffer_count = ubo_count;
|
|
||||||
|
|
||||||
/* Set late due to depending on render state */
|
/* Set late due to depending on render state */
|
||||||
unsigned flags = MALI_EARLY_Z | 0x20 | 0x200;
|
unsigned flags = ctx->fragment_shader_core.midgard1.flags;
|
||||||
|
|
||||||
|
/* Depending on whether it's legal to in the given shader, we
|
||||||
|
* try to enable early-z testing (or forward-pixel kill?) */
|
||||||
|
|
||||||
|
if (!variant->can_discard)
|
||||||
|
flags |= MALI_EARLY_Z;
|
||||||
|
|
||||||
/* Any time texturing is used, derivatives are implicitly
|
/* Any time texturing is used, derivatives are implicitly
|
||||||
* calculated, so we need to enable helper invocations */
|
* calculated, so we need to enable helper invocations */
|
||||||
|
|
@ -1123,10 +1145,6 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
|
|
||||||
ctx->fragment_shader_core.midgard1.flags = flags;
|
ctx->fragment_shader_core.midgard1.flags = flags;
|
||||||
|
|
||||||
/* Assign texture/sample count right before upload */
|
|
||||||
ctx->fragment_shader_core.texture_count = ctx->sampler_view_count[PIPE_SHADER_FRAGMENT];
|
|
||||||
ctx->fragment_shader_core.sampler_count = ctx->sampler_count[PIPE_SHADER_FRAGMENT];
|
|
||||||
|
|
||||||
/* Assign the stencil refs late */
|
/* Assign the stencil refs late */
|
||||||
ctx->fragment_shader_core.stencil_front.ref = ctx->stencil_ref.ref_value[0];
|
ctx->fragment_shader_core.stencil_front.ref = ctx->stencil_ref.ref_value[0];
|
||||||
ctx->fragment_shader_core.stencil_back.ref = ctx->stencil_ref.ref_value[1];
|
ctx->fragment_shader_core.stencil_back.ref = ctx->stencil_ref.ref_value[1];
|
||||||
|
|
@ -1140,7 +1158,6 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
|
||||||
|
|
||||||
if (variant->can_discard) {
|
if (variant->can_discard) {
|
||||||
ctx->fragment_shader_core.unknown2_3 |= MALI_CAN_DISCARD;
|
ctx->fragment_shader_core.unknown2_3 |= MALI_CAN_DISCARD;
|
||||||
ctx->fragment_shader_core.midgard1.flags &= ~MALI_EARLY_Z;
|
|
||||||
ctx->fragment_shader_core.midgard1.flags |= 0x400;
|
ctx->fragment_shader_core.midgard1.flags |= 0x400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue