|
89 | 89 | device_or_nothing(device::Device) = device |
90 | 90 | device_or_nothing(handle::Handle) = device_or_nothing(parent(handle)) |
91 | 91 | device_or_nothing(::Nothing) = nothing |
| 92 | + |
| 93 | + |
| 94 | +#==================================================================================================== |
| 95 | +NOTE: the below is special handling of Device for the sake of removing a deprecation warning which |
| 96 | + otherwise is always triggered by the wrapper constructors. |
| 97 | +
|
| 98 | + The Device method provided here is more specific and thus usually takes precedence, |
| 99 | + users should use this method. |
| 100 | +====================================================================================================# |
| 101 | +function _device_create_info(queue_create_infos::AbstractArray, enabled_extension_names::AbstractArray; |
| 102 | + next = C_NULL, flags = 0, enabled_features = C_NULL, |
| 103 | +) |
| 104 | + queue_create_info_count = pointer_length(queue_create_infos) |
| 105 | + enabled_layer_count = 0 |
| 106 | + enabled_extension_count = pointer_length(enabled_extension_names) |
| 107 | + next = cconvert(Ptr{Cvoid}, next) |
| 108 | + queue_create_infos = cconvert(Ptr{VkDeviceQueueCreateInfo}, queue_create_infos) |
| 109 | + enabled_layer_names = C_NULL |
| 110 | + enabled_extension_names = cconvert(Ptr{Cstring}, enabled_extension_names) |
| 111 | + enabled_features = cconvert(Ptr{VkPhysicalDeviceFeatures}, enabled_features) |
| 112 | + deps = Any[next, queue_create_infos, enabled_layer_names, enabled_extension_names, enabled_features] |
| 113 | + vks = VkDeviceCreateInfo(structure_type(VkDeviceCreateInfo), unsafe_convert(Ptr{Cvoid}, next), flags, queue_create_info_count, unsafe_convert(Ptr{VkDeviceQueueCreateInfo}, queue_create_infos), enabled_layer_count, unsafe_convert(Ptr{Cstring}, enabled_layer_names), enabled_extension_count, unsafe_convert(Ptr{Cstring}, enabled_extension_names), unsafe_convert(Ptr{VkPhysicalDeviceFeatures}, enabled_features)) |
| 114 | + _DeviceCreateInfo(vks, deps) |
| 115 | +end |
| 116 | + |
| 117 | +function Device(physical_device::PhysicalDevice, |
| 118 | + queue_create_infos::AbstractArray, |
| 119 | + enabled_layers::AbstractArray, enabled_extension_names::AbstractArray; |
| 120 | + next=C_NULL, flags=0, enabled_features=C_NULL, |
| 121 | +) |
| 122 | + isempty(enabled_layers) || @warn("Device: enabled_layers is long deprecated, will be ignored") |
| 123 | + info = _device_create_info(queue_create_infos, enabled_extension_names; next, flags, enabled_features) |
| 124 | + unwrap(_create_device(physical_device, info)) |
| 125 | +end |
0 commit comments