gallium: make handles of set_global_binding 64 bit
authorKarol Herbst <kherbst@redhat.com>
Fri, 28 Feb 2020 14:54:08 +0000 (15:54 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Mar 2020 22:06:19 +0000 (22:06 +0000)
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>

13 files changed:
src/gallium/auxiliary/driver_ddebug/dd_context.c
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/drivers/freedreno/freedreno_state.c
src/gallium/drivers/llvmpipe/lp_state_cs.c
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/tegra/tegra_context.c
src/gallium/include/pipe/p_context.h
src/gallium/state_trackers/clover/core/kernel.cpp
src/gallium/tests/trivial/compute.c

index 40da6cf41c7073bb59f5106d3779d6ee7280119d..fa70cb554b0d7948b1a5a3787808c8e3ee224152 100644 (file)
@@ -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);
index 30790949336317260248c9abe399931392fff30b..5002b762d3fff98f8d7be5f1b261af604ad75449 100644 (file)
@@ -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;
index d9c8f9f89a28ec3d29eb23b5d38962aba4ff1fe7..9fb1cb6e6b6cef732529c2f49e6acf2dfc040486 100644 (file)
@@ -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;
                        }
 
index 92e156b411123c1d6251465c67a63b39bd9126d1..81168be675fb55f790f685b46cc8820f9d9a1b08 100644 (file)
@@ -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];
index 6488c71f4ad8a307b0c023241ebd99b4d82c9f89..f642b6bde909c0af454c4cfa91abe69a33da5131 100644 (file)
@@ -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;
index 49546e5de68b60afeef83a9ff99f42ef85d09661..5a6af5df8c9e9b1975611605f5c418f32579adcf 100644 (file)
@@ -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;
index 2ebffdcfdc1c0986575f0ca647c0ecbe53e36e4d..7bfabce7b96f096e7069af21e8d2c4a1bddbd0de 100644 (file)
@@ -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 */
 }
index 98d4b97d7fc00014d5bf78761ae8a00f0a842299..aa16596d1262751277080203a54d5d47d4925030 100644 (file)
@@ -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 */
index 610c13335974442268b5dd847b7e279a3cbe9bb2..889f2f02ccae5ac54ef89beed350ca2befc963c0 100644 (file)
@@ -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));
index e91baf0be343c95a6cba8c6004063cafdc1313eb..8c57a70b71d152543b87c07d698fc99521e8d647 100644 (file)
@@ -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);
 
index 3a8b9eba462ac6479b68ad936ba33e6e545ebf6b..3e3377a22e2275ffa006bc0da712f2f1f390be44 100644 (file)
@@ -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
index 3cffec320e1fc1c583f395359011875b652df14a..428229c050390672e0b86826a41a2c96c5b42700 100644 (file)
@@ -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);
index cfdbdf1cc8dc29b3f3f9a416116c955db465b98c..2eaf62633920a51e34b407f282101c615622c4a4 100644 (file)
@@ -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);