diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2019-06-22 19:34:26 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2020-02-11 11:57:11 +0100 |
commit | eb48be51dbe97aa4fbbbe0d0ebd8a98bee6b263e (patch) | |
tree | 9a5b6bfd50e7ddb5b348c97bd60d30b290d27d49 /platform/windows/os_windows.cpp | |
parent | 4fe3ee1730167b90ec8ae70c871c1dad032981d5 (diff) |
Add static Vulkan loader.
Initial Vulkan support for Windows.
Initial Vulkan support for macOS.
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rwxr-xr-x | platform/windows/os_windows.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3a8e8bdb5a..1f2fbd3f4f 100755 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -35,8 +35,15 @@ #include "core/io/marshalls.h" #include "core/version_generated.gen.h" + +#if defined(OPENGL_ENABLED) #include "drivers/gles2/rasterizer_gles2.h" #include "drivers/gles3/rasterizer_gles3.h" +#endif +#if defined(VULKAN_ENABLED) +#include "servers/visual/rasterizer/rasterizer_rd.h" +#endif + #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/mutex_windows.h" @@ -893,6 +900,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) preserve_window_size = false; set_window_size(Size2(video_mode.width, video_mode.height)); } +#if defined(VULKAN_ENABLED) + context_vulkan->window_resize(0, video_mode.width, video_mode.height); +#endif } if (wParam == SIZE_MAXIMIZED) { @@ -1489,7 +1499,18 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int gl_context->set_use_vsync(video_mode.use_vsync); set_vsync_via_compositor(video_mode.vsync_via_compositor); #endif +#if defined(VULKAN_ENABLED) + video_driver_index = VIDEO_DRIVER_VULKAN; + + context_vulkan = memnew(VulkanContextWindows); + context_vulkan->initialize(); + context_vulkan->window_create(hWnd, hInstance, get_video_mode().width, get_video_mode().height); + //temporary + rendering_device = memnew(RenderingDeviceVulkan); + rendering_device->initialize(context_vulkan); + RasterizerRD::make_current(); +#endif visual_server = memnew(VisualServerRaster); if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); @@ -1665,6 +1686,13 @@ void OS_Windows::finalize() { memdelete(gl_context); #endif +#if defined(VULKAN_ENABLED) + rendering_device->finalize(); + memdelete(rendering_device); + + memdelete(context_vulkan); +#endif + if (user_proc) { SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); }; @@ -1965,6 +1993,10 @@ void OS_Windows::set_window_size(const Size2 p_size) { video_mode.width = w; video_mode.height = h; +#if defined(VULKAN_ENABLED) + context_vulkan->window_resize(0, video_mode.width, video_mode.height); +#endif + if (video_mode.fullscreen) { return; } @@ -3121,18 +3153,24 @@ OS::LatinKeyboardVariant OS_Windows::get_latin_keyboard_variant() const { } void OS_Windows::release_rendering_thread() { - +#if defined(OPENGL_ENABLED) gl_context->release_current(); +#endif } void OS_Windows::make_rendering_thread() { - +#if defined(OPENGL_ENABLED) gl_context->make_current(); +#endif } void OS_Windows::swap_buffers() { - +#if defined(OPENGL_ENABLED) gl_context->swap_buffers(); +#endif +#if defined(VULKAN_ENABLED) + context_vulkan->swap_buffers(); +#endif } void OS_Windows::force_process_input() { @@ -3299,9 +3337,10 @@ String OS_Windows::get_joy_guid(int p_device) const { } void OS_Windows::_set_use_vsync(bool p_enable) { - +#if defined(OPENGL_ENABLED) if (gl_context) gl_context->set_use_vsync(p_enable); +#endif } /* bool OS_Windows::is_vsync_enabled() const { |