alexhuntley / Plots

A graph plotting app for GNOME
GNU General Public License v3.0
189 stars 36 forks source link

Asahi Linux Support (OpenGL 3.1-ish) #141

Open DavidBuchanan314 opened 8 months ago

DavidBuchanan314 commented 8 months ago

Hi. I'm running asahi linux on an M1 mac, using the open-source gpu drivers.

I managed to get plots running, after setting the MESA_GLSL_VERSION_OVERRIDE=150 environment variable and patching the shaders accordingly:

diff --git a/plots/shaders/fragment.glsl b/plots/shaders/fragment.glsl
index 078482b..cb2e159 100644
--- a/plots/shaders/fragment.glsl
+++ b/plots/shaders/fragment.glsl
@@ -17,7 +17,7 @@
    along with Plots.  If not, see <https://www.gnu.org/licenses/>.
 */

-#version 330 core
+#version 150
 in vec2 graph_pos;
 out vec4 rgba;

diff --git a/plots/shaders/text_frag.glsl b/plots/shaders/text_frag.glsl
index 7f7f176..acd087d 100644
--- a/plots/shaders/text_frag.glsl
+++ b/plots/shaders/text_frag.glsl
@@ -17,7 +17,7 @@
    along with Plots.  If not, see <https://www.gnu.org/licenses/>.
 */

-#version 330 core
+#version 150

 in vec2 vUV;

diff --git a/plots/shaders/text_vert.glsl b/plots/shaders/text_vert.glsl
index ad81481..c963089 100644
--- a/plots/shaders/text_vert.glsl
+++ b/plots/shaders/text_vert.glsl
@@ -17,9 +17,9 @@
    along with Plots.  If not, see <https://www.gnu.org/licenses/>.
 */

-#version 330 core
+#version 150

-layout (location = 0) in vec4 vertex;
+in vec4 vertex;

 out vec2 vUV;

diff --git a/plots/shaders/vertex.glsl b/plots/shaders/vertex.glsl
index bd6d376..40ecb0b 100644
--- a/plots/shaders/vertex.glsl
+++ b/plots/shaders/vertex.glsl
@@ -17,8 +17,8 @@
    along with Plots.  If not, see <https://www.gnu.org/licenses/>.
 */

-#version 330 core
-layout (location = 0) in vec3 position;
+#version 150
+in vec3 position;
 out vec2 graph_pos;
 uniform vec2 viewport;
 uniform vec2 translation;

I haven't checked exhaustively to make sure everything is working, but basic plotting definitely works.

Perhaps there is some scope for lowering the version requirement?

Is the layout keyword required? It seems to work just fine without it but I have no idea what I'm doing, heh.

Either way, I hope this information can at least be useful for anyone else trying to make things work on asahi.