tests: Update GPU tests to use new swapchain best practice

This commit is contained in:
cosmonaut
2024-12-19 15:55:04 -08:00
parent 401c8f8e4e
commit e46d8756e5
2 changed files with 17 additions and 24 deletions

View File

@@ -82,11 +82,11 @@ SDL_AppResult SDL_AppIterate(void *appstate)
} }
SDL_GPUTexture *swapchainTexture; SDL_GPUTexture *swapchainTexture;
if (!SDL_AcquireGPUSwapchainTexture(cmdbuf, state->windows[0], &swapchainTexture, NULL, NULL)) { if (!SDL_WaitAndAcquireGPUSwapchainTexture(cmdbuf, state->windows[0], &swapchainTexture, NULL, NULL)) {
SDL_Log("SDL_AcquireGPUSwapchainTexture failed: %s", SDL_GetError()); SDL_Log("SDL_AcquireGPUSwapchainTexture failed: %s", SDL_GetError());
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
if (swapchainTexture != NULL) {
const double currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency(); const double currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
SDL_GPURenderPass *renderPass; SDL_GPURenderPass *renderPass;
SDL_GPUColorTargetInfo color_target_info; SDL_GPUColorTargetInfo color_target_info;
@@ -101,7 +101,6 @@ SDL_AppResult SDL_AppIterate(void *appstate)
renderPass = SDL_BeginGPURenderPass(cmdbuf, &color_target_info, 1, NULL); renderPass = SDL_BeginGPURenderPass(cmdbuf, &color_target_info, 1, NULL);
SDL_EndGPURenderPass(renderPass); SDL_EndGPURenderPass(renderPass);
}
SDL_SubmitGPUCommandBuffer(cmdbuf); SDL_SubmitGPUCommandBuffer(cmdbuf);

View File

@@ -341,20 +341,14 @@ Render(SDL_Window *window, const int windownum)
SDL_Log("Failed to acquire command buffer :%s", SDL_GetError()); SDL_Log("Failed to acquire command buffer :%s", SDL_GetError());
quit(2); quit(2);
} }
if (!SDL_AcquireGPUSwapchainTexture(cmd, state->windows[windownum], &swapchainTexture, &drawablew, &drawableh)) { if (!SDL_WaitAndAcquireGPUSwapchainTexture(cmd, state->windows[windownum], &swapchainTexture, &drawablew, &drawableh)) {
SDL_Log("Failed to acquire swapchain texture: %s", SDL_GetError()); SDL_Log("Failed to acquire swapchain texture: %s", SDL_GetError());
quit(2); quit(2);
} }
if (swapchainTexture == NULL) {
/* No swapchain was acquired, probably too many frames in flight */
SDL_SubmitGPUCommandBuffer(cmd);
return;
}
/* /*
* Do some rotation with Euler angles. It is not a fixed axis as * Do some rotation with Euler angles. It is not a fixed axis as
* quaterions would be, but the effect is cool. * quaternions would be, but the effect is cool.
*/ */
rotate_matrix((float)winstate->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview); rotate_matrix((float)winstate->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview);
rotate_matrix((float)winstate->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate); rotate_matrix((float)winstate->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate);