Class VKUtil

java.lang.Object
icyllis.arc3d.vulkan.VKUtil

public final class VKUtil extends Object
Provides user-defined Vulkan utilities.
  • Field Details

  • Constructor Details

    • VKUtil

      public VKUtil()
  • Method Details

    • makeVulkan

      @Nullable public static ImmediateContext makeVulkan(VulkanBackendContext backendContext)
      Creates a DirectContext for a backend context, using default context options.
      Returns:
      context or null if failed to create
      See Also:
    • makeVulkan

      @Nullable public static ImmediateContext makeVulkan(VulkanBackendContext backendContext, ContextOptions options)
      Creates a ImmediateContext for a backend context, using specified context options.

      The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned ImmediateContext is destroyed. This also means that any objects created with this ImmediateContext (e.g. Surfaces, Images, etc.) must also be released as they may hold refs on the ImmediateContext. Once all these objects and the ImmediateContext are released, then it is safe to delete the Vulkan objects.

      Returns:
      context or null if failed to create
    • _CHECK_

      public static void _CHECK_(int vkResult)
      Runtime assertion against a VkResult value, throws an exception with a human-readable error message if failed.
      Parameters:
      vkResult - the VkResult value
      Throws:
      AssertionError - the VkResult is not VK_SUCCESS
    • _CHECK_ERROR_

      public static void _CHECK_ERROR_(int vkResult)
      Runtime assertion against a VkResult value, throws an exception with a human-readable error message if failed.
      Parameters:
      vkResult - the VkResult value
      Throws:
      AssertionError - the VkResult is negative
    • getResultMessage

      public static String getResultMessage(int result)
      Translates a Vulkan VkResult value to a String describing the result.
      Parameters:
      result - the VkResult value
      Returns:
      the result description
    • getVendorIDName

      public static String getVendorIDName(int vkVendorID)
    • getPhysicalDeviceTypeName

      public static String getPhysicalDeviceTypeName(int vkPhysicalDeviceType)
    • vkFormatToIndex

      public static int vkFormatToIndex(int vkFormat)
      Lists all supported Vulkan image formats and converts to table index. 0 is reserved for unsupported formats.
    • vkFormatIsSupported

      public static boolean vkFormatIsSupported(int vkFormat)
      Consistent with vkFormatToIndex(int)
    • vkFormatChannels

      public static int vkFormatChannels(int vkFormat)
      Returns:
      see Color
    • vkFormatCompressionType

      public static int vkFormatCompressionType(int vkFormat)
    • vkFormatBytesPerBlock

      public static int vkFormatBytesPerBlock(int vkFormat)
      Currently we are just over estimating this value to be used in gpu size calculations even though the actually size is probably less. We should instead treat planar formats similar to compressed textures that go through their own special query for calculating size.
      
       case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: return 3;
       case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:  return 3;
       case VK_FORMAT_S8_UINT:                   return 1;
       case VK_FORMAT_D24_UNORM_S8_UINT:         return 4;
       case VK_FORMAT_D32_SFLOAT_S8_UINT:        return 8;
       
    • vkFormatDepthBits

      public static int vkFormatDepthBits(int vkFormat)
    • vkFormatStencilBits

      public static int vkFormatStencilBits(int vkFormat)
    • vkFormatName

      public static String vkFormatName(int vkFormat)
    • toVkSampleCount

      public static int toVkSampleCount(int sampleCount)