Skip to content

Commit

Permalink
Implement functions on D3D12
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut committed Dec 11, 2024
1 parent deac376 commit 2b973f0
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions src/gpu/d3d12/SDL_gpu_d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -7148,7 +7148,8 @@ static bool D3D12_WaitForSwapchain(
return true;
}

static bool D3D12_AcquireSwapchainTexture(
static bool D3D12_INTERNAL_AcquireSwapchainTexture(
bool block,
SDL_GPUCommandBuffer *commandBuffer,
SDL_Window *window,
SDL_GPUTexture **swapchainTexture,
Expand Down Expand Up @@ -7188,7 +7189,7 @@ static bool D3D12_AcquireSwapchainTexture(
}

if (windowData->inFlightFences[windowData->frameCounter] != NULL) {
if (windowData->present_mode == SDL_GPU_PRESENTMODE_VSYNC) {
if (block) {
// In VSYNC mode, block until the least recent presented frame is done
if (!D3D12_WaitForFences(
(SDL_GPURenderer *)renderer,
Expand All @@ -7198,13 +7199,11 @@ static bool D3D12_AcquireSwapchainTexture(
return false;
}
} else {
// If we are not blocking and the least recent fence is not signaled,
// return true to indicate that there is no error but rendering should be skipped.
if (!D3D12_QueryFence(
(SDL_GPURenderer *)renderer,
windowData->inFlightFences[windowData->frameCounter])) {
/*
* In MAILBOX or IMMEDIATE mode, if the least recent fence is not signaled,
* return true to indicate that there is no error but rendering should be skipped
*/
return true;
}
}
Expand Down Expand Up @@ -7262,6 +7261,38 @@ static bool D3D12_AcquireSwapchainTexture(
return true;
}

static bool D3D12_AcquireSwapchainTexture(
SDL_GPUCommandBuffer *command_buffer,
SDL_Window *window,
SDL_GPUTexture **swapchain_texture,
Uint32 *swapchain_texture_width,
Uint32 *swapchain_texture_height
) {
return D3D12_INTERNAL_AcquireSwapchainTexture(
false,
command_buffer,
window,
swapchain_texture,
swapchain_texture_width,
swapchain_texture_height);
}

static bool D3D12_WaitAndAcquireSwapchainTexture(
SDL_GPUCommandBuffer *command_buffer,
SDL_Window *window,
SDL_GPUTexture **swapchain_texture,
Uint32 *swapchain_texture_width,
Uint32 *swapchain_texture_height
) {
return D3D12_INTERNAL_AcquireSwapchainTexture(
true,
command_buffer,
window,
swapchain_texture,
swapchain_texture_width,
swapchain_texture_height);
}

static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
{
SDL_LockMutex(renderer->disposeLock);
Expand Down

0 comments on commit 2b973f0

Please sign in to comment.