aboutsummaryrefslogtreecommitdiffstats
path: root/src/compute-renderpass.cpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2022-07-09 23:45:26 +0200
committerladevieq <ladevie.quentin@gmail.com>2022-07-10 00:04:17 +0200
commitcfcb5c3212f0fce667885ff0de6fa0b9fc4b3ca8 (patch)
treed076b243e0203537d5816c9a15010723581d7f97 /src/compute-renderpass.cpp
parent928b1b0503d2ecab09cc275e9775593a41e417cb (diff)
Improve compilation time
Diffstat (limited to 'src/compute-renderpass.cpp')
-rw-r--r--src/compute-renderpass.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/compute-renderpass.cpp b/src/compute-renderpass.cpp
index 7399ae3..99ee4a9 100644
--- a/src/compute-renderpass.cpp
+++ b/src/compute-renderpass.cpp
@@ -4,8 +4,14 @@
#include "vk-renderer.hpp"
-void ComputeRenderpass::set_pipeline(std::string& shader_name) {
- this->pipeline = api.create_compute_pipeline(shader_name.c_str());
+ComputeRenderpass::~ComputeRenderpass() {
+ api.destroy_pipeline(pipeline);
+}
+
+void ComputeRenderpass::set_pipeline(const char* shader_name) {
+ if (this->pipeline.handle != VK_NULL_HANDLE)
+ api.destroy_pipeline(this->pipeline);
+ this->pipeline = api.create_compute_pipeline(shader_name);
}
void ComputeRenderpass::set_ouput_texture(Texture* output_texture) {
@@ -14,7 +20,7 @@ void ComputeRenderpass::set_ouput_texture(Texture* output_texture) {
auto image = api.get_image(output_texture->device_image);
// TODO: Remove hardcoded offset
- memcpy(constants.data() + 56, &image.bindless_storage_index, sizeof(bindless_index));
+ memcpy(constants + 56, &image.bindless_storage_index, sizeof(bindless_index));
}
void ComputeRenderpass::set_dispatch_size(size_t count_x, size_t count_y, size_t count_z) {
@@ -24,20 +30,20 @@ void ComputeRenderpass::set_dispatch_size(size_t count_x, size_t count_y, size_t
}
void ComputeRenderpass::set_constant(off_t offset, uint64_t* constant) {
- memcpy(constants.data() + offset, constant, sizeof(uint64_t));
+ memcpy(constants + offset, constant, sizeof(uint64_t));
}
void ComputeRenderpass::set_constant(off_t offset, Texture* texture) {
auto image = api.get_image(texture->device_image);
- memcpy(constants.data() + offset, (void*)&image.bindless_storage_index, sizeof(bindless_index));
+ memcpy(constants + offset, (void*)&image.bindless_storage_index, sizeof(bindless_index));
input_textures.push_back(texture);
}
void ComputeRenderpass::set_constant(off_t offset, Buffer* buffer) {
auto device_buffer = api.get_buffer(buffer->device_buffer);
- memcpy(constants.data() + offset, (void*)&device_buffer.device_address, sizeof(VkDeviceAddress));
+ memcpy(constants + offset, (void*)&device_buffer.device_address, sizeof(VkDeviceAddress));
}
void ComputeRenderpass::execute(vkrenderer& renderer, VkCommandBuffer command_buffer) {