ANGLE converts application shaders into Vulkan VkShaderModules through a series of steps:
glCompileShader
are passed to the ANGLE
shader translator. The translator compiles application shaders into Vulkan-compatible
GLSL. Vulkan-compatible GLSL matches the GL_KHR_vulkan_glsl extension spec
with some additional workarounds and emulation. We emulate OpenGL's different depth range, viewport
y flipping, default uniforms, and OpenGL
line segment rasterization. For more info see
TranslatorVulkan.cpp. After initial compilation the shaders are not
complete. The translator initially assigns resources and in/out variables arbitrary descriptor set,
binding and location indices. The correct values are determined at link time. For the sake of
transform feedback, some markers are left in the shader for link-time substitution.The translator outputs some feature code conditional to Vulkan specialization constants, which are resolved at draw-time. For example, Bresenham line rasterization emulation.
Link-Time Compilation and Transformation: During a call to glLinkProgram
the Vulkan
back-end can know the necessary locations and properties to write to connect the shader stage
interfaces. We get the completed shader source using ANGLE's
GlslangWrapperVk helper class. At this time, we use Khronos'
glslang to convert the Vulkan-compatible GLSL into SPIR-V. A transformation pass is done
on the generated SPIR-V to update the arbitrary descriptor set, binding and location indices set in
step 1. Additionally, component and various transform feedback decorations are added and inactive
varyings are removed from the shader interface. We currently don't generate VkShaderModules
at
this time, but that could be a future optimization.
Draw-time Pipeline Creation: Once the application records a draw call, the SPIR-V is compiled
into VkShaderModule
s. The appropriate specialization constants are then resolved and the
VkPipeline
object is created. Note that we currently don't use SPIRV-Tools to
perform any SPIR-V optimization. This could be something to improve on in the future.
See the below diagram for a high-level view of the shader translation flow:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。