vulkan多线程渲染_介绍Vulkan渲染器预览

时间:2024-04-04 14:00:07
vulkan多线程渲染_介绍Vulkan渲染器预览

vulkan多线程渲染

今天,我们将发布即将发布的Unity Vulkan渲染器第一个开发人员预览版 ,正如Google I / O宣布的那样。 Vulkan是新一代的图形和计算API,可在PC和移动平台上提供对现代GPU的高效,跨平台访问。 Google最近发布的Android Nougat版本带来了对Vulkan API的官方支持,我们正在努力使我们的用户将图形性能提升到一个新的水平。 (Today we’re releasing the first developer preview of the upcoming Vulkan renderer for Unity, as announced at Google I/O. Vulkan is a new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs in both PCs and on mobile platforms. The recently released Android Nougat version from Google brings official support for the Vulkan API, and we’re working towards enabling our users to boost the graphics performance to the next level.)

vulkan多线程渲染_介绍Vulkan渲染器预览

Unity Labs scene running on Linux using the Vulkan renderer

使用Vulkan渲染器在Linux上运行的Unity Labs场景

好处 (Benefits)

The main benefit of Vulkan over older mobile rendering APIs such as OpenGL ES 3.x is speed. Vulkan is designed to take advantage of multiple CPU cores by allowing the application to build command lists in multiple threads in parallel. This allows the application to take advantage of all of the CPU cores on the device, improving performance. The Vulkan preview release supports this via the “Enable Graphics Jobs” checkbox in the player settings. However, we’re seeing large performance gains even when running the renderer in a single thread. In one of our internal benchmarks we’re seeing up to 35% improvement in frame times on Android, compared to OpenGL ES 3.1 renderer, even though they’re both running in a single rendering thread!

与早期的移动渲染API(例如OpenGL ES 3.x)相比,Vulkan的主要优点是速度 。 Vulkan旨在通过允许应用程序在多个线程中并行构建命令列表来利用多个CPU内核。 这使应用程序可以利用设备上的所有CPU内核,从而提高性能。 Vulkan预览版通过播放器设置中的“启用图形作业”复选框来支持此功能。 但是,即使在单个线程中运行渲染器,我们也可以看到很大的性能提升。 在我们的一项内部基准测试中,我们发现与OpenGL ES 3.1渲染器相比,Android的帧时间缩短了35% ,即使它们都在单个渲染线程中运行!

入门 (Getting started)

Get the experimental build from our beta page. The build is based on Unity 5.5 beta 4 release. Remember to back up your projects before trying this out!

从我们的Beta版页面获得实验版本 。 该构建基于Unity 5.5 beta 4版本。 切记在尝试之前备份您的项目

To enable Vulkan support, open “Player Settings…”, go to the “Other Settings” pane and clear the “Auto Graphics API” checkbox. You are presented with an ordered list of graphics APIs to choose from. If Vulkan is not on that list, click the ‘+’ sign at the bottom of the list to add it. Then drag Vulkan to be the first item on the list so that it’ll be used whenever supported, and you’re done! All your existing shaders will get translated to Vulkan SPIR-V (unless specifically disabled via #pragma only_renderers or similar), and the idea is that things should “Just Work”.

要启用Vulkan支持,请打开“播放器设置…”,转到“其他设置”窗格,然后清除“自动图形API”复选框。 您会看到有序的图形API列表供您选择。 如果Vulkan不在该列表中,请单击列表底部的“ +”号将其添加。 然后将Vulkan拖动到列表中的第一项,以便在受支持时将使用它,完成了! 您所有现有的着色器都将转换为Vulkan SPIR-V(除非已通过#pragma only_renderers或类似功能特别禁用),并且其想法是事情应该“正常工作”。

vulkan多线程渲染_介绍Vulkan渲染器预览

You can also experiment with the Enable Graphics Jobs checkbox, it can give a nice performance boost especially on multi-core CPUs.

您还可以尝试使用“启用图形作业”复选框,它可以显着提高性能,尤其是在多核CPU上。

NOTE! When targeting Android, make sure you never have both “Multithreaded Rendering” and “Graphics Jobs (Experimental)” settings enabled at the same time. They are mutually exclusive, and in the final version we’ll silently ignore the Multithreaded Renderer setting if Graphics Jobs are enabled.

注意! 以Android为目标时,请确保不要同时启用“多线程渲染”和“图形作业(实验)”设置。 它们是互斥的,并且在最终版本中,如果启用了图形作业,我们将默默地忽略“多线程渲染器”设置。

Now, just build & run, and if everything went as planned, you should see something like this in the player log at startup:

现在,只需构建并运行,如果一切按计划进行,启动时,您应该在播放器日志中看到类似以下内容:

vulkan多线程渲染_介绍Vulkan渲染器预览
()

支持的设备 (Supported devices)

This preview build has Vulkan support enabled for the following targets:

此预览版本为以下目标启用了Vulkan支持:

  • Windows standalone (no Vulkan support in the editor yet)

    Windows独立版本(编辑器中尚无Vulkan支持)
  • Android

    安卓系统
  • Linux standalone

    Linux独立

On Windows, we’ve been mainly testing on Nvidia and AMD GPUs. Remember to update your GPU drivers! Vulkan is a new technology and the drivers keep improving constantly, so before reporting a crash, check first if an updated driver fixes the problem.

在Windows上,我们主要在Nvidia和AMD GPU上进行测试。 记住要更新您的GPU驱动程序! Vulkan是一项新技术,其驱动程序会不断改进,因此在报告崩溃之前,请先检查更新的驱动程序是否可以解决问题。

On Android, we’ve tested on the following devices:

在Android上,我们已经在以下设备上进行了测试:

  • Samsung Galaxy S7 (European version, with ARM Mali GPU). Make sure you have the latest firmware, with build date August 2016 or later. Previous firmwares have older drivers that are known not to work.

    三星Galaxy S7(欧洲版本,带有ARM Mali GPU)。 确保您拥有最新的固件,且构建日期为2016年8月或更晚。 以前的固件具有较旧的驱动程序,已知无法正常工作。
  • Nvidia Shield Tablet (both versions), Shield Console.

    Nvidia Shield Tablet(两个版本),Shield Console。
  • Google Nexus 6P, 5X (although you might see more issues on these handsets compared to the others).

    Google Nexus 6P,5X(尽管与其他手机相比,您可能会在这些手机上看到更多问题)。

The following devices are known not to work with the currently available firmware:

已知以下设备不能与当前可用的固件一起使用:

  • Samsung Galaxy S7 (US version, with Qualcomm GPU). We expect that an upcoming firmware with an updated driver should fix this. UPDATE: Samsung confirmed that they will release a fixed Vulkan driver for the Qualcomm based Galaxy S7 with the next system update in October 2016.

    三星Galaxy S7(美国版,带Qualcomm GPU)。 我们希望即将发布的固件具有更新的驱动程序可以解决此问题。 更新:三星确认将在2016年10月发布下一个系统更新,为基于Qualcomm的Galaxy S7发布固定的Vulkan驱动程序。

On Linux, only the Nvidia GPUs have been tested. You’ll need to have libvulkan1 installed (either from your distro or via the LunarG Vulkan SDK) and recent enough drivers (367.x or newer). However, we’ve seen random hangs when transitioning from the splash screen into the game itself. So when testing this experimental release, you might consider disabling the Unity splash screen, if you have that option.

在Linux上,仅Nvidia GPU已经过测试。 您需要安装libvulkan1(通过发行版或通过LunarG Vulkan SDK)和最新的驱动程序(367.x或更高版本)。 但是,我们已经看到从初始屏幕过渡到游戏本身时随机挂起。 因此,在测试此实验版本时,如果可以的话,您可以考虑禁用Unity启动屏幕。

已知的问题 (Known issues)

As this is an experimental developer preview, there are some known issues we’re working on. We also welcome your feedback! Please let us know of any bugs or issues you find:

由于这是开发人员的试验性预览,因此我们正在处理一些已知问题。 我们也欢迎您的反馈! 如果您发现任何错误或问题,请告知我们:

  • Graphics jobs on Vulkan are especially experimental at this stage. If you see crashes, try disabling Graphics Jobs to see if that’s the one causing it.

    在此阶段,Vulkan上的图形工作尤其处于试验阶段。 如果看到崩溃,请尝试禁用“图形作业”,以查看是否是导致崩溃的原因。
  • GrabPass is not supported with Graphics Jobs.

    图形作业不支持GrabPass。
  • On Nvidia GPUs, when rendering with multiple cameras with MSAA enabled, display corruption may occur.

    在Nvidia GPU上,使用启用了MSAA的多个摄像机进行渲染时,可能会发生显示损坏。
  • On Android the Graphics Jobs are currently configured to run in 2 concurrent threads only. Because of this, you’ll usually get better performance by using the Multithreaded renderer instead (this is the existing client/worker threaded renderer).

    在Android上,“图形作业”当前配置为仅在2个并发线程中运行。 因此,通常可以通过使用多线程渲染器(这是现有的客户端/工作线程渲染器)来获得更好的性能。
  • Compute shaders haven’t been thoroughly tested yet, YMMV.

    YMMV还没有对计算着色器进行彻底的测试。

We hope you’ll have fun experimenting with the new renderer. Please talk to us about it at our forums: what works, what doesn’t, what you like about it and what you’re missing. If you believe you’ve found a bug, please report it via our bug reporting system (make sure to mention it refers to the experimental Vulkan build). We’re especially interested in cases where the Vulkan renderer would be slower than GL ES 3.x on Android, or significantly slower than DX11 or DX9 on Windows.

我们希望您在尝试使用新的渲染器时会感到开心。 请在我们的论坛上与我们讨论 :什么有效,什么无效,您喜欢它什么以及缺少什么。 如果您认为自己已找到错误,请通过我们的错误报告系统进行报告(请确保提及的是实验性Vulkan构建)。 我们对Vulkan渲染器在Android上比GL ES 3.x慢或在Windows上比DX11或DX9慢得多的情况特别感兴趣。

翻译自: https://blogs.unity3d.com/2016/09/29/introducing-the-vulkan-renderer-preview/

vulkan多线程渲染