Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix init image at creation #759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cvk_image*>(mem));
auto initcmd = new cvk_command_image_init(
this, static_cast<cvk_image*>(mem), m_context);
_cl_event* initev;
cl_int err = enqueue_command_with_retry(initcmd, &initev);
if (err != CL_SUCCESS) {
Expand Down
19 changes: 13 additions & 6 deletions src/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
}
Expand Down