aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLProgramBuilder.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-04-19 15:24:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-19 15:24:29 -0700
commitb800248c73c75b02ab808c5bdb53e19e6abc3adc (patch)
tree7f81a22be8bb794768bb6e65972c31e846a05365 /src/gpu/glsl/GrGLSLProgramBuilder.cpp
parent45b61a1c4c0be896e7b12fd1405abfece799114f (diff)
Revert of Refactor how we store and use samplers in Ganesh (patchset #7 id:120001 of https://codereview.chromium.org/1885863004/ )
Reason for revert: breaking bots Original issue's description: > Refactor how we store and use samplers in Ganesh > > The main goal of this refactorization is to allow Vulkan to use separate > sampler and texture objects in the shader and descriptor sets and combine > them into a sampler2d in the shader where needed. > > A large part of this is separating how we store samplers and uniforms in the > UniformHandler. We no longer need to store handles to samplers besides when > we are initially emitting code. After we emit code all we ever do is loop over > all samplers and do some processor independent work on them, so we have no need > for direct access to individual samplers. > > In the GLProgram all we ever do is set the sampler uniforms in the ctor and never > touch them again, so no need to save sampler info there. The texture access on > program reuse just assume that they come in the same order as we set the texture > units for the samplers > > For Vulkan, it is a similar story. We create the descriptor set layouts with the samplers, > then when we get new textures, we just assume they come in in the same order as we > set the samplers on the descriptor sets. Thus no need to save direct vulkan info. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1885863004 > > Committed: https://skia.googlesource.com/skia/+/45b61a1c4c0be896e7b12fd1405abfece799114f TBR=bsalomon@google.com,jvanverth@google.com,cdalton@nvidia.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1896013003
Diffstat (limited to 'src/gpu/glsl/GrGLSLProgramBuilder.cpp')
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 31d1de29b3..88ef5b9245 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -27,6 +27,7 @@ GrGLSLProgramBuilder::GrGLSLProgramBuilder(const GrPipeline& pipeline,
, fDesc(desc)
, fGeometryProcessor(nullptr)
, fXferProcessor(nullptr)
+ , fSamplerUniforms(4)
, fNumVertexSamplers(0)
, fNumGeometrySamplers(0)
, fNumFragmentSamplers(0) {
@@ -96,8 +97,8 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
SkASSERT(!fGeometryProcessor);
fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps());
- SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures());
- SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
+ SkSTArray<4, GrGLSLSampler> texSamplers(proc.numTextures());
+ SkSTArray<2, GrGLSLSampler> bufferSamplers(proc.numBuffers());
this->emitSamplers(proc, &texSamplers, &bufferSamplers);
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
@@ -108,8 +109,8 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
proc,
outputColor->c_str(),
outputCoverage->c_str(),
- texSamplers.begin(),
- bufferSamplers.begin(),
+ texSamplers,
+ bufferSamplers,
fCoordTransforms,
&fOutCoords);
fGeometryProcessor->emitCode(args);
@@ -149,8 +150,8 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
GrGLSLFragmentProcessor* fragProc = fp.createGLSLInstance();
- SkSTArray<4, SamplerHandle> texSamplers(fp.numTextures());
- SkSTArray<2, SamplerHandle> bufferSamplers(fp.numBuffers());
+ SkSTArray<4, GrGLSLSampler> texSamplers(fp.numTextures());
+ SkSTArray<2, GrGLSLSampler> bufferSamplers(fp.numBuffers());
this->emitSamplers(fp, &texSamplers, &bufferSamplers);
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
@@ -160,8 +161,8 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
output->c_str(),
input.isOnes() ? nullptr : input.c_str(),
fOutCoords[index],
- texSamplers.begin(),
- bufferSamplers.begin());
+ texSamplers,
+ bufferSamplers);
fragProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
@@ -196,8 +197,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
openBrace.printf("{ // Xfer Processor: %s\n", xp.name());
fFS.codeAppend(openBrace.c_str());
- SkSTArray<4, SamplerHandle> texSamplers(xp.numTextures());
- SkSTArray<2, SamplerHandle> bufferSamplers(xp.numBuffers());
+ SkSTArray<4, GrGLSLSampler> texSamplers(xp.numTextures());
+ SkSTArray<2, GrGLSLSampler> bufferSamplers(xp.numBuffers());
this->emitSamplers(xp, &texSamplers, &bufferSamplers);
bool usePLSDstRead = (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState);
@@ -208,8 +209,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
ignoresCoverage ? nullptr : coverageIn.c_str(),
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),
- texSamplers.begin(),
- bufferSamplers.begin(),
+ texSamplers,
+ bufferSamplers,
usePLSDstRead);
fXferProcessor->emitCode(args);
@@ -220,8 +221,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
}
void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor,
- SkTArray<SamplerHandle>* outTexSamplers,
- SkTArray<SamplerHandle>* outBufferSamplers) {
+ GrGLSLSampler::SamplerArray* outTexSamplers,
+ GrGLSLSampler::SamplerArray* outBufferSamplers) {
SkString name;
int numTextures = processor.numTextures();
for (int t = 0; t < numTextures; ++t) {
@@ -264,7 +265,7 @@ void GrGLSLProgramBuilder::emitSampler(GrSLType samplerType,
GrPixelConfig config,
const char* name,
GrShaderFlags visibility,
- SkTArray<SamplerHandle>* outSamplers) {
+ GrGLSLSampler::SamplerArray* outSamplers) {
if (visibility & kVertex_GrShaderFlag) {
++fNumVertexSamplers;
}
@@ -276,12 +277,9 @@ void GrGLSLProgramBuilder::emitSampler(GrSLType samplerType,
++fNumFragmentSamplers;
}
GrSLPrecision precision = this->glslCaps()->samplerPrecision(config, visibility);
- SamplerHandle handle = this->uniformHandler()->addSampler(visibility,
- config,
- samplerType,
- precision,
- name);
- outSamplers->emplace_back(handle);
+ UniformHandle u = this->uniformHandler()->addUniform(visibility, samplerType, precision, name);
+ fSamplerUniforms.push_back(u);
+ outSamplers->emplace_back(u, config);
}
void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) {
@@ -371,10 +369,6 @@ void GrGLSLProgramBuilder::appendUniformDecls(GrShaderFlags visibility, SkString
this->uniformHandler()->appendUniformDecls(visibility, out);
}
-const GrGLSLSampler& GrGLSLProgramBuilder::getSampler(SamplerHandle handle) const {
- return this->uniformHandler()->getSampler(handle);
-}
-
void GrGLSLProgramBuilder::addRTAdjustmentUniform(GrSLPrecision precision,
const char* name,
const char** outName) {