Exemple #1
0
        /// <summary>
        /// Resolves platform information as typed structure value of type <typeparamref name="T"/>
        /// </summary>
        /// <typeparam name="T">The target type.</typeparam>
        /// <param name="platform">The platform.</param>
        /// <param name="type">The information type.</param>
        /// <returns>The resolved value.</returns>
        public static T GetPlatformInfo <T>(IntPtr platform, CLPlatformInfoType type)
            where T : struct
        {
            T value = default;

            CLException.ThrowIfFailed(NativeMethods.GetPlatformInfo(
                                          platform,
                                          type,
                                          new IntPtr(Interop.SizeOf <T>()),
                                          Unsafe.AsPointer(ref value),
                                          IntPtr.Zero));
            return(value);
        }
Exemple #2
0
        /// <summary>
        /// Resolves platform information as string value.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="type">The information type.</param>
        /// <returns>The resolved string value.</returns>
        public static string GetPlatformInfo(IntPtr platform, CLPlatformInfoType type)
        {
            const int MaxStringLength = 1024;
            var       stringValue     = stackalloc sbyte[MaxStringLength];
            var       size            = IntPtr.Zero;

            CLException.ThrowIfFailed(NativeMethods.GetPlatformInfo(
                                          platform,
                                          type,
                                          new IntPtr(MaxStringLength),
                                          stringValue,
                                          new IntPtr(&size)));
            int intSize = size.ToInt32();

            return(intSize > 0 && intSize < MaxStringLength
                ? new string(stringValue, 0, intSize - 1)
                : string.Empty);
        }
Exemple #3
0
 public static extern CLError GetPlatformInfo(
     [In] IntPtr platform,
     [In] CLPlatformInfoType platformInfoType,
     [In] IntPtr maxSize,
     [Out] void *value,
     [Out] IntPtr size);