Package icyllis.arc3d.vulkan
Class VKUtil
java.lang.Object
icyllis.arc3d.vulkan.VKUtil
Provides user-defined Vulkan utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final intKnown vendor IDs.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void_CHECK_(int vkResult) Runtime assertion against aVkResultvalue, throws an exception with a human-readable error message if failed.static void_CHECK_ERROR_(int vkResult) Runtime assertion against aVkResultvalue, throws an exception with a human-readable error message if failed.static StringgetPhysicalDeviceTypeName(int vkPhysicalDeviceType) static StringgetResultMessage(int result) Translates a VulkanVkResultvalue to a String describing the result.static StringgetVendorIDName(int vkVendorID) static @Nullable ImmediateContextmakeVulkan(VulkanBackendContext backendContext) Creates a DirectContext for a backend context, using default context options.static @Nullable ImmediateContextmakeVulkan(VulkanBackendContext backendContext, ContextOptions options) Creates a ImmediateContext for a backend context, using specified context options.static inttoVkSampleCount(int sampleCount) static intvkFormatBytesPerBlock(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 intvkFormatChannels(int vkFormat) static intvkFormatCompressionType(int vkFormat) static intvkFormatDepthBits(int vkFormat) static booleanvkFormatIsSupported(int vkFormat) Consistent withvkFormatToIndex(int)static StringvkFormatName(int vkFormat) static intvkFormatStencilBits(int vkFormat) static intvkFormatToIndex(int vkFormat) Lists all supported Vulkan image formats and converts to table index.
-
Field Details
-
kAMD_VendorID
public static final int kAMD_VendorIDKnown vendor IDs.- See Also:
-
kImgTec_VendorID
public static final int kImgTec_VendorIDKnown vendor IDs.- See Also:
-
kApple_VendorID
public static final int kApple_VendorIDKnown vendor IDs.- See Also:
-
kNVIDIA_VendorID
public static final int kNVIDIA_VendorIDKnown vendor IDs.- See Also:
-
kARM_VendorID
public static final int kARM_VendorIDKnown vendor IDs.- See Also:
-
kBroadcom_VendorID
public static final int kBroadcom_VendorIDKnown vendor IDs.- See Also:
-
kGoogle_VendorID
public static final int kGoogle_VendorIDKnown vendor IDs.- See Also:
-
kMooreThreads_VendorID
public static final int kMooreThreads_VendorIDKnown vendor IDs.- See Also:
-
kQualcomm_VendorID
public static final int kQualcomm_VendorIDKnown vendor IDs.- See Also:
-
kIntel_VendorID
public static final int kIntel_VendorIDKnown vendor IDs.- See Also:
-
LAST_COLOR_FORMAT_INDEX
public static final int LAST_COLOR_FORMAT_INDEX- See Also:
-
-
Constructor Details
-
VKUtil
public VKUtil()
-
-
Method Details
-
makeVulkan
Creates a DirectContext for a backend context, using default context options.- Returns:
- context or null if failed to create
- See Also:
-
makeVulkan
public static @Nullable 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 aVkResultvalue, throws an exception with a human-readable error message if failed.- Parameters:
vkResult- theVkResultvalue- Throws:
AssertionError- the VkResult is not VK_SUCCESS
-
_CHECK_ERROR_
public static void _CHECK_ERROR_(int vkResult) Runtime assertion against aVkResultvalue, throws an exception with a human-readable error message if failed.- Parameters:
vkResult- theVkResultvalue- Throws:
AssertionError- the VkResult is negative
-
getResultMessage
Translates a VulkanVkResultvalue to a String describing the result.- Parameters:
result- theVkResultvalue- Returns:
- the result description
-
getVendorIDName
-
getPhysicalDeviceTypeName
-
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 withvkFormatToIndex(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
-
toVkSampleCount
public static int toVkSampleCount(int sampleCount)
-