From 7be4b7c3bbbfa45fd1b1064e5d14c8e13ffefa69 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 5 Apr 2021 17:14:30 +0200 Subject: [PATCH 1/7] device: Support evdev gamepads on FreeBSD --- makepanda/makepanda.py | 4 ++-- panda/src/device/evdevInputDevice.cxx | 2 ++ panda/src/device/linuxInputDeviceManager.cxx | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 71f8c00e3e..1563040026 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -960,6 +960,7 @@ if (COMPILER=="GCC"): if (os.path.isdir("/usr/PCBSD")): IncDirectory("ALWAYS", "/usr/PCBSD/local/include") LibDirectory("ALWAYS", "/usr/PCBSD/local/lib") + SmartPkgEnable("INOTIFY", "libinotify", ("inotify"), "sys/inotify.h") if GetTarget() != "windows": PkgDisable("DIRECTCAM") @@ -2707,7 +2708,6 @@ def WriteConfigSettings(): dtool_config["IS_FREEBSD"] = '1' dtool_config["PHAVE_ALLOCA_H"] = 'UNDEF' dtool_config["PHAVE_MALLOC_H"] = 'UNDEF' - dtool_config["PHAVE_LINUX_INPUT_H"] = 'UNDEF' dtool_config["HAVE_PROC_CURPROC_FILE"] = '1' dtool_config["HAVE_PROC_CURPROC_MAP"] = '1' dtool_config["HAVE_PROC_CURPROC_CMDLINE"] = '1' @@ -4478,7 +4478,7 @@ if (not RUNTIME): OPTS=['DIR:panda/metalibs/panda', 'BUILDING:PANDA', 'JPEG', 'PNG', 'HARFBUZZ', 'TIFF', 'OPENEXR', 'ZLIB', 'OPENSSL', 'FREETYPE', 'FFTW', 'ADVAPI', 'WINSOCK2', 'SQUISH', 'NVIDIACG', 'VORBIS', 'OPUS', 'WINUSER', 'WINMM', 'WINGDI', 'IPHLPAPI', - 'SETUPAPI'] + 'SETUPAPI', 'INOTIFY'] TargetAdd('panda_panda.obj', opts=OPTS, input='panda.cxx') diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index db6285ba19..b609501797 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -691,6 +691,7 @@ init_device() { _rtrigger_code = -1; } +#ifndef __FreeBSD__ char path[64]; char buffer[256]; const char *parent = ""; @@ -728,6 +729,7 @@ init_device() { } fclose(f); } +#endif // Special-case fix for Xbox 360 Wireless Receiver: the Linux kernel // driver always reports 4 connected gamepads, regardless of the number diff --git a/panda/src/device/linuxInputDeviceManager.cxx b/panda/src/device/linuxInputDeviceManager.cxx index 7b9b9fdf6f..2406e8c839 100644 --- a/panda/src/device/linuxInputDeviceManager.cxx +++ b/panda/src/device/linuxInputDeviceManager.cxx @@ -134,6 +134,7 @@ consider_add_evdev_device(size_t ev_index) { // having read permissions set, but doesn't export all of the features // (notably, force feedback). +#ifndef __FreeBSD__ // We do this by checking for a js# directory inside the sysfs directory. sprintf(path, "/sys/class/input/event%zd/device", ev_index); @@ -168,6 +169,8 @@ consider_add_evdev_device(size_t ev_index) { } closedir(dir); +#endif + return nullptr; } From 51a6923008deb97b926b203c32e52e6cd2beda3a Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 5 Apr 2021 17:19:47 +0200 Subject: [PATCH 2/7] device: Work around FreeBSD kernel bug for querying gamepad axes This is to support older kernels, which always returned 0 from successful ioctl, rather than the number of bits. This was fixed in the FreeBSD kernel trunk. --- panda/src/device/evdevInputDevice.cxx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index b609501797..9cf94e1dfc 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -328,7 +328,22 @@ init_device() { uint8_t axes[(ABS_MAX + 8) >> 3] = {0}; if (test_bit(EV_ABS, evtypes)) { // Check which axes are on the device. - num_bits = ioctl(_fd, EVIOCGBIT(EV_ABS, sizeof(axes)), axes) << 3; + int result = ioctl(_fd, EVIOCGBIT(EV_ABS, sizeof(axes)), axes); +#ifdef __FreeBSD__ + // Older kernels had a bug where this would always return 0, see D28218 + if (result == 0) { + for (int i = ABS_MAX; i >= 0; --i) { + if (test_bit(i, axes)) { + num_bits = i + 1; + break; + } + } + } + else +#endif + if (result > 0) { + num_bits = result << 3; + } has_axes = true; } From 67b6729d38444ee1a9e60bb6a5508c25013ff448 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 5 Apr 2021 17:26:13 +0200 Subject: [PATCH 3/7] Also switch from Travis to GitHub Actions on release branch --- .github/workflows/ci.yml | 75 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 65 ---------------------------------- 2 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..a06b563405 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: Continuous Integration +on: [push, pull_request] + +jobs: + makepanda: + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + strategy: + matrix: + os: [ubuntu-16.04, windows-2016, macOS-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - name: Install dependencies (Ubuntu) + if: matrix.os == 'ubuntu-16.04' + run: | + sudo apt-get update + sudo apt-get install build-essential bison flex libfreetype6-dev libgl1-mesa-dev libjpeg-dev libode-dev libopenal-dev libpng-dev libssl-dev libvorbis-dev libx11-dev libxcursor-dev libxrandr-dev nvidia-cg-toolkit zlib1g-dev + - name: Get thirdparty packages (Windows) + if: runner.os == 'Windows' + shell: powershell + run: | + $wc = New-Object System.Net.WebClient + $wc.DownloadFile("https://www.panda3d.org/download/panda3d-1.10.9/panda3d-1.10.9-tools-win64.zip", "thirdparty-tools.zip") + Expand-Archive -Path thirdparty-tools.zip + Move-Item -Path thirdparty-tools/panda3d-1.10.9/thirdparty -Destination . + - name: Get thirdparty packages (macOS) + if: runner.os == 'macOS' + run: | + curl -O https://www.panda3d.org/download/panda3d-1.10.9/panda3d-1.10.9-tools-mac.tar.gz + tar -xf panda3d-1.10.9-tools-mac.tar.gz + mv panda3d-1.10.9/thirdparty thirdparty + rmdir panda3d-1.10.9 + (cd thirdparty/darwin-libs-a && rm -rf rocket) + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Build Python 3.9 + shell: bash + run: | + python makepanda/makepanda.py --git-commit=${{github.sha}} --outputdir=built --everything --no-eigen --python-incdir="$pythonLocation/include" --python-libdir="$pythonLocation/lib" --verbose --threads=4 + - name: Test Python 3.9 + shell: bash + run: | + python -m pip install pytest + PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Build Python 3.8 + shell: bash + run: | + python makepanda/makepanda.py --git-commit=${{github.sha}} --outputdir=built --everything --no-eigen --python-incdir="$pythonLocation/include" --python-libdir="$pythonLocation/lib" --verbose --threads=4 + - name: Test Python 3.8 + shell: bash + run: | + python -m pip install pytest + PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Build Python 3.7 + shell: bash + run: | + python makepanda/makepanda.py --git-commit=${{github.sha}} --outputdir=built --everything --no-eigen --python-incdir="$pythonLocation/include" --python-libdir="$pythonLocation/lib" --verbose --threads=4 + - name: Test Python 3.7 + shell: bash + run: | + python -m pip install pytest + PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest + - name: Make installer + run: | + python makepanda/makepackage.py --verbose --lzma diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 871b3e26c7..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -language: cpp -sudo: false -branches: - only: - - release/1.10.x - - release/1.9.x -matrix: - include: - - compiler: clang - env: PYTHONV=python3 FLAGS=--installer - - compiler: clang - env: PYTHONV=python2.7 FLAGS=--override=STDFLOAT_DOUBLE=1 - - compiler: gcc - env: PYTHONV=python2.7 FLAGS=--optimize=4 - before_install: - - export CC=gcc-4.7 - - export CXX=g++-4.7 - - compiler: clang - env: PYTHONV=python3 FLAGS=--no-python SKIP_TESTS=1 -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-4.7 - - g++-4.7 - - bison - - flex - - libfreetype6-dev - - libgl1-mesa-dev - - libjpeg-dev - - libode-dev - - libopenal-dev - - libpng-dev - - libssl-dev - - libvorbis-dev - - libx11-dev - - libxcursor-dev - - libxrandr-dev - - nvidia-cg-toolkit - - python-dev - - python3-dev - - python-virtualenv - - zlib1g-dev - - fakeroot -install: - - virtualenv --python=$PYTHONV venv && source venv/bin/activate - - $PYTHONV -m pip install pytest -script: - - $PYTHONV makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT $FLAGS --threads 4 - - test -n "$SKIP_TESTS" || LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV makepanda/test_imports.py - - test -n "$SKIP_TESTS" || LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest -v tests -notifications: - irc: - channels: - - secure: "jfwHT9RHAVOGRGTMY8TpYKJI6rq8nFoIj41Y0soZdJQNWtSSFEK9AyzZeMY+2dHga7cR/X+/0NWZ2ehhedTnd9FvlzOnMWWC3K0I/b3XWbEdVEqIZnggFkKGqs82Gy3omguRC63yWupeJCcSCckIhoWbLzWy6xV8lF5WC80iXi8=" - on_success: change - on_failure: always - use_notice: true - skip_join: false - webhooks: - urls: - - https://www.panda3d.org/webhooks/travis-ci.php - on_success: change - on_failure: always From bcb61fec0977d619b37e9b7c6c0dc1176a3ac894 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Apr 2021 16:38:51 +0200 Subject: [PATCH 4/7] pgraphnodes: Fix draw callback called twice in certain cases This would happen if you call upcall() in a CallbackNode's cull callback. --- panda/src/pgraphnodes/nodeCullCallbackData.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index 5a9dbc9e0a..c1f0ac7464 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -56,6 +56,13 @@ upcall() { } } - // Now traverse below. - _trav->traverse_below(_data); + // Now visit all the node's children. + PandaNodePipelineReader *node_reader = _data.node_reader(); + PandaNode::Children children = node_reader->get_children(); + node_reader->release(); + int num_children = children.get_num_children(); + for (int i = 0; i < num_children; ++i) { + CullTraverserData next_data(_data, children.get_child(i)); + _trav->traverse(next_data); + } } From ab4367ee7bf0fe11fec936e28ddc0f936a6548ff Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Apr 2021 00:20:38 +0200 Subject: [PATCH 5/7] glgsg: Fixes to format selection in OpenGL renderbuffers Fixes #1137 --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index ff28f4c192..032c4ed2a3 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -964,8 +964,26 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, } else { gl_format = GL_R16F; } - } else if (_fb_properties.get_color_bits() > 8 * 3) { - gl_format = GL_RGB16_EXT; + } else if (_fb_properties.get_color_bits() > 10 * 3 || + _fb_properties.get_red_bits() > 10 || + _fb_properties.get_green_bits() > 10 || + _fb_properties.get_blue_bits() > 10) { + // 16-bit normalized. + if (_fb_properties.get_blue_bits() > 0 || + _fb_properties.get_color_bits() == 1 || + _fb_properties.get_color_bits() > 16 * 2) { + gl_format = GL_RGBA16; + } else if (_fb_properties.get_green_bits() > 0 || + _fb_properties.get_color_bits() > 16) { + gl_format = GL_RG16; + } else { + gl_format = GL_R16; + } + } else if (_fb_properties.get_color_bits() > 8 * 3 || + _fb_properties.get_red_bits() > 8 || + _fb_properties.get_green_bits() > 8 || + _fb_properties.get_blue_bits() > 8) { + gl_format = GL_RGB10_A2; } else { gl_format = GL_RGB; } @@ -982,7 +1000,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, if (_fb_properties.get_color_bits() > 16 * 3) { gl_format = GL_RGBA32F_ARB; } else if (_fb_properties.get_color_bits() > 8 * 3) { - gl_format = GL_RGBA16_EXT; + gl_format = GL_RGBA16; } else { gl_format = GL_RGBA; } From addbc8a2e887e1e98c8254cdf0629cfac280789d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Apr 2021 12:07:00 +0200 Subject: [PATCH 6/7] dtoolutil: Work around odd Linux bug with lseek on a directory fd Fixes #1140 --- dtool/src/dtoolutil/pandaFileStreamBuf.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 676f17e0e6..1caecaf991 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -333,7 +333,7 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { // Posix case. { off_t li = lseek(_fd, off, SEEK_END); - if (li == (off_t)-1) { + if (li == (off_t)-1 || (sizeof(off_t) == 8 && li == 0x7fffffffffffffff)) { return -1; } new_pos = (size_t)li; From 4a7d03d9b12b91ade60434321122c7e97e73813b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Apr 2021 12:08:03 +0200 Subject: [PATCH 7/7] pnmtext: Fix loading an invalid font resulting in a crash Related to #1140 --- panda/src/pnmtext/freetypeFont.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index f922943b7f..bab2734464 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -108,12 +108,14 @@ load_font(const Filename &font_filename, int face_index) { vfs->resolve_filename(path, get_model_path()); exists = vfs->read_file(path, _face->_font_data, true); if (exists) { - FT_Face face; + FT_Face face = 0; error = FT_New_Memory_Face(_face->_ft_library, (const FT_Byte *)_face->_font_data.data(), _face->_font_data.length(), face_index, &face); - _face->set_face(face); + if (face) { + _face->set_face(face); + } } bool okflag = false;