diff --git a/src/gpu/gpu_core.h b/src/gpu/gpu_core.h index aa7e57b7..f092870e 100644 --- a/src/gpu/gpu_core.h +++ b/src/gpu/gpu_core.h @@ -493,4 +493,4 @@ void GPU_YieldOnSwapchain(GPU_Swapchain *swapchain); * 2. Blits `texture` into position `dst` in the backbuffer * 3. Presents the backbuffer * 4. Returns the value that the Direct queue fence will reach once GPU completes blitting (`texture` shouldn't be released while blit is in flight) */ -i64 GPU_PresentSwapchain(GPU_Swapchain *swapchain, GPU_Resource *texture, Vec2I32 backbuffer_size, Vec2I32 dst, i32 vsync); +i64 GPU_PresentSwapchain(GPU_Swapchain *swapchain, GPU_Resource *texture, i32 vsync, Vec2I32 backbuffer_size, Vec2I32 dst_p0, Vec2I32 dst_p1, Vec2I32 src_p0, Vec2I32 src_p1); diff --git a/src/gpu/gpu_dx12/gpu_dx12.c b/src/gpu/gpu_dx12/gpu_dx12.c index bbb30112..b97ca8b1 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.c +++ b/src/gpu/gpu_dx12/gpu_dx12.c @@ -1960,7 +1960,7 @@ GPU_D12_SwapchainBuffer *GPU_D12_UpdateSwapchain(GPU_D12_Swapchain *swapchain, V return &swapchain->buffers[backbuffer_index]; } -i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *dst, GPU_D12_Resource *texture, Vec2I32 dst_pos) +i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *dst, GPU_D12_Resource *texture, Vec2I32 dst_p0, Vec2I32 dst_p1, Vec2I32 src_p0, Vec2I32 src_p1) { GPU_D12_SharedState *g = &GPU_D12_shared_state; @@ -2029,15 +2029,14 @@ i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *dst, GPU_D12_Resource *text src_loc.SubresourceIndex = 0; Vec2I32 dst_size = swapchain->resolution; - Vec2I32 src_size = VEC2I32(texture->desc.texture.size.x, texture->desc.texture.size.y); - i32 dst_left = dst_pos.x; - i32 dst_top = dst_pos.y; + i32 dst_top = dst_p0.y; + i32 dst_left = dst_p0.x; - i32 src_left = 0; - i32 src_top = 0; - i32 src_right = src_size.x; - i32 src_bottom = src_size.y; + i32 src_left = src_p0.x; + i32 src_top = src_p0.y; + i32 src_right = src_p1.x; + i32 src_bottom = src_p1.y; /* Clamp copy src & dst */ if (dst_left < 0) @@ -2195,7 +2194,7 @@ void GPU_YieldOnSwapchain(GPU_Swapchain *gpu_swapchain) } } -i64 GPU_PresentSwapchain(GPU_Swapchain *gpu_swapchain, GPU_Resource *gpu_texture, Vec2I32 backbuffer_size, Vec2I32 dst, i32 vsync) +i64 GPU_PresentSwapchain(GPU_Swapchain *gpu_swapchain, GPU_Resource *gpu_texture, i32 vsync, Vec2I32 backbuffer_size, Vec2I32 dst_p0, Vec2I32 dst_p1, Vec2I32 src_p0, Vec2I32 src_p1) { GPU_D12_Swapchain *swapchain = (GPU_D12_Swapchain *)gpu_swapchain; GPU_D12_Resource *texture = (GPU_D12_Resource *)gpu_texture; @@ -2215,7 +2214,7 @@ i64 GPU_PresentSwapchain(GPU_Swapchain *gpu_swapchain, GPU_Resource *gpu_texture if (is_blitable) { /* Blit */ - fence_target = GPU_D12_BlitToSwapchain(swapchain_buffer, texture, dst); + fence_target = GPU_D12_BlitToSwapchain(swapchain_buffer, texture, dst_p0, dst_p1, src_p0, src_p1); u32 present_flags = 0; if (GPU_D12_TearingIsAllowed && vsync == 0) diff --git a/src/gpu/gpu_dx12/gpu_dx12.h b/src/gpu/gpu_dx12/gpu_dx12.h index f8d1bc52..4050a94a 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.h +++ b/src/gpu/gpu_dx12/gpu_dx12.h @@ -380,7 +380,7 @@ u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl); void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain); GPU_D12_SwapchainBuffer *GPU_D12_UpdateSwapchain(GPU_D12_Swapchain *swapchain, Vec2I32 resolution); -i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *swapchain_buffer, GPU_D12_Resource *texture, Vec2I32 dst_pos); +i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *dst, GPU_D12_Resource *texture, Vec2I32 dst_p0, Vec2I32 dst_p1, Vec2I32 src_p0, Vec2I32 src_p1); //////////////////////////////////////////////////////////// //~ Sync job diff --git a/src/pp/pp.c b/src/pp/pp.c index 3ef02e4e..c9cc1a16 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -359,10 +359,8 @@ void PP_UpdateUser(void) //- Begin UI frame UI_FrameFlag ui_frame_flags = 0; - if (g->ui_debug) - { - ui_frame_flags |= UI_FrameFlag_Debug; - } + ui_frame_flags |= UI_FrameFlag_Debug * !!g->ui_debug; + ui_frame_flags |= UI_FrameFlag_Vsync * !!VSYNC; UI_Frame ui_frame = UI_BeginFrame(ui_frame_flags); WND_Frame window_frame = ui_frame.window_frame; ControllerEventsArray controller_events = window_frame.controller_events; diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index dbb255a3..a367d35a 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1353,14 +1353,16 @@ i64 UI_EndFrame(UI_Frame frame) //- Present & end frame { - /* FIXME: Real xform */ - Vec2I32 backbuffer_size = monitor_size; if (!g->swapchain) { g->swapchain = GPU_AcquireSwapchain(frame.window_frame.window_handle, GPU_Format_R8G8B8A8_Unorm, backbuffer_size); } - g->gpu_submit_fence_target = GPU_PresentSwapchain(g->swapchain, g->render_target, backbuffer_size, VEC2I32(0, 0), VSYNC); + Vec2I32 dst_p0 = VEC2I32(0, 0); + Vec2I32 dst_p1 = VEC2I32(0, 0); + Vec2I32 src_p0 = VEC2I32(0, 0); + Vec2I32 src_p1 = draw_size; + g->gpu_submit_fence_target = GPU_PresentSwapchain(g->swapchain, g->render_target, AnyBit(g->frame_flags, UI_FrameFlag_Vsync), backbuffer_size, dst_p0, dst_p1, src_p0, src_p1); } WND_EndFrame(frame.window_frame); diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index ced12891..2ab0bcce 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -269,6 +269,7 @@ Enum(UI_FrameFlag) { UI_FrameFlag_None = 0, UI_FrameFlag_Debug = (1 << 0), + UI_FrameFlag_Vsync = (1 << 1), }; Struct(UI_Frame)