简体   繁体   中英

C#/OpenCL - 2D array as kernel argumment

I'm using the Cloo libary for C#.

I can't figure out or find anything about how to add a 2D array as a kernel argument.

Here is my code:

ComputeBuffer<char> field = new ComputeBuffer<char>(Program.context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.CopyHostPointer, veld);

It just gives me the error: 'Cannot convert from char[,] to long'. Implying it sees it as one of other the overloads.

What am I doing wrong?

veld

variable should be contiguous memory area. Use 1D array but enough size to use as a 2D array on device side.

When you need host side operations, access with i+w*j indexing for imitating 2D access. This may not be a performance loss if you do this in an unsafe context using pinned array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM