Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: src/gpu/glsl/GrGLSLShaderBuilder.cpp

Issue 1885863004: Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unneeded assert Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLUniformHandler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLShaderBuilder.cpp
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 1031f84460acf3089afac81ee8ffd5c4f93c5005..1342d1ce9801f50afc615a2a3b6b535091c425f7 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -63,71 +63,68 @@ void GrGLSLShaderBuilder::emitFunction(GrSLType returnType,
}
void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
- const GrGLSLSampler& sampler,
+ SamplerHandle samplerHandle,
const char* coordName,
GrSLType varyingType) const {
const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
- GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
- GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUniform).getType();
+ const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle);
+ GrSLType samplerType = sampler.type();
if (samplerType == kSampler2DRect_GrSLType) {
if (varyingType == kVec2f_GrSLType) {
out->appendf("%s(%s, textureSize(%s) * %s)",
GrGLSLTexture2DFunctionName(varyingType, samplerType,
glslCaps->generation()),
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
+ sampler.getSamplerNameForTexture2D(),
+ sampler.getSamplerNameForTexture2D(),
coordName);
} else {
out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))",
GrGLSLTexture2DFunctionName(varyingType, samplerType,
glslCaps->generation()),
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
+ sampler.getSamplerNameForTexture2D(),
+ sampler.getSamplerNameForTexture2D(),
coordName,
coordName);
}
} else {
out->appendf("%s(%s, %s)",
GrGLSLTexture2DFunctionName(varyingType, samplerType, glslCaps->generation()),
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
+ sampler.getSamplerNameForTexture2D(),
coordName);
}
this->appendTextureSwizzle(out, sampler.config());
}
-void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler,
+void GrGLSLShaderBuilder::appendTextureLookup(SamplerHandle samplerHandle,
const char* coordName,
GrSLType varyingType) {
- this->appendTextureLookup(&this->code(), sampler, coordName, varyingType);
+ this->appendTextureLookup(&this->code(), samplerHandle, coordName, varyingType);
}
void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
- const GrGLSLSampler& sampler,
+ SamplerHandle samplerHandle,
const char* coordName,
GrSLType varyingType) {
SkString lookup;
- this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
+ this->appendTextureLookup(&lookup, samplerHandle, coordName, varyingType);
this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
}
void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
- const GrGLSLSampler& sampler,
+ SamplerHandle samplerHandle,
const char* coordExpr) const {
- const GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
+ const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle);
SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
- SkASSERT(GrSLTypeIsSamplerType(
- uniformHandler->getUniformVariable(sampler.fSamplerUniform).getType()));
+ SkASSERT(GrSLTypeIsSamplerType(sampler.type()));
- out->appendf("texelFetch(%s, %s)",
- uniformHandler->getUniformCStr(sampler.fSamplerUniform),
- coordExpr);
+ out->appendf("texelFetch(%s, %s)", sampler.getSamplerNameForTexelFetch(), coordExpr);
this->appendTextureSwizzle(out, sampler.config());
}
-void GrGLSLShaderBuilder::appendTexelFetch(const GrGLSLSampler& sampler, const char* coordExpr) {
- this->appendTexelFetch(&this->code(), sampler, coordExpr);
+void GrGLSLShaderBuilder::appendTexelFetch(SamplerHandle samplerHandle, const char* coordExpr) {
+ this->appendTexelFetch(&this->code(), samplerHandle, coordExpr);
}
void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig config) const {
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLUniformHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698