Package icyllis.arc3d.vulkan
Class VKUtil
java.lang.Object
icyllis.arc3d.vulkan.VKUtil
Provides user-defined Vulkan utilities.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
Known vendor IDs.static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
_CHECK_
(int vkResult) Runtime assertion against aVkResult
value, throws an exception with a human-readable error message if failed.static void
_CHECK_ERROR_
(int vkResult) Runtime assertion against aVkResult
value, throws an exception with a human-readable error message if failed.static String
getPhysicalDeviceTypeName
(int vkPhysicalDeviceType) static String
getResultMessage
(int result) Translates a VulkanVkResult
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 withvkFormatToIndex(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.
-
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
@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 aVkResult
value, throws an exception with a human-readable error message if failed.- Parameters:
vkResult
- theVkResult
value- Throws:
AssertionError
- the VkResult is not VK_SUCCESS
-
_CHECK_ERROR_
public static void _CHECK_ERROR_(int vkResult) Runtime assertion against aVkResult
value, throws an exception with a human-readable error message if failed.- Parameters:
vkResult
- theVkResult
value- Throws:
AssertionError
- the VkResult is negative
-
getResultMessage
Translates a VulkanVkResult
value to a String describing the result.- Parameters:
result
- theVkResult
value- 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)
-