Skip to content

Commit

Permalink
[vulkan] Fixed query pool invalid usage (#5717)
Browse files Browse the repository at this point in the history
* Reset query pools after command buffer execution

* Removed clang extension syntax

* Fixed compilation

* Fixed reset query pool

* Disable validation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PENGUINLIONG and pre-commit-ci[bot] authored Aug 12, 2022
1 parent 428a515 commit e7a900a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
18 changes: 10 additions & 8 deletions c_api/src/c_api_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TiNdarrayAndMem make_ndarray(TiRuntime runtime,
alloc_size = 1;

} else {
assert(false);
TI_ASSERT(false);
}

for (int i = 0; i < arr_dims; i++) {
Expand Down Expand Up @@ -95,15 +95,17 @@ TiNdarrayAndMem make_ndarray(TiRuntime runtime,
e_shape.dims[i] = element_shape[i];
}

TiNdArray arg_array = {.memory = res.memory_,
.shape = shape,
.elem_shape = e_shape,
.elem_type = dtype};
TiNdArray arg_array{};
arg_array.memory = res.memory_;
arg_array.shape = shape;
arg_array.elem_shape = e_shape;
arg_array.elem_type = dtype;

TiArgumentValue arg_value = {.ndarray = arg_array};
TiArgumentValue arg_value{};
arg_value.ndarray = arg_array;

res.arg_ = {.type = TiArgumentType::TI_ARGUMENT_TYPE_NDARRAY,
.value = arg_value};
res.arg_.type = TiArgumentType::TI_ARGUMENT_TYPE_NDARRAY;
res.arg_.value = arg_value;

return res;
}
Expand Down
4 changes: 4 additions & 0 deletions taichi/python/export_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ void export_misc(py::module &m) {
m.def("pop_python_print_buffer", []() { return py_cout.pop_content(); });
m.def("toggle_python_print_buffer", [](bool opt) { py_cout.enabled = opt; });
m.def("with_cuda", is_cuda_api_available);
#ifdef TI_WITH_METAL
m.def("with_metal", taichi::lang::metal::is_metal_api_available);
#else
m.def("with_metal", []() { return false; });
#endif
#ifdef TI_WITH_OPENGL
m.def("with_opengl", taichi::lang::opengl::is_opengl_api_available,
py::arg("use_gles") = false);
Expand Down
1 change: 1 addition & 0 deletions taichi/rhi/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ VulkanCommandList::VulkanCommandList(VulkanDevice *ti_device,
info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;

vkBeginCommandBuffer(buffer->buffer, &info);
vkCmdResetQueryPool(buffer->buffer, query_pool_->query_pool, 0, 2);
vkCmdWriteTimestamp(buffer->buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
query_pool_->query_pool, 0);
}
Expand Down

0 comments on commit e7a900a

Please sign in to comment.