dotnet / Silk.NET

The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.
https://dotnet.github.io/Silk.NET
MIT License
3.88k stars 378 forks source link

SymbolLoadingException #2233

Open 00f8t opened 1 week ago

00f8t commented 1 week ago

Summary

Silk.NET.Core.Loader.SymbolLoadingException: 'Native symbol not found (Symbol: vkGetPhysicalDeviceVideoCapabilitiesKHR)'

when trying to get Physical Device Video Capabilities

private void InitDecoder()
{
    KhrVideoQueue? khrVideoQueue;
    if (!vk!.TryGetDeviceExtension(instance, device, out khrVideoQueue))
    {
        throw new NotSupportedException("VK_KHR_video_queue extension not found.");
    }

    VideoDecodeH264CapabilitiesKHR videoDecodeH264CapabilitiesKHR = new()
    {
        SType = StructureType.VideoDecodeH264CapabilitiesKhr,
    };

    VideoDecodeCapabilitiesKHR videoDecodeCapabilitiesKHR = new()
    {
        SType = StructureType.VideoDecodeCapabilitiesKhr,
        PNext = &videoDecodeH264CapabilitiesKHR,
    };

    VideoCapabilitiesKHR videoCapabilitiesKHR = new()
    {
        SType = StructureType.VideoCapabilitiesKhr,
        PNext = &videoDecodeCapabilitiesKHR,
    };

    VideoDecodeH264ProfileInfoKHR videoDecodeH264ProfileInfoKHR = new()
    {
        SType = StructureType.VideoDecodeH264ProfileInfoKhr,
        StdProfileIdc = StdVideoH264ProfileIdc.Baseline,
        PictureLayout = VideoDecodeH264PictureLayoutFlagsKHR.InterlacedInterleavedLinesBitKhr,
    };

    VideoProfileInfoKHR videoProfileInfoKHR = new()
    {
        SType = StructureType.VideoProfileInfoKhr,
        PNext = &videoDecodeH264ProfileInfoKHR,
        VideoCodecOperation = VideoCodecOperationFlagsKHR.DecodeH264BitKhr,
        ChromaSubsampling = VideoChromaSubsamplingFlagsKHR.Subsampling420BitKhr,
        LumaBitDepth = VideoComponentBitDepthFlagsKHR.Depth8BitKhr,
        ChromaBitDepth = VideoComponentBitDepthFlagsKHR.Depth8BitKhr,
    };

    VideoProfileListInfoKHR videoProfileListInfoKHR = new()
    {
        SType = StructureType.VideoProfileListInfoKhr,
        ProfileCount = 1,
        PProfiles = &videoProfileInfoKHR,
    };

    if (khrVideoQueue!.GetPhysicalDeviceVideoCapabilities(physicalDevice, &videoProfileInfoKHR, out videoCapabilitiesKHR) != Result.Success)
    {
        throw new Exception("failed to get video capabilities..");
    }
}

enabled extensions

Steps to reproduce

00f8t commented 1 day ago

a temporary solution is to get this function yourself

#region Additional functions
    private Result GetPhysicalDeviceVideoFormatProperties(PhysicalDevice physicalDevice, PhysicalDeviceVideoFormatInfoKHR* physicalDeviceVideoFormatInfoKHR, uint* formatPropertiesCount, VideoFormatPropertiesKHR* videoFormatPropertiesKHR)
    {
        IntPtr funcPtr = vk!.GetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoFormatPropertiesKHR");

        if (funcPtr == IntPtr.Zero)
        {
            return Result.ErrorInitializationFailed;
        }
        else
        {
            var vkGetPhysicalDeviceVideoFormatPropertiesKHR = (delegate* unmanaged<PhysicalDevice, PhysicalDeviceVideoFormatInfoKHR*, uint*, VideoFormatPropertiesKHR*, Result>)funcPtr;

            return vkGetPhysicalDeviceVideoFormatPropertiesKHR(physicalDevice, physicalDeviceVideoFormatInfoKHR, formatPropertiesCount, videoFormatPropertiesKHR);
        }
    }

    private Result GetPhysicalDeviceVideoCapabilities(PhysicalDevice physicalDevice, VideoProfileInfoKHR* videoProfileInfoKHR, VideoCapabilitiesKHR* videoCapabilitiesKHR)
    {
        IntPtr funcPtr = vk!.GetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoCapabilitiesKHR");

        if (funcPtr == IntPtr.Zero)
        {
            return Result.ErrorInitializationFailed;
        }
        else
        {
            var vkGetPhysicalDeviceVideoCapabilitiesKHR = (delegate* unmanaged<PhysicalDevice, VideoProfileInfoKHR*, VideoCapabilitiesKHR*, Result>)funcPtr;

            return vkGetPhysicalDeviceVideoCapabilitiesKHR(physicalDevice, videoProfileInfoKHR, videoCapabilitiesKHR);
        }
    }
#endregion