Skip to content

Commit 7f4f212

Browse files
authored
Add high level Device method to bypass deprecation (#60)
1 parent 8bb8c75 commit 7f4f212

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Vulkan"
22
uuid = "9f14b124-c50e-4008-a7d4-969b3a6cd68a"
33
authors = ["Cédric Belmant"]
4-
version = "0.6.29"
4+
version = "0.6.30"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/device.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,37 @@ end
8989
device_or_nothing(device::Device) = device
9090
device_or_nothing(handle::Handle) = device_or_nothing(parent(handle))
9191
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

Comments
 (0)