WinRT: fixed bug whereby offscreen-rendered content could get improperly rotated Attributes on the host device's rotation were getting applied to offscreen textures in an invalid manner. This was causing some apps to look different, depending on how the device was rotated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index cd28696..f99fdb1 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -1330,10 +1330,22 @@ D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
}
static int
+D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
+ if (data->currentOffscreenRenderTargetView) {
+ return DXGI_MODE_ROTATION_IDENTITY;
+ } else {
+ return data->rotation;
+ }
+}
+
+static int
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
- switch (data->rotation) {
+ const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
+ switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
outRect->right = sdlRect->x + sdlRect->w;
@@ -2151,6 +2163,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
SDL_FRect orientationAlignedViewport;
BOOL swapDimensions;
D3D11_VIEWPORT viewport;
+ const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
/* If the viewport is empty, assume that it is because
@@ -2166,7 +2179,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
* default coordinate system) so rotations will be done in the opposite
* direction of the DXGI_MODE_ROTATION enumeration.
*/
- switch (data->rotation) {
+ switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
projection = MatrixIdentity();
break;
@@ -2217,7 +2230,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
* a landscape mode, for all Windows 8/RT devices, or a portrait mode,
* for Windows Phone devices.
*/
- swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
+ swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation);
if (swapDimensions) {
orientationAlignedViewport.x = (float) renderer->viewport.y;
orientationAlignedViewport.y = (float) renderer->viewport.x;