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

Method emitAndInstallFragProc

src/gpu/ProgramBuilder.cpp:103–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103std::string ProgramBuilder::emitAndInstallFragProc(const FragmentProcessor* processor,
104 size_t transformedCoordVarsIdx,
105 const std::string& input) {
106 ProcessorGuard processorGuard(this, processor);
107 std::string output;
108 nameExpression(&output, "output");
109
110 // Enclose custom code in a block to avoid namespace conflicts
111 fragmentShaderBuilder()->codeAppendf("{ // Processor%d : %s\n",
112 programInfo->getProcessorIndex(processor),
113 processor->name().c_str());
114
115 std::vector<SamplerHandle> texSamplers;
116 FragmentProcessor::Iter fpIter(processor);
117 int samplerIndex = 0;
118 while (const auto subFP = fpIter.next()) {
119 for (size_t i = 0; i < subFP->numTextureSamplers(); ++i) {
120 std::string name = "TextureSampler_";
121 name += std::to_string(samplerIndex++);
122 auto texture = subFP->textureAt(i);
123 texSamplers.emplace_back(emitSampler(texture, name));
124 }
125 }
126 FragmentProcessor::TransformedCoordVars coords(
127 processor, GetPointer(transformedCoordVars, transformedCoordVarsIdx));
128 FragmentProcessor::TextureSamplers textureSamplers(processor, GetPointer(texSamplers, 0));
129 FragmentProcessor::EmitArgs args(fragmentShaderBuilder(), uniformHandler(), output, input,
130 subsetVarName, &coords, &textureSamplers);
131
132 processor->emitCode(args);
133 fragmentShaderBuilder()->codeAppend("}");
134 return output;
135}
136
137void ProgramBuilder::emitAndInstallXferProc(const std::string& colorIn,
138 const std::string& coverageIn) {

Callers

nothing calls this directly

Calls 10

GetPointerFunction · 0.85
codeAppendfMethod · 0.80
getProcessorIndexMethod · 0.80
c_strMethod · 0.80
codeAppendMethod · 0.80
nameMethod · 0.45
nextMethod · 0.45
numTextureSamplersMethod · 0.45
textureAtMethod · 0.45
emitCodeMethod · 0.45

Tested by

no test coverage detected