MCPcopy Create free account
hub / github.com/Tencent/tgfx / internalEmitChild

Method internalEmitChild

src/gpu/processors/FragmentProcessor.cpp:160–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160void FragmentProcessor::internalEmitChild(
161 size_t childIndex, const std::string& inputColor, const std::string& outputColor,
162 EmitArgs& args, std::function<std::string(std::string_view)> coordFunc) const {
163 auto fragBuilder = args.fragBuilder;
164 const auto childProc = childProcessor(childIndex);
165 fragBuilder->onBeforeChildProcEmitCode(childProc); // call first so mangleString is updated
166 auto programInfo = fragBuilder->getProgramInfo();
167 // Prepare a mangled input color variable if the default is not used,
168 // inputName remains the empty string if no variable is needed.
169 std::string inputName;
170 if (!inputColor.empty() && inputColor != "vec4(1.0)") {
171 // The input name is based off of the current mangle string, and
172 // since this is called after onBeforeChildProcEmitCode(), it will be
173 // unique to the child processor (exactly what we want for its input).
174 inputName += "_childInput";
175 inputName += programInfo->getMangledSuffix(childProc);
176 fragBuilder->codeAppendf("vec4 %s = %s;", inputName.c_str(), inputColor.c_str());
177 }
178
179 // emit the code for the child in its own scope
180 fragBuilder->codeAppend("{\n");
181 fragBuilder->codeAppendf("// Processor%d : %s\n", programInfo->getProcessorIndex(childProc),
182 childProc->name().c_str());
183 TransformedCoordVars coordVars = args.transformedCoords->childInputs(childIndex);
184 TextureSamplers textureSamplers = args.textureSamplers->childInputs(childIndex);
185
186 EmitArgs childArgs(fragBuilder, args.uniformHandler, outputColor,
187 inputName.empty() ? "vec4(1.0)" : inputName, args.inputSubset, &coordVars,
188 &textureSamplers, std::move(coordFunc));
189 childProcessor(childIndex)->emitCode(childArgs);
190 fragBuilder->codeAppend("}\n");
191
192 fragBuilder->onAfterChildProcEmitCode();
193}
194
195template <typename T, size_t (FragmentProcessor::*COUNT)() const>
196FragmentProcessor::BuilderInputProvider<T, COUNT>

Callers

nothing calls this directly

Calls 12

getMangledSuffixMethod · 0.80
codeAppendfMethod · 0.80
c_strMethod · 0.80
codeAppendMethod · 0.80
getProcessorIndexMethod · 0.80
childInputsMethod · 0.80
getProgramInfoMethod · 0.45
emptyMethod · 0.45
nameMethod · 0.45
emitCodeMethod · 0.45

Tested by

no test coverage detected