aboutsummaryrefslogtreecommitdiffstats
path: root/src/vk-renderer.cpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-03-11 22:32:41 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-03-11 22:32:41 +0100
commit5812e12d804fc47e1260e52a92e39705e3056364 (patch)
tree51357f167872b2e673721b8c30300d716109e04c /src/vk-renderer.cpp
parent7e25e65c44864f5e2c1f8227b41ceb6c0fc5e54f (diff)
Fix accumulation textures format and reset accumulation on move/resize
Diffstat (limited to 'src/vk-renderer.cpp')
-rw-r--r--src/vk-renderer.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/vk-renderer.cpp b/src/vk-renderer.cpp
index 8c225fb..dfd2bca 100644
--- a/src/vk-renderer.cpp
+++ b/src/vk-renderer.cpp
@@ -321,6 +321,18 @@ void vkrenderer::begin_frame() {
}
+void vkrenderer::reset_accumulation() {
+ auto cmd_buf = command_buffers[frame_index];
+ auto accumulation_image = accumulation_images[1];
+ VkClearColorValue clear_color = { 0.f, 0.f, 0.f, 1.f };
+
+ api.image_barrier(cmd_buf, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, accumulation_image);
+
+ vkCmdClearColorImage(cmd_buf, accumulation_image.handle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_color, 1, &accumulation_image.subresource_range);
+
+ api.image_barrier(cmd_buf, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, accumulation_image);
+}
+
void vkrenderer::ui() {
ImDrawData* draw_data = ImGui::GetDrawData();
@@ -407,7 +419,7 @@ void vkrenderer::recreate_swapchain() {
.height = swapchain.extent.height,
.depth = 1,
};
- accumulation_images = api.create_images(image_size, swapchain.surface_format.format, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 2);
+ accumulation_images = api.create_images(image_size, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 2);
auto cmd_buf = command_buffers[frame_index];
api.start_record(cmd_buf);