序
如果在十五年前,那时候我刚开始看Linux内核情景分析,看到了微软这么用心的支持Linux、甚至是在Windows上支持Linux,我可能会很激动吧。
但是现在,我只会说,哦,这样啊!
Linux on Windows有两个阶段:不支持Linux GUI应用的WSL;支持Linux GUI的 WSL2。
XDC2020上有些话题是关于WSL2的图形系统的,这里稍微摘录整理下。
OpenGL over D3D
https://www.collabora.com/news-and-blog/blog/2020/07/09/deep-dive-into-opengl-over-directx-layering/
DXIL: compiled shaders (DXIL bytecode). DXIL is essentially LLVM 3.7 bitcode with some extra metadata and validation.
NIR: Mesa will also translate GLSL shaders into an intermediate representation named NIR.
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HOQW5MFX-1608183835236)(https://raw.githubusercontent.com/axinging/GPUDocs/master/xorg/d3d12_architecture.png)]
Graphics Architecture on Windows Subsystem for Linux
https://xdc2020.x.org/event/9/contributions/610/attachments/700/1295/XDC_-_WSL_Graphics_Architecture.pdf
Linux子系统其实就是一个完全独立的运行在windows上的虚拟机。
VM提供了虚拟的显存和虚拟的GPU供Linux子系统使用。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Fc84CoYr-1608183835242)(https://raw.githubusercontent.com/axinging/GPUDocs/master/xorg/graphics_on_wsl.jpg)]
如果将OpenGL over D3D和Graphics Architecture on Windows Subsystem for Linux, 就可以一窥整个Windows Graphics for Linux的大概:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xTR03Pfr-1608183835246)(https://raw.githubusercontent.com/axinging/GPUDocs/master/xorg/graphics_on_wsl2.png)]
And Android on WSL2 without emulator becomes possible:
https://www.reddit.com/r/bashonubuntuonwindows/comments/eofn5s/run_anbox_on_wsl_2/
About OpenGL and Vulkan interoperability
EXT_external_objects(_fd) extensions enable:
- Allocation of resources (textures, buffers) from Vulkan and sharing
of those resources from both APIs - Synchronization of the access to shared resources between APIs.
- Example: a VR compositor where the left and right eye images are allocated and
displayed by Vulkan but their contents are filled by OpenGL processes.
Linux extension:
EXT_external_objects_fd (EXT_memory_object_fd, EXT_semaphore_fd):
- enables an OpenGL application to import a memory object or semaphore
from POSIX file descriptor external handles
EXT_external_objects (EXT_memory_object, EXT_semaphore):
- enables an OpenGL application to create OpenGL objects corresponding to
Vulkan objects (textures, buffers, semaphores) and synchronize access to
shared objects across APIs - extends existing GL calls that set and query properties
Reference:
https://xdc2020.x.org/event/9/contributions/620/attachments/696/1308/estea-xdc2020.pdf