gallium: make handles of set_global_binding 64 bit
needed by CL Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4072> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4072>
This commit is contained in:
@@ -688,7 +688,7 @@ static void
|
||||
dd_context_set_global_binding(struct pipe_context *_pipe,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
||||
pipe->set_global_binding(pipe, first, count, resources, handles);
|
||||
|
@@ -1066,7 +1066,7 @@ tc_set_compute_resources(struct pipe_context *_pipe, unsigned start,
|
||||
static void
|
||||
tc_set_global_binding(struct pipe_context *_pipe, unsigned first,
|
||||
unsigned count, struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct threaded_context *tc = threaded_context(_pipe);
|
||||
struct pipe_context *pipe = tc->pipe;
|
||||
|
@@ -541,7 +541,7 @@ fd_set_compute_resources(struct pipe_context *pctx,
|
||||
static void
|
||||
fd_set_global_binding(struct pipe_context *pctx,
|
||||
unsigned first, unsigned count, struct pipe_resource **prscs,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
struct fd_global_bindings_stateobj *so = &ctx->global_bindings;
|
||||
@@ -558,7 +558,6 @@ fd_set_global_binding(struct pipe_context *pctx,
|
||||
if (so->buf[n]) {
|
||||
struct fd_resource *rsc = fd_resource(so->buf[n]);
|
||||
uint64_t iova = fd_bo_get_iova(rsc->bo);
|
||||
// TODO need to scream if iova > 32b or fix gallium API..
|
||||
*handles[i] += iova;
|
||||
}
|
||||
|
||||
|
@@ -1279,7 +1279,7 @@ static void
|
||||
llvmpipe_set_global_binding(struct pipe_context *pipe,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
struct lp_compute_shader *cs = llvmpipe->cs;
|
||||
@@ -1305,7 +1305,7 @@ llvmpipe_set_global_binding(struct pipe_context *pipe,
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint64_t va;
|
||||
uint32_t offset;
|
||||
uint64_t offset;
|
||||
pipe_resource_reference(&cs->global_buffers[first + i], resources[i]);
|
||||
struct llvmpipe_resource *lp_res = llvmpipe_resource(resources[i]);
|
||||
offset = *handles[i];
|
||||
|
@@ -1237,18 +1237,11 @@ nv50_set_compute_resources(struct pipe_context *pipe,
|
||||
}
|
||||
|
||||
static inline void
|
||||
nv50_set_global_handle(uint32_t *phandle, struct pipe_resource *res)
|
||||
nv50_set_global_handle(uint64_t *phandle, struct pipe_resource *res)
|
||||
{
|
||||
struct nv04_resource *buf = nv04_resource(res);
|
||||
if (buf) {
|
||||
uint64_t limit = (buf->address + buf->base.width0) - 1;
|
||||
if (limit < (1ULL << 32)) {
|
||||
*phandle = (uint32_t)buf->address;
|
||||
} else {
|
||||
NOUVEAU_ERR("Cannot map into TGSI_RESOURCE_GLOBAL: "
|
||||
"resource not contained within 32-bit address space !\n");
|
||||
*phandle = 0;
|
||||
}
|
||||
*phandle = buf->address;
|
||||
} else {
|
||||
*phandle = 0;
|
||||
}
|
||||
@@ -1258,7 +1251,7 @@ static void
|
||||
nv50_set_global_bindings(struct pipe_context *pipe,
|
||||
unsigned start, unsigned nr,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct nv50_context *nv50 = nv50_context(pipe);
|
||||
struct pipe_resource **ptr;
|
||||
|
@@ -1354,18 +1354,11 @@ nvc0_set_shader_buffers(struct pipe_context *pipe,
|
||||
}
|
||||
|
||||
static inline void
|
||||
nvc0_set_global_handle(uint32_t *phandle, struct pipe_resource *res)
|
||||
nvc0_set_global_handle(uint64_t *phandle, struct pipe_resource *res)
|
||||
{
|
||||
struct nv04_resource *buf = nv04_resource(res);
|
||||
if (buf) {
|
||||
uint64_t limit = (buf->address + buf->base.width0) - 1;
|
||||
if (limit < (1ULL << 32)) {
|
||||
*phandle = (uint32_t)buf->address;
|
||||
} else {
|
||||
NOUVEAU_ERR("Cannot map into TGSI_RESOURCE_GLOBAL: "
|
||||
"resource not contained within 32-bit address space !\n");
|
||||
*phandle = 0;
|
||||
}
|
||||
*phandle = buf->address;
|
||||
} else {
|
||||
*phandle = 0;
|
||||
}
|
||||
@@ -1375,7 +1368,7 @@ static void
|
||||
nvc0_set_global_bindings(struct pipe_context *pipe,
|
||||
unsigned start, unsigned nr,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct nvc0_context *nvc0 = nvc0_context(pipe);
|
||||
struct pipe_resource **ptr;
|
||||
|
@@ -149,7 +149,7 @@ static void
|
||||
panfrost_set_global_binding(struct pipe_context *pctx,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
@@ -986,7 +986,7 @@ static void evergreen_set_compute_resources(struct pipe_context *ctx,
|
||||
static void evergreen_set_global_binding(struct pipe_context *ctx,
|
||||
unsigned first, unsigned n,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
struct compute_memory_pool *pool = rctx->screen->global_pool;
|
||||
@@ -1018,15 +1018,15 @@ static void evergreen_set_global_binding(struct pipe_context *ctx,
|
||||
|
||||
for (i = first; i < first + n; i++)
|
||||
{
|
||||
uint32_t buffer_offset;
|
||||
uint32_t handle;
|
||||
uint64_t buffer_offset;
|
||||
uint64_t handle;
|
||||
assert(resources[i]->target == PIPE_BUFFER);
|
||||
assert(resources[i]->bind & PIPE_BIND_GLOBAL);
|
||||
|
||||
buffer_offset = util_le32_to_cpu(*(handles[i]));
|
||||
buffer_offset = util_le64_to_cpu(*(handles[i]));
|
||||
handle = buffer_offset + buffers[i]->chunk->start_in_dw * 4;
|
||||
|
||||
*(handles[i]) = util_cpu_to_le32(handle);
|
||||
*(handles[i]) = util_cpu_to_le64(handle);
|
||||
}
|
||||
|
||||
/* globals for writing */
|
||||
|
@@ -294,7 +294,7 @@ static void si_bind_compute_state(struct pipe_context *ctx, void *state)
|
||||
static void si_set_global_binding(
|
||||
struct pipe_context *ctx, unsigned first, unsigned n,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
unsigned i;
|
||||
struct si_context *sctx = (struct si_context*)ctx;
|
||||
@@ -326,10 +326,10 @@ static void si_set_global_binding(
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
uint64_t va;
|
||||
uint32_t offset;
|
||||
uint64_t offset;
|
||||
pipe_resource_reference(&program->global_buffers[first + i], resources[i]);
|
||||
va = si_resource(resources[i])->gpu_address;
|
||||
offset = util_le32_to_cpu(*handles[i]);
|
||||
offset = util_le64_to_cpu(*handles[i]);
|
||||
va += offset;
|
||||
va = util_cpu_to_le64(va);
|
||||
memcpy(handles[i], &va, sizeof(va));
|
||||
|
@@ -1039,7 +1039,7 @@ tegra_set_compute_resources(struct pipe_context *pcontext,
|
||||
static void
|
||||
tegra_set_global_binding(struct pipe_context *pcontext, unsigned int first,
|
||||
unsigned int count, struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct tegra_context *context = to_tegra_context(pcontext);
|
||||
|
||||
|
@@ -804,7 +804,7 @@ struct pipe_context {
|
||||
void (*set_global_binding)(struct pipe_context *context,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles);
|
||||
uint64_t **handles);
|
||||
|
||||
/**
|
||||
* Launch the compute kernel starting from instruction \a pc of the
|
||||
|
@@ -59,8 +59,8 @@ kernel::launch(command_queue &q,
|
||||
|
||||
// The handles are created during exec_context::bind(), so we need make
|
||||
// sure to call exec_context::bind() before retrieving them.
|
||||
std::vector<uint32_t *> g_handles = map([&](size_t h) {
|
||||
return (uint32_t *)&exec.input[h];
|
||||
std::vector<uint64_t *> g_handles = map([&](size_t h) {
|
||||
return (uint64_t *)&exec.input[h];
|
||||
}, exec.g_handles);
|
||||
|
||||
q.pipe->bind_compute_state(q.pipe, st);
|
||||
|
@@ -403,7 +403,7 @@ static void destroy_sampler_states(struct context *ctx)
|
||||
}
|
||||
|
||||
static void init_globals(struct context *ctx, const int *slots,
|
||||
uint32_t **handles)
|
||||
uint64_t **handles)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct pipe_resource *res[MAX_RESOURCES];
|
||||
@@ -651,7 +651,7 @@ static void test_input_global(struct context *ctx)
|
||||
" STORE RGLOBAL.x, TEMP[1].yyyy, TEMP[1]\n"
|
||||
" RET\n"
|
||||
" ENDSUB\n";
|
||||
uint32_t input[8] = { 0x10001, 0x10002, 0x10003, 0x10004,
|
||||
uint64_t input[8] = { 0x10001, 0x10002, 0x10003, 0x10004,
|
||||
0x10005, 0x10006, 0x10007, 0x10008 };
|
||||
|
||||
printf("- %s\n", __func__);
|
||||
@@ -666,7 +666,7 @@ static void test_input_global(struct context *ctx)
|
||||
init_tex(ctx, 3, PIPE_BUFFER, true, PIPE_FORMAT_R32_FLOAT, 32, 0,
|
||||
test_default_init);
|
||||
init_globals(ctx, (int []){ 0, 1, 2, 3, -1 },
|
||||
(uint32_t *[]){ &input[1], &input[3],
|
||||
(uint64_t *[]){ &input[1], &input[3],
|
||||
&input[5], &input[7] });
|
||||
launch_grid(ctx, (uint []){4, 1, 1}, (uint []){1, 1, 1}, 0, input);
|
||||
check_tex(ctx, 0, test_input_global_expect, NULL);
|
||||
|
Reference in New Issue
Block a user