panfrost: Hoist blend finalize calls
[mesa.git] / src / gallium / drivers / panfrost / pan_cmdstream.c
index 0b4a9bed4f49812564f63e43a9cb06def85ed3d4..bc9158b03af6b026b79709eac2de53cef317bc8e 100644 (file)
@@ -72,7 +72,7 @@ panfrost_vt_emit_shared_memory(struct panfrost_context *ctx,
                 shared.scratchpad = stack->gpu;
         }
 
-        postfix->shared_memory = panfrost_pool_upload(&batch->pool, &shared, sizeof(shared));
+        postfix->shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared, sizeof(shared), 64);
 }
 
 static void
@@ -540,7 +540,8 @@ panfrost_fs_required(
 static void
 panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
                                 struct mali_shader_meta *fragmeta,
-                                void *rts)
+                                void *rts,
+                                struct panfrost_blend_final *blend)
 {
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
         const struct panfrost_device *dev = pan_device(ctx->base.screen);
@@ -557,11 +558,6 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
         /* Get blending setup */
         unsigned rt_count = ctx->pipe_framebuffer.nr_cbufs;
 
-        struct panfrost_blend_final blend[PIPE_MAX_COLOR_BUFS];
-
-        for (unsigned c = 0; c < rt_count; ++c)
-                blend[c] = panfrost_get_blend_for_context(ctx, c);
-
         /* Disable shader execution if we can */
         if (dev->quirks & MIDGARD_SHADERLESS
                         && !panfrost_fs_required(fs, blend, rt_count)) {
@@ -709,7 +705,8 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
 static void
 panfrost_frag_shader_meta_init(struct panfrost_context *ctx,
                                struct mali_shader_meta *fragmeta,
-                               void *rts)
+                               void *rts,
+                               struct panfrost_blend_final *blend)
 {
         const struct panfrost_device *dev = pan_device(ctx->base.screen);
         struct panfrost_shader_state *fs;
@@ -768,7 +765,7 @@ panfrost_frag_shader_meta_init(struct panfrost_context *ctx,
 
         panfrost_frag_meta_rasterizer_update(ctx, fragmeta);
         panfrost_frag_meta_zsa_update(ctx, fragmeta);
-        panfrost_frag_meta_blend_update(ctx, fragmeta, rts);
+        panfrost_frag_meta_blend_update(ctx, fragmeta, rts, blend);
 }
 
 void
@@ -816,7 +813,12 @@ panfrost_emit_shader_meta(struct panfrost_batch *batch,
                 if (rt_size)
                         rts = rzalloc_size(ctx, rt_size * rt_count);
 
-                panfrost_frag_shader_meta_init(ctx, &meta, rts);
+                struct panfrost_blend_final blend[PIPE_MAX_COLOR_BUFS];
+
+                for (unsigned c = 0; c < ctx->pipe_framebuffer.nr_cbufs; ++c)
+                        blend[c] = panfrost_get_blend_for_context(ctx, c);
+
+                panfrost_frag_shader_meta_init(ctx, &meta, rts, blend);
 
                 xfer = panfrost_pool_alloc_aligned(&batch->pool, desc_size, sizeof(meta));
 
@@ -905,10 +907,10 @@ panfrost_map_constant_buffer_gpu(struct panfrost_batch *batch,
                  * PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT */
                 return rsrc->bo->gpu + cb->buffer_offset;
         } else if (cb->user_buffer) {
-                return panfrost_pool_upload(&batch->pool,
+                return panfrost_pool_upload_aligned(&batch->pool,
                                                  cb->user_buffer +
                                                  cb->buffer_offset,
-                                                 cb->buffer_size);
+                                                 cb->buffer_size, 16);
         } else {
                 unreachable("No constant buffer");
         }
@@ -1199,8 +1201,8 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch,
                 .shared_shift = util_logbase2(single_size) + 1
         };
 
-        vtp->postfix.shared_memory = panfrost_pool_upload(&batch->pool, &shared,
-                                                               sizeof(shared));
+        vtp->postfix.shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared,
+                                                               sizeof(shared), 64);
 }
 
 static mali_ptr
@@ -1290,10 +1292,11 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
                         trampolines[i] = panfrost_get_tex_desc(batch, stage, view);
                 }
 
-                postfix->textures = panfrost_pool_upload(&batch->pool,
+                postfix->textures = panfrost_pool_upload_aligned(&batch->pool,
                                                               trampolines,
                                                               sizeof(uint64_t) *
-                                                              ctx->sampler_view_count[stage]);
+                                                              ctx->sampler_view_count[stage],
+                                                              sizeof(uint64_t));
         }
 }
 
@@ -1338,7 +1341,7 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
         struct panfrost_transfer S = panfrost_pool_alloc_aligned(&batch->pool,
                         MALI_ATTRIBUTE_BUFFER_LENGTH * vs->attribute_count *
                         (could_npot ? 2 : 1),
-                        MALI_ATTRIBUTE_BUFFER_LENGTH);
+                        MALI_ATTRIBUTE_BUFFER_LENGTH * 2);
 
         struct panfrost_transfer T = panfrost_pool_alloc_aligned(&batch->pool,
                         MALI_ATTRIBUTE_LENGTH * vs->attribute_count,
@@ -1996,7 +1999,7 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
         unsigned xfb_base = pan_xfb_base(present);
         struct panfrost_transfer T = panfrost_pool_alloc_aligned(&batch->pool,
                         MALI_ATTRIBUTE_BUFFER_LENGTH * (xfb_base + ctx->streamout.num_targets),
-                        MALI_ATTRIBUTE_BUFFER_LENGTH);
+                        MALI_ATTRIBUTE_BUFFER_LENGTH * 2);
         struct mali_attribute_buffer_packed *varyings =
                 (struct mali_attribute_buffer_packed *) T.cpu;
 
@@ -2159,5 +2162,5 @@ panfrost_emit_sample_locations(struct panfrost_batch *batch)
             0, 0,
         };
 
-        return panfrost_pool_upload(&batch->pool, locations, 96 * sizeof(uint16_t));
+        return panfrost_pool_upload_aligned(&batch->pool, locations, 96 * sizeof(uint16_t), 64);
 }