Implementation:Alibaba MNN OpenCL CL Ext Qcom Header
| Knowledge Sources | |
|---|---|
| Domains | GPU_Computing, OpenCL |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Vendored Qualcomm-specific OpenCL extension header declaring Adreno GPU optimizations including buffer-from-image creation, extended image formats, performance hints, Android native buffer interop, and specialized image channel orders for MNN's OpenCL backend.
Description
cl_ext_qcom.h defines Qualcomm-specific OpenCL extensions targeting Adreno GPUs commonly found in Snapdragon mobile SoCs. The header declares the cl_qcom_create_buffer_from_image extension for zero-copy buffer creation from image objects, cl_qcom_extended_images for larger-than-standard 2D/3D image dimensions, cl_qcom_perf_hint for GPU frequency scaling control (high/normal/low performance modes), cl_qcom_android_native_buffer_host_ptr for direct Android native buffer import, and cl_qcom_other_image for specialized image channel orders including NV12, P010, MIPI, and tiled variants used in camera and video processing pipelines. MNN vendors this header to enable optimized memory sharing and image processing on Qualcomm mobile devices.
Usage
This header is included internally by MNN's OpenCL backend. It is not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File: 3rd_party/OpenCLHeaders/CL/cl_ext_qcom.h
- Lines: 1-413
Signature
// Buffer-from-image extension
#define CL_BUFFER_FROM_IMAGE_ROW_PITCH_QCOM 0x40C0
#define CL_BUFFER_FROM_IMAGE_SLICE_PITCH_QCOM 0x40C1
extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateBufferFromImageQCOM(cl_mem image,
cl_mem_flags flags,
cl_int *errcode_ret);
// Performance hint extension
typedef cl_uint cl_perf_hint;
#define CL_CONTEXT_PERF_HINT_QCOM 0x40C2
#define CL_PERF_HINT_HIGH_QCOM 0x40C3
#define CL_PERF_HINT_NORMAL_QCOM 0x40C4
#define CL_PERF_HINT_LOW_QCOM 0x40C5
extern CL_API_ENTRY cl_int CL_API_CALL
clSetPerfHintQCOM(cl_context context,
cl_perf_hint perf_hint);
// Extended image formats (NV12, P010, MIPI, tiled variants)
#define CL_QCOM_NV12 0x4133
#define CL_QCOM_NV12_Y 0x4134
#define CL_QCOM_NV12_UV 0x4135
#define CL_QCOM_P010 0x413C
#define CL_QCOM_UNORM_MIPI10 0x4159
Import
#include "3rd_party/OpenCLHeaders/CL/cl_ext_qcom.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | Header-only; no runtime inputs |
Outputs
| Name | Type | Description |
|---|---|---|
| API declarations | C functions/typedefs | Qualcomm-specific OpenCL extension function declarations, Adreno GPU performance hint API, Android native buffer interop structures, and specialized image format constants |
Usage Examples
// MNN internal usage (not user-facing)
#include "CL/cl_ext_qcom.h"
// Set GPU performance hint for high-performance inference
clSetPerfHintQCOM(context, CL_PERF_HINT_HIGH_QCOM);
// Create a buffer from an existing image (zero-copy on Adreno)
cl_int err;
cl_mem buffer = clCreateBufferFromImageQCOM(image, CL_MEM_READ_ONLY, &err);
// Query buffer row pitch from image
size_t row_pitch;
clGetMemObjectInfo(buffer, CL_BUFFER_FROM_IMAGE_ROW_PITCH_QCOM,
sizeof(row_pitch), &row_pitch, NULL);
// Extended image dimensions on Adreno
cl_uint max_width;
clGetDeviceInfo(device, CL_DEVICE_EXTENDED_IMAGE2D_MAX_WIDTH_QCOM,
sizeof(max_width), &max_width, NULL);
Related Pages
- Environment:Alibaba_MNN_GPU_OpenCL_Environment
- Alibaba_MNN_OpenCL_CL_Ext_Header - Base extension header (included by this file)
- Alibaba_MNN_OpenCL_CL_Header - Core OpenCL API
- Alibaba_MNN_OpenCL_CL_Platform_Header - Platform type definitions