diff --git a/src/memory.cpp b/src/memory.cpp index dad59d5e..9038fadd 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -515,7 +515,7 @@ bool cvk_image::init_vulkan_image() { return false; } - auto initimage = new cvk_command_image_init(queue, this); + auto initimage = new cvk_command_image_init(queue, this, m_context); ret = queue->enqueue_command_with_deps(initimage, 0, nullptr, nullptr); if (ret != CL_SUCCESS) { diff --git a/src/queue.cpp b/src/queue.cpp index 4ebfe4b8..1b88cedf 100644 --- a/src/queue.cpp +++ b/src/queue.cpp @@ -103,8 +103,8 @@ cl_int cvk_command_queue::satisfy_data_dependencies(cvk_command* cmd) { continue; } CVK_ASSERT(mem->is_image_type()); - auto initcmd = - new cvk_command_image_init(this, static_cast(mem)); + auto initcmd = new cvk_command_image_init( + this, static_cast(mem), m_context); _cl_event* initev; cl_int err = enqueue_command_with_retry(initcmd, &initev); if (err != CL_SUCCESS) { diff --git a/src/queue.hpp b/src/queue.hpp index e63db68f..f5c9de36 100644 --- a/src/queue.hpp +++ b/src/queue.hpp @@ -386,11 +386,14 @@ struct cvk_command_buffer { #define CLVK_COMMAND_BATCH 0x5000 #define CLVK_COMMAND_IMAGE_INIT 0x5001 -struct cvk_command { +struct cvk_command : public refcounted { + cvk_command(cl_command_type type, cvk_command_queue* queue, + cvk_context* ctx) + : m_type(type), m_queue(queue), + m_event(new cvk_event(ctx, this, queue)) {} cvk_command(cl_command_type type, cvk_command_queue* queue) - : m_type(type), m_queue(queue), - m_event(new cvk_event(m_queue->context(), this, queue)) {} + : cvk_command(type, queue, queue->context()) {} virtual ~cvk_command() { m_event->release(); } @@ -672,8 +675,11 @@ struct cvk_command_fill_buffer final : public cvk_command_buffer_base_region { }; struct cvk_command_batchable : public cvk_command { + cvk_command_batchable(cl_command_type type, cvk_command_queue* queue, + cvk_context* ctx) + : cvk_command(type, queue, ctx), m_query_pool(VK_NULL_HANDLE) {} cvk_command_batchable(cl_command_type type, cvk_command_queue* queue) - : cvk_command(type, queue), m_query_pool(VK_NULL_HANDLE) {} + : cvk_command_batchable(type, queue, queue->context()) {} virtual ~cvk_command_batchable() { if (m_query_pool != VK_NULL_HANDLE) { @@ -1176,8 +1182,9 @@ struct cvk_command_fill_image final : public cvk_command { struct cvk_command_image_init final : public cvk_command_batchable { - cvk_command_image_init(cvk_command_queue* queue, cvk_image* image) - : cvk_command_batchable(CLVK_COMMAND_IMAGE_INIT, queue), + cvk_command_image_init(cvk_command_queue* queue, cvk_image* image, + cvk_context* ctx) + : cvk_command_batchable(CLVK_COMMAND_IMAGE_INIT, queue, ctx), m_image(image) { CVK_ASSERT(!m_image->is_backed_by_buffer_view()); }