Package icyllis.arc3d.vulkan

# Class VKUtil

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

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `kAMD_VendorID`
  Known vendor IDs.
  `static final int`
  `kApple_VendorID`
  Known vendor IDs.
  `static final int`
  `kARM_VendorID`
  Known vendor IDs.
  `static final int`
  `kBroadcom_VendorID`
  Known vendor IDs.
  `static final int`
  `kGoogle_VendorID`
  Known vendor IDs.
  `static final int`
  `kImgTec_VendorID`
  Known vendor IDs.
  `static final int`
  `kIntel_VendorID`
  Known vendor IDs.
  `static final int`
  `kMooreThreads_VendorID`
  Known vendor IDs.
  `static final int`
  `kNVIDIA_VendorID`
  Known vendor IDs.
  `static final int`
  `kQualcomm_VendorID`
  Known vendor IDs.
  `static final int`
  `LAST_COLOR_FORMAT_INDEX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VKUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `_CHECK_(int vkResult)`
  Runtime assertion against a `VkResult` value, throws an exception with a human-readable error message if failed.
  `static void`
  `_CHECK_ERROR_(int vkResult)`
  Runtime assertion against a `VkResult` value, throws an exception with a human-readable error message if failed.
  `static String`
  `getPhysicalDeviceTypeName(int vkPhysicalDeviceType)`
  `static String`
  `getResultMessage(int result)`
  Translates a Vulkan `VkResult` value to a String describing the result.
  `static String`
  `getVendorIDName(int vkVendorID)`
  `static ImmediateContext`
  `makeVulkan(VulkanBackendContext backendContext)`
  Creates a DirectContext for a backend context, using default context options.
  `static ImmediateContext`
  `makeVulkan(VulkanBackendContext backendContext, ContextOptions options)`
  Creates a ImmediateContext for a backend context, using specified context options.
  `static int`
  `toVkSampleCount(int sampleCount)`
  `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.
  `static int`
  `vkFormatChannels(int vkFormat)`
  `static int`
  `vkFormatCompressionType(int vkFormat)`
  `static int`
  `vkFormatDepthBits(int vkFormat)`
  `static boolean`
  `vkFormatIsSupported(int vkFormat)`
  Consistent with `vkFormatToIndex(int)`
  `static String`
  `vkFormatName(int vkFormat)`
  `static int`
  `vkFormatStencilBits(int vkFormat)`
  `static int`
  `vkFormatToIndex(int vkFormat)`
  Lists all supported Vulkan image formats and converts to table index.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### kAMD_VendorID

    public static final int kAMD_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kImgTec_VendorID

    public static final int kImgTec_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kApple_VendorID

    public static final int kApple_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kNVIDIA_VendorID

    public static final int kNVIDIA_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kARM_VendorID

    public static final int kARM_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kBroadcom_VendorID

    public static final int kBroadcom_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kGoogle_VendorID

    public static final int kGoogle_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kMooreThreads_VendorID

    public static final int kMooreThreads_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kQualcomm_VendorID

    public static final int kQualcomm_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### kIntel_VendorID

    public static final int kIntel_VendorID
    Known vendor IDs.
    See Also:
      - Constant Field Values

  - ### LAST_COLOR_FORMAT_INDEX

    public static final int LAST_COLOR_FORMAT_INDEX
    See Also:
      - `vkFormatToIndex(int)`
      - Constant Field Values

- ## 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(VulkanBackendContext, ContextOptions)`

  - ### 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)