0

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?

Hanno Ottens
  • 51
  • 1
  • 11

1 Answers1

0

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.

huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97