Add Native GL Option
Some checks reported errors
minecraft-pi-docker/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
TheBrokenRail 2020-10-16 15:39:04 -04:00
parent c513426e05
commit 3b886e055d
16 changed files with 84 additions and 30 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/core/build
/mods/build
/out
/debian/tmp

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
MCPI_FEATURES='' MCPI_USERNAME='' docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml pull

5
debian/client/common/DEBIAN/postinst vendored Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
MCPI_MODE='' MCPI_FEATURES='' MCPI_USERNAME='' docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml pull

View File

@ -10,10 +10,6 @@ fi
export MCPI_FEATURES
export MCPI_USERNAME
# Start VirGL
virgl_test_server &
VIRGL_PID="$!"
# Ensure Groups Are Correct
if [ -z "${MCPI_SUBSHELL}" ]; then
if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
@ -25,13 +21,9 @@ fi
# Allow X11 Connections From Root
xhost local:root
# Launch Minecraft
DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml"
# Update Docker Container
export DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml"
(${DOCKER_COMPOSE} pull || :) | zenity --class 'Minecraft - Pi edition' --progress --pulsate --no-cancel --auto-close --text 'Updating Minecraft...'
${DOCKER_COMPOSE} run --rm minecraft-pi || :
RET="$?"
# Kill VirGL
kill "${VIRGL_PID}"
exit "${RET}"
# Run
/usr/lib/minecraft-pi/run.sh

View File

@ -11,3 +11,4 @@ services:
- 'DISPLAY=unix${DISPLAY}'
- 'MCPI_FEATURES=${MCPI_FEATURES}'
- 'MCPI_USERNAME=${MCPI_USERNAME}'
- 'MCPI_MODE=${MCPI_MODE}'

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

8
debian/client/native/DEBIAN/control vendored Normal file
View File

@ -0,0 +1,8 @@
Package: minecraft-pi-native
Version: 1.0.0
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: all
Depends: docker.io, docker-compose, zenity, policykit-1, passwd, login, qemu-user-static, binfmt-support
Conflicts: minecraft-pi-virgl

View File

@ -0,0 +1,9 @@
#!/bin/sh
set -e
# Enable VirGL
export MCPI_MODE=native
# Launch Minecraft
${DOCKER_COMPOSE} run --rm minecraft-pi

View File

@ -1,7 +1,8 @@
Package: minecraft-pi
Package: minecraft-pi-virgl
Version: 1.0.0
Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: all
Depends: docker.io, docker-compose, virgl-server, zenity, policykit-1, passwd, login, qemu-user-static, binfmt-support
Conflicts: minecraft-pi-native

View File

@ -0,0 +1,19 @@
#!/bin/sh
set -e
# Enable VirGL
export MCPI_MODE=virgl
# Start VirGL
virgl_test_server &
VIRGL_PID="$!"
# Launch Minecraft
${DOCKER_COMPOSE} run --rm minecraft-pi || :
RET="$?"
# Kill VirGL
kill "${VIRGL_PID}"
exit "${RET}"

View File

@ -41,7 +41,7 @@ static void store_x11_window() {
// Handle GLFW Error
static void glfw_error(__attribute__((unused)) int error, const char *description) {
fprintf(stderr, "GLFW Error: %s\n", description);
fprintf(stderr, "[ERR] GLFW Error: %s\n", description);
exit(1);
}
@ -465,9 +465,12 @@ HOOK(eglTerminate, EGLBoolean, (__attribute__((unused)) EGLDisplay display)) {
// Use VirGL
__attribute__((constructor)) static void init() {
is_server = extra_get_is_server();
int mode = extra_get_mode();
if (mode == 0) {
setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
if (!is_server) {
setenv("GALLIUM_DRIVER", "virpipe", 1);
}
}
is_server = mode == 2;
}

View File

@ -154,12 +154,22 @@ int extra_has_feature(const char *name) {
}
}
int extra_get_is_server() {
return getenv("MCPI_SERVER") != NULL;
int extra_get_mode() {
char *mode = getenv("MCPI_MODE");
if (strcmp("virgl", mode) == 0) {
return 0;
} else if (strcmp("native", mode) == 0) {
return 1;
} else if (strcmp("server", mode) == 0) {
return 2;
} else {
fprintf(stderr, "[ERR] Inavlid MCPI_MODE: %s\n", mode);
exit(1);
}
}
__attribute__((constructor)) static void init() {
is_server = extra_get_is_server();
is_server = extra_get_mode() == 2;
if (is_server) {
server_init();
}

View File

@ -7,7 +7,7 @@ extern "C" {
#endif
int extra_has_feature(const char *name);
int extra_get_is_server();
int extra_get_mode();
void extra_key_press(char key);
void extra_clear_input();

View File

@ -3,4 +3,4 @@
set -e
docker build ${DOCKER_BUILD_OPTIONS} --tag thebrokenrail/minecraft-pi:client -f Dockerfile.client .
docker build ${DOCKER_BUILD_OPTIONS} --tag thebrokenrail/minecraft-pi:server -f Dockerfile.server .
#docker build ${DOCKER_BUILD_OPTIONS} --tag thebrokenrail/minecraft-pi:server -f Dockerfile.server .

View File

@ -9,8 +9,18 @@ chmod -R g-s debian
rm -rf out
mkdir -p out/deb
# Generate DEB
dpkg -b debian/client out/deb
# Package Client DEBs
package_client() {
rm -rf debian/tmp
rsync -r debian/client/common/ debian/tmp
rsync -r "debian/client/$1/" debian/tmp
dpkg -b debian/tmp out/deb
rm -rf debian/tmp
}
package_client virgl
package_client native
# Package Server DEB
dpkg -b debian/server out/deb
# Export Libraries