I'm working with vulkan using vulkan-go bindings. I successfully enumerate through validation layers and confirm that VK_LAYER_KHRONOS_validation is in that list. I then pass that as a validation layer (and the only validation layer) to my create instance call. It returns a VK_ERROR_LAYER_NOT_PRESENT.
I've verified my registry is correct and all the layers have correct entries. I've verified the files in the entries exist I'm using the latest SDK from LunarG at the time of writing (1.1.114.0) I'm using go bindings from vulkan-go but that appears to not be the issue as it's the call into C that returns the error, and the error is a vulkan response code. Also happens for any other layer returned in the enumerated layer properties Extensions work fine, using the same enumeration tactic etc
Enumeration (outputs 12 layers including the one mentioned in the question):
// FindAvailableInstanceValidationLayers returns a list of available validation layers on your device
func (vkctx *VulkanContext) FindAvailableInstanceValidationLayers() ([]string, error) {
var count uint32
if res := vk.EnumerateInstanceLayerProperties(&count, nil); res != vk.Success {
dbg.Error("Failed to get instance validation layer count!")
return nil, errors.New("failed to get instance validation layer count")
}
properties := make([]vk.LayerProperties, count, count)
if res := vk.EnumerateInstanceLayerProperties(&count, properties); res != vk.Success {
dbg.Error("Failed to enumerate instance validation layers!")
return nil, errors.New("failed to get instance validation layer count")
}
var layers []string
for _, prop := range properties {
prop.Deref()
name := string(bytes.Trim(prop.LayerName[:], "\x00"))
layers = append(layers, name)
}
return layers, nil
}
// returns => [VK_LAYER_NV_optimus VK_LAYER_VALVE_steam_overlay VK_LAYER_VALVE_steam_fossilize VK_LAYER_LUNARG_api_dump VK_LAYER_LUNARG_assistant_layer VK_LAYER_LUNARG_core_validation VK_LAYER_LUNARG_device_simulation VK_LAYER_KHRONOS_validation VK_LAYER_LUNARG_monitor VK_LAYER_LUNARG_object_tracker VK_LAYER_LUNARG_screenshot VK_LAYER_LUNARG_standard_validation VK_LAYER_LUNARG_parameter_validation VK_LAYER_GOOGLE_threading VK_LAYER_GOOGLE_unique_objects VK_LAYER_LUNARG_vktrace]
create instance call:
// declare app info
appinfo := &vk.ApplicationInfo{
SType: vk.StructureTypeApplicationInfo,
PApplicationName: "Stack Overflow Example",
ApplicationVersion: vk.MakeVersion(1, 0, 0),
PEngineName: "no engine",
EngineVersion: vk.MakeVersion(1, 0, 0),
ApiVersion: vk.ApiVersion11,
}
// declare create info (supported layers contains correct string)
createinfo := &vk.InstanceCreateInfo{
SType: vk.StructureTypeInstanceCreateInfo,
PApplicationInfo: appinfo,
EnabledExtensionCount: uint32(2),
PpEnabledExtensionNames: []string{ "VK_KHR_surface", "VK_KHR_win32_surface" },
EnabledLayerCount: uint32(1),
PpEnabledLayerNames: []string{ "VK_LAYER_KHRONOS_validation" },
}
// create the instance
inst := new(vk.Instance)
if result := vk.CreateInstance(createinfo, nil, inst); result != vk.Success {
// result => vk.ErrorLayerNotPresent
dbg.Error("Failed to create vulkan instance!")
return nil, errors.New("vulkan instance creation failed")
}
I expect CreateInstance to pass (or fail for other reasons) but instead it enters the if statement and the "result" variable is set to VK_ERROR_LAYER_NOT_PRESENT. It is using the same string from that list of available layers, so there's no doubt it's the same. It's the only layer. If I use any other layer (say VK_LAYER_LUNARG_core_validation) then it will have the same result. No matter the layer listed in the enumeration.