### Meson Cross-Compilation Setup (32-bit x86 Linux Example) Source: https://docs.mesa3d.org/meson.html Example configuration for a 32-bit x86 Linux cross-compilation setup using Meson. Specifies paths for essential build tools like C/C++ compilers, archiver, stripper, and pkg-config. ```ini [binaries] c = '/usr/bin/gcc' cpp = '/usr/bin/g++' ar = '/usr/bin/gcc-ar' strip = '/usr/bin/strip' llvm-config = '/usr/bin/llvm-config32' pkg-config = '/usr/bin/pkg-config-32' ``` -------------------------------- ### Verify OpenGL Driver Installation Source: https://docs.mesa3d.org/drivers/svga3d.html Example output from the glxinfo command used to verify that the VMware SVGA3D driver is correctly loaded and active. ```text OpenGL vendor string: VMware, Inc. OpenGL renderer string: SVGA3D; build: RELEASE; OpenGL version string: 4.3 (Compatibility Profile) Mesa 23.0 ``` -------------------------------- ### Meson Build with LLVMpipe and Swrast Drivers Source: https://docs.mesa3d.org/install.html Example of configuring Mesa with Meson to include specific drivers like LLVMpipe for Gallium and swrast for Vulkan, while installing to a custom prefix. This demonstrates setting specific build options. ```bash meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" \ -Dgallium-drivers=llvmpipe -Dvulkan-drivers=swrast meson install -C builddir/ ``` -------------------------------- ### Configure and Build Mesa Source: https://docs.mesa3d.org/drivers/svga3d.html Configures the Mesa project with specific driver flags for SVGA support and GLVND, then compiles and installs the binaries. ```bash cd $TOP/mesa meson builddir -Dvulkan-drivers= -Dgallium-drivers=svga -Ddri-drivers= -Dglvnd=enabled -Dglvnd-vendor-name=mesa meson compile -C builddir sudo meson install -C builddir ``` -------------------------------- ### Install and Manage VMware Workstation Pro Source: https://docs.mesa3d.org/drivers/svga3d.html Commands to install, uninstall components, and launch VMware Workstation Pro on Linux systems using the official bundle installer. ```bash sudo ./VMware-Workstation-Full-17.6.3-24583834.x86_64.bundle -l sudo ./VMware-Workstation-Full-17.6.3-24583834.x86_64.bundle --uninstall-component=vmware-workstation sudo ./VMware-Workstation-Full-17.6.3-24583834.x86_64.bundle /usr/bin/vmware ``` -------------------------------- ### Basic Meson Build Process for Mesa Source: https://docs.mesa3d.org/install.html Standard commands to set up, compile, and install Mesa using the Meson build system. This process is applicable to *nix systems, macOS, Haiku, and Windows. ```bash meson setup builddir/ meson compile -C builddir/ sudo meson install -C builddir/ ``` -------------------------------- ### Meson Build with Custom Install Prefix Source: https://docs.mesa3d.org/install.html Example of configuring Mesa with Meson to install into a custom directory specified by the MESA_INSTALLDIR environment variable. This is part of the manual setup for running against a local build. ```bash meson setup builddir/ -Dprefix="$MESA_INSTALLDIR" OTHER_OPTIONS meson install -C builddir/ ``` -------------------------------- ### Configure and Build libdrm Source: https://docs.mesa3d.org/drivers/svga3d.html Configures the libdrm library using Meson and installs it to the system. Requires the LIBDIR environment variable to be set to the system's library path. ```bash export LIBDIR=/usr/lib/x86_64-linux-gnu cd $TOP/drm meson builddir --prefix=/usr --libdir=${LIBDIR} meson compile -C builddir sudo meson install -C builddir ``` -------------------------------- ### Install and Verify Mesa3D Source: https://docs.mesa3d.org/meson.html Commands to install the compiled binaries and verify the installation using OpenGL diagnostic tools. ```bash ninja -C build/ install glxinfo | grep OpenGL sudo ldconfig ``` -------------------------------- ### Install Build Dependencies for Mesa SVGA3D Source: https://docs.mesa3d.org/drivers/svga3d.html A comprehensive list of packages required to build the Mesa SVGA3D driver on Ubuntu systems, including build tools, X11 headers, and development libraries. ```bash sudo apt-get install autoconf automake libtool flex bison zstd sudo apt-get install build-essential g++ git sudo apt-get install libexpat1-dev libpciaccess-dev \ libpthread-stubs0-dev \ libudev-dev libx11-xcb-dev \ libxcb-dri2-0-dev libxcb-dri3-dev sudo apt-get install libxcb-glx0-dev libxcb-present-dev \ libxcb-shm0-dev libxcb-xfixes0-dev sudo apt-get install libxdamage-dev libxext-dev \ libxfixes-dev libxkbcommon-dev sudo apt-get install libxml2-dev libxrandr-dev \ libxshmfence-dev libxxf86vm-dev sudo apt-get install mesa-utils meson ninja-build \ pkg-config python3-mako python3-setuptools sudo apt-get install x11proto-dri2-dev x11proto-gl-dev \ xutils-dev libglvnd-dev ``` -------------------------------- ### Advanced Build Customization Source: https://docs.mesa3d.org/meson.html Techniques for setting custom installation prefixes, passing compiler-specific arguments, and specifying alternative compilers. ```bash meson --prefix="${PWD}/build/install" build/ meson setup builddir/ -Dc_args=-fmax-errors=10 -Dcpp_args=-DMAGIC=123 CC=clang CXX=clang++ meson setup build-clang ninja -C build-clang ninja -C build-clang clean ``` -------------------------------- ### Install Kernel Headers for VMware Modules Source: https://docs.mesa3d.org/drivers/svga3d.html Commands to install the required Linux kernel headers for building VMware modules on Ubuntu and Fedora distributions. ```bash # Ubuntu sudo apt-get install linux-headers-$(uname -r) # Fedora sudo dnf install linux-devel-$(uname -r) ``` -------------------------------- ### OpenGL Buffer Setup via MapBufferRange Source: https://docs.mesa3d.org/gallium/buffermapping.html Demonstrates the initialization and explicit flushing of buffer ranges using glMapBufferRange. This approach is used during setup to prepare buffers for later rendering. ```OpenGL 679259 glGenBuffersARB(n = 1, buffers = &1314) 679260 glBindBufferARB(target = GL_ELEMENT_ARRAY_BUFFER, buffer = 1314) 679261 glBufferDataARB(target = GL_ELEMENT_ARRAY_BUFFER, size = 3072, data = NULL, usage = GL_STATIC_DRAW) 679264 glMapBufferRange(target = GL_ELEMENT_ARRAY_BUFFER, offset = 0, length = 3072, access = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT) = 0xd7384000 679269 glFlushMappedBufferRange(target = GL_ELEMENT_ARRAY_BUFFER, offset = 0, length = 3072) 679270 glUnmapBuffer(target = GL_ELEMENT_ARRAY_BUFFER) = GL_TRUE ``` -------------------------------- ### Install Nginx and Lua Module Source: https://docs.mesa3d.org/ci/LAVA.html Commands to install the Nginx web server and the required Lua module for advanced request processing. ```bash sudo apt install nginx libnginx-mod-http-lua ``` -------------------------------- ### Example Disassembled Firmware Snippet Source: https://docs.mesa3d.org/drivers/freedreno.html An example of disassembled GPU firmware, showing instruction addresses (PC) and their corresponding operations. This is used to find the instruction that caused the fault. ```assembly l018: 00d1: 08dd0001 add $addr, $06, 0x0001 00d2: 981ff806 mov $data, $data 00d3: 8a080001 mov $08, 0x0001 << 16 00d4: 3108ffff or $08, $08, 0xffff 00d5: 9be8f805 and $data, $data, $08 00d6: 9806e806 mov $addr, $06 00d7: 9803f806 mov $data, $03 <------------- 00d8: d8000000 waitin 00d9: 981f0806 mov $01, $data ``` -------------------------------- ### Install Flex and Bison on Windows with MinGW Source: https://docs.mesa3d.org/install.html Command to install Flex and Bison on Windows using the MinGW package manager. These tools are necessary for building the Mesa IR and GLSL compiler. ```bash mingw-get install msys-flex msys-bison ``` -------------------------------- ### Cross-Compilation Setup for Panfrost without Host LLVM Source: https://docs.mesa3d.org/drivers/panfrost.html This command sequence is used for cross-compiling Panfrost when LLVM is not available on the host. It builds and installs necessary tools on the host system where LLVM is present, then uses system options for the cross-compile side. ```bash meson . build-host/ -Dtools=panfrost -Dmesa-clc=enabled -Dinstall-mesa-clc=true -Dprecomp-compiler=enabled -Dinstall-precomp-compiler=true meson . build/ -Dmesa-clc=system -Dprecomp-compiler=system ``` -------------------------------- ### Configure LLVM via CMake Module Path Source: https://docs.mesa3d.org/meson.html Demonstrates how to use the -Dcmake_module_path option in Meson to specify an alternative installation prefix for LLVM when standard discovery fails. ```bash meson setup builddir -Dcmake_module_path=/home/user/mycmake/prefix ``` -------------------------------- ### Apply Native and Cross-Compilation Files Source: https://docs.mesa3d.org/meson.html Commands to initialize a Meson build directory using the defined native or cross-compilation configuration files. ```bash meson setup builddir/ --native-file custom-llvm.ini ``` ```bash meson setup builddir/ --cross-file cross-llvm.ini ``` -------------------------------- ### Create a Custom LLVM Binary Wrap Source: https://docs.mesa3d.org/meson.html An example of a meson.build file for a binary wrap, which manually finds LLVM libraries and declares a dependency object for the build system. ```meson project('llvm', ['cpp']) cpp = meson.get_compiler('cpp') _deps = [] _search = join_paths(meson.current_source_dir(), 'lib') foreach d : ['libLLVMCodeGen', 'libLLVMScalarOpts', 'libLLVMAnalysis', 'libLLVMTransformUtils', 'libLLVMCore', 'libLLVMX86CodeGen', 'libLLVMSelectionDAG', 'libLLVMipo', 'libLLVMAsmPrinter', 'libLLVMInstCombine', 'libLLVMInstrumentation', 'libLLVMMC', 'libLLVMGlobalISel', 'libLLVMObjectYAML', 'libLLVMDebugInfoPDB', 'libLLVMVectorize', 'libLLVMPasses', 'libLLVMSupport', 'libLLVMLTO', 'libLLVMObject', 'libLLVMDebugInfoCodeView', 'libLLVMDebugInfoDWARF', 'libLLVMOrcJIT', 'libLLVMProfileData', 'libLLVMObjCARCOpts', 'libLLVMBitReader', 'libLLVMCoroutines', 'libLLVMBitWriter', 'libLLVMRuntimeDyld', 'libLLVMMIRParser', 'libLLVMX86Desc', 'libLLVMAsmParser', 'libLLVMTableGen', 'libLLVMFuzzMutate', 'libLLVMLinker', 'libLLVMMCParser', 'libLLVMExecutionEngine', 'libLLVMCoverage', 'libLLVMInterpreter', 'libLLVMTarget', 'libLLVMX86AsmParser', 'libLLVMSymbolize', 'libLLVMDebugInfoMSF', 'libLLVMMCJIT', 'libLLVMXRay', 'libLLVMX86AsmPrinter', 'libLLVMX86Disassembler', 'libLLVMMCDisassembler', 'libLLVMOption', 'libLLVMIRReader', 'libLLVMLibDriver', 'libLLVMDlltoolDriver', 'libLLVMDemangle', 'libLLVMBinaryFormat', 'libLLVMLineEditor', 'libLLVMWindowsManifest', 'libLLVMX86Info', 'libLLVMX86Utils'] _deps += cpp.find_library(d, dirs : _search) endforeach dep_llvm = declare_dependency( include_directories : include_directories('include'), dependencies : _deps, version : '6.0.0', ) has_rtti = false irbuilder_h = files('include/llvm/IR/IRBuilder.h') ``` -------------------------------- ### Pipeline Creation with Dynamic State Initialization (C) Source: https://docs.mesa3d.org/vulkan/graphics-state.html Demonstrates initializing a graphics pipeline's dynamic state. It involves zeroing out the dynamic state structure, setting pointers to associated states like vertex input and sample locations, and then calling `vk_dynamic_graphics_state_init` to set default values. ```c memset(&pipeline->dynamic, 0, sizeof(pipeline->dynamic)); pipeline->dynamic->vi = &pipeline->vi_state; pipeline->dynamic->ms.sample_locations = &pipeline->sl_state; vk_dynamic_graphics_state_init(&pipeline->dynamic, &state); ``` -------------------------------- ### Initialize Environment and Clone Repositories Source: https://docs.mesa3d.org/drivers/svga3d.html Sets the base directory for the project and clones the required Mesa and libdrm source code repositories from Freedesktop.org. ```bash export TOP=$PWD git clone https://gitlab.freedesktop.org/mesa/mesa.git git clone https://gitlab.freedesktop.org/mesa/drm.git ``` -------------------------------- ### C Code Formatting: Single-Line Comments Source: https://docs.mesa3d.org/codingstyle.html Provides examples of single-line comments in C code. Comments can be placed on their own line before the code they explain or at the end of a line of code. ```c /* null-out pointer to prevent dangling reference below */ bufferObj = NULL; ``` ```c bufferObj = NULL; /* prevent dangling reference below */ ``` -------------------------------- ### Configure and Build Mesa3D with Meson and Ninja Source: https://docs.mesa3d.org/meson.html Standard workflow for initializing a build directory, configuring build options, and executing the compilation process. ```bash meson setup build/ ninja -C build/ ``` -------------------------------- ### vk_instance Structure and Initialization Source: https://docs.mesa3d.org/vulkan/base-objs.html Details about the vk_instance structure, its members, and the initialization function vk_instance_init. ```APIDOC ## vk_instance Structure ### Description Represents a Vulkan instance used for triggering renderdoc captures from within the driver. ### Members - **alloc** (VkAllocationCallbacks) - Allocator used when creating this instance. Used as a fall-back for NULL pAllocator in device-level create functions. - **app_info** (vk_app_info) - Contains VkInstanceCreateInfo::pApplicationInfo. - **supported_extensions** (const struct vk_instance_extension_table *) - Table of all supported instance extensions. - **enabled_extensions** (struct vk_instance_extension_table) - Table of all enabled instance extensions, generated from VkInstanceCreateInfo::ppEnabledExtensionNames. - **dispatch_table** (struct vk_instance_dispatch_table) - Instance-level dispatch table. - **[anonymous]** (struct) - List of all physical devices and callbacks for automatic physical device management. - **trace_mode** (uint64_t) - Enabled tracing modes. - **trace_per_submit** (bool) - Indicates if capture mode is per-submit. ### vk_instance_init #### Description Initializes a vk_instance, validates Vulkan version, and checks for supported extensions. #### Parameters - **instance** (struct vk_instance *) - [out] The instance to initialize. - **supported_extensions** (const struct vk_instance_extension_table *) - [in] Table of all instance extensions supported by this instance. - **dispatch_table** (const struct vk_instance_dispatch_table *) - [in] Instance-level dispatch table. - **pCreateInfo** (const VkInstanceCreateInfo *) - [in] VkInstanceCreateInfo pointer passed to vkCreateInstance(). - **alloc** (const VkAllocationCallbacks *) - [in] Allocation callbacks used to create this instance; must not be NULL. #### Returns - VK_SUCCESS on successful initialization. - VK_ERROR_EXTENSION_NOT_PRESENT if an unsupported extension is requested. ``` -------------------------------- ### C Code Formatting: Multi-Line Comments Source: https://docs.mesa3d.org/codingstyle.html Demonstrates the style for multi-line comments in C code. These are typically used for more extensive explanations or when quoting external specifications. Each line within the comment block should start with an asterisk. ```c /* If this is a new buffer object id, or one which was generated but * never used before, allocate a buffer object now. */ ``` ```c /* Page 38 of the PDF of the OpenGL ES 3.0 spec says: * * "An INVALID_OPERATION error is generated for any of the following * conditions: * * * is zero." * * Additionally, page 94 of the PDF of the OpenGL 4.5 core spec * (30.10.2014) also says this, so it's no longer allowed for desktop GL, * either. */ ``` -------------------------------- ### Initializing Vulkan Instance with Dispatch Table (C) Source: https://docs.mesa3d.org/vulkan/dispatch.html Demonstrates the typical pattern within a Vulkan driver for initializing an instance. It involves creating a dispatch table by layering entrypoint tables and then calling `vk_instance_init`. ```c struct vk_instance_dispatch_table dispatch_table; vk_instance_dispatch_table_from_entrypoints( &dispatch_table, &anv_instance_entrypoints, true); vk_instance_dispatch_table_from_entrypoints( &dispatch_table, &wsi_instance_entrypoints, false); result = vk_instance_init(&instance->vk, &instance_extensions, &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_free(pAllocator, instance); return result; } ``` -------------------------------- ### Meson Build with Visual Studio Backend on Windows Source: https://docs.mesa3d.org/install.html Commands to set up a Mesa build using Meson with the Visual Studio backend on Windows, followed by compilation using MSBuild. This is an alternative to the standard Meson build process on Windows. ```bash meson setup builddir --backend=vs cd builddir msbuild mesa.sln /m ``` -------------------------------- ### C Code Formatting: Function Comment Example (Doxygen) Source: https://docs.mesa3d.org/codingstyle.html Shows the recommended Doxygen-style comment block for C functions. This includes a brief description, parameter explanations (using `\param`), and return value description (using `\return`). The function return type and qualifiers are on one line, and the function name and parameters are on the next. ```c /** * Create and initialize a new buffer object. Called via the * ctx->Driver.CreateObject() driver callback function. * \param name integer name of the object * \param type one of GL_FOO, GL_BAR, etc. * \return pointer to new object or NULL if error */ struct gl_object * _mesa_create_object(GLuint name, GLenum type) { /* function body */ } ``` -------------------------------- ### Replay and Analyze apitrace with Metrics Source: https://docs.mesa3d.org/drivers/vc4.html Replay captured apitrace files to inspect hardware performance counters. '--list-metrics' shows available counters, and '--pdraw' replays with specific metrics like 'GL_AMD_performance_monitor:QPU-total-clk-cycles-vertex-coord-shading'. ```bash apitrace replay .trace --list-metrics ``` ```bash apitrace replay .trace --pdraw=GL_AMD_performance_monitor:QPU-total-clk-cycles-vertex-coord-shading ``` -------------------------------- ### Install Homebrew Package Manager Source: https://docs.mesa3d.org/drivers/kosmickrisp.html Installs the Homebrew package manager using a curl script. This is a prerequisite for installing other development tools and libraries required for building KosmicKrisp. ```shell /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Build and Run virglrenderer with Venus Support Source: https://docs.mesa3d.org/drivers/venus.html Steps to clone the virglrenderer repository, build it with Venus support using meson, and start the vtest server. ```bash git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git cd virglrenderer meson out -Dvenus=true meson compile -C out meson devenv -C out ./vtest/virgl_test_server --venus exit ``` -------------------------------- ### Install Development Dependencies for Mesa Source: https://docs.mesa3d.org/install.html Package manager commands to install build dependencies for Mesa on different Linux distributions. These commands help retrieve necessary libraries and headers for compiling Mesa. ```bash zypper source-install --build-deps-only Mesa # openSUSE/SLED/SLES yum-builddep mesa # yum Fedora, OpenSuse(?) dnf builddep mesa # dnf Fedora apt-get build-dep mesa # Debian and derivatives ``` -------------------------------- ### Install TensorFlow Lite Runtime and Python Dependencies Source: https://docs.mesa3d.org/teflon.html Steps to install necessary runtime dependencies, including Python 3.10, pytest, exceptiongroup, and the TensorFlow Lite runtime Python package. Pillow is also installed for image processing scripts. ```bash # Install Python 3.10 and dependencies (as root) ~ # echo deb-src http://deb.debian.org/debian testing main >> /etc/apt/sources.list ~ # echo deb http://deb.debian.org/debian unstable main >> /etc/apt/sources.list ~ # echo 'APT::Default-Release "testing";' >> /etc/apt/apt.conf ~ # apt-get update ~ # apt-get -y install python3.10 python3-pytest python3-exceptiongroup # Install TensorFlow Lite Python package (as non-root) ~ $ python3.10 -m pip install --break-system-packages tflite-runtime==2.13.0 # For the classification.py script mentioned below, you will need PIL ~ $ python3.10 -m pip install --break-system-packages pillow ``` -------------------------------- ### Generate Meson build configuration for LLVM Source: https://docs.mesa3d.org/drivers/llvmpipe.html This script verifies the existence of the LLVM installation directory, creates a subproject directory, and generates a 'meson.build' file that dynamically links all necessary LLVM libraries. ```bash : "$LLVM_INSTALL_PREFIX" if [ ! -d "$LLVM_INSTALL_PREFIX" ]; then echo "Cannot find an LLVM build in $LLVM_INSTALL_PREFIX" 1>&2 exit 1 fi mkdir -p subprojects/llvm cat << EOF > subprojects/llvm/meson.build project('llvm', ['cpp']) cpp = meson.get_compiler('cpp') _deps = [] _search = join_paths('$LLVM_INSTALL_PREFIX', 'lib') foreach d: ['libLLVMAggressiveInstCombine', 'libLLVMAnalysis', 'libLLVMAsmParser', 'libLLVMAsmPrinter', 'libLLVMBinaryFormat', 'libLLVMBitReader', 'libLLVMBitstreamReader', 'libLLVMBitWriter', 'libLLVMCFGuard', 'libLLVMCFIVerify', 'libLLVMCodeGen', 'libLLVMCodeGenTypes', 'libLLVMCore', 'libLLVMCoroutines', 'libLLVMCoverage', 'libLLVMDebugInfoBTF', 'libLLVMDebugInfoCodeView', 'libLLVMDebuginfod', 'libLLVMDebugInfoDWARF', 'libLLVMDebugInfoGSYM', 'libLLVMDebugInfoLogicalView', 'libLLVMDebugInfoMSF', 'libLLVMDebugInfoPDB', 'libLLVMDemangle', 'libLLVMDiff', 'libLLVMDlltoolDriver', 'libLLVMDWARFLinker', 'libLLVMDWARFLinkerClassic', 'libLLVMDWARFLinkerParallel', 'libLLVMDWP', 'libLLVMExecutionEngine', 'libLLVMExegesis', 'libLLVMExegesisX86', 'libLLVMExtensions', 'libLLVMFileCheck', 'libLLVMFrontendDriver', 'libLLVMFrontendHLSL', 'libLLVMFrontendOffloading', 'libLLVMFrontendOpenACC', 'libLLVMFrontendOpenMP', 'libLLVMFuzzerCLI', 'libLLVMFuzzMutate', 'libLLVMGlobalISel', 'libLLVMHipStdPar', 'libLLVMInstCombine', 'libLLVMInstrumentation', 'libLLVMInterfaceStub', 'libLLVMInterpreter', 'libLLVMipo', 'libLLVMIRPrinter', 'libLLVMIRReader', 'libLLVMJITLink', 'libLLVMLibDriver', 'libLLVMLineEditor', 'libLLVMLinker', 'libLLVMLTO', 'libLLVMMC', 'libLLVMMCA', 'libLLVMMCDisassembler', 'libLLVMMCJIT', 'libLLVMMCParser', 'libLLVMMIRParser', 'libLLVMObjCARCOpts', 'libLLVMObjCopy', 'libLLVMObject', 'libLLVMObjectYAML', 'libLLVMOption', 'libLLVMOrcDebugging', 'libLLVMOrcJIT', 'libLLVMOrcShared', 'libLLVMTargetProcess', 'libLLVMPasses', 'libLLVMProfileData', 'libLLVMRemarks', 'libLLVMRuntimeDyld', 'libLLVMScalarOpts', 'libLLVMSelectionDAG', 'libLLVMSupport', 'libLLVMSymbolize', 'libLLVMTableGen', 'libLLVMTableGenCommon', 'libLLVMTarget', 'libLLVMTargetParser', 'libLLVMTextAPI', 'libLLVMTextAPIBinaryReader', 'libLLVMTransformUtils', 'libLLVMVectorize', 'libLLVMWindowsDriver', 'libLLVMWindowsManifest', 'libLLVMX86AsmParser', 'libLLVMX86CodeGen', 'libLLVMX86Desc', 'libLLVMX86Disassembler', 'libLLVMX86Info', 'libLLVMX86TargetMCA', 'libLLVMXRay'] _deps += cpp.find_library(d, dirs : _search) endforeach dep_llvm = declare_dependency( include_directories : include_directories('$LLVM_INSTALL_PREFIX/include'), dependencies : _deps, version : '$(sed -n -e 's/^#define LLVM_VERSION_STRING "\([^"]*\)".*/\1/p' "${LLVM_INSTALL_PREFIX}/include/llvm/Config/llvm-config.h" )', ) has_rtti = false irbuilder_h = files('$LLVM_INSTALL_PREFIX/include/llvm/IR/IRBuilder.h') EOF ``` -------------------------------- ### Manage Build Configuration and Options Source: https://docs.mesa3d.org/meson.html Commands to review current build settings and modify them using the -D flag for specific parameters. ```bash meson configure build/ meson configure build/ -Dprefix=/tmp/install -Dglx=true ``` -------------------------------- ### Texture Sample Instruction Example Source: https://docs.mesa3d.org/drivers/freedreno/ir3-notes.html An example of a texture sample (sam) instruction in IR3 assembly, demonstrating how multiple consecutive scalar registers are consumed for coordinates and written for output components. ```Assembly sam (f32)(xyz)r2.x, r0.z, s#0, t#0 ``` -------------------------------- ### Implement vkGetInstanceProcAddr for Vulkan ICD Source: https://docs.mesa3d.org/vulkan/base-objs.html Demonstrates how to implement the vkGetInstanceProcAddr entrypoint for a Vulkan ICD using the vk_instance structure. It utilizes VK_FROM_HANDLE to retrieve the instance and delegates the lookup to vk_instance_get_proc_addr. ```c VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL drv_GetInstanceProcAddr(VkInstance _instance, const char *pName) { VK_FROM_HANDLE(vk_instance, instance, _instance); return vk_instance_get_proc_addr(instance, &drv_instance_entrypoints, pName); } PUBLIC VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName) { return drv_GetInstanceProcAddr(instance, pName); } ``` -------------------------------- ### Run Command with Meson Devenv Source: https://docs.mesa3d.org/install.html Command to execute a specific program (e.g., glxinfo) using the Meson 'devenv' subcommand. This allows running applications against a local Mesa build without a system-wide installation, useful for debugging. ```bash meson devenv -C builddir glxinfo ``` -------------------------------- ### Initialize Vulkan Device (C) Source: https://docs.mesa3d.org/vulkan/base-objs.html Initializes a Vulkan device, validating requested extensions and features. It checks `VkInstanceCreateInfo::ppEnabledExtensionNames` against supported extensions and feature structs in `pCreateInfo->pNext` against `vkGetPhysicalDeviceFeatures2`. Returns `VK_ERROR_EXTENSION_NOT_PRESENT` or `VK_ERROR_FEATURE_NOT_PRESENT` if unsupported items are requested. ```c VkResult vk_device_init( struct vk_device *device, struct vk_physical_device *physical_device, const struct vk_device_dispatch_table *dispatch_table, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *alloc ); /* Parameters: * device - [out] The device to initialize * physical_device - [in] The physical device * dispatch_table - [in] Device-level dispatch table * pCreateInfo - [in] VkDeviceCreateInfo pointer passed to vkCreateDevice() * alloc - [in] Allocation callbacks passed to vkCreateDevice() */ ``` -------------------------------- ### Relative Addressing Example in Mesa3D Source: https://docs.mesa3d.org/drivers/freedreno/ir3-notes.html Demonstrates the use of relative addressing with `a0.x` as an address register to access registers in the const file. The example shows how an instruction can reference a register based on the value of `a0.x` plus an offset. ```assembly mova a0.x, hr1.y sub r1.y, r2.x, r3.x add r0.x, r1.y, c ``` -------------------------------- ### NIR Indirect Register Write Example Source: https://docs.mesa3d.org/drivers/freedreno/ir3-notes.html Shows the translation of a NIR indirect register write, where data is written to an array element using a dynamic offset. This example highlights the use of `mov.u32u32` to write to array elements and the `address` field for dependency tracking. ```assembly 0000:0000:001: shl.b hssa_29, hssa_27, himm[0.000000,1,0x1] 0000:0000:002: mov.s16s16 hr61.x, hssa_29 0000:0000:001: mov.u32u32 arr[id=1, offset=0, size=4, ssa_17], c2.y, address=_[0000:0000:002: mov.s16s16] 0000:0000:004: mov.u32u32 arr[id=1, offset=1, size=4, ssa_31], c2.z, address=_[0000:0000:002: mov.s16s16] ``` -------------------------------- ### Set Vulkan ICD Path for Local Build Source: https://docs.mesa3d.org/install.html Environment variable setting to point to the Vulkan ICD (Installable Client Driver) JSON file for running Vulkan applications against a local Mesa build. This allows Vulkan applications to discover the locally built Vulkan driver. ```bash VK_DRIVER_FILES="$MESA_INSTALLDIR/share/vulkan/icd.d/my_icd.json" vulkaninfo ``` -------------------------------- ### LLVMpipe and Softpipe Driver Improvements Source: https://docs.mesa3d.org/relnotes/7.10.1.html This code snippet focuses on improvements for the LLVMpipe and Softpipe drivers. It includes ensuring binning is active when a query begins or ends in LLVMpipe and fixing an off-by-one error in `setup_fragcoord_coeff()` for Softpipe. ```c // llvmpipe: make sure binning is active when we begin/end a query // softpipe: fix off-by-one error in setup_fragcoord_coeff() ```