GPU: Add SetGPUAllowedFramesInFlight (#11599)

This commit is contained in:
Evan Hemsley 2024-12-06 11:56:20 -08:00 committed by GitHub
parent 47429227ab
commit fa5f84fb6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 109 additions and 9 deletions

View file

@ -3496,6 +3496,29 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUSwapchainParameters(
SDL_GPUSwapchainComposition swapchain_composition,
SDL_GPUPresentMode present_mode);
/**
* Configures the maximum allowed number of frames in flight.
*
* The default value when the device is created is 2.
* This means that after you have submitted 2 frames for presentation, if the GPU has not finished working on the first frame, SDL_AcquireGPUSwapchainTexture() will block or return false depending on the present mode.
*
* Higher values increase throughput at the expense of visual latency.
* Lower values decrease visual latency at the expense of throughput.
*
* Note that calling this function will stall and flush the command queue to prevent synchronization issues.
*
* The minimum value of allowed frames in flight is 1, and the maximum is 3.
*
* \param device a GPU context.
* \param allowed_frames_in_flight the maximum number of frames that can be pending on the GPU before AcquireSwapchainTexture blocks or returns false.
* \returns true if successful, false on error; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.2.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUAllowedFramesInFlight(
SDL_GPUDevice *device,
Uint32 allowed_frames_in_flight);
/**
* Obtains the texture format of the swapchain for the given window.
*