aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/vulkan_common
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-03-05 07:32:18 +0100
committercrueter <crueter@eden-emu.dev>2026-03-05 07:32:18 +0100
commit9a07bd0570ceba262b4a918f4927e5674b6f7269 (patch)
treeea0b393c537bb59e85adb374997a48e1a04ef8dc /src/video_core/vulkan_common
parent05f6942befe0ab1209ecc5e2ddb9716f49d65574 (diff)
[vk] unify VkSurfaceKHR with Android and the rest of platforms; remove technically incorrect nullptr() ctor for handles (#2971)
Removes some odd #ifdef-ing that just can use a shrimple opaque type. Also removes nullptr() ctor'ing for vulkan handles and such; it's not incorrect per se like how `void *p = 0;` isn't incorrect, just that, y'know, any static analyzer will go "woah". Also there isn't any guarantee that handles `sizeof(Handle) == sizeof(void*)` so may as well :) Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2971 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/video_core/vulkan_common')
-rw-r--r--src/video_core/vulkan_common/vulkan.h5
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp2
-rw-r--r--src/video_core/vulkan_common/vulkan_surface.cpp2
-rw-r--r--src/video_core/vulkan_common/vulkan_wrapper.h44
4 files changed, 28 insertions, 25 deletions
diff --git a/src/video_core/vulkan_common/vulkan.h b/src/video_core/vulkan_common/vulkan.h
index 8d2e8e2a37..2cc0f0d7f0 100644
--- a/src/video_core/vulkan_common/vulkan.h
+++ b/src/video_core/vulkan_common/vulkan.h
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
@@ -40,3 +40,6 @@
#undef False
#undef None
#undef True
+
+// "Catch-all" handle for both Android and.. the rest of platforms
+struct VkSurfaceKHR_T;
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index a2ff3ee6ed..b51c57d380 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -419,7 +419,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
: instance{instance_}, dld{dld_}, physical{physical_},
format_properties(GetFormatProperties(physical)) {
// Get suitability and device properties.
- const bool is_suitable = GetSuitability(surface != nullptr);
+ const bool is_suitable = GetSuitability(surface != VkSurfaceKHR{});
const VkDriverId driver_id = properties.driver.driverID;
diff --git a/src/video_core/vulkan_common/vulkan_surface.cpp b/src/video_core/vulkan_common/vulkan_surface.cpp
index dc65d3960a..761b7759c8 100644
--- a/src/video_core/vulkan_common/vulkan_surface.cpp
+++ b/src/video_core/vulkan_common/vulkan_surface.cpp
@@ -15,7 +15,7 @@ vk::SurfaceKHR CreateSurface(
const vk::Instance& instance,
[[maybe_unused]] const Core::Frontend::EmuWindow::WindowSystemInfo& window_info) {
[[maybe_unused]] const vk::InstanceDispatch& dld = instance.Dispatch();
- VkSurfaceKHR unsafe_surface = nullptr;
+ VkSurfaceKHR unsafe_surface = VkSurfaceKHR{};
#ifdef _WIN32
if (window_info.type == Core::Frontend::WindowSystemType::Windows) {
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h
index 5c04132f7b..872fbd858e 100644
--- a/src/video_core/vulkan_common/vulkan_wrapper.h
+++ b/src/video_core/vulkan_common/vulkan_wrapper.h
@@ -404,13 +404,13 @@ public:
/// Construct a handle transferring the ownership from another handle.
Handle(Handle&& rhs) noexcept
- : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, dld{rhs.dld} {}
+ : handle{std::exchange(rhs.handle, Type{})}, owner{rhs.owner}, dld{rhs.dld} {}
/// Assign the current handle transferring the ownership from another handle.
/// Destroys any previously held object.
Handle& operator=(Handle&& rhs) noexcept {
Release();
- handle = std::exchange(rhs.handle, nullptr);
+ handle = std::exchange(rhs.handle, Type{});
owner = rhs.owner;
dld = rhs.dld;
return *this;
@@ -424,7 +424,7 @@ public:
/// Destroys any held object.
void reset() noexcept {
Release();
- handle = nullptr;
+ handle = Type{};
}
/// Returns the address of the held object.
@@ -440,7 +440,7 @@ public:
/// Returns true when there's a held object.
explicit operator bool() const noexcept {
- return handle != nullptr;
+ return handle != Type{};
}
#ifndef ANDROID
@@ -455,7 +455,7 @@ public:
#endif
protected:
- Type handle = nullptr;
+ Type handle{};
OwnerType owner = nullptr;
const Dispatch* dld = nullptr;
@@ -463,7 +463,7 @@ private:
/// Destroys the held object if it exists.
void Release() noexcept {
if (handle) {
- Destroy(owner, handle, *dld);
+ Destroy(OwnerType(owner), Type(handle), *dld);
}
}
};
@@ -506,7 +506,7 @@ public:
/// Destroys any held object.
void reset() noexcept {
Release();
- handle = nullptr;
+ handle = {};
}
/// Returns the address of the held object.
@@ -522,7 +522,7 @@ public:
/// Returns true when there's a held object.
explicit operator bool() const noexcept {
- return handle != nullptr;
+ return handle != Type{};
}
#ifndef ANDROID
@@ -537,7 +537,7 @@ public:
#endif
protected:
- Type handle = nullptr;
+ Type handle{};
const Dispatch* dld = nullptr;
private:
@@ -607,7 +607,7 @@ private:
std::unique_ptr<AllocationType[]> allocations;
std::size_t num = 0;
VkDevice device = nullptr;
- PoolType pool = nullptr;
+ PoolType pool{};
const DeviceDispatch* dld = nullptr;
};
@@ -669,12 +669,12 @@ public:
Image& operator=(const Image&) = delete;
Image(Image&& rhs) noexcept
- : handle{std::exchange(rhs.handle, nullptr)}, usage{rhs.usage}, owner{rhs.owner},
+ : handle{std::exchange(rhs.handle, VkImage{})}, usage{rhs.usage}, owner{rhs.owner},
allocator{rhs.allocator}, allocation{rhs.allocation}, dld{rhs.dld} {}
Image& operator=(Image&& rhs) noexcept {
Release();
- handle = std::exchange(rhs.handle, nullptr);
+ handle = std::exchange(rhs.handle, VkImage{});
usage = rhs.usage;
owner = rhs.owner;
allocator = rhs.allocator;
@@ -693,11 +693,11 @@ public:
void reset() noexcept {
Release();
- handle = nullptr;
+ handle = VkImage{};
}
explicit operator bool() const noexcept {
- return handle != nullptr;
+ return handle != VkImage{};
}
void SetObjectNameEXT(const char* name) const;
@@ -709,7 +709,7 @@ public:
private:
void Release() const noexcept;
- VkImage handle = nullptr;
+ VkImage handle{};
VkImageUsageFlags usage{};
VkDevice owner = nullptr;
VmaAllocator allocator = nullptr;
@@ -730,13 +730,13 @@ public:
Buffer& operator=(const Buffer&) = delete;
Buffer(Buffer&& rhs) noexcept
- : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator},
+ : handle{std::exchange(rhs.handle, VkBuffer{})}, owner{rhs.owner}, allocator{rhs.allocator},
allocation{rhs.allocation}, mapped{rhs.mapped},
is_coherent{rhs.is_coherent}, dld{rhs.dld} {}
Buffer& operator=(Buffer&& rhs) noexcept {
Release();
- handle = std::exchange(rhs.handle, nullptr);
+ handle = std::exchange(rhs.handle, VkBuffer{});
owner = rhs.owner;
allocator = rhs.allocator;
allocation = rhs.allocation;
@@ -756,11 +756,11 @@ public:
void reset() noexcept {
Release();
- handle = nullptr;
+ handle = VkBuffer{};
}
explicit operator bool() const noexcept {
- return handle != nullptr;
+ return handle != VkBuffer{};
}
/// Returns the host mapped memory, an empty span otherwise.
@@ -786,7 +786,7 @@ public:
private:
void Release() const noexcept;
- VkBuffer handle = nullptr;
+ VkBuffer handle{};
VkDevice owner = nullptr;
VmaAllocator allocator = nullptr;
VmaAllocation allocation = nullptr;
@@ -1020,10 +1020,10 @@ public:
[[nodiscard]] PipelineLayout CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const;
[[nodiscard]] Pipeline CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci,
- VkPipelineCache cache = nullptr) const;
+ VkPipelineCache cache = {}) const;
[[nodiscard]] Pipeline CreateComputePipeline(const VkComputePipelineCreateInfo& ci,
- VkPipelineCache cache = nullptr) const;
+ VkPipelineCache cache = {}) const;
[[nodiscard]] Sampler CreateSampler(const VkSamplerCreateInfo& ci) const;