MCPcopy Create free account
hub / github.com/csyonghe/Spire / PrintExportInstr

Method PrintExportInstr

Source/SpireCore/SpirVCodeGen.cpp:4116–4227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4114 }
4115
4116 void PrintExportInstr(ExportInstruction * instr)
4117 {
4118 String exportOpName = instr->ExportOperator;
4119
4120 if (exportOpName == "fragmentExport")
4121 {
4122 CompiledComponent ccomp;
4123 bool isNormal = false;
4124 bool isDepthOutput = false;
4125 if (currentWorld->LocalComponents.TryGetValue(instr->ComponentName, ccomp))
4126 {
4127 if (ccomp.Attributes.ContainsKey("Norma"))
4128 isNormal = true;
4129 if (ccomp.Attributes.ContainsKey("DepthOutput"))
4130 isDepthOutput = true;
4131 }
4132 String exportName;
4133 if (isDepthOutput)
4134 exportName = "gl_FragDepth";
4135 else
4136 exportName = instr->ComponentName;
4137
4138 int exportID = ctx.InterfaceNameToID[exportName];
4139 if (exportID == -1)
4140 throw InvalidOperationException("can not find component for export instruction for fragmentExport in PrintExportInstr(): " + exportName);
4141
4142 int operandID = GetOperandValue(instr->Operand.Ptr());
4143 if (isNormal)
4144 operandID = ctx.AddInstrMulAdd(operandID, 0.5, 0.5);
4145
4146 ctx.AddInstrStore((ILOperand*)instr, exportID, operandID);
4147 }
4148
4149 else if (exportOpName == "standardExport")
4150 {
4151 int storeID = ctx.AddInstrAccessChain_StructMember(0, ctx.InterfaceNameToID["blk" + currentWorld->WorldOutput->Name], instr->ComponentName);
4152 ctx.AddInstrStore((ILOperand*)instr, storeID, GetOperandValue(instr->Operand.Ptr()));
4153 }
4154
4155 else if (exportOpName == "bufferExport")
4156 {
4157 auto & comp = currentWorld->WorldOutput->Entries[instr->ComponentName]();
4158
4159 auto UIntType = GetTypeFromString("uint");
4160 auto FloatType = GetTypeFromString("float");
4161 int GIIDx = ctx.AddInstrLoad(
4162 ctx.AddInstrAccessChain_VectorMember(0, ctx.InterfaceNameToID["gl_GlobalInvocationID"], -1, 0),
4163 MemoryAccess::None
4164 ); //GlobalInvocationID.x
4165 int baseIndex = ctx.AddInstrBinaryInstr(
4166 0,
4167 UIntType,
4168 "OpIMu",
4169 GIIDx,
4170 ctx.AddInstrConstantUInt(currentWorld->WorldOutput->Size / 4)
4171 );
4172 baseIndex = ctx.AddInstrBinaryInstr(
4173 0,

Callers

nothing calls this directly

Calls 15

GetTypeFromStringFunction · 0.85
AddInstrMulAddMethod · 0.80
AddInstrStoreMethod · 0.80
AddInstrLoadMethod · 0.80
AddInstrBinaryInstrMethod · 0.80
AddInstrConstantUIntMethod · 0.80
IsUIntMethod · 0.80
IsUIntVectorMethod · 0.80
GetVectorSizeMethod · 0.80

Tested by

no test coverage detected