specify backbuffer src & dst positions in call to present

This commit is contained in:
jacob 2025-11-05 18:55:26 -06:00
parent 7fc083785e
commit 0b98c24f46
6 changed files with 19 additions and 19 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -269,6 +269,7 @@ Enum(UI_FrameFlag)
{
UI_FrameFlag_None = 0,
UI_FrameFlag_Debug = (1 << 0),
UI_FrameFlag_Vsync = (1 << 1),
};
Struct(UI_Frame)