panfrost: Drop rasterizer null checks in draw calls
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 14 Aug 2020 21:50:44 +0000 (17:50 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 08:24:37 +0000 (08:24 +0000)
rasterizer must be non-null when draw_vbo is called (indeed, we assert
this there), so anything in the per-draw graphics path can safely assume
we have a rasterizer object bound.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6327>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_job.c

index fee07253e79cff57ff87ace08968c0ae0244ff05..6c67512d20ae3a2a97abd3d8ce16e4ae2f4e9f4d 100644 (file)
@@ -82,13 +82,13 @@ panfrost_vt_update_rasterizer(struct panfrost_rasterizer *rasterizer,
 {
         postfix->gl_enables |= 0x7;
         SET_BIT(postfix->gl_enables, MALI_FRONT_CCW_TOP,
-                rasterizer && rasterizer->base.front_ccw);
+                rasterizer->base.front_ccw);
         SET_BIT(postfix->gl_enables, MALI_CULL_FACE_FRONT,
-                rasterizer && (rasterizer->base.cull_face & PIPE_FACE_FRONT));
+                (rasterizer->base.cull_face & PIPE_FACE_FRONT));
         SET_BIT(postfix->gl_enables, MALI_CULL_FACE_BACK,
-                rasterizer && (rasterizer->base.cull_face & PIPE_FACE_BACK));
+                (rasterizer->base.cull_face & PIPE_FACE_BACK));
         SET_BIT(prefix->unknown_draw, MALI_DRAW_FLATSHADE_FIRST,
-                rasterizer && rasterizer->base.flatshade_first);
+                rasterizer->base.flatshade_first);
 }
 
 void
@@ -99,11 +99,7 @@ panfrost_vt_update_primitive_size(struct panfrost_context *ctx,
         struct panfrost_rasterizer *rasterizer = ctx->rasterizer;
 
         if (!panfrost_writes_point_size(ctx)) {
-                bool points = prefix->draw_mode == MALI_DRAW_MODE_POINTS;
-                float val = 0.0f;
-
-                if (rasterizer)
-                        val = points ?
+                float val = (prefix->draw_mode == MALI_DRAW_MODE_POINTS) ?
                               rasterizer->base.point_size :
                               rasterizer->base.line_width;
 
@@ -450,18 +446,6 @@ 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;
@@ -735,7 +719,7 @@ panfrost_frag_shader_meta_init(struct panfrost_context *ctx,
 
         fs = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
 
-        bool msaa = ctx->rasterizer && ctx->rasterizer->base.multisample;
+        bool msaa = ctx->rasterizer->base.multisample;
         fragmeta->coverage_mask = msaa ? ctx->sample_mask : ~0;
 
         fragmeta->unknown2_3 = MALI_DEPTH_FUNC(MALI_FUNC_ALWAYS) | 0x10;
@@ -884,7 +868,7 @@ panfrost_emit_viewport(struct panfrost_batch *batch,
         unsigned miny = MIN2(fb->height, vp_miny);
         unsigned maxy = MIN2(fb->height, vp_maxy);
 
-        if (ss && rast && rast->scissor) {
+        if (ss && rast->scissor) {
                 minx = MAX2(ss->minx, minx);
                 miny = MAX2(ss->miny, miny);
                 maxx = MIN2(ss->maxx, maxx);
@@ -2101,13 +2085,10 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
 
         /* If rasterizer discard is enable, only submit the vertex */
 
-        bool rasterizer_discard = ctx->rasterizer &&
-                                  ctx->rasterizer->base.rasterizer_discard;
-
         unsigned vertex = panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_VERTEX, false, 0,
                                            vp, vp_size, false);
 
-        if (rasterizer_discard)
+        if (ctx->rasterizer->base.rasterizer_discard)
                 return;
 
         panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_TILER, false, vertex, tp, tp_size,
index 46cbfe896fff77beec98df03216a15f658228651..0107f87d6a3d3f5b18082636ee369fafae1a5eda 100644 (file)
@@ -241,7 +241,7 @@ panfrost_scissor_culls_everything(struct panfrost_context *ctx)
 
         /* Check if we're scissoring at all */
 
-        if (!(ctx->rasterizer && ctx->rasterizer->base.scissor))
+        if (!ctx->rasterizer->base.scissor)
                 return false;
 
         return (ss->minx == ss->maxx) || (ss->miny == ss->maxy);
index 9aa1f1bb71d9061c6b6bbf21cad646d07a990f0b..fe99b29b7da4b0b5079d0d60f8e718c451022d79 100644 (file)
@@ -1208,7 +1208,7 @@ panfrost_batch_set_requirements(struct panfrost_batch *batch)
 {
         struct panfrost_context *ctx = batch->ctx;
 
-        if (ctx->rasterizer && ctx->rasterizer->base.multisample)
+        if (ctx->rasterizer->base.multisample)
                 batch->requirements |= PAN_REQ_MSAA;
 
         if (ctx->depth_stencil && ctx->depth_stencil->base.depth.writemask) {