-static void
-panfrost_frag_meta_rasterizer_update(struct panfrost_context *ctx,
- struct mali_shader_meta *fragmeta)
-{
- if (!ctx->rasterizer) {
- SET_BIT(fragmeta->unknown2_4, MALI_NO_MSAA, true);
- SET_BIT(fragmeta->unknown2_3, MALI_HAS_MSAA, false);
- fragmeta->depth_units = 0.0f;
- fragmeta->depth_factor = 0.0f;
- SET_BIT(fragmeta->unknown2_4, MALI_DEPTH_RANGE_A, false);
- SET_BIT(fragmeta->unknown2_4, MALI_DEPTH_RANGE_B, false);
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_CLIP_NEAR, true);
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_CLIP_FAR, true);
- return;
- }
-
- struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
-
- bool msaa = rast->multisample;
-
- /* TODO: Sample size */
- SET_BIT(fragmeta->unknown2_3, MALI_HAS_MSAA, msaa);
- SET_BIT(fragmeta->unknown2_4, MALI_NO_MSAA, !msaa);
-
- struct panfrost_shader_state *fs;
- fs = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
-
- /* EXT_shader_framebuffer_fetch requires the shader to be run
- * per-sample when outputs are read. */
- bool per_sample = ctx->min_samples > 1 || fs->outputs_read;
- SET_BIT(fragmeta->unknown2_3, MALI_PER_SAMPLE, msaa && per_sample);
-
- fragmeta->depth_units = rast->offset_units * 2.0f;
- fragmeta->depth_factor = rast->offset_scale;
-
- /* XXX: Which bit is which? Does this maybe allow offseting not-tri? */
-
- SET_BIT(fragmeta->unknown2_4, MALI_DEPTH_RANGE_A, rast->offset_tri);
- SET_BIT(fragmeta->unknown2_4, MALI_DEPTH_RANGE_B, rast->offset_tri);
-
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_CLIP_NEAR, rast->depth_clip_near);
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_CLIP_FAR, rast->depth_clip_far);
-}
-
-static void
-panfrost_frag_meta_zsa_update(struct panfrost_context *ctx,
- struct mali_shader_meta *fragmeta)
-{
- const struct panfrost_zsa_state *so = ctx->depth_stencil;
- int zfunc = PIPE_FUNC_ALWAYS;
-
- if (!so) {
- /* If stenciling is disabled, the state is irrelevant */
- SET_BIT(fragmeta->unknown2_4, MALI_STENCIL_TEST, false);
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_WRITEMASK, false);
- } else {
- SET_BIT(fragmeta->unknown2_4, MALI_STENCIL_TEST,
- so->base.stencil[0].enabled);
-
- fragmeta->stencil_mask_front = so->stencil_mask_front;
- fragmeta->stencil_mask_back = so->stencil_mask_back;
-
- /* Bottom bits for stencil ref, exactly one word */
- fragmeta->stencil_front.opaque[0] = so->stencil_front.opaque[0] | ctx->stencil_ref.ref_value[0];
-
- /* If back-stencil is not enabled, use the front values */
-
- if (so->base.stencil[1].enabled)
- fragmeta->stencil_back.opaque[0] = so->stencil_back.opaque[0] | ctx->stencil_ref.ref_value[1];
- else
- fragmeta->stencil_back = fragmeta->stencil_front;
-
- if (so->base.depth.enabled)
- zfunc = so->base.depth.func;
-
- /* Depth state (TODO: Refactor) */
-
- SET_BIT(fragmeta->unknown2_3, MALI_DEPTH_WRITEMASK,
- so->base.depth.writemask);
- }
-
- fragmeta->unknown2_3 &= ~MALI_DEPTH_FUNC_MASK;
- fragmeta->unknown2_3 |= MALI_DEPTH_FUNC(panfrost_translate_compare_func(zfunc));
-}
-