Otherwise applications (like the OpenCL CTS) will try to allocate more memory than what the GPU is actually able to provide.
Signed-off-by: Karol Herbst <kher...@redhat.com> --- src/gallium/drivers/nouveau/nv50/nv50_screen.c | 5 +++-- src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 44a1a8a9374..ebeb7f72647 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -422,6 +422,7 @@ nv50_screen_get_compute_param(struct pipe_screen *pscreen, enum pipe_compute_cap param, void *data) { struct nv50_screen *screen = nv50_screen(pscreen); + struct nouveau_device *dev = screen->base.device; #define RET(x) do { \ if (data) \ @@ -439,7 +440,7 @@ nv50_screen_get_compute_param(struct pipe_screen *pscreen, case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: RET((uint64_t []) { 512 }); case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: /* g0-15[] */ - RET((uint64_t []) { 1ULL << 32 }); + RET((uint64_t []) { MIN2(1ULL << 32, dev->vram_size) }); case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: /* s[] */ RET((uint64_t []) { 16 << 10 }); case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE: /* l[] */ @@ -449,7 +450,7 @@ nv50_screen_get_compute_param(struct pipe_screen *pscreen, case PIPE_COMPUTE_CAP_SUBGROUP_SIZE: RET((uint32_t []) { 32 }); case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: - RET((uint64_t []) { 1ULL << 40 }); + RET((uint64_t []) { dev->vram_size }); case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED: RET((uint32_t []) { 0 }); case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS: diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 37e10dcd07f..0966f371143 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -474,6 +474,7 @@ nvc0_screen_get_compute_param(struct pipe_screen *pscreen, { struct nvc0_screen *screen = nvc0_screen(pscreen); const uint16_t obj_class = screen->compute->oclass; + struct nouveau_device *dev = screen->base.device; #define RET(x) do { \ if (data) \ @@ -501,7 +502,7 @@ nvc0_screen_get_compute_param(struct pipe_screen *pscreen, RET((uint64_t []) { 512 }); } case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: /* g[] */ - RET((uint64_t []) { 1ULL << 40 }); + RET((uint64_t []) { dev->vram_size }); case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: /* s[] */ switch (obj_class) { case GM200_COMPUTE_CLASS: @@ -521,7 +522,7 @@ nvc0_screen_get_compute_param(struct pipe_screen *pscreen, case PIPE_COMPUTE_CAP_SUBGROUP_SIZE: RET((uint32_t []) { 32 }); case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: - RET((uint64_t []) { 1ULL << 40 }); + RET((uint64_t []) { dev->vram_size }); case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED: RET((uint32_t []) { 0 }); case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS: -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev