unsigned ubo_count = panfrost_ubo_count(ctx, stage);
assert(ubo_count >= 1);
- size_t sz = sizeof(uint64_t) * ubo_count;
- uint64_t ubos[PAN_MAX_CONST_BUFFERS];
- int uniform_count = ss->uniform_count;
+ size_t sz = MALI_UNIFORM_BUFFER_LENGTH * ubo_count;
+ struct panfrost_transfer ubos = panfrost_pool_alloc(&batch->pool, sz);
+ uint64_t *ubo_ptr = (uint64_t *) ubos.cpu;
/* Upload uniforms as a UBO */
- ubos[0] = MALI_MAKE_UBO(2 + uniform_count, transfer.gpu);
+
+ if (ss->uniform_count) {
+ pan_pack(ubo_ptr, UNIFORM_BUFFER, cfg) {
+ cfg.entries = ss->uniform_count;
+ cfg.pointer = transfer.gpu;
+ }
+ } else {
+ *ubo_ptr = 0;
+ }
/* The rest are honest-to-goodness UBOs */
bool empty = usz == 0;
if (!enabled || empty) {
- /* Stub out disabled UBOs to catch accesses */
- ubos[ubo] = MALI_MAKE_UBO(0, 0xDEAD0000);
+ ubo_ptr[ubo] = 0;
continue;
}
- mali_ptr gpu = panfrost_map_constant_buffer_gpu(batch, stage,
- buf, ubo);
-
- unsigned bytes_per_field = 16;
- unsigned aligned = ALIGN_POT(usz, bytes_per_field);
- ubos[ubo] = MALI_MAKE_UBO(aligned / bytes_per_field, gpu);
+ pan_pack(ubo_ptr + ubo, UNIFORM_BUFFER, cfg) {
+ cfg.entries = DIV_ROUND_UP(usz, 16);
+ cfg.pointer = panfrost_map_constant_buffer_gpu(batch,
+ stage, buf, ubo);
+ }
}
- mali_ptr ubufs = panfrost_pool_upload(&batch->pool, ubos, sz);
postfix->uniforms = transfer.gpu;
- postfix->uniform_buffers = ubufs;
+ postfix->uniform_buffers = ubos.gpu;
buf->dirty_mask = 0;
}
.size = 1024
};
- uint64_t my_ubo = MALI_MAKE_UBO(64, ubo->gpu + 1024);
+ pan_pack(ubo->cpu, UNIFORM_BUFFER, cfg) {
+ cfg.entries = 64;
+ cfg.pointer = ubo->gpu + 1024;
+ }
- memcpy(ubo->cpu, &my_ubo, sizeof(my_ubo));
memcpy(var->cpu, &vmeta, sizeof(vmeta));
vmeta.unknown1 = 0x2; /* XXX: only attrib? */
/* ORed into an MFBD address to specify the fbx section is included */
#define MALI_MFBD_TAG_EXTRA (0x2)
-/* 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.
- */
-
-#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
* fused payloads.
<value name="Mirrored Clamp to Border" value="15"/>
</enum>
+ <struct name="Uniform Buffer">
+ <field name="Entries" size="12" start="0" type="uint" modifier="minus(1)"/>
+ <field name="Pointer" size="52" start="12" type="address" modifier="shr(4)" element="16" count="Entries"/>
+ </struct>
+
<struct name="Viewport">
<field name="Minimum X" size="32" start="0:0" default="-INFINITY" type="float"/>
<field name="Minimum Y" size="32" start="1:0" default="-INFINITY" type="float"/>