Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AmesingFlank committed Oct 31, 2021
1 parent b0dcc93 commit 6867aab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions taichi/backends/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,11 +1092,11 @@ void VulkanCommandList::blit_image(DeviceAllocation dst_img,

vkCmdBlitImage(buffer_->buffer, src_vk_image->image,
image_layout_ti_to_vk(src_img_layout), dst_vk_image->image,
image_layout_ti_to_vk(dst_img_layout), 1, &blit,VK_FILTER_NEAREST);
image_layout_ti_to_vk(dst_img_layout), 1, &blit,
VK_FILTER_NEAREST);

buffer_->refs.push_back(dst_vk_image);
buffer_->refs.push_back(src_vk_image);

}

void VulkanCommandList::set_line_width(float width) {
Expand Down Expand Up @@ -2029,7 +2029,7 @@ VulkanSurface::~VulkanSurface() {
if (screenshot_buffer_ != kDeviceNullAllocation) {
device_->dealloc_memory(screenshot_buffer_);
}
if(screenshot_image_ != kDeviceNullAllocation){
if (screenshot_image_ != kDeviceNullAllocation) {
device_->destroy_image(screenshot_image_);
}
}
Expand Down Expand Up @@ -2100,24 +2100,22 @@ DeviceAllocation VulkanSurface::get_image_data() {
auto cmd_list = stream->new_command_list();
cmd_list->blit_image(screenshot_image_, img_alloc, ImageLayout::transfer_dst,
ImageLayout::transfer_src, {w, h, 1});
cmd_list->image_transition(screenshot_image_, ImageLayout::transfer_dst,
ImageLayout::transfer_src);
stream->submit_synced(cmd_list.get());

device_->image_transition(screenshot_image_, ImageLayout::transfer_dst,
ImageLayout::transfer_src);

BufferImageCopyParams copy_params;
copy_params.image_extent.x = w;
copy_params.image_extent.y = h;
cmd_list = stream->new_command_list();
cmd_list->image_to_buffer(screenshot_buffer_.get_ptr(), screenshot_image_,
ImageLayout::transfer_src, copy_params);
cmd_list->image_transition(screenshot_image_, ImageLayout::transfer_src,
ImageLayout::transfer_dst);
cmd_list->image_transition(img_alloc, ImageLayout::transfer_src,
ImageLayout::present_src);
stream->submit_synced(cmd_list.get());

device_->image_transition(screenshot_image_, ImageLayout::transfer_src,
ImageLayout::transfer_dst);
device_->image_transition(img_alloc, ImageLayout::transfer_src,
ImageLayout::present_src);

return screenshot_buffer_;
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/vulkan/vulkan_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class VulkanCommandList : public CommandList {
ImageLayout dst_img_layout,
ImageLayout src_img_layout,
const ImageCopyParams &params) override;

void blit_image(DeviceAllocation dst_img,
DeviceAllocation src_img,
ImageLayout dst_img_layout,
Expand Down
4 changes: 2 additions & 2 deletions taichi/ui/backends/vulkan/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Window::init(const AppConfig &config) {
}

void Window::show() {
if(!drawn_frame_){
if (!drawn_frame_) {
draw_frame();
}
present_frame();
Expand Down Expand Up @@ -84,7 +84,7 @@ Window::~Window() {
}

void Window::write_image(const std::string &filename) {
if(!drawn_frame_){
if (!drawn_frame_) {
draw_frame();
}
renderer_->swap_chain().write_image(filename);
Expand Down

0 comments on commit 6867aab

Please sign in to comment.