kenba/opencl3

Consider adding PhantomData to Image and Pipe memory objects

Closed this issue · 2 comments

kenba commented

Consider adding PhantomData to Image and Pipe memory objects to match the Buffer implementation of pull request #1.

kenba commented

PhantomData was added to Buffer because a Buffer refers to an array/Vector of data of a given type and the PhantomData is used to hold the type information to help the Rust compiler's type checking.

Image and Pipe are different in that they refer to the underlying data in different ways:

  • An Image refers to the underlying image in cl_image_format and cl_image_desc structures.
  • A Pipe only refers to the pipe_packet_size, i.e. the sizeof the type of data being sent down the Pipe.

There is nothing to be gained by storing type information in Image or Pipe, so they do not require a PhantomData variable.

There is also no reason for any Image or Pipe methods to be declared as template functions, so the templates should be removed.

kenba commented

Unnecessary templates removed from methods in commit 7a2d015