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
This commit is contained in:
Sam Lantinga 2023-07-03 17:09:49 -07:00
parent b6645bb255
commit 304d425f99

View File

@ -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);