aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLProgramBuilder.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-07-31 13:53:11 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-31 18:16:11 +0000
commite782f8472f61a5a553c57fef788ad4405844887b (patch)
treec987b012c7b7db78ce0764a46c9281c23409eb07 /src/gpu/glsl/GrGLSLProgramBuilder.cpp
parent990ec990a66aab06bfa18aa16a5e3960a4b34118 (diff)
Remove GrResourceIOProcessor.
Fold its functionality into GrPrimitiveProcessor and GrFragmentProcessor. Make each have its own TextureSampler nested class. Currently the only difference is that fragment processors lose the ability to inject their samplers into the vertex shader. However, this facilitates refactoring GrPrimitiveProcessor's TextureSampler class such that the textures are specified separately from the TextureSampler. Bug: skia: Change-Id: I1e590187e7a6ae79ee3147155d397fcdcf5e4619 Reviewed-on: https://skia-review.googlesource.com/142814 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/glsl/GrGLSLProgramBuilder.cpp')
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 05b78eef0c..b0cf8169d4 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -96,8 +96,15 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
SkASSERT(!fGeometryProcessor);
fGeometryProcessor.reset(proc.createGLSLInstance(*this->shaderCaps()));
- SkSTArray<4, SamplerHandle> texSamplers(proc.numTextureSamplers());
- this->emitSamplers(proc, &texSamplers);
+ SkAutoSTMalloc<4, SamplerHandle> texSamplers(proc.numTextureSamplers());
+ for (int i = 0; i < proc.numTextureSamplers(); ++i) {
+ SkString name;
+ name.printf("TextureSampler_%d", i);
+ const auto& sampler = proc.textureSampler(i);
+ GrTextureType textureType = sampler.peekTexture()->texturePriv().textureType();
+ texSamplers[i] = this->emitSampler(textureType, sampler.peekTexture()->config(),
+ name.c_str(), sampler.visibility());
+ }
GrGLSLPrimitiveProcessor::FPCoordTransformHandler transformHandler(fPipeline,
&fTransformedCoordVars);
@@ -111,7 +118,7 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
outputColor->c_str(),
outputCoverage->c_str(),
rtAdjustName,
- texSamplers.begin(),
+ texSamplers.get(),
&transformHandler);
fGeometryProcessor->emitCode(args);
@@ -168,15 +175,23 @@ SkString GrGLSLProgramBuilder::emitAndInstallFragProc(
GrGLSLFragmentProcessor* fragProc = fp.createGLSLInstance();
- SkSTArray<4, SamplerHandle> textureSamplerArray(fp.numTextureSamplers());
- GrFragmentProcessor::Iter iter(&fp);
- while (const GrFragmentProcessor* subFP = iter.next()) {
- this->emitSamplers(*subFP, &textureSamplerArray);
+ SkSTArray<4, SamplerHandle> texSamplers;
+ GrFragmentProcessor::Iter fpIter(&fp);
+ int samplerIdx = 0;
+ while (const auto* subFP = fpIter.next()) {
+ for (int i = 0; i < subFP->numTextureSamplers(); ++i) {
+ SkString name;
+ name.printf("TextureSampler_%d", samplerIdx++);
+ const auto& sampler = subFP->textureSampler(i);
+ GrTextureType textureType = sampler.peekTexture()->texturePriv().textureType();
+ texSamplers.emplace_back(this->emitSampler(textureType, sampler.peekTexture()->config(),
+ name.c_str(), kFragment_GrShaderFlag));
+ }
}
const GrShaderVar* coordVars = fTransformedCoordVars.begin() + transformedCoordVarsIdx;
GrGLSLFragmentProcessor::TransformedCoordVars coords(&fp, coordVars);
- GrGLSLFragmentProcessor::TextureSamplers textureSamplers(&fp, textureSamplerArray.begin());
+ GrGLSLFragmentProcessor::TextureSamplers textureSamplers(&fp, texSamplers.begin());
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
this->shaderCaps(),
@@ -250,20 +265,6 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
fFS.codeAppend("}");
}
-void GrGLSLProgramBuilder::emitSamplers(
- const GrResourceIOProcessor& processor,
- SkTArray<SamplerHandle>* outTexSamplerHandles) {
- SkString name;
- int numTextureSamplers = processor.numTextureSamplers();
- for (int t = 0; t < numTextureSamplers; ++t) {
- const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(t);
- name.printf("TextureSampler_%d", outTexSamplerHandles->count());
- GrTextureType textureType = sampler.peekTexture()->texturePriv().textureType();
- outTexSamplerHandles->emplace_back(this->emitSampler(
- textureType, sampler.peekTexture()->config(), name.c_str(), sampler.visibility()));
- }
-}
-
void GrGLSLProgramBuilder::updateSamplerCounts(GrShaderFlags visibility) {
if (visibility & kVertex_GrShaderFlag) {
++fNumVertexSamplers;