xref: /aosp_15_r20/external/angle/doc/DynamicShaderCompilation.md (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# About
2*8975f5c5SAndroid Build Coastguard Worker
3*8975f5c5SAndroid Build Coastguard WorkerBecause ANGLE can only generate full HLSL programs after we known the signatures
4*8975f5c5SAndroid Build Coastguard Workerbetween the vertex and pixel stages, we can not immediately call the D3D
5*8975f5c5SAndroid Build Coastguard Workercompiler at GL shader compile time. Moreover, we can insert additional
6*8975f5c5SAndroid Build Coastguard Workeroptimization code right at draw-time.
7*8975f5c5SAndroid Build Coastguard Worker
8*8975f5c5SAndroid Build Coastguard WorkerESSL 1.00 shaders treat all vertex inputs as floating point. We insert a
9*8975f5c5SAndroid Build Coastguard Workerconversion routine to transform un-normalized integer vertex attributes in the
10*8975f5c5SAndroid Build Coastguard Workershader preamble to floating point, saving CPU conversion time.
11*8975f5c5SAndroid Build Coastguard Worker
12*8975f5c5SAndroid Build Coastguard WorkerAt draw-time, we also optimize out any unused render target outputs. This
13*8975f5c5SAndroid Build Coastguard Workerimproved draw call performance significantly on lower spec and integrated
14*8975f5c5SAndroid Build Coastguard Workerdevices. Changing render target setups may trigger a shader recompile at draw
15*8975f5c5SAndroid Build Coastguard Workertime.
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker# Addendum
18*8975f5c5SAndroid Build Coastguard Worker
19*8975f5c5SAndroid Build Coastguard WorkerANGLE is not the only program to do this kind of draw-time optimization. A
20*8975f5c5SAndroid Build Coastguard Workercommon complaint from application developers is that draw calls sometimes
21*8975f5c5SAndroid Build Coastguard Workerperform very slowly due to dynamic shader re-compilation. A future design
22*8975f5c5SAndroid Build Coastguard Workerdirection for ANGLE, when targeting a more modern API, is to perform the vertex
23*8975f5c5SAndroid Build Coastguard Workerconversion in a separate shader pass, which would then be linked with another
24*8975f5c5SAndroid Build Coastguard Workercompiled shader.
25