48 lines
2.2 KiB
Plaintext
48 lines
2.2 KiB
Plaintext
#! Contains the tests of calls of the loader: the version it gives, an instance
|
|||
|
|
#! made and the devices it finds, what a device has, and a function found by
|
||
|
|
#! its name and called through its type.
|
||
|
|
|
||
|
|
import std::testing;
|
||
|
|
import malunal::vulkan;
|
||
|
|
|
||
|
|
@test def gives_the_version_it_has(t: &mut tester): void {
|
||
|
|
var version: u32 = 0;
|
||
|
|
t.expects(vkEnumerateInstanceVersion(&mut version) == VK_SUCCESS);
|
||
|
|
t.expects(VK_API_VERSION_MAJOR(version) == 1 && VK_API_VERSION_MINOR(version) >= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def makes_an_instance_and_finds_its_devices(t: &mut tester): void {
|
||
|
|
val app := application_info{ application_name = "malunal.vulkan.tests".data, api_version = VK_API_VERSION_1_3 };
|
||
|
|
val info := instance_create_info{ application_info = address(&app) };
|
||
|
|
var instance: u64 = 0;
|
||
|
|
t.expects(vkCreateInstance(&info, null, &mut instance) == VK_SUCCESS && instance != VK_NULL_HANDLE);
|
||
|
|
if instance == VK_NULL_HANDLE {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var count: u32 = 0;
|
||
|
|
t.expects(vkEnumeratePhysicalDevices(instance, &mut count, null) == VK_SUCCESS);
|
||
|
|
var devices: u64[8];
|
||
|
|
count = count < 8 ? count : 8;
|
||
|
|
if count > 0 {
|
||
|
|
_ = vkEnumeratePhysicalDevices(instance, &mut count, (&mut devices) as *mut u64);
|
||
|
|
var properties := physical_device_properties{};
|
||
|
|
vkGetPhysicalDeviceProperties(devices[0], &mut properties);
|
||
|
|
t.expects(properties.device_name[0] != 0 && VK_API_VERSION_MAJOR(properties.api_version) == 1);
|
||
|
|
t.expects(properties.limits.max_image_dimension_2d >= 4096 && properties.limits.timestamp_period > 0f);
|
||
|
|
|
||
|
|
# Vulkan 1.3's features, chained after 1.0's: a device of 1.3 has these.
|
||
|
|
var thirteen := physical_device_vulkan_1_3_features{};
|
||
|
|
var features := physical_device_features_2{ next = address(&mut thirteen) as *mut u8 };
|
||
|
|
vkGetPhysicalDeviceFeatures2(devices[0], &mut features);
|
||
|
|
if VK_API_VERSION_MINOR(properties.api_version) >= 3 {
|
||
|
|
t.expects(thirteen.dynamic_rendering == VK_TRUE && thirteen.synchronization2 == VK_TRUE);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# A function found by name, and called through its type.
|
||
|
|
val found := vkGetInstanceProcAddr(instance, "vkDestroyInstance".data) as u64;
|
||
|
|
t.expects(found != 0);
|
||
|
|
val destroy := found as PFN_vkDestroyInstance;
|
||
|
|
destroy(instance, null);
|
||
|
|
}
|