cl_aligned_u32(cl, fui(f));
}
-static inline void
-cl_start_reloc(struct vc4_cl *cl, struct vc4_cl_out **out, uint32_t n)
-{
- assert(n == 1 || n == 2);
- assert(cl->reloc_count == 0);
-#ifndef NDEBUG
- cl->reloc_count = n;
-#endif
-
- cl_u8(out, VC4_PACKET_GEM_HANDLES);
- cl->reloc_next = *out;
- cl_u32(out, 0); /* Space where hindex will be written. */
- cl_u32(out, 0); /* Space where hindex will be written. */
-}
-
static inline struct vc4_cl_out *
cl_start_shader_reloc(struct vc4_cl *cl, uint32_t n)
{
struct vc4_resource *rsc = vc4_resource(prsc);
struct vc4_cl_out *bcl = cl_start(&job->bcl);
- cl_start_reloc(&job->bcl, &bcl, 1);
+
+ /* The original design for the VC4 kernel UABI had multiple
+ * packets that used relocations in the BCL (some of which
+ * needed two BOs), but later modifications eliminated all but
+ * this one usage. We have an arbitrary 32-bit offset value,
+ * and need to also supply an arbitrary 32-bit index buffer
+ * GEM handle, so we have this fake packet we emit in our BCL
+ * to be validated, which the kernel uses at validation time
+ * to perform the relocation in the IB packet (without
+ * emitting to the actual HW).
+ */
+ cl_u8(&bcl, VC4_PACKET_GEM_HANDLES);
+ cl_u32(&bcl, vc4_gem_hindex(job, rsc->bo));
+ cl_u32(&bcl, 0);
+
cl_u8(&bcl, VC4_PACKET_GL_INDEXED_PRIMITIVE);
cl_u8(&bcl,
info->mode |
VC4_INDEX_BUFFER_U16:
VC4_INDEX_BUFFER_U8));
cl_u32(&bcl, info->count);
- cl_reloc(job, &job->bcl, &bcl, rsc->bo, offset);
+ cl_u32(&bcl, offset);
cl_u32(&bcl, vc4->max_index);
+
cl_end(&job->bcl, bcl);
job->draw_calls_queued++;