Check surface support when choosing device

This commit is contained in:
2025-04-12 20:27:30 +10:00
parent 6cbf8df17a
commit 930bba636e
5 changed files with 58 additions and 16 deletions

View File

@@ -9,12 +9,16 @@
#include <nova/api.h>
#include <nova/types.h>
#include <initializer_list>
#include <span>
#include <string>
#include <vector>
namespace Nova {
struct RenderDevice {
static constexpr u32 AUTO = static_cast<u32>(-1);
using SurfaceID = uptr;
class RenderDriver;
struct NOVA_API RenderDevice {
enum class Vendor { UNKNOWN = 0, INTEL = 0x8086, AMD = 0x1002, NVIDIA = 0x10de };
enum class Type { OTHER = 0, INTEGRATED = 1, DISCRETE = 2, VIRTUAL = 3, CPU = 4 };
@@ -24,6 +28,12 @@ namespace Nova {
u32 deviceID;
void* handle;
NOVA_API static u32 choose_device(const std::vector<RenderDevice>& devices);
static u32 choose_device(RenderDriver* driver, std::span<const SurfaceID> surfaces = {});
static u32 choose_device(RenderDriver* driver, std::initializer_list<SurfaceID> surfaces) {
return choose_device(driver, {surfaces.begin(), surfaces.end()});
}
static u32 choose_device(RenderDriver* driver, SurfaceID surface) {
return choose_device(driver, {surface});
}
};
} // namespace Nova

View File

@@ -8,7 +8,6 @@
#include <nova/api.h>
#include <nova/render/render_api.h>
#include <nova/render/render_device.h>
#include <nova/types.h>
#include <string>
@@ -17,6 +16,7 @@ namespace Nova {
using WindowID = uptr;
using SurfaceID = uptr;
struct RenderDevice;
class WindowDriver;
class NOVA_API RenderDriver {
@@ -31,6 +31,7 @@ namespace Nova {
[[nodiscard]] virtual u32 get_device_count() const = 0;
[[nodiscard]] virtual const RenderDevice& get_device(u32 index) const = 0;
[[nodiscard]] virtual bool get_device_supports_surface(u32 index, SurfaceID surface) const = 0;
virtual void select_device(u32 index) = 0;
[[nodiscard]] virtual SurfaceID create_surface(WindowID window) = 0;