cl_khr_mipmap_image

Extension adds support for mipmaps.

#pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable

Description

This extension adds support for mipmaps. This proposal is implemented as two optional extensions. The cl_khr_mipmap_image extension implements support to create a mipmapped image, enqueue commands to read/write/copy/map a region of a mipmapped image and built-in functions that can be used to read a mip-mapped image in an OpenCL C program. The cl_khr_mipmap_image_writes extension adds built-in functions that can be used to write a mip-mapped image in an OpenCL C program. If the cl_khr_mipmap_image_writes extension is supported by the OpenCL device, the cl_khr_mipmap_image extension must also be supported.

Additions to section 5.3 – Image Objects:

A mip-mapped 1D image, 1D image array, 2D image, 2D image array or 3D image is created by specifying num_mip_levels to be a value > 1 in cl_image_desc passed to clCreateImage. The dimensions of a mip-mapped image can be a power of two or a non-power of two. Each successively smaller mipmap level is half the size of the previous level. If this half value is a fractional value, it is rounded down to the nearest integer.

  • The following restrictions apply when mip-mapped images are created with clCreateImage:
  • CL_MEM_USE_HOST_PTR or CL_MEM_COPY_HOST_PTR cannot be specified if a mipmapped image is created.
  • The host_ptr argument to clCreateImage must be a NULL value.
  • Mip-mapped images cnnot be created for CL_MEM_OBJECT_IMAGE1D_BUFFER images and multi-sampled (i.e. msaa) images.

Calls to clEnqueueReadImage, clEnqueueWriteImage, and clEnqueueMapImage can be used to read from or write to a specific mip-level of a mip-mapped image. If image argument is a 1D image, origin[1] specifies the mip-level to use. If image argument is a 1D image array, origin[2] specifies the mip-level to use. If image argument is a 2D image, origin[3] specifies the mip-level to use. If image argument is a 2D image array or a 3D image, origin[3] specifies the mip-level to use.

Calls to clEnqueueCopyImage, clEnqueueCopyImageToBuffer, and clEnqueueCopyBufferToImage can also be used to copy from and to a specific mip-level of a mip-mapped image. If src_image argument is a 1D image, src_origin[1] specifies the mip-level to use. If src_image argument is a 1D image array, src_origin[2] specifies the mip-level to use. If src_image argument is a 2D image, src_origin[3] specifies the mip-level to use. If src_image argument is a 2D image array or a 3D image, src_origin[3] specifies the mip-level to use. If dst_image argument is a 1D image, dst_origin[1] specifies the mip-level to use. If dst_image argument is a 1D image array, dst_origin[2] specifies the mip-level to use. If dst_image argument is a 2D image, dst_origin[3] specifies the mip-level to use. If dst_image argument is a 2D image array or a 3D image, dst_origin[3] specifies the mip-level to use.

If the mip level specified is not a valid value, these functions return the error CL_INVALID_MIP_LEVEL.

Additions to section 5.7 – Sampler Objects:

Add the following sampler properties that can be specified when a sampler object is created using clCreateSamplerWithProperties.

cl_sampler_properties enum Property Value Default Value
CL_SAMPLER_MIP_FILTER_MODE cl_filter_mode CL_FILTER_NONE
CL_SAMPLER_LOD_MIN float 0.0f
CL_SAMPLER_LOD_MAX float MAXFLOAT

NOTE: The sampler properties CL_SAMPLER_MIP_FILTER_MODE, CL_SAMPLER_LOD_MIN, and CL_SAMPLER_LOD_MAX cannot be specified with any samplers initialized in the OpenCL program source. Only the default values for these properties will be used. To create a sampler with specific values for these properties, a sampler object must be created with clCreateSamplerWithProperties and passed as an argument to a kernel.

Additions to section 6.13.14 – Image Read, Write, and Query Functions

The image read and write functions read from and write to mip-level 0 if the image argument is a mip-mapped image. New built-in image read, write, and query functions are added to the image functions available.

NOTE: CL_SAMPLER_NORMALIZED_COORDS must be CL_TRUE for the new built-in read functions referred to above that read from a mip-mapped image; otherwise the behavior is undefined. The value specified in the lod argument is clamped to the minimum of (actual number of mip-levels – 1) in the image or value specified for CL_SAMPLER_LOD_MAX.

Additions to section 9.7 – Sharing Memory Objects with OpenGL / OpenGL ES Texture Objects

If the cl_khr_mipmap_image extension is supported by the OpenCL device, the cl_khr_gl_sharing extension adds support for creating a mip-mapped CL image from a mip-mapped GL texture.

To create a mip-mapped CL image from a mip-mapped GL texture, the miplevel argument to clCreateFromGLTexture should be a negative value. If miplevel is a negative value then a CL mipmapped image object is created from a mipmapped GL texture object instead of a CL image object for a specific miplevel of a GL texture.

Specification

OpenCL Specification

Also see

EXTENSION, clCreateProgramWithBinary, Image Functions, clCreateFromGLTexture, clEnqueueCopyImage, clEnqueueCopyImageToBuffer, clEnqueueCopyBufferToImage, clEnqueueReadImage, clEnqueueWriteImage, clEnqueueMapImage, clCreateImage

Copyright © 2007-2013 The Khronos Group Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.