for (int i = 0; i < n; i++)
{
+ uint32_t buffer_offset;
+ uint32_t handle;
assert(resources[i]->target == PIPE_BUFFER);
assert(resources[i]->bind & PIPE_BIND_GLOBAL);
- *(handles[i]) = buffers[i]->chunk->start_in_dw * 4;
+ buffer_offset = util_le32_to_cpu(*(handles[i]));
+ handle = buffer_offset + buffers[i]->chunk->start_in_dw * 4;
+
+ *(handles[i]) = util_cpu_to_le32(handle);
}
evergreen_set_rat(ctx->cs_shader_state.shader, 0, pool->bo, 0, pool->size_in_dw * 4);
for (i = first; i < first + n; i++) {
uint64_t va;
+ uint32_t offset;
program->global_buffers[i] = resources[i];
va = r600_resource_va(ctx->screen, resources[i]);
+ offset = util_le32_to_cpu(*handles[i]);
+ va += offset;
+ va = util_cpu_to_le64(va);
memcpy(handles[i], &va, sizeof(va));
}
}
* unless it's NULL, in which case no new
* resources will be bound.
* \param handles array of pointers to the memory locations that
- * will be filled with the respective base
- * addresses each buffer will be mapped to. It
- * should contain at least \a count elements,
- * unless \a resources is NULL in which case \a
- * handles should be NULL as well.
+ * will be updated with the address each buffer
+ * will be mapped to. The base memory address of
+ * each of the buffers will be added to the value
+ * pointed to by its corresponding handle to form
+ * the final address argument. It should contain
+ * at least \a count elements, unless \a
+ * resources is NULL in which case \a handles
+ * should be NULL as well.
*
* Note that the driver isn't required to make any guarantees about
* the contents of the \a handles array being valid anytime except
align(ctx.input, marg.target_align);
if (buf) {
- ctx.g_handles.push_back(allocate(ctx.input, marg.target_size));
- ctx.g_buffers.push_back(buf->resource(*ctx.q).pipe);
+ const resource &r = buf->resource(*ctx.q);
+ ctx.g_handles.push_back(ctx.input.size());
+ ctx.g_buffers.push_back(r.pipe);
+
+ // How to handle multi-demensional offsets?
+ // We don't need to. Buffer offsets are always
+ // one-dimensional.
+ auto v = bytes(r.offset[0]);
+ extend(v, marg.ext_type, marg.target_size);
+ byteswap(v, ctx.q->device().endianness());
+ insert(ctx.input, v);
} else {
// Null pointer.
allocate(ctx.input, marg.target_size);
align(ctx.input, marg.target_align);
if (buf) {
- auto v = bytes(ctx.resources.size() << 24);
+ resource &r = buf->resource(*ctx.q);
+ auto v = bytes(ctx.resources.size() << 24 | r.offset[0]);
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->device().endianness());
insert(ctx.input, v);
- st = buf->resource(*ctx.q).bind_surface(*ctx.q, false);
+ st = r.bind_surface(*ctx.q, false);
ctx.resources.push_back(st);
} else {
// Null pointer.