Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pointer">
        /// </param>
        internal static unsafe PerformanceCounter MarshalFrom(SharpVk.Interop.Khronos.PerformanceCounter *pointer)
        {
            PerformanceCounter result = default(PerformanceCounter);

            result.Unit    = pointer->Unit;
            result.Scope   = pointer->Scope;
            result.Storage = pointer->Storage;
            result.Uuid    = new Guid(Interop.HeapUtil.MarshalFrom(pointer->Uuid, Constants.UuidSize));
            return(result);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="extendedHandle">
 /// The PhysicalDevice handle to extend.
 /// </param>
 /// <param name="queueFamilyIndex">
 /// </param>
 /// <param name="counters">
 /// </param>
 /// <param name="counterDescriptions">
 /// </param>
 public static unsafe Result EnumerateQueueFamilyPerformanceQueryCounters(this SharpVk.PhysicalDevice extendedHandle, uint queueFamilyIndex, out PerformanceCounter[] counters, out PerformanceCounterDescription[] counterDescriptions)
 {
     try
     {
         Result       result = default(Result);
         uint         marshalledCounterCount = default(uint);
         CommandCache commandCache           = default(CommandCache);
         SharpVk.Interop.Khronos.PerformanceCounter *           marshalledCounters            = default(SharpVk.Interop.Khronos.PerformanceCounter *);
         SharpVk.Interop.Khronos.PerformanceCounterDescription *marshalledCounterDescriptions = default(SharpVk.Interop.Khronos.PerformanceCounterDescription *);
         commandCache = extendedHandle.commandCache;
         SharpVk.Interop.Khronos.VkPhysicalDeviceEnumerateQueueFamilyPerformanceQueryCountersDelegate commandDelegate = commandCache.Cache.vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
         result = commandDelegate(extendedHandle.handle, queueFamilyIndex, &marshalledCounterCount, marshalledCounters, marshalledCounterDescriptions);
         if (SharpVkException.IsError(result))
         {
             throw SharpVkException.Create(result);
         }
         marshalledCounterDescriptions = (SharpVk.Interop.Khronos.PerformanceCounterDescription *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PerformanceCounterDescription>((uint)(marshalledCounterCount)));
         marshalledCounters            = (SharpVk.Interop.Khronos.PerformanceCounter *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PerformanceCounter>((uint)(marshalledCounterCount)));
         commandDelegate(extendedHandle.handle, queueFamilyIndex, &marshalledCounterCount, marshalledCounters, marshalledCounterDescriptions);
         if (marshalledCounters != null)
         {
             var fieldPointer = new SharpVk.Khronos.PerformanceCounter[(uint)(marshalledCounterCount)];
             for (int index = 0; index < (uint)(marshalledCounterCount); index++)
             {
                 fieldPointer[index] = SharpVk.Khronos.PerformanceCounter.MarshalFrom(&marshalledCounters[index]);
             }
             counters = fieldPointer;
         }
         else
         {
             counters = null;
         }
         if (marshalledCounterDescriptions != null)
         {
             var fieldPointer = new SharpVk.Khronos.PerformanceCounterDescription[(uint)(marshalledCounterCount)];
             for (int index = 0; index < (uint)(marshalledCounterCount); index++)
             {
                 fieldPointer[index] = SharpVk.Khronos.PerformanceCounterDescription.MarshalFrom(&marshalledCounterDescriptions[index]);
             }
             counterDescriptions = fieldPointer;
         }
         else
         {
             counterDescriptions = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }