-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlogfile
70 lines (49 loc) · 2.58 KB
/
logfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Work on ast transformation to single static assignments
notes from before. The AST from the macro shoulld be transformed into
a list of single static assingments. Each assingment/identifier should
a have constraint that declares, wher the value can be calculated.
a value can be calculated on the CPU, the Fragment-Shader, or the
Vertex-Shader.
a constrait can be defined explicitly:
let a {.VS.} = ...
let b {.FS.} = ...
a constraint can be defined implicitly:
let a = foo(vertex.position)
# this forces a to be calculated in the vertex-shader.
gl.Position = bar(a)
2017-11-14
The AST can be transformed to single static assignments. Typechecking
the AST removes pragma expressions, that means I can't use pragma
expressions to store the constraints. My solution to this problem is
to create a table that maps from symbols of the ast to the
constraints. The table needs to be cleared each time the macro is
called.
2017-11-15
Enabling/disabling clipping planes should be handled somehow. The
Uniforms are extracted simply by iterating the single static
assignments. Whenever a symbol is used that is not defined in the
block of code it is assumed to be a uniform. compile time constants
are compiled as values, not uniforms into the glsl source code.
2017-12-8
The logic where parts of the shader should be evaluated is now implemented.
First of all the shader needs to be in SSA form.
When the shader is in SSA form, then there are two passes on the program.
Pass1 from bottom to top, for each assignment it is decided, where
each expression needs to be evaluated semantically. For example an
assignment to gl_Position needs to be evaluated in the vertex shader,
while the same expression assigned to the fragment color would be
semantically in the fragment shader.
In pass 2 from top to bottom, each assignment in raised as much as
possible for optimization. The optimization is done in the assumption
that CPU is fastest, then vertex shader, then fragment shader. an
expression `foo(a,b)` can be optimized from FS to VS, when
`interpolation(foo(a,b))` is mathematically indestinctable from
`foo(interpolation(a), interpolation(b))`. The optimization from VS to
CPU can be done, when the expression does not depend on any vertex
attributes.
When it is decided for each expression, where it seeds to be
evalueted, the shader program is split into the different sections of
CPU-instructions, VS and FS. And the communications channels between
them. Each defined symbol in the CPU section that is used in eather
the FS or the VS is a uniform. Symbols defined in the VS but accessed
in the fragment shader are varyings.