From 67d911b76f9aba1b1c196af65a89d7dda435b924 Mon Sep 17 00:00:00 2001 From: Pablo Escobar <mail@rvrs.in> Date: Mon, 21 Dec 2020 13:51:01 +0100 Subject: [PATCH] add support for getting buffer address (VK_KHR_buffer_device_address) --- liblava/resource/buffer.cpp | 12 ++++++++++++ liblava/resource/buffer.hpp | 1 + 2 files changed, 13 insertions(+) diff --git a/liblava/resource/buffer.cpp b/liblava/resource/buffer.cpp index fe5ec219..85dd957a 100644 --- a/liblava/resource/buffer.cpp +++ b/liblava/resource/buffer.cpp @@ -105,6 +105,18 @@ namespace lava { device = nullptr; } + VkDeviceAddress buffer::get_address() const { + if (device->call().vkGetBufferDeviceAddressKHR) { + VkBufferDeviceAddressInfoKHR addr_info{ + .sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR, + .buffer = vk_buffer + }; + return device->call().vkGetBufferDeviceAddressKHR(device->get(), &addr_info); + } else { + return 0; + } + } + void buffer::flush(VkDeviceSize offset, VkDeviceSize size) { vmaFlushAllocation(device->alloc(), allocation, offset, size); } diff --git a/liblava/resource/buffer.hpp b/liblava/resource/buffer.hpp index 67e58e70..0a323c07 100644 --- a/liblava/resource/buffer.hpp +++ b/liblava/resource/buffer.hpp @@ -45,6 +45,7 @@ namespace lava { return get_descriptor(); } + VkDeviceAddress get_address() const; VkDeviceSize get_size() const { return allocation_info.size; } -- GitLab