formatting
This commit is contained in:
parent
1a19a9e693
commit
d38046a007
BIN
res/sprite/tim.ase
(Stored with Git LFS)
BIN
res/sprite/tim.ase
(Stored with Git LFS)
Binary file not shown.
@ -236,6 +236,7 @@ INTERNAL JOB_DEF(playback_job, _)
|
|||||||
DWORD task = 0;
|
DWORD task = 0;
|
||||||
HANDLE mmc_handle = AvSetMmThreadCharacteristicsW(L"Pro Audio", &task);
|
HANDLE mmc_handle = AvSetMmThreadCharacteristicsW(L"Pro Audio", &task);
|
||||||
ASSERT(mmc_handle);
|
ASSERT(mmc_handle);
|
||||||
|
(UNUSED)mmc_handle;
|
||||||
|
|
||||||
/* FIXME: If playback fails at any point and mixer stops advancing, we
|
/* FIXME: If playback fails at any point and mixer stops advancing, we
|
||||||
* need to halt mixer to prevent memory leak when sounds are played. */
|
* need to halt mixer to prevent memory leak when sounds are played. */
|
||||||
|
|||||||
@ -7,25 +7,20 @@
|
|||||||
|
|
||||||
#if PROFILING
|
#if PROFILING
|
||||||
|
|
||||||
/* Include tracy client */
|
#define PROFILING_SYSTEM_TRACE 0
|
||||||
#define TRACY_ENABLE
|
|
||||||
#if 0
|
|
||||||
/* Enable manual lifetime */
|
|
||||||
# define TRACY_MANUAL_LIFETIME
|
|
||||||
# define TRACY_DELAYED_INIT
|
|
||||||
#endif
|
|
||||||
#if 1
|
|
||||||
/* Disable system tracing (very slow) */
|
|
||||||
# define TRACY_NO_CALLSTACK
|
|
||||||
# define TRACY_NO_SYSTEM_TRACING
|
|
||||||
#endif
|
|
||||||
#include STRINGIZE(TRACY_INCLUDE_PATH)
|
|
||||||
|
|
||||||
#define PROFILING_CAPTURE_FRAME_IMAGE 0
|
#define PROFILING_CAPTURE_FRAME_IMAGE 0
|
||||||
#define PROFILING_LOCKS 0
|
#define PROFILING_LOCKS 0
|
||||||
#define PROFILING_D3D 1
|
#define PROFILING_D3D 1
|
||||||
#define PROFILING_CMD_WSTR L"tracy-profiler.exe -a 127.0.0.1"
|
#define PROFILING_CMD_WSTR L"tracy-profiler.exe -a 127.0.0.1"
|
||||||
|
|
||||||
|
/* Include tracy client */
|
||||||
|
#define TRACY_ENABLE
|
||||||
|
#if !PROFILING_SYSTEM_TRACE
|
||||||
|
# define TRACY_NO_CALLSTACK
|
||||||
|
# define TRACY_NO_SYSTEM_TRACING
|
||||||
|
#endif
|
||||||
|
#include STRINGIZE(TRACY_INCLUDE_PATH)
|
||||||
|
|
||||||
/* Clang/GCC cleanup macros */
|
/* Clang/GCC cleanup macros */
|
||||||
#define __prof static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { NULL, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
#define __prof static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { NULL, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
||||||
#define __profscope(name) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
#define __profscope(name) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
||||||
@ -131,12 +126,4 @@ INLINE void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3
|
|||||||
# define __profframeimage(image, width, height, offset, flipped)
|
# define __profframeimage(image, width, height, offset, flipped)
|
||||||
#endif /* PROFILING_CAPTURE_FRAME_IMAGE */
|
#endif /* PROFILING_CAPTURE_FRAME_IMAGE */
|
||||||
|
|
||||||
#ifdef TRACY_MANUAL_LIFETIME
|
|
||||||
# define __prof_startup ___tracy_startup_profiler()
|
|
||||||
# define __prof_shutdown ___tracy_shutdown_profiler()
|
|
||||||
#else
|
|
||||||
# define __prof_startup
|
|
||||||
# define __prof_shutdown
|
|
||||||
#endif /* TRACY_MANUAL_LIFETIME */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
118
src/sys_win32.c
118
src/sys_win32.c
@ -960,71 +960,74 @@ INTERNAL SYS_THREAD_DEF(window_thread_entry_point, arg)
|
|||||||
|
|
||||||
while (!atomic_i32_eval(&window->event_thread_shutdown)) {
|
while (!atomic_i32_eval(&window->event_thread_shutdown)) {
|
||||||
MSG msg = ZI;
|
MSG msg = ZI;
|
||||||
GetMessageW(&msg, 0, 0, 0);
|
{
|
||||||
|
GetMessageW(&msg, 0, 0, 0);
|
||||||
if (atomic_i32_eval(&window->event_thread_shutdown)) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
/* Update cursor */
|
__profscope(Process window message);
|
||||||
if (GetFocus() == window->hwnd) {
|
if (atomic_i32_eval(&window->event_thread_shutdown)) {
|
||||||
u32 cursor_flags = window->cursor_set_flags;
|
break;
|
||||||
|
|
||||||
/* Hide cursor */
|
|
||||||
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_HIDE) {
|
|
||||||
while(ShowCursor(false) >= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show cursor */
|
/* Update cursor */
|
||||||
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_SHOW) {
|
if (GetFocus() == window->hwnd) {
|
||||||
while(ShowCursor(true) < 0);
|
u32 cursor_flags = window->cursor_set_flags;
|
||||||
|
|
||||||
|
/* Hide cursor */
|
||||||
|
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_HIDE) {
|
||||||
|
while(ShowCursor(false) >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show cursor */
|
||||||
|
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_SHOW) {
|
||||||
|
while(ShowCursor(true) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update position */
|
||||||
|
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_POSITION) {
|
||||||
|
struct v2 window_space_pos = window->cursor_set_position;
|
||||||
|
POINT p = { window_space_pos.x, window_space_pos.y };
|
||||||
|
ClientToScreen(window->hwnd, &p);
|
||||||
|
SetCursorPos(p.x, p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stop clipping cursor */
|
||||||
|
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_DISABLE_CLIP) {
|
||||||
|
ClipCursor(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clip cursor in window window */
|
||||||
|
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_ENABLE_CLIP) {
|
||||||
|
i32 left = window->x + math_round_to_int(window->cursor_clip_bounds.x);
|
||||||
|
i32 right = left + math_round_to_int(window->cursor_clip_bounds.width);
|
||||||
|
i32 top = window->y + math_round_to_int(window->cursor_clip_bounds.y);
|
||||||
|
i32 bottom = top + math_round_to_int(window->cursor_clip_bounds.height);
|
||||||
|
RECT clip = {
|
||||||
|
.left = clamp_i32(left, window->x, window->x + window->width),
|
||||||
|
.right = clamp_i32(right, window->x, window->x + window->width),
|
||||||
|
.top = clamp_i32(top, window->y, window->y + window->height),
|
||||||
|
.bottom = clamp_i32(bottom, window->y, window->y + window->height)
|
||||||
|
};
|
||||||
|
ClipCursor(&clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
window->cursor_set_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update position */
|
/* Process message */
|
||||||
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_POSITION) {
|
switch (msg.message) {
|
||||||
struct v2 window_space_pos = window->cursor_set_position;
|
case WM_QUIT: {
|
||||||
POINT p = { window_space_pos.x, window_space_pos.y };
|
win32_window_process_event(window, (struct sys_event) { .kind = SYS_EVENT_KIND_QUIT });
|
||||||
ClientToScreen(window->hwnd, &p);
|
} break;
|
||||||
SetCursorPos(p.x, p.y);
|
|
||||||
|
default: {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageW(&msg);
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop clipping cursor */
|
|
||||||
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_DISABLE_CLIP) {
|
|
||||||
ClipCursor(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clip cursor in window window */
|
|
||||||
if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_ENABLE_CLIP) {
|
|
||||||
i32 left = window->x + math_round_to_int(window->cursor_clip_bounds.x);
|
|
||||||
i32 right = left + math_round_to_int(window->cursor_clip_bounds.width);
|
|
||||||
i32 top = window->y + math_round_to_int(window->cursor_clip_bounds.y);
|
|
||||||
i32 bottom = top + math_round_to_int(window->cursor_clip_bounds.height);
|
|
||||||
RECT clip = {
|
|
||||||
.left = clamp_i32(left, window->x, window->x + window->width),
|
|
||||||
.right = clamp_i32(right, window->x, window->x + window->width),
|
|
||||||
.top = clamp_i32(top, window->y, window->y + window->height),
|
|
||||||
.bottom = clamp_i32(bottom, window->y, window->y + window->height)
|
|
||||||
};
|
|
||||||
ClipCursor(&clip);
|
|
||||||
}
|
|
||||||
|
|
||||||
window->cursor_set_flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process message */
|
|
||||||
switch (msg.message) {
|
|
||||||
case WM_QUIT: {
|
|
||||||
win32_window_process_event(window, (struct sys_event) { .kind = SYS_EVENT_KIND_QUIT });
|
|
||||||
} break;
|
|
||||||
|
|
||||||
default: {
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessageW(&msg);
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Destroy window hwnd */
|
/* Destroy window hwnd */
|
||||||
DestroyWindow(window->hwnd);
|
DestroyWindow(window->hwnd);
|
||||||
}
|
}
|
||||||
@ -1220,6 +1223,7 @@ INTERNAL void win32_window_wake(struct win32_window *window)
|
|||||||
|
|
||||||
INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
|
__prof;
|
||||||
struct win32_window *window = (struct win32_window *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
struct win32_window *window = (struct win32_window *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
|
|
||||||
if (!window) {
|
if (!window) {
|
||||||
@ -2352,7 +2356,6 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
(UNUSED)prev_instance;
|
(UNUSED)prev_instance;
|
||||||
(UNUSED)cmdline_wstr;
|
(UNUSED)cmdline_wstr;
|
||||||
(UNUSED)show_code;
|
(UNUSED)show_code;
|
||||||
__prof_startup;
|
|
||||||
|
|
||||||
u64 cmdline_len = wstr_len(cmdline_wstr, ARRAY_COUNT(G.cmdline_args_wstr) - 1);
|
u64 cmdline_len = wstr_len(cmdline_wstr, ARRAY_COUNT(G.cmdline_args_wstr) - 1);
|
||||||
MEMCPY(G.cmdline_args_wstr, cmdline_wstr, cmdline_len * sizeof(*cmdline_wstr));
|
MEMCPY(G.cmdline_args_wstr, cmdline_wstr, cmdline_len * sizeof(*cmdline_wstr));
|
||||||
@ -2561,7 +2564,6 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__prof_shutdown;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user