unsigned ubo_count = panfrost_ubo_count(ctx, i);
assert(ubo_count >= 1);
- size_t sz = sizeof(struct mali_uniform_buffer_meta) * ubo_count;
- struct mali_uniform_buffer_meta ubos[PAN_MAX_CONST_BUFFERS];
+ size_t sz = sizeof(uint64_t) * ubo_count;
+ uint64_t ubos[PAN_MAX_CONST_BUFFERS];
/* Upload uniforms as a UBO */
- ubos[0].size = MALI_POSITIVE((2 + uniform_count));
- ubos[0].ptr = transfer.gpu >> 2;
+ ubos[0] = MALI_MAKE_UBO(2 + uniform_count, transfer.gpu);
/* The rest are honest-to-goodness UBOs */
if (!enabled || empty) {
/* Stub out disabled UBOs to catch accesses */
-
- ubos[ubo].size = 0;
- ubos[ubo].ptr = 0xDEAD0000;
+ ubos[ubo] = MALI_MAKE_UBO(0, 0xDEAD0000);
continue;
}
unsigned bytes_per_field = 16;
unsigned aligned = ALIGN_POT(usz, bytes_per_field);
- unsigned fields = aligned / bytes_per_field;
-
- ubos[ubo].size = MALI_POSITIVE(fields);
- ubos[ubo].ptr = gpu >> 2;
+ ubos[ubo] = MALI_MAKE_UBO(aligned / bytes_per_field, gpu);
}
mali_ptr ubufs = panfrost_upload_transient(batch, ubos, sz);
/* ORed into an MFBD address to specify the fbx section is included */
#define MALI_MFBD_TAG_EXTRA (0x2)
-struct mali_uniform_buffer_meta {
- /* This is actually the size minus 1 (MALI_POSITIVE), in units of 16
- * bytes. This gives a maximum of 2^14 bytes, which just so happens to
- * be the GL minimum-maximum for GL_MAX_UNIFORM_BLOCK_SIZE.
- */
- u64 size : 10;
+/* Uniform buffer objects are 64-bit fields divided as:
+ *
+ * u64 size : 10;
+ * mali_ptr ptr : 64 - 10;
+ *
+ * The size is actually the size minus 1 (MALI_POSITIVE), in units of 16 bytes.
+ * This gives a maximum of 2^14 bytes, which just so happens to be the GL
+ * minimum-maximum for GL_MAX_UNIFORM_BLOCK_SIZE.
+ *
+ * The pointer is missing the bottom 2 bits and top 8 bits. The top 8 bits
+ * should be 0 for userspace pointers, according to
+ * https://lwn.net/Articles/718895/. By reusing these bits, we can make each
+ * entry in the table only 64 bits.
+ */
- /* This is missing the bottom 2 bits and top 8 bits. The top 8 bits
- * should be 0 for userspace pointers, according to
- * https://lwn.net/Articles/718895/. By reusing these bits, we can make
- * each entry in the table only 64 bits.
- */
- mali_ptr ptr : 64 - 10;
-};
+#define MALI_MAKE_UBO(elements, ptr) \
+ (MALI_POSITIVE((elements)) | (((ptr) >> 2) << 10))
/* On Bifrost, these fields are the same between the vertex and tiler payloads.
* They also seem to be the same between Bifrost and Midgard. They're shared in
pandecode_uniform_buffers(mali_ptr pubufs, int ubufs_count, int job_no)
{
struct pandecode_mapped_memory *umem = pandecode_find_mapped_gpu_mem_containing(pubufs);
- struct mali_uniform_buffer_meta *PANDECODE_PTR_VAR(ubufs, umem, pubufs);
+ uint64_t *PANDECODE_PTR_VAR(ubufs, umem, pubufs);
for (int i = 0; i < ubufs_count; i++) {
- unsigned size = (ubufs[i].size + 1) * 16;
- mali_ptr addr = ubufs[i].ptr << 2;
+ unsigned size = (ubufs[i] & ((1 << 10) - 1)) * 16;
+ mali_ptr addr = (ubufs[i] >> 10) << 2;
pandecode_validate_buffer(addr, size);
- char *ptr = pointer_as_memory_reference(ubufs[i].ptr << 2);
+ char *ptr = pointer_as_memory_reference(addr);
pandecode_log("ubuf_%d[%u] = %s;\n", i, size, ptr);
free(ptr);
}