From bdd35fc2af40496b4cff9121ea5a3a364259642d Mon Sep 17 00:00:00 2001 From: Quentin LADEVIE Date: Thu, 3 Mar 2022 17:49:03 +0100 Subject: Primitive renderpass api & use handle for low level api resources --- src/compute-renderpass.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/compute-renderpass.cpp') diff --git a/src/compute-renderpass.cpp b/src/compute-renderpass.cpp index c680bac..7399ae3 100644 --- a/src/compute-renderpass.cpp +++ b/src/compute-renderpass.cpp @@ -11,8 +11,10 @@ void ComputeRenderpass::set_pipeline(std::string& shader_name) { void ComputeRenderpass::set_ouput_texture(Texture* output_texture) { this->output_texture = output_texture; + auto image = api.get_image(output_texture->device_image); + // TODO: Remove hardcoded offset - memcpy(constants.data() + 56, &output_texture->device_image.bindless_storage_index, sizeof(bindless_index)); + memcpy(constants.data() + 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) { @@ -26,17 +28,19 @@ void ComputeRenderpass::set_constant(off_t offset, uint64_t* constant) { } void ComputeRenderpass::set_constant(off_t offset, Texture* texture) { - memcpy(constants.data() + offset, (void*)&texture->device_image.bindless_storage_index, sizeof(bindless_index)); + auto image = api.get_image(texture->device_image); + + memcpy(constants.data() + offset, (void*)&image.bindless_storage_index, sizeof(bindless_index)); input_textures.push_back(texture); } void ComputeRenderpass::set_constant(off_t offset, Buffer* buffer) { - auto address = buffer->device_address(); - memcpy(constants.data() + offset, (void*)&address, sizeof(VkDeviceAddress)); + auto device_buffer = api.get_buffer(buffer->device_buffer); + memcpy(constants.data() + offset, (void*)&device_buffer.device_address, sizeof(VkDeviceAddress)); } -void ComputeRenderpass::execute(VkCommandBuffer command_buffer) { +void ComputeRenderpass::execute(vkrenderer& renderer, VkCommandBuffer command_buffer) { api.update_constants(command_buffer, VK_SHADER_STAGE_COMPUTE_BIT, 0, 64, (void*)&constants); for (auto& texture: input_textures) { -- cgit v1.3