Method: OpenCL.create_image_2d

Defined in:
lib/opencl_ruby_ffi/Image.rb

.create_image_2d(context, format, width, height, options = {}) ⇒ Object Also known as: create_image_2D

Creates a 2D Image

Attributes

  • context - Context the created Image will be associated to

  • format - an ImageFormat

  • width - width of the image

Options

  • :flags - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image

  • :host_ptr - if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use

  • :row_pitch - if provided the row_pitch of data in host_ptr



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/opencl_ruby_ffi/Image.rb', line 68

def self.create_image_2d( context, format, width, height, options = {} )
  row_pitch = 0
  row_pitch = options[:row_pitch] if options[:row_pitch]
  if context.platform.version_number > 1.1 then
    desc = ImageDesc::new(Mem::IMAGE2D, width, height, 0, 0, row_pitch, 0, 0, 0, nil)
    return create_image( context, format, desc, options )
  end
  flags = get_flags( options )
  host_ptr = options[:host_ptr]
  error = MemoryPointer::new( :cl_int )
  img_ptr = clCreateImage2D( context, flags, format, width, height, row_pitch, host_ptr, error )
  error_check(error.read_cl_int)
  return Image::new(img_ptr, false)
end