From 6f86a09586444bc4bee29b205763f3714e9c32cd Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Mon, 13 Jan 2014 17:29:11 -0500 Subject: [PATCH RFC 1/1] clover: Don't crash on NULL global mem objects. Specs say it's legal. TODO: pointer to a NULL value should also be treated as NULL. Fixes clones.xml gegl test. Signed-off-by: Jan Vesely --- src/gallium/drivers/r600/evergreen_compute.c | 9 ++++++--- src/gallium/state_trackers/clover/core/kernel.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index a2db69b..f14b7c5 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -655,10 +655,13 @@ static void evergreen_set_global_binding( for (int i = 0; i < n; i++) { - assert(resources[i]->target == PIPE_BUFFER); - assert(resources[i]->bind & PIPE_BIND_GLOBAL); + if (resources[i]) { + assert(resources[i]->target == PIPE_BUFFER); + assert(resources[i]->bind & PIPE_BIND_GLOBAL); - *(handles[i]) = buffers[i]->chunk->start_in_dw * 4; + *(handles[i]) = buffers[i]->chunk->start_in_dw * 4; + } else + *(handles[i]) = NULL; } evergreen_set_rat(ctx->cs_shader_state.shader, 0, pool->bo, 0, pool->size_in_dw * 4); diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index ac57c71..b9e5e2b 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -331,7 +331,10 @@ kernel::global_argument::set(size_t size, const void *value) { if (size != sizeof(cl_mem)) throw error(CL_INVALID_ARG_SIZE); - buf = &obj(*(cl_mem *)value); + if (value) + buf = &obj(*(cl_mem *)value); + else + buf = NULL; //DUMMY NULL BUFFER? _set = true; } @@ -340,7 +343,7 @@ kernel::global_argument::bind(exec_context &ctx, const module::argument &marg) { align(ctx.input, marg.target_align); ctx.g_handles.push_back(allocate(ctx.input, marg.target_size)); - ctx.g_buffers.push_back(buf->resource(*ctx.q).pipe); + ctx.g_buffers.push_back(buf ? buf->resource(*ctx.q).pipe: NULL); } void -- 1.8.4.2