While creating a Logical Device in go-vulkan an ErrorExtensionNotPresent(-7) error is occurring and I am not sure why. All the extensions are supported while enumerating the Physicaldeviceextensions.
Below is the actual code.
func (p *Engine) CreatePhysicalDevice() {
var pPhysicalDeviceCount uint32
result := vk.EnumeratePhysicalDevices(p.Instance, &pPhysicalDeviceCount, nil)
if result != vk.Success {
panic(result)
}
physicalDevices := make([]vk.PhysicalDevice, pPhysicalDeviceCount)
result = vk.EnumeratePhysicalDevices(p.Instance, &pPhysicalDeviceCount, physicalDevices)
if result != vk.Success {
panic(result)
}
p.PhysicalDevice = physicalDevices[0]
indices := p.findQueueFamily()
var uniqueIndice []uint32
uniqueIndice = append(uniqueIndice, *indices.graphicsFamily)
if *indices.graphicsFamily != *indices.presentFamily {
uniqueIndice = append(uniqueIndice, *indices.presentFamily)
}
var pPropertyCount uint32
vk.EnumerateDeviceExtensionProperties(p.PhysicalDevice, "", &pPropertyCount, nil)
deviceExtensions := []string{"VK_KHR_swapchain", "VK_KHR_display_swapchain"}
propertyList := make([]vk.ExtensionProperties, pPropertyCount)
vk.EnumerateDeviceExtensionProperties(p.PhysicalDevice, "", &pPropertyCount, propertyList)
for _, property := range propertyList {
property.Deref()
extensionName := string(property.ExtensionName[:])
nullIndex := bytes.IndexByte(property.ExtensionName[:], 0)
if nullIndex != -1 {
extensionName = extensionName[:nullIndex]
}
contains := false
for _, ext := range deviceExtensions {
if extensionName != ext {
contains = true
}
}
if !contains {
panic("Extension Not found")
}
fmt.Println("Extension Physical:", extensionName)
}
queuePriority := float32(1.0)
queueCreateInfos := []vk.DeviceQueueCreateInfo{}
for _, index := range uniqueIndice {
info := vk.DeviceQueueCreateInfo{
SType: vk.StructureTypeDeviceQueueCreateInfo,
Flags: vk.DeviceQueueCreateFlags(0),
QueueFamilyIndex: index,
QueueCount: 1,
PQueuePriorities: []float32{queuePriority},
}
queueCreateInfos = append(queueCreateInfos, info)
}
var pdFeatures vk.PhysicalDeviceFeatures
vk.GetPhysicalDeviceFeatures(p.PhysicalDevice, &pdFeatures)
enabledLayer := []string{"VK_LAYER_KHRONOS_validation"}
createInfo := vk.DeviceCreateInfo{
SType: vk.StructureTypeDeviceCreateInfo,
Flags: vk.DeviceCreateFlags(0),
QueueCreateInfoCount: uint32(len(queueCreateInfos)),
PQueueCreateInfos: queueCreateInfos,
EnabledExtensionCount: uint32(len(deviceExtensions)),
PpEnabledExtensionNames: deviceExtensions,
EnabledLayerCount: uint32(len(enabledLayer)),
PpEnabledLayerNames: enabledLayer,
PEnabledFeatures: []vk.PhysicalDeviceFeatures{pdFeatures},
}
result = vk.CreateDevice(p.PhysicalDevice, &createInfo, nil, &p.LogicalDevice)
if result != vk.Success {
panic(result)
}
}
I tried to see if it was because I was using XCB surface on a Wayland Arch system and If all the extension are supported by enumerating the physcialdeviceextensions.
As u can see in code error it is only occurring while in CreateDevice.