From 304d425f99b3b62e5f77ef869731bb702810a572 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 3 Jul 2023 17:09:49 -0700 Subject: [PATCH] The clip rect is defined in terms of the current viewport Don't use the viewport offset when setting the clip rect in the D3D12 renderer. This fixes "testautomation --filter render_testViewport" on Windows --- src/render/direct3d12/SDL_render_d3d12.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 376361bfe..16fcb5ee3 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -2604,6 +2604,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, case SDL_RENDERCMD_SETCLIPRECT: { const SDL_Rect *rect = &cmd->data.cliprect.rect; + SDL_Rect viewport_cliprect; if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; rendererData->cliprectDirty = SDL_TRUE; @@ -2611,7 +2612,11 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (!rendererData->currentCliprectEnabled) { /* If the clip rect is disabled, then the scissor rect should be the whole viewport, since direct3d12 doesn't allow disabling the scissor rectangle */ - rect = &rendererData->currentViewport; + viewport_cliprect.x = 0; + viewport_cliprect.y = 0; + viewport_cliprect.w = rendererData->currentViewport.w; + viewport_cliprect.h = rendererData->currentViewport.h; + rect = &viewport_cliprect; } if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&rendererData->currentCliprect, rect);