@@ -33,6 +33,7 @@ ARG DEBIAN_VERSION_NAME=trixie
3333ARG GCC_VERSION=14
3434ARG LLVM_VERSION=18
3535ARG VULKAN_VERSION=1.3.283.0
36+ ARG MESA_VERSION=24.1.3
3637
3738# +-----------------------------+
3839# | Downloader |
@@ -43,16 +44,19 @@ ARG VULKAN_VERSION=1.3.283.0
4344
4445FROM debian:trixie-slim AS downloader
4546
46- # reusing global arg
47+ # Reuse global arguments
48+ # ARG GCC_VERSION
4749ARG VULKAN_VERSION
50+ # ARG MESA_VERSION
4851
4952# ENV CURL_OPTIONS="--silent --show-error --retry 5 --connect-timeout 20 --max-time 10"
5053ENV CURL_OPTIONS_BAR="--progress-bar"
5154
5255WORKDIR /tmp
5356RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && \
5457# curl $CURL_OPTIONS_BAR -o gcc.xz "http://ftp.gnu.org/gnu/gcc/gcc-13.3.0/gcc-13.3.0.tar.xz" && \
55- curl $CURL_OPTIONS_BAR -o vulkansdk.xz "https://sdk.lunarg.com/sdk/download/${VULKAN_VERSION}/linux/vulkansdk-linux-x86_64-${VULKAN_VERSION}.tar.xz"
58+ curl $CURL_OPTIONS_BAR -o vulkansdk.xz "https://sdk.lunarg.com/sdk/download/${VULKAN_VERSION}/linux/vulkansdk-linux-x86_64-${VULKAN_VERSION}.tar.xz" && \
59+ # curl $CURL_OPTIONS_BAR -o mesa.xz "https://archive.mesa3d.org/mesa-${MESA_VERSION}.tar.xz"
5660
5761# +-----------------------------+
5862# | BASE IMAGE | See https://hub.docker.com/_/debian
@@ -82,7 +86,7 @@ LABEL \
8286 org.opencontainers.image.url='https://ghcr.io/jakoch/cpp-devbox' \
8387 org.opencontainers.image.source='https://github.com/jakoch/cpp-devbox' \
8488 org.opencontainers.image.title='ghcr.io/jakoch/cpp-devbox' \
85- org.opencontainers.image.description="C++ DevBox (Debian ${DEBIAN_VERSION}-${DEBIAN_VERSION_NAME} with LLVM ${LLVM_VERSION} & GCC ${GCC_VERSION}, CMake, VCPKG, zsh)" \
89+ org.opencontainers.image.description="C++ DevBox (Debian ${DEBIAN_VERSION}-${DEBIAN_VERSION_NAME} with LLVM ${LLVM_VERSION%%.* } & GCC ${GCC_VERSION%%.* }, CMake, VCPKG, zsh)" \
8690 org.opencontainers.image.licenses=MIT
8791
8892
@@ -512,14 +516,129 @@ ENV LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
512516# Switch back to dialog for any ad-hoc use of apt-get
513517ENV DEBIAN_FRONTEND=dialog
514518
519+ # +----------------------------------+
520+ # | Stage: mesa-builder |
521+ # +----------------------------------+
522+
523+ # FROM cpp-devbox-base AS mesa-builder
524+
525+ # # Mesa Build Options: https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/meson_options.txt
526+ # #
527+ # COPY --from=downloader /tmp/mesa.xz /tmp/mesa.xz
528+
529+ # ENV MESA_PACKAGE_FOLDER=/mesa-package
530+
531+ # # +------------------+
532+ # # | SPIRV-TOOLS |
533+ # # +------------------+
534+ # # Notes:
535+ # # - SPIRV_VERSION_TAG has to match your LLVM version.
536+ # # - spirv-tools dependency is needed for e.g. spirv-objdump, which is not in the vk sdk
537+ # # SPIRV_VERSION_TAG=v18.1.2
538+
539+ # SHELL ["/bin/bash", "-o", "pipefail", "-c"]
540+ # RUN SPIRV_VERSION_TAG=v18.1.2 && \
541+ # LLVM_VERSION=$(llvm-config --version) && \
542+ # apt-get update && apt-get install -y --no-install-recommends \
543+ # libcurl4-openssl-dev \
544+ # libedit-dev \
545+ # libzstd-dev \
546+ # # spirv-tools is needed (for e.g. spirv-objdump, because not part of vulkan sdk)
547+ # spirv-tools && \
548+ # git clone --depth=1 https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git --branch $SPIRV_VERSION_TAG && \
549+ # mkdir SPIRV-LLVM-Translator/build && \
550+ # cd SPIRV-LLVM-Translator/build && \
551+ # cmake .. -D BASE_LLVM_VERSION=$LLVM_VERSION && \
552+ # make llvm-spirv -j`nproc` && \
553+ # cmake --install . --prefix=/usr/local
554+
555+ # SHELL ["/bin/bash", "-o", "pipefail", "-c"]
556+ # RUN mkdir /tmp/mesa && \
557+ # tar xvf /tmp/mesa.xz -C /tmp/mesa --strip-components 1 && \
558+ # rm /tmp/mesa.xz && \
559+ # #
560+ # # Install Mesa dependencies..
561+ # #
562+ # # TODO not sure if we need all this
563+ # #
564+ # apt-get update && apt-get install -y --no-install-recommends \
565+ # meson bison byacc flex libzstd-dev pkg-config \
566+ # python3-mako python3-ply \
567+ # libdrm2 libdrm-dev \
568+ # libclc-18-dev \
569+ # libexpat1-dev \
570+ # libunwind-dev \
571+ # libwayland-dev wayland-protocols \
572+ # libx11-dev libxext-dev libxfixes-dev \
573+ # libxrandr2 libxrandr-dev libxcb-randr0-dev \
574+ # libx11-xcb-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev \
575+ # libxcb-shm0-dev libxshmfence-dev \
576+ # rust-all bindgen cbindgen \
577+ # # fix mesa error: libclc shader missing. Consider installing the libclc package
578+ # libclc-18 \
579+ # # only needed, if vulkan isn't already installed
580+ # glslang-tools
581+ # # Dependencies possibly need when altering Mesa configuration:
582+ # # libudev-dev \
583+ # # libelf-dev \
584+ # # libwayland-egl-backend-dev \
585+ # # libxcb-glx0-dev \
586+ # # libxxf86vm-dev
587+
588+ # ENV CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
589+
590+ # #
591+ # # Configure Mesa
592+ # #
593+ # # Note: Vulkan drivers require dri3 for X11 support
594+ # #
595+ # WORKDIR /tmp/mesa
596+ # RUN meson build/ \
597+ # -D buildtype=release \
598+ # -D prefix=/usr \
599+ # #-D prefix=/usr/local \
600+ # #-D libdir=/usr/local/lib \
601+ # -D dri3=enabled \
602+ # -D egl=disabled \
603+ # -D gallium-drivers=swrast,zink \
604+ # -D gallium-nine=false \
605+ # -D glx=xlib \
606+ # -D gles1=disabled \
607+ # -D gles2=disabled \
608+ # -D glvnd=disabled \
609+ # -D libunwind=enabled \
610+ # -D llvm=enabled \
611+ # -D microsoft-clc=disabled \
612+ # -D osmesa=false \
613+ # -D platforms=x11,wayland \
614+ # -D valgrind=disabled \
615+ # -D vulkan-beta=false \
616+ # -D vulkan-drivers=auto && \
617+ # #
618+ # # Build and Install Mesa
619+ # #
620+ # ninja -C build/ && \
621+ # DESTDIR=${MESA_PACKAGE_FOLDER} && \
622+ # ninja -C build/ install && \
623+ # rm -rf /tmp/mesa && \
624+ # #
625+ # # Package Mesa
626+ # #
627+ # tar cvf mesa-package.tar.gz ${MESA_PACKAGE_FOLDER}
628+
515629# +----------------------------------+
516630# | Stage: cpp-devbox-with-vulkansdk |
517631# +----------------------------------+
518632
519633FROM cpp-devbox-base AS cpp-devbox-with-vulkansdk
520634
521- # reusing global arg
635+ # Reuse global arguments
636+ ARG DEBIAN_VERSION
637+ ARG DEBIAN_VERSION_NAME
638+ ARG LLVM_VERSION
639+ ARG GCC_VERSION
522640ARG VULKAN_VERSION
641+ ARG MESA_VERSION
523642
524643# +-----------------------------+
525644# | METADATA |
@@ -534,7 +653,7 @@ LABEL \
534653 org.opencontainers.image.url='https://ghcr.io/jakoch/cpp-devbox' \
535654 org.opencontainers.image.source='https://github.com/jakoch/cpp-devbox' \
536655 org.opencontainers.image.title='ghcr.io/jakoch/cpp-devbox' \
537- org.opencontainers.image.description="C++ DevBox (Debian ${DEBIAN_VERSION}-${DEBIAN_VERSION_NAME} with LLVM ${LLVM_VERSION} & GCC ${GCC_VERSION}, VulkanSDK ${VULKAN_VERSION}, CMake, VCPKG, zsh)" \
656+ org.opencontainers.image.description="C++ DevBox (Debian ${DEBIAN_VERSION}-${DEBIAN_VERSION_NAME} with LLVM ${LLVM_VERSION%%.* } & GCC ${GCC_VERSION%%.* }, VulkanSDK ${VULKAN_VERSION%%.*}, Mesa ${MESA_VERSION%%.* }, CMake, VCPKG, zsh)" \
538657 org.opencontainers.image.licenses=MIT
539658
540659#
@@ -562,9 +681,36 @@ RUN mkdir -p /opt/vulkan && \
562681# (do not refer to env var within the same statement where it is defined)
563682ENV VULKAN_SDK=/opt/vulkan/${VULKAN_VERSION}/x86_64
564683ENV PATH="$VULKAN_SDK/bin:$PATH" \
565- LD_LIBRARY_PATH="$VULKAN_SDK/lib: ${LD_LIBRARY_PATH:- }" \
684+ LD_LIBRARY_PATH="$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH }" \
566685 VK_LAYER_PATH="$VULKAN_SDK/etc/vulkan/explicit_layer.d"
567686
687+ # +-----------------------------+
688+ # | Mesa |
689+ # +-----------------------------+
690+
691+ # Mesa's software Vulkan implementation is called lavapipe (libvulkan_lvp).
692+ #
693+ # To setup Vulkan to use the CPU for rendering, you need to set the env var
694+ # VK_ICD_FILENAMES to point to the software renderer.
695+ # That JSON file points to the location of the driver (libvulkan_lvp.so).
696+ #
697+ # To test CPU rendering using the Mesa Vulkan drivers, you can use "vkcube",
698+ # which is a simple spinning-cube app to demonstrate Vulkan functionality.
699+ #
700+
701+ # Copy the packaged mesa drivers and extract into root.
702+ # COPY --from=mesa-builder /tmp/mesa-package.tar.gz /tmp
703+ # RUN tar xvf /tmp/mesa-package.tar.gz -C / --strip-components 1 && \
704+ # rm /tmp/mesa-package.tar.gz
705+
706+ RUN apt-get update && apt-get install -y --no-install-recommends \
707+ mesa-vulkan-drivers
708+
709+ #
710+ # https://docs.mesa3d.org/envvars.html
711+ # LIBGL_ALWAYS_SOFTWARE 1 = use software rendering
712+ ENV VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
713+ LIBGL_ALWAYS_SOFTWARE=1
568714
569715# The AsciiArt for the VSCode minimap is generated using
570716# shellcheck disable=SC2046
0 commit comments