Commit 2592b480 authored by Florian Oetke's avatar Florian Oetke
Browse files

modifications for vulkan 1.0.66

parent ac1bec37
......@@ -18,7 +18,10 @@ namespace mirrage::graphic {
class Device_memory {
public:
using Deleter = void(void*, std::uint32_t index, std::uint32_t layer, vk::DeviceMemory memory);
using Deleter = void(void*,
std::uint32_t index,
std::uint32_t layer,
vk::DeviceMemory memory);
Device_memory();
Device_memory(void* owner,
......@@ -78,7 +81,8 @@ namespace mirrage::graphic {
std::size_t alignment,
std::uint32_t type_mask,
bool host_visible,
Memory_lifetime lifetime = Memory_lifetime::normal) -> util::maybe<Device_memory>;
Memory_lifetime lifetime = Memory_lifetime::normal)
-> util::maybe<Device_memory>;
auto alloc_dedicated(vk::Image, bool host_visible) -> util::maybe<Device_memory>;
auto alloc_dedicated(vk::Buffer, bool host_visible) -> util::maybe<Device_memory>;
......@@ -90,7 +94,9 @@ namespace mirrage::graphic {
return _is_dedicated_allocations_supported;
}
auto is_unified_memory_architecture() const noexcept { return _is_unified_memory_architecture; }
auto is_unified_memory_architecture() const noexcept {
return _is_unified_memory_architecture;
}
private:
friend class Device_memory;
......@@ -102,14 +108,15 @@ namespace mirrage::graphic {
std::vector<std::uint32_t> _host_visible_pools;
std::vector<std::uint32_t> _device_local_pools;
auto alloc_dedicated(vk::Buffer, vk::Image, bool host_visible) -> util::maybe<Device_memory>;
auto alloc_dedicated(vk::Buffer, vk::Image, bool host_visible)
-> util::maybe<Device_memory>;
};
template <class T, class Deleter>
template <class T>
class Memory_backed {
public:
Memory_backed() = default;
Memory_backed(vk::UniqueHandle<T, Deleter>&& instance, Device_memory&& memory)
Memory_backed(vk::UniqueHandle<T>&& instance, Device_memory&& memory)
: _instance(std::move(instance)), _memory(std::move(memory)) {}
const T& operator*() const noexcept { return *_instance; }
......@@ -118,10 +125,10 @@ namespace mirrage::graphic {
auto memory() -> auto& { return _memory; }
private:
vk::UniqueHandle<T, Deleter> _instance;
Device_memory _memory;
vk::UniqueHandle<T> _instance;
Device_memory _memory;
};
using Backed_buffer = Memory_backed<vk::Buffer, vk::BufferDeleter>;
using Backed_image = Memory_backed<vk::Image, vk::ImageDeleter>;
using Backed_buffer = Memory_backed<vk::Buffer>;
using Backed_image = Memory_backed<vk::Image>;
} // namespace mirrage::graphic
......@@ -421,14 +421,20 @@ namespace mirrage::graphic {
auto formats = gpu.getSurfaceFormatsKHR(window.surface());
if(formats.size() == 1 && formats.front().format == vk::Format::eUndefined) {
return {target_format, target_space};
auto surface_format = vk::SurfaceFormatKHR{};
surface_format.format = target_format;
surface_format.colorSpace = target_space;
return surface_format;
}
auto opt_found = std::find_if(formats.begin(), formats.end(), [&](auto& f) {
return f.format == target_format && f.colorSpace == target_space;
});
if(opt_found != formats.end()) {
return {target_format, target_space};
auto surface_format = vk::SurfaceFormatKHR{};
surface_format.format = target_format;
surface_format.colorSpace = target_space;
return surface_format;
}
opt_found = std::find_if(formats.begin(), formats.end(), [&](auto& f) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment