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

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

Issue 1869063005: Add GLSL support for texelFetch (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_renaem
Patch Set: rebase 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') | no next file » | 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 91a0f9b1b56a881cee48d0a7f80f86cbb681e5b7..1031f84460acf3089afac81ee8ffd5c4f93c5005 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -93,14 +93,7 @@ void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
coordName);
}
- // This refers to any swizzling we may need to get from some backend internal format to the
- // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will
- // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba".
- const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.config());
-
- if (configSwizzle != GrSwizzle::RGBA()) {
- out->appendf(".%s", configSwizzle.c_str());
- }
+ this->appendTextureSwizzle(out, sampler.config());
}
void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler,
@@ -118,6 +111,33 @@ void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
}
+void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
+ const GrGLSLSampler& sampler,
+ const char* coordExpr) const {
+ const GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
+ SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
+ SkASSERT(GrSLTypeIsSamplerType(
+ uniformHandler->getUniformVariable(sampler.fSamplerUniform).getType()));
+
+ out->appendf("texelFetch(%s, %s)",
+ uniformHandler->getUniformCStr(sampler.fSamplerUniform),
+ coordExpr);
+
+ this->appendTextureSwizzle(out, sampler.config());
+}
+
+void GrGLSLShaderBuilder::appendTexelFetch(const GrGLSLSampler& sampler, const char* coordExpr) {
+ this->appendTexelFetch(&this->code(), sampler, coordExpr);
+}
+
+void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig config) const {
+ const GrSwizzle& configSwizzle = fProgramBuilder->glslCaps()->configTextureSwizzle(config);
+
+ if (configSwizzle != GrSwizzle::RGBA()) {
+ out->appendf(".%s", configSwizzle.c_str());
+ }
+}
+
bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) {
if (featureBit & fFeaturesAddedMask) {
return false;
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698