internal/shaderir/hlsl: add function forward declarations

This commit is contained in:
Hajime Hoshi 2022-03-26 19:09:54 +09:00
parent 1de1bfef55
commit d30a31b16c
3 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,5 @@
void F0(in float4 l0, out float4 l1);
void F0(in float4 l0, out float4 l1) {
float4 l2 = 0.0;
l2 = mul(l0, float4x4FromScalar(1.0));

View File

@ -1,3 +1,5 @@
void F0(out float l0, out float l1[4], out float4 l2);
void F0(out float l0, out float l1[4], out float4 l2) {
l0 = 0.0;
l1[0] = 0.0;

View File

@ -122,6 +122,9 @@ func Compile(p *shaderir.Program) (string, []int) {
if len(p.Funcs) > 0 {
lines = append(lines, "")
for _, f := range p.Funcs {
lines = append(lines, c.function(p, &f, true)...)
}
for _, f := range p.Funcs {
if len(lines) > 0 && lines[len(lines)-1] != "" {
lines = append(lines, "")