ui: simplify shader versions and fix hardcoded texture size (#2112)

* fix shader version

* fix texture buffer size

* Attribute/Varying is deprecated
pull/2113/head
Willem Melching 2020-08-31 15:02:01 +02:00 committed by GitHub
parent 01b3079451
commit 42b6292fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 45 deletions

View File

@ -18,7 +18,7 @@ AddOption('--asan',
cython_dependencies = [Value(v) for v in (sys.version, distutils.__version__, Cython.__version__)]
Export('cython_dependencies')
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
if platform.system() == "Darwin":
arch = "Darwin"
if arch == "aarch64" and not os.path.isdir("/system"):
@ -181,18 +181,7 @@ qt_env = None
if arch in ["x86_64", "Darwin", "larch64"]:
qt_env = env.Clone()
if arch == "larch64":
qt_env['QTDIR'] = "/usr/local/Qt-5.15.0"
QT_BASE = "/usr/local/Qt-5.15.0/"
qt_dirs = [
QT_BASE + "include/",
QT_BASE + "include/QtWidgets",
QT_BASE + "include/QtGui",
QT_BASE + "include/QtCore",
QT_BASE + "include/QtDBus",
]
qt_env["RPATH"] += [QT_BASE + "lib"]
elif arch == "Darwin":
if arch == "Darwin":
qt_env['QTDIR'] = "/usr/local/opt/qt"
QT_BASE = "/usr/local/opt/qt/"
qt_dirs = [
@ -205,11 +194,11 @@ if arch in ["x86_64", "Darwin", "larch64"]:
qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"]
else:
qt_dirs = [
f"/usr/include/{arch}-linux-gnu/qt5",
f"/usr/include/{arch}-linux-gnu/qt5/QtWidgets",
f"/usr/include/{arch}-linux-gnu/qt5/QtGui",
f"/usr/include/{arch}-linux-gnu/qt5/QtCore",
f"/usr/include/{arch}-linux-gnu/qt5/QtDBus",
f"/usr/include/{real_arch}-linux-gnu/qt5",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtWidgets",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtCore",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtDBus",
]
qt_env.Tool('qt')
@ -309,12 +298,11 @@ SConscript(['selfdrive/loggerd/SConscript'])
SConscript(['selfdrive/locationd/SConscript'])
SConscript(['selfdrive/locationd/models/SConscript'])
SConscript(['selfdrive/sensord/SConscript'])
SConscript(['selfdrive/ui/SConscript'])
if arch != "Darwin":
SConscript(['selfdrive/logcatd/SConscript'])
if arch != "larch64":
SConscript(['selfdrive/ui/SConscript'])
if arch == "x86_64":
SConscript(['tools/lib/index_log/SConscript'])

View File

@ -256,11 +256,11 @@ static void draw_frame(UIState *s) {
glBindTexture(GL_TEXTURE_2D, s->frame_front_texs[s->cur_vision_front_idx]);
} else if (!scene->frontview && s->cur_vision_idx >= 0) {
glBindTexture(GL_TEXTURE_2D, s->frame_texs[s->cur_vision_idx]);
#ifndef QCOM
// TODO: a better way to do this?
//printf("%d\n", ((int*)s->priv_hnds[s->cur_vision_idx])[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1164, 874, 0, GL_RGB, GL_UNSIGNED_BYTE, s->priv_hnds[s->cur_vision_idx]);
#endif
// TODO: a better way to do this?
#ifndef QCOM
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->rgb_width, s->rgb_height, 0, GL_RGB, GL_UNSIGNED_BYTE, s->priv_hnds[s->cur_vision_idx]);
#endif
}
glUseProgram(s->frame_program);
@ -690,9 +690,12 @@ void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGpaint &
nvgFill(vg);
}
#ifdef NANOVG_GL3_IMPLEMENTATION
static const char frame_vertex_shader[] =
#ifdef NANOVG_GL3_IMPLEMENTATION
"#version 150 core\n"
#else
"#version 300 es\n"
#endif
"in vec4 aPosition;\n"
"in vec4 aTexCoord;\n"
"uniform mat4 uTransform;\n"
@ -703,7 +706,11 @@ static const char frame_vertex_shader[] =
"}\n";
static const char frame_fragment_shader[] =
#ifdef NANOVG_GL3_IMPLEMENTATION
"#version 150 core\n"
#else
"#version 300 es\n"
#endif
"precision mediump float;\n"
"uniform sampler2D uTexture;\n"
"in vec4 vTexCoord;\n"
@ -711,25 +718,6 @@ static const char frame_fragment_shader[] =
"void main() {\n"
" colorOut = texture(uTexture, vTexCoord.xy);\n"
"}\n";
#else
static const char frame_vertex_shader[] =
"attribute vec4 aPosition;\n"
"attribute vec4 aTexCoord;\n"
"uniform mat4 uTransform;\n"
"varying vec4 vTexCoord;\n"
"void main() {\n"
" gl_Position = uTransform * aPosition;\n"
" vTexCoord = aTexCoord;\n"
"}\n";
static const char frame_fragment_shader[] =
"precision mediump float;\n"
"uniform sampler2D uTexture;\n"
"varying vec4 vTexCoord;\n"
"void main() {\n"
" gl_FragColor = texture2D(uTexture, vTexCoord.xy);\n"
"}\n";
#endif
static const mat4 device_transform = {{
1.0, 0.0, 0.0, 0.0,

View File

@ -16,8 +16,12 @@ int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MainWindow w;
#ifdef QCOM2
w.showFullScreen();
#else
w.setFixedSize(vwp_w, vwp_h);
w.show();
#endif
return a.exec();
}