| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "servers/display/display_server.h" |
| 34 |
|
| 35 |
class RenderingDeviceDriver; |
| 36 |
|
| 37 |
class RenderingContextDriver { |
| 38 |
public: |
| 39 |
typedef uint64_t SurfaceID; |
| 40 |
|
| 41 |
private: |
| 42 |
HashMap<DisplayServer::WindowID, SurfaceID> window_surface_map; |
| 43 |
|
| 44 |
public: |
| 45 |
SurfaceID surface_get_from_window(DisplayServer::WindowID p_window) const; |
| 46 |
Error window_create(DisplayServer::WindowID p_window, const void *p_platform_data); |
| 47 |
void window_set_size(DisplayServer::WindowID p_window, uint32_t p_width, uint32_t p_height); |
| 48 |
void window_set_vsync_mode(DisplayServer::WindowID p_window, DisplayServer::VSyncMode p_vsync_mode); |
| 49 |
DisplayServer::VSyncMode window_get_vsync_mode(DisplayServer::WindowID p_window) const; |
| 50 |
void window_destroy(DisplayServer::WindowID p_window); |
| 51 |
|
| 52 |
public: |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
struct Vendor { |
| 58 |
constexpr static uint32_t VENDOR_UNKNOWN = 0x0; |
| 59 |
constexpr static uint32_t VENDOR_AMD = 0x1002; |
| 60 |
constexpr static uint32_t VENDOR_IMGTEC = 0x1010; |
| 61 |
constexpr static uint32_t VENDOR_APPLE = 0x106B; |
| 62 |
constexpr static uint32_t VENDOR_NVIDIA = 0x10DE; |
| 63 |
constexpr static uint32_t VENDOR_ARM = 0x13B5; |
| 64 |
constexpr static uint32_t VENDOR_MICROSOFT = 0x1414; |
| 65 |
constexpr static uint32_t VENDOR_QUALCOMM = 0x5143; |
| 66 |
constexpr static uint32_t VENDOR_INTEL = 0x8086; |
| 67 |
}; |
| 68 |
|
| 69 |
enum DeviceType { |
| 70 |
DEVICE_TYPE_OTHER = 0x0, |
| 71 |
DEVICE_TYPE_INTEGRATED_GPU = 0x1, |
| 72 |
DEVICE_TYPE_DISCRETE_GPU = 0x2, |
| 73 |
DEVICE_TYPE_VIRTUAL_GPU = 0x3, |
| 74 |
DEVICE_TYPE_CPU = 0x4, |
| 75 |
DEVICE_TYPE_MAX = 0x5 |
| 76 |
}; |
| 77 |
|
| 78 |
struct Workarounds { |
| 79 |
bool avoid_compute_after_draw = false; |
| 80 |
}; |
| 81 |
|
| 82 |
struct Device { |
| 83 |
String name = "Unknown"; |
| 84 |
uint32_t vendor = Vendor::VENDOR_UNKNOWN; |
| 85 |
DeviceType type = DEVICE_TYPE_OTHER; |
| 86 |
Workarounds workarounds; |
| 87 |
}; |
| 88 |
|
| 89 |
virtual ~RenderingContextDriver(); |
| 90 |
virtual Error initialize() = 0; |
| 91 |
virtual const Device &device_get(uint32_t p_device_index) const = 0; |
| 92 |
virtual uint32_t device_get_count() const = 0; |
| 93 |
virtual bool device_supports_present(uint32_t p_device_index, SurfaceID p_surface) const = 0; |
| 94 |
virtual RenderingDeviceDriver *driver_create() = 0; |
| 95 |
virtual void driver_free(RenderingDeviceDriver *p_driver) = 0; |
| 96 |
virtual SurfaceID surface_create(const void *p_platform_data) = 0; |
| 97 |
virtual void surface_set_size(SurfaceID p_surface, uint32_t p_width, uint32_t p_height) = 0; |
| 98 |
virtual void surface_set_vsync_mode(SurfaceID p_surface, DisplayServer::VSyncMode p_vsync_mode) = 0; |
| 99 |
virtual DisplayServer::VSyncMode surface_get_vsync_mode(SurfaceID p_surface) const = 0; |
| 100 |
virtual uint32_t surface_get_width(SurfaceID p_surface) const = 0; |
| 101 |
virtual uint32_t surface_get_height(SurfaceID p_surface) const = 0; |
| 102 |
virtual void surface_set_needs_resize(SurfaceID p_surface, bool p_needs_resize) = 0; |
| 103 |
virtual bool surface_get_needs_resize(SurfaceID p_surface) const = 0; |
| 104 |
virtual void surface_destroy(SurfaceID p_surface) = 0; |
| 105 |
virtual bool is_debug_utils_enabled() const = 0; |
| 106 |
|
| 107 |
String get_driver_and_device_memory_report() const; |
| 108 |
|
| 109 |
virtual const char *get_tracked_object_name(uint32_t p_type_index) const; |
| 110 |
virtual uint64_t get_tracked_object_type_count() const; |
| 111 |
|
| 112 |
virtual uint64_t get_driver_total_memory() const; |
| 113 |
virtual uint64_t get_driver_allocation_count() const; |
| 114 |
virtual uint64_t get_driver_memory_by_object_type(uint32_t p_type) const; |
| 115 |
virtual uint64_t get_driver_allocs_by_object_type(uint32_t p_type) const; |
| 116 |
|
| 117 |
virtual uint64_t get_device_total_memory() const; |
| 118 |
virtual uint64_t get_device_allocation_count() const; |
| 119 |
virtual uint64_t get_device_memory_by_object_type(uint32_t p_type) const; |
| 120 |
virtual uint64_t get_device_allocs_by_object_type(uint32_t p_type) const; |
| 121 |
}; |