Skip to content

feature: add rotation shader for rotating output#1655

Open
joshuatam wants to merge 7 commits into
ValveSoftware:masterfrom
joshuatam:feat-main/rotation-shader
Open

feature: add rotation shader for rotating output#1655
joshuatam wants to merge 7 commits into
ValveSoftware:masterfrom
joshuatam:feat-main/rotation-shader

Conversation

@joshuatam

Copy link
Copy Markdown

Added a rotation shader to fix blank display problem on portrait screen with unsupported DRM rotation.

Once enabled, the DRM orientation is hardcoded to 0 degrees (left) or 180 degrees (right), and the rotation shader is hardcoded for 270 degrees rotation (counter clockwise 90 degrees)

Tested on: OneXPlayer X1 Intel

It could possibly fix an upstream issue: #819

@misyltoad

Copy link
Copy Markdown
Collaborator

This shouldn't be necessary. One could just set up the regular composition scene graph and image to be rotated without an additional step here.

@joshuatam

joshuatam commented Dec 16, 2024

Copy link
Copy Markdown
Author

This shouldn't be necessary. One could just set up the regular composition scene graph and image to be rotated without an additional step here.

Do you have other suggestion on the implemention? In fact I have tried several ways to rotate the image, adding a rotation shader is the best in terms of performance and the amount of code added.

As the main problem is that, intel drm driver i915 does not support 90/270 degrees rotation on a portrait screen. So before apply the rotation shader, the image is rendered in landscape size on a portrait screen (drm rotation = normal), and then rotated after applied the rotation shader.

@joshuatam joshuatam force-pushed the feat-main/rotation-shader branch from 5fbd420 to 3831a9e Compare December 22, 2024 15:41
@joshuatam joshuatam force-pushed the feat-main/rotation-shader branch from 3831a9e to 90ab765 Compare December 24, 2024 01:14
@yshui

yshui commented Apr 21, 2026

Copy link
Copy Markdown

Like @stellar-aria has observed in #1883, this is very useful for ARM devices.

Also this PR assumes the device supports 180 rotation, but some devices don't not support any rotation at all. Such as the Adreno 740 mentioned in #1883. I can also confirm the Adreno 650 I have is the same. So maybe some sort of detection needs to be implemented.

@soosticus

Copy link
Copy Markdown

What needs to be done to get this merged?

Comment thread src/main.cpp Outdated
{ "composite-debug", no_argument, nullptr, 0 },
{ "disable-xres", no_argument, nullptr, 'x' },
{ "fade-out-duration", required_argument, nullptr, 0 },
{ "use-rotation-shader", required_argument, nullptr, 0 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be no_argument?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated

Comment thread src/wlserver.cpp
break;
}

if (g_bEnableDRMRotationShader) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only handles ORIENTATION_90 (see the switch case just above this diff). Since with 270 DRM is used to flip the panel 180 degrees. This diff from @Drakulix fixes it

diff --git a/src/wlserver.cpp b/src/wlserver.cpp
index d6f01d2..84e2adb 100644
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -2832,8 +2832,19 @@ static void apply_touchscreen_orientation(GamescopePanelOrientation orientation,
 	}
 
 	if (g_bEnableDRMRotationShader) {
-		tx = 1.0 - *y;
-		ty = *x;
+		switch ( orientation )
+		{
+			case GAMESCOPE_PANEL_ORIENTATION_180:
+				tx = *y;
+				ty = 1.0 - *x;
+				break;
+			default:
+			case GAMESCOPE_PANEL_ORIENTATION_0:
+			case GAMESCOPE_PANEL_ORIENTATION_AUTO:
+				tx = 1.0 - *y;
+				ty = *x;
+				break;
+		}
 	}
 
 	*x = tx;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, curious about the source of this change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from a downstream package for postmarketOS to get gamescope+steam running on an Ayaneo Pocket S2: https://gitlab.postmarketos.org/Drakulix/steam-session-pkgs/-/tree/main/pkgs/gamescope?ref_type=heads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants