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 (cherry picked from commit 304d425f99b3b62e5f77ef869731bb702810a572) (cherry picked from commit bf277eb808103cb86a5af235495e866d33f87b0a)
diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c
index 9e69cef..5ad8e26 100644
--- a/src/render/direct3d12/SDL_render_d3d12.c
+++ b/src/render/direct3d12/SDL_render_d3d12.c
@@ -2609,6 +2609,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;
@@ -2616,7 +2617,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);