From: Karol Herbst Date: Fri, 28 Feb 2020 14:54:08 +0000 (+0100) Subject: gallium: make handles of set_global_binding 64 bit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e1ffb72a05f9b50ee47767aaadbab3e47896ee14;p=mesa.git gallium: make handles of set_global_binding 64 bit needed by CL Signed-off-by: Karol Herbst Reviewed-by: Marek Olšák Reviewed-by: Alyssa Rosenzweig Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/auxiliary/driver_ddebug/dd_context.c b/src/gallium/auxiliary/driver_ddebug/dd_context.c index 40da6cf41c7..fa70cb554b0 100644 --- a/src/gallium/auxiliary/driver_ddebug/dd_context.c +++ b/src/gallium/auxiliary/driver_ddebug/dd_context.c @@ -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); diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 30790949336..5002b762d3f 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -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; diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index d9c8f9f89a2..9fb1cb6e6b6 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -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; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index 92e156b4111..81168be675f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -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]; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c index 6488c71f4ad..f642b6bde90 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c @@ -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; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 49546e5de68..5a6af5df8c9 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 2ebffdcfdc1..7bfabce7b96 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -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 */ } diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index 98d4b97d7fc..aa16596d126 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -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 */ diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 610c1333597..889f2f02cca 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -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)); diff --git a/src/gallium/drivers/tegra/tegra_context.c b/src/gallium/drivers/tegra/tegra_context.c index e91baf0be34..8c57a70b71d 100644 --- a/src/gallium/drivers/tegra/tegra_context.c +++ b/src/gallium/drivers/tegra/tegra_context.c @@ -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); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 3a8b9eba462..3e3377a22e2 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -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 diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index 3cffec320e1..428229c0503 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -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 g_handles = map([&](size_t h) { - return (uint32_t *)&exec.input[h]; + std::vector g_handles = map([&](size_t h) { + return (uint64_t *)&exec.input[h]; }, exec.g_handles); q.pipe->bind_compute_state(q.pipe, st); diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c index cfdbdf1cc8d..2eaf6263392 100644 --- a/src/gallium/tests/trivial/compute.c +++ b/src/gallium/tests/trivial/compute.c @@ -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);