v3d: add new flag dirty TMU cache at v3d_compiler
[mesa.git] / src / gallium / drivers / panfrost / pan_instancing.c
index cd93fa7be9c38079a72ab019cf02a8dfbe6dfdeb..473026cb8a0607ff6749698f3bddeaaa584bc728 100644 (file)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "pan_bo.h"
 #include "pan_context.h"
 
 /* See mali_job for notes on how this works. But basically, for small vertex
@@ -164,7 +165,7 @@ panfrost_padded_vertex_count(
 
 static unsigned
 panfrost_vertex_instanced(
-        struct panfrost_job *batch,
+        struct panfrost_batch *batch,
         struct panfrost_resource *rsrc,
         unsigned divisor,
         union mali_attr *attrs,
@@ -221,21 +222,21 @@ panfrost_vertex_instanced(
                 unsigned m = m_f;
 
                 /* Default case */
-                unsigned magic_divisor = m, extra_flags = 0;
+                uint32_t magic_divisor = m, extra_flags = 0;
 
                 /* e = 2^(shift + 32) % d */
                 uint64_t e = t % hw_divisor;
 
                 /* Apply round-down algorithm? e <= 2^shift?. XXX: The blob
                  * seems to use a different condition */
-                if (e <= (1 << shift)) {
+                if (e <= (1ll << shift)) {
                         magic_divisor = m - 1;
                         extra_flags = 1;
                 }
 
                 /* Top flag implicitly set */
-                assert(magic_divisor & (1 << 31));
-                magic_divisor &= ~(1 << 31);
+                assert(magic_divisor & (1u << 31));
+                magic_divisor &= ~(1u << 31);
 
                 /* Upload to two different slots */
 
@@ -253,7 +254,7 @@ panfrost_vertex_instanced(
 }
 
 void
-panfrost_emit_vertex_data(struct panfrost_job *batch)
+panfrost_emit_vertex_data(struct panfrost_batch *batch)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct panfrost_vertex_state *so = ctx->vertex;
@@ -292,17 +293,23 @@ panfrost_emit_vertex_data(struct panfrost_job *batch)
                  * will be adjusted back when we fixup the src_offset in
                  * mali_attr_meta */
 
-                mali_ptr raw_addr = panfrost_vertex_buffer_address(ctx, vbi);
+                mali_ptr raw_addr = rsrc->bo->gpu + buf->buffer_offset;
                 mali_ptr addr = raw_addr & ~63;
                 unsigned chopped_addr = raw_addr - addr;
 
                 /* Add a dependency of the batch on the vertex buffer */
-                panfrost_job_add_bo(batch, rsrc->bo);
+                panfrost_batch_add_bo(batch, rsrc->bo,
+                                      PAN_BO_ACCESS_SHARED |
+                                      PAN_BO_ACCESS_READ |
+                                      PAN_BO_ACCESS_VERTEX_TILER);
 
                 /* Set common fields */
                 attrs[k].elements = addr;
                 attrs[k].stride = buf->stride;
-                attrs[k].size = rsrc->base.width0;
+
+                /* Since we advanced the base pointer, we shrink the buffer
+                 * size */
+                attrs[k].size = rsrc->base.width0 - buf->buffer_offset;
 
                 /* We need to add the extra size we masked off (for
                  * correctness) so the data doesn't get clamped away */
@@ -338,7 +345,7 @@ panfrost_emit_vertex_data(struct panfrost_job *batch)
         /* Upload whatever we emitted and go */
 
         ctx->payloads[PIPE_SHADER_VERTEX].postfix.attributes =
-                panfrost_upload_transient(ctx, attrs, k * sizeof(union mali_attr));
+                panfrost_upload_transient(batch, attrs, k * sizeof(union mali_attr));
 }