首页 > 解决方案 > Vulkan 实例层返回 VK_ERROR_LAYER_NOT_PRESENT 尽管在枚举层属性时出现?

问题描述

我正在使用 vulkan-go 绑定与 vulkan 合作。我成功枚举了验证层并确认 VK_LAYER_KHRONOS_validation 在该列表中。然后我将它作为验证层(也是唯一的验证层)传递给我的创建实例调用。它返回一个 VK_ERROR_LAYER_NOT_PRESENT。

我已经验证我的注册表是正确的,并且所有层都有正确的条目。我已经验证条目中的文件存在 我正在使用 LunarG 在撰写本文时的最新 SDK (1.1.114.0) 我正在使用来自 vulkan-go 的 go 绑定,但这似乎不是问题,因为它是调用返回错误的C,错误是一个vulkan响应代码。枚举层属性中返回的任何其他层也会发生扩展工作正常,使用相同的枚举策略等

枚举(输出 12 层,包括问题中提到的那一层):

// 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]

创建实例调用:

// 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")
    }

我希望 CreateInstance 通过(或由于其他原因失败),但它进入 if 语句,并且“结果”变量设置为 VK_ERROR_LAYER_NOT_PRESENT。它使用可用层列表中的相同字符串,所以毫无疑问它是相同的。这是唯一的一层。如果我使用任何其他层(比如 VK_LAYER_LUNARG_core_validation),那么它会得到相同的结果。无论枚举中列出的层。

标签: golayervulkan

解决方案


推荐阅读