因为我的设备是Headless,而且不跑Android,那么也可以离屏渲染.
可以看到设备节点
/dev/dri/
├── card0 (226, 0)
├── card1 (226, 1)
└── renderD128 (226, 128)
内核也能看到关键信息
[drm] Initialized panfrost 1.2.0 20180908 for 1800000.gpu on minor 1
panfrost 1800000.gpu: mali-unknown id 0x9091 major 0x0 minor 0x1 status 0x0
panfrost 1800000.gpu: Features: L2:0x07110206 Shader:0x00000000 Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7
OpenGL很容易测试
root@avaota-a1:~# EGL_PLATFORM=drm MESA_LOADER_DRIVER_OVERRIDE=panfrost eglinfo -B
GBM platform:
EGL API version: 1.5
EGL vendor string: Mesa Project
EGL version string: 1.5
EGL client APIs: OpenGL OpenGL_ES
OpenGL core profile vendor: Mesa
OpenGL core profile renderer: Mali-G57 (Panfrost)
OpenGL core profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL core profile shading language version: 1.40
OpenGL compatibility profile vendor: Mesa
OpenGL compatibility profile renderer: Mali-G57 (Panfrost)
OpenGL compatibility profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL compatibility profile shading language version: 1.40
OpenGL ES profile vendor: Mesa
OpenGL ES profile renderer: Mali-G57 (Panfrost)
OpenGL ES profile version: OpenGL ES 3.1 Mesa 25.0.7-2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.10
Wayland platform:
eglinfo: eglInitialize failed
X11 platform:
eglinfo: eglInitialize failed
Surfaceless platform:
EGL API version: 1.5
EGL vendor string: Mesa Project
EGL version string: 1.5
EGL client APIs: OpenGL OpenGL_ES
OpenGL core profile vendor: Mesa
OpenGL core profile renderer: Mali-G57 (Panfrost)
OpenGL core profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL core profile shading language version: 1.40
OpenGL compatibility profile vendor: Mesa
OpenGL compatibility profile renderer: Mali-G57 (Panfrost)
OpenGL compatibility profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL compatibility profile shading language version: 1.40
OpenGL ES profile vendor: Mesa
OpenGL ES profile renderer: Mali-G57 (Panfrost)
OpenGL ES profile version: OpenGL ES 3.1 Mesa 25.0.7-2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.10
Device platform:
Device #0:
Platform Device platform:
EGL API version: 1.5
EGL vendor string: Mesa Project
EGL version string: 1.5
EGL client APIs: OpenGL OpenGL_ES
OpenGL core profile vendor: Mesa
OpenGL core profile renderer: Mali-G57 (Panfrost)
OpenGL core profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL core profile shading language version: 1.40
OpenGL compatibility profile vendor: Mesa
OpenGL compatibility profile renderer: Mali-G57 (Panfrost)
OpenGL compatibility profile version: 3.1 (Core Profile) Mesa 25.0.7-2
OpenGL compatibility profile shading language version: 1.40
OpenGL ES profile vendor: Mesa
OpenGL ES profile renderer: Mali-G57 (Panfrost)
OpenGL ES profile version: OpenGL ES 3.1 Mesa 25.0.7-2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.10
Device #1:
Platform Device platform:
EGL API version: 1.5
EGL vendor string: Mesa Project
EGL version string: 1.5
EGL client APIs: OpenGL OpenGL_ES
OpenGL core profile vendor: Mesa
OpenGL core profile renderer: llvmpipe (LLVM 19.1.7, 128 bits)
OpenGL core profile version: 4.5 (Core Profile) Mesa 25.0.7-2
OpenGL core profile shading language version: 4.50
OpenGL compatibility profile vendor: Mesa
OpenGL compatibility profile renderer: llvmpipe (LLVM 19.1.7, 128 bits)
OpenGL compatibility profile version: 4.5 (Compatibility Profile) Mesa 25.0.7-2
OpenGL compatibility profile shading language version: 4.50
OpenGL ES profile vendor: Mesa
OpenGL ES profile renderer: llvmpipe (LLVM 19.1.7, 128 bits)
OpenGL ES profile version: OpenGL ES 3.2 Mesa 25.0.7-2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.20
而OpenCL验证也很简单
root@avaota-a1:~# RUSTICL_ENABLE=panfrost clinfo Number of platforms 2 Platform Name rusticl Platform Vendor Mesa/X.org Platform Version OpenCL 3.0 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd cl_khr_byte_addressable_store cl_khr_create_command_queue cl_khr_expect_assume cl_khr_extended_versioning cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_il_program cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_integer_dot_product cl_khr_spirv_no_integer_wrap_decoration cl_khr_suggested_local_work_size cl_khr_3d_image_writes cl_khr_depth_images Platform Extensions with Version cl_khr_icd 0x400000 (1.0.0) cl_khr_byte_addressable_store 0x400000 (1.0.0) cl_khr_create_command_queue 0x400000 (1.0.0) cl_khr_expect_assume 0x400000 (1.0.0) cl_khr_extended_versioning 0x400000 (1.0.0) cl_khr_global_int32_base_atomics 0x400000 (1.0.0) cl_khr_global_int32_extended_atomics 0x400000 (1.0.0) cl_khr_il_program 0x400000 (1.0.0) cl_khr_local_int32_base_atomics 0x400000 (1.0.0) cl_khr_local_int32_extended_atomics 0x400000 (1.0.0) cl_khr_integer_dot_product 0x800000 (2.0.0) cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0) cl_khr_suggested_local_work_size 0x400000 (1.0.0) cl_khr_3d_image_writes 0x400000 (1.0.0) cl_khr_depth_images 0x400000 (1.0.0) Platform Numeric Version 0xc00000 (3.0.0) Platform Extensions function suffix MESA Platform Host timer resolution 1ns Platform Name Clover Platform Vendor Mesa Platform Version OpenCL 1.1 Mesa 25.0.7-2 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd Platform Extensions function suffix MESA Platform Name rusticl Number of devices 1 Device Name Mali-G57 (Panfrost) Device Vendor Arm Device Vendor ID 0 Device Version OpenCL 3.0 Device Numeric Version 0xc00000 (3.0.0) Driver Version 25.0.7-2 Device OpenCL C Version OpenCL C 1.2 Device OpenCL C Numeric Version 0x402000 (1.2.0) Device OpenCL C all versions OpenCL C 0xc00000 (3.0.0) OpenCL C 0x402000 (1.2.0) OpenCL C 0x401000 (1.1.0) OpenCL C 0x400000 (1.0.0) Device OpenCL C features __opencl_c_integer_dot_product_input_4x8bit 0x800000 (2.0.0) __opencl_c_integer_dot_product_input_4x8bit_packed 0x800000 (2.0.0) __opencl_c_int64 0x400000 (1.0.0) __opencl_c_images 0x400000 (1.0.0) __opencl_c_read_write_images 0x400000 (1.0.0) __opencl_c_3d_image_writes 0x400000 (1.0.0) Latest conformance test passed v0000-01-01-00 Device Type GPU Device Profile FULL_PROFILE Device Available Yes Compiler Available Yes Linker Available Yes Max compute units 1 Max clock frequency 800MHz Device Partition (core) Max number of sub-devices 0 Supported partition types None Supported affinity domains (n/a) Max work item dimensions 3 Max work item sizes 256x256x256 Max work group size 256 Preferred work group size multiple (device) 16 Preferred work group size multiple (kernel) 16 Max sub-groups per work group 0 Preferred / native vector sizes char 1 / 1 short 1 / 1 int 1 / 1 long 1 / 1 half 0 / 0 (n/a) float 1 / 1 double 0 / 0 (n/a) Half-precision Floating-point support (n/a) Single-precision Floating-point support (core) Denormals No Infinity and NANs Yes Round to nearest Yes Round to zero No Round to infinity No IEEE754-2008 fused multiply-add No Support is emulated in software No Correctly-rounded divide and sqrt operations No Double-precision Floating-point support (n/a) Address bits 64, Little-Endian Global memory size 2039715840 (1.9GiB) Error Correction support No Max memory allocation 2039715840 (1.9GiB) Unified memory for Host and Device Yes Shared Virtual Memory (SVM) capabilities (core) Coarse-grained buffer sharing No Fine-grained buffer sharing No Fine-grained system sharing No Atomics No Minimum alignment for any data type 128 bytes Alignment of base address 4096 bits (512 bytes) Preferred alignment for atomics SVM 0 bytes Global 0 bytes Local 0 bytes Atomic memory capabilities relaxed, work-group scope Atomic fence capabilities relaxed, acquire/release, work-group scope Max size for global variable 0 Preferred total size of global vars 0 Global Memory cache type None Image support Yes Max number of samplers per kernel 32 Max size for 1D images from buffer 65536 pixels Max 1D or 2D image array size 2048 images Base address alignment for 2D image buffers 0 bytes Pitch alignment for 2D image buffers 0 pixels Max 2D image size 32768x32768 pixels Max 3D image size 32768x32768x32768 pixels Max number of read image args 128 Max number of write image args 64 Max number of read/write image args 64 Pipe support No Max number of pipe args 0 Max active pipe reservations 0 Max pipe packet size 0 Local memory type Global Local memory size 32768 (32KiB) Max number of constant args 16 Max constant buffer size 67108864 (64MiB) Generic address space support No Max size of kernel argument 4096 (4KiB) Queue properties (on host) Out-of-order execution Yes Profiling Yes Device enqueue capabilities (n/a) Queue properties (on device) Out-of-order execution No Profiling No Preferred size 0 Max size 0 Max queues on device 0 Max events on device 0 Prefer user sync for interop Yes Profiling timer resolution 0ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Non-uniform work-groups No Work-group collective functions No Sub-group independent forward progress No IL version SPIR-V_1.0 SPIR-V_1.1 SPIR-V_1.2 SPIR-V_1.3 SPIR-V_1.4 ILs with version SPIR-V 0x400000 (1.0.0) SPIR-V 0x401000 (1.1.0) SPIR-V 0x402000 (1.2.0) SPIR-V 0x403000 (1.3.0) SPIR-V 0x404000 (1.4.0) printf() buffer size 1048576 (1024KiB) Built-in kernels (n/a) Built-in kernels with version (n/a) Device Extensions cl_khr_byte_addressable_store cl_khr_create_command_queue cl_khr_expect_assume cl_khr_extended_versioning cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_il_program cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_integer_dot_product cl_khr_spirv_no_integer_wrap_decoration cl_khr_suggested_local_work_size cl_khr_3d_image_writes cl_khr_depth_images Device Extensions with Version cl_khr_byte_addressable_store 0x400000 (1.0.0) cl_khr_create_command_queue 0x400000 (1.0.0) cl_khr_expect_assume 0x400000 (1.0.0) cl_khr_extended_versioning 0x400000 (1.0.0) cl_khr_global_int32_base_atomics 0x400000 (1.0.0) cl_khr_global_int32_extended_atomics 0x400000 (1.0.0) cl_khr_il_program 0x400000 (1.0.0) cl_khr_local_int32_base_atomics 0x400000 (1.0.0) cl_khr_local_int32_extended_atomics 0x400000 (1.0.0) cl_khr_integer_dot_product 0x800000 (2.0.0) cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0) cl_khr_suggested_local_work_size 0x400000 (1.0.0) cl_khr_3d_image_writes 0x400000 (1.0.0) cl_khr_depth_images 0x400000 (1.0.0) Platform Name Clover Number of devices 0 NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) rusticl clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [MESA] clCreateContext(NULL, ...) [default] Success [MESA] clCreateContext(NULL, ...) [other] clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1) Platform Name rusticl Device Name Mali-G57 (Panfrost) clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1) Platform Name rusticl Device Name Mali-G57 (Panfrost) clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name rusticl Device Name Mali-G57 (Panfrost) ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.3.3 ICD loader Profile OpenCL 3.0
只是说命令,真的没什么好说的,这里重点解释为什么加了一些env约束.
clinfo → OpenCL ICD loader(ocl-icd / OpenCL-ICD-Loader)→ 扫描 /etc/OpenCL/vendors/*.icd → dlopen 对应 ICD 库(比如 Mesa 的 libMesaOpenCL.so)→ ICD 内部再去枚举设备.
关键在最后一步:Mesa 的 OpenCL 现在主要是 Rusticl.Rusticl 并不是"看见 GPU 就一定报一个 OpenCL 设备",它通常有一层"允许列表/开关",原因很现实:
- 有些 Gallium 驱动的 OpenCL 支持还在补课中(功能不全,稳定性/一致性/CTS 还没过,或者某些机型容易炸).
- Mesa 团队倾向于 默认保守:宁可默认不暴露,也不想让用户莫名其妙跑出错结果然后来骂 OpenCL "不靠谱".
所以 RUSTICL_ENABLE=panfrost 的作用通常是:明确告诉 Rusticl:把 panfrost 这个后端也当成可用 OpenCL 设备去暴露.
OpenGL 要 EGL_PLATFORM=drm + MESA_LOADER_DRIVER_OVERRIDE=panfrost 才能正常?因为很多程序会用 eglGetDisplay(EGL_DEFAULT_DISPLAY) 或类似方式拿 display.在headless下获取不到.所以就告诉他到指定drm获取.