Attempt to fix Renderdoc issue
This commit is contained in:
parent
ebb7862792
commit
817cb9f0dd
@ -211,7 +211,7 @@ if (NOT BB_IS_CI)
|
|||||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
|
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
|
||||||
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_WIN32)
|
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_WIN32)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XCB_KHR)
|
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR)
|
||||||
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_X11)
|
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_X11)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_METAL_EXT)
|
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_METAL_EXT)
|
||||||
|
@ -209,8 +209,12 @@ void run_app()
|
|||||||
{
|
{
|
||||||
state.arena = arena_init(MB(512), MB(2), MB(2));
|
state.arena = arena_init(MB(512), MB(2), MB(2));
|
||||||
|
|
||||||
os_graphics_init((OSGraphicsInitializationOptions) {
|
os_windowing_init((OSWindowingInitializationOptions) {
|
||||||
|
#ifdef __linux__
|
||||||
.should_use_x11 = 1,
|
.should_use_x11 = 1,
|
||||||
|
#else
|
||||||
|
.should_use_x11 = 0,
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
state.renderer = renderer_initialize(state.arena);
|
state.renderer = renderer_initialize(state.arena);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ typedef void OSWindowCursorEnter(OSWindow window, void* context, u8 entered);
|
|||||||
typedef void OSWindowScroll(OSWindow window, void* context, f64 x, f64 y);
|
typedef void OSWindowScroll(OSWindow window, void* context, f64 x, f64 y);
|
||||||
typedef void OSWindowDrop(OSWindow window, void* context, CStringSlice paths);
|
typedef void OSWindowDrop(OSWindow window, void* context, CStringSlice paths);
|
||||||
|
|
||||||
STRUCT(OSGraphicCallbacks)
|
STRUCT(OSWindowingCallbacks)
|
||||||
{
|
{
|
||||||
OSFramebufferResize* framebuffer_resize;
|
OSFramebufferResize* framebuffer_resize;
|
||||||
OSWindowResize* window_resize;
|
OSWindowResize* window_resize;
|
||||||
@ -140,9 +140,9 @@ STRUCT(OSGraphicCallbacks)
|
|||||||
OSWindowDrop* window_drop;
|
OSWindowDrop* window_drop;
|
||||||
};
|
};
|
||||||
|
|
||||||
STRUCT(OSGraphicsInitializationOptions)
|
STRUCT(OSWindowingInitializationOptions)
|
||||||
{
|
{
|
||||||
OSGraphicCallbacks callback;
|
OSWindowingCallbacks callback;
|
||||||
u8 should_use_x11;
|
u8 should_use_x11;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ STRUCT(OSCursorPosition)
|
|||||||
f64 y;
|
f64 y;
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT void os_graphics_init(OSGraphicsInitializationOptions options);
|
EXPORT void os_windowing_init(OSWindowingInitializationOptions options);
|
||||||
EXPORT OSWindow os_window_create(OSWindowCreate create);
|
EXPORT OSWindow os_window_create(OSWindowCreate create);
|
||||||
EXPORT u8 os_window_should_close(OSWindow window);
|
EXPORT u8 os_window_should_close(OSWindow window);
|
||||||
EXPORT void os_poll_events(OSEventQueue* event_queue);
|
EXPORT void os_poll_events(OSEventQueue* event_queue);
|
||||||
@ -188,3 +188,5 @@ EXPORT Window x11_window_get(OSWindow window);
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
EXPORT HANDLE win32_window_get(OSWindow window);
|
EXPORT HANDLE win32_window_get(OSWindow window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int window_create_surface(void* instance, OSWindow window, const void* allocator, void** surface);
|
||||||
|
@ -1565,13 +1565,13 @@ fn void swapchain_recreate(Renderer* renderer, RenderWindow* window)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void GLFWwindow;
|
// typedef void GLFWwindow;
|
||||||
extern VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
// extern VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
RenderWindow* renderer_window_initialize(Renderer* renderer, OSWindow window)
|
RenderWindow* renderer_window_initialize(Renderer* renderer, OSWindow window)
|
||||||
{
|
{
|
||||||
RenderWindow* result = &renderer_window_memory;
|
RenderWindow* result = &renderer_window_memory;
|
||||||
vkok(glfwCreateWindowSurface(renderer->instance, window, renderer->allocator, &result->surface));
|
vkok((VkResult)window_create_surface(renderer->instance, window, renderer->allocator, (void**)&result->surface));
|
||||||
|
|
||||||
swapchain_recreate(renderer, result);
|
swapchain_recreate(renderer, result);
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
|
|
||||||
global_variable OSGraphicCallbacks callbacks;
|
global_variable OSWindowingCallbacks callbacks;
|
||||||
|
|
||||||
// TODO: thread local
|
// TODO: thread local
|
||||||
global_variable OSEventQueue* event_queue = 0;
|
global_variable OSEventQueue* event_queue = 0;
|
||||||
|
global_variable u8 use_x11 = 0;
|
||||||
|
|
||||||
fn void monitor_callback(GLFWmonitor* monitor, int event)
|
fn void monitor_callback(GLFWmonitor* monitor, int event)
|
||||||
{
|
{
|
||||||
@ -41,11 +42,16 @@ fn void bitset_list_add(VirtualBuffer(OSEventBitset)* list, u32* counter, u64 va
|
|||||||
list->pointer[bitset_index].value |= (value << bit_index);
|
list->pointer[bitset_index].value |= (value << bit_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void os_graphics_init(OSGraphicsInitializationOptions options)
|
void os_windowing_init(OSWindowingInitializationOptions options)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
use_x11 = options.should_use_x11;
|
||||||
int platform_hint = options.should_use_x11 ? GLFW_PLATFORM_X11 : GLFW_PLATFORM_WAYLAND;
|
int platform_hint = options.should_use_x11 ? GLFW_PLATFORM_X11 : GLFW_PLATFORM_WAYLAND;
|
||||||
glfwInitHint(GLFW_PLATFORM, platform_hint);
|
glfwInitHint(GLFW_PLATFORM, platform_hint);
|
||||||
|
if (platform_hint == GLFW_PLATFORM_X11)
|
||||||
|
{
|
||||||
|
glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, GLFW_FALSE);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (glfwInit() != GLFW_TRUE)
|
if (glfwInit() != GLFW_TRUE)
|
||||||
@ -427,3 +433,28 @@ OSCursorPosition os_window_cursor_position_get(OSWindow window)
|
|||||||
glfwGetCursorPos(window, &result.x, &result.y);
|
glfwGetCursorPos(window, &result.x, &result.y);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int window_create_surface(void* instance, OSWindow window, const void* allocator, void** surface)
|
||||||
|
{
|
||||||
|
#define FORCE_XLIB_INITIALIZATION 1
|
||||||
|
auto* surface_pointer = (VkSurfaceKHR*)surface;
|
||||||
|
if (use_x11 && FORCE_XLIB_INITIALIZATION)
|
||||||
|
{
|
||||||
|
auto* x11_display = glfwGetX11Display();
|
||||||
|
auto x11_window = glfwGetX11Window(window);
|
||||||
|
VkXlibSurfaceCreateInfoKHR create_info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR,
|
||||||
|
.pNext = 0,
|
||||||
|
.flags = 0,
|
||||||
|
.dpy = x11_display,
|
||||||
|
.window = x11_window,
|
||||||
|
};
|
||||||
|
|
||||||
|
return vkCreateXlibSurfaceKHR(instance, &create_info, allocator, surface_pointer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return glfwCreateWindowSurface(instance, window, allocator, surface_pointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user