Silk.NET icon indicating copy to clipboard operation
Silk.NET copied to clipboard

Incorrect delegate signature Silk.NET.OpenCL.NotifyCallback

Open UCIS opened this issue 3 years ago • 0 comments

Summary

The Silk.NET.OpenCL.NotifyCallback delegate type is used everywhere a callback function can be specified in the OpenCL API, however the callback functions used in he OpenCL API methods each have different signatures.

The currently implemented NotifyCallback appears to have the signature used by the clCreateContext API, which is quite different from the callback signature used by the setEventCallback API. This causes callback arguments to be misplaced and possibly worse.

One solution might be to use different delegate types for each of the callbacks. Another option might be to just allow a pointer to be specified so the user can use Marshal.GetFunctionPointerForDelegate to a delegate type of their own.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET 4.8
  • API: OpenCL
  • API Version: OpenCL 1.2
  1. I queued a memory read (EnqueueReadBuffer) with an event
  2. I registered a callback function (SetEventCallback)
  3. I noticed the user data I passed to SetEventCallback was not in the userData parameter, but shifted one position to the cb parameter in the callback.

If you know how to fix this issue, please submit a pull request instead! Unfortunately it is not yet clear to me how the OpenCL code is generated, otherwise I would have considered submitting a pull request instead.

UCIS avatar Jul 11 '22 19:07 UCIS