Skip to content

Commit 3d66e88

Browse files
committed
fix shaders
1 parent 8220599 commit 3d66e88

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

selfdrive/ui/onroad/cameraview.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import numpy as np
23
import pyray as rl
34

@@ -9,8 +10,17 @@
910

1011
CONNECTION_RETRY_INTERVAL = 0.2 # seconds between connection attempts
1112

12-
VERTEX_SHADER = """
13+
VERSION = """
1314
#version 300 es
15+
precision mediump float;
16+
"""
17+
if platform.system() == "Darwin":
18+
VERSION = """
19+
#version 330 core
20+
"""
21+
22+
23+
VERTEX_SHADER = VERSION + """
1424
in vec3 vertexPosition;
1525
in vec2 vertexTexCoord;
1626
in vec3 vertexNormal;
@@ -40,9 +50,7 @@
4050
}
4151
"""
4252
else:
43-
FRAME_FRAGMENT_SHADER = """
44-
#version 300 es
45-
precision mediump float;
53+
FRAME_FRAGMENT_SHADER = VERSION + """
4654
in vec2 fragTexCoord;
4755
uniform sampler2D texture0;
4856
uniform sampler2D texture1;
@@ -72,6 +80,7 @@ def __init__(self, name: str, stream_type: VisionStreamType):
7280
self._texture_needs_update = True
7381
self.last_connection_attempt: float = 0.0
7482
self.shader = rl.load_shader_from_memory(VERTEX_SHADER, FRAME_FRAGMENT_SHADER)
83+
assert self.shader.id > 0
7584
self._texture1_loc: int = rl.get_shader_location(self.shader, "texture1") if not TICI else -1
7685

7786
self.frame: VisionBuf | None = None

system/ui/lib/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def init_window(self, title: str, fps: int = DEFAULT_FPS):
9999
HARDWARE.set_display_power(True)
100100
HARDWARE.set_screen_brightness(65)
101101

102-
self._set_log_callback()
102+
#self._set_log_callback()
103103
rl.set_trace_log_level(rl.TraceLogLevel.LOG_ALL)
104104

105105
flags = rl.ConfigFlags.FLAG_MSAA_4X_HINT
@@ -140,6 +140,7 @@ def _load_texture_from_image(self, image_path: str, width: int, height: int, alp
140140

141141
# Resize with aspect ratio preservation if requested
142142
if keep_aspect_ratio:
143+
print(image.width, image.height)
143144
orig_width = image.width
144145
orig_height = image.height
145146

system/ui/lib/shader_polygon.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
import platform
12
import pyray as rl
23
import numpy as np
34
from typing import Any
45

56
MAX_GRADIENT_COLORS = 15
67

7-
FRAGMENT_SHADER = """
8+
VERSION = """
89
#version 300 es
910
precision mediump float;
11+
"""
12+
if platform.system() == "Darwin":
13+
VERSION = """
14+
#version 330 core
15+
"""
1016

17+
FRAGMENT_SHADER = VERSION + """
1118
in vec2 fragTexCoord;
1219
out vec4 finalColor;
1320

0 commit comments

Comments
 (0)