| 4682 | } |
| 4683 | |
| 4684 | int GenerateFunctionDefinition(CompiledFunction *func, ILOperand *vertexOutput = nullptr) |
| 4685 | //return the ID of the Function |
| 4686 | { |
| 4687 | ctx.ClearBuffer(); |
| 4688 | |
| 4689 | ctx.PushScope(); |
| 4690 | |
| 4691 | int funcID = ctx.FunctionNameToFunctionID[func->Name](); |
| 4692 | int funcTypeID = ctx.FunctionNameToFunctionTypeID[func->Name](); |
| 4693 | |
| 4694 | ctx.AddInstrFunction(funcID, ctx.DefineType(func->ReturnType), funcTypeID, GetFuncOriginalName(func->Name)); |
| 4695 | |
| 4696 | for (auto & instr : *func->Code) |
| 4697 | if (auto arg = instr.As<FetchArgInstruction>()) |
| 4698 | if (arg->ArgId != 0) |
| 4699 | { |
| 4700 | if (!ctx.ParameterNameToID.ContainsKey((ILOperand*)&instr)) |
| 4701 | { |
| 4702 | ctx.DefineType(arg->Type); |
| 4703 | int typeID = ctx.DefineTypePointer(arg->Type, StorageClass::Function); |
| 4704 | ctx.AddInstrFunctionParameter((ILOperand*)&instr, typeID, arg->Name); |
| 4705 | } |
| 4706 | } |
| 4707 | |
| 4708 | ++ctx.CurrentID; |
| 4709 | ctx.AddInstrLabel_AtFunctionHeader(ctx.CurrentID); |
| 4710 | |
| 4711 | func->Code->NameAllInstructions(); |
| 4712 | GenerateCode(func->Code.Ptr(), ctx.CurrentID); |
| 4713 | |
| 4714 | if (vertexOutput) |
| 4715 | { |
| 4716 | int valueID = ctx.AddInstrLoad(nullptr, vertexOutput, MemoryAccess::None); |
| 4717 | int gl_PositionID = ctx.AddInstrAccessChain_StructMember( |
| 4718 | 0, |
| 4719 | ctx.InterfaceNameToID["variable_gl_PerVertex"], |
| 4720 | "gl_Position" |
| 4721 | ); |
| 4722 | ctx.AddInstrStore(0, gl_PositionID, valueID); |
| 4723 | } |
| 4724 | |
| 4725 | ctx.AddInstrReturn(); |
| 4726 | ctx.AddInstrFunctionEnd(); |
| 4727 | |
| 4728 | ctx.ProduceFunction(); |
| 4729 | |
| 4730 | ctx.PopScope(); |
| 4731 | |
| 4732 | return funcID; |
| 4733 | } |
| 4734 | |
| 4735 | void Decorate(int ID, Decoration deco, int op1 = -1) |
| 4736 | { |
no test coverage detected