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

Unified Diff: src/gpu/gl/builders/GrGLShaderBuilder.cpp

Issue 1426653008: Revert of Create swizzle table inside of glsl caps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/gl/builders/GrGLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLCaps.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLShaderBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.cpp b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
index 2c00bafcf7c2c7b7e7fe67d1e5316633cdf1ef1c..03dc1667c76fe81e04d4814ac8e6832f46023461 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
@@ -6,67 +6,46 @@
*/
#include "GrGLShaderBuilder.h"
+#include "gl/GrGLGpu.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLShaderVar.h"
#include "glsl/GrGLSLTextureSampler.h"
-static void map_swizzle(const char* swizzleMap, const char* swizzle, char* mangledSwizzle) {
- int i;
- for (i = 0; '\0' != swizzle[i]; ++i) {
- switch (swizzle[i]) {
- case 'r':
- mangledSwizzle[i] = swizzleMap[0];
- break;
- case 'g':
- mangledSwizzle[i] = swizzleMap[1];
- break;
- case 'b':
- mangledSwizzle[i] = swizzleMap[2];
- break;
- case 'a':
- mangledSwizzle[i] = swizzleMap[3];
- break;
- default:
- SkFAIL("Unsupported swizzle");
- }
- }
- mangledSwizzle[i] ='\0';
-}
-
-static void append_texture_lookup(SkString* out,
- const GrGLSLCaps* glslCaps,
- const char* samplerName,
- const char* coordName,
- GrPixelConfig config,
- const char* swizzle,
- GrSLType varyingType = kVec2f_GrSLType) {
+namespace {
+void append_texture_lookup(SkString* out,
+ GrGLGpu* gpu,
+ const char* samplerName,
+ const char* coordName,
+ uint32_t configComponentMask,
+ const char* swizzle,
+ GrSLType varyingType = kVec2f_GrSLType) {
SkASSERT(coordName);
out->appendf("%s(%s, %s)",
- GrGLSLTexture2DFunctionName(varyingType, glslCaps->generation()),
+ GrGLSLTexture2DFunctionName(varyingType, gpu->glslGeneration()),
samplerName,
coordName);
char mangledSwizzle[5];
- // This refers to any swizzling we may need to get from some backend internal format to the
- // format used in GrPixelConfig. Some backends will automatically do the sizzling for us.
- if (glslCaps->mustSwizzleInShader()) {
- const char* swizzleMap = glslCaps->getSwizzleMap(config);
- // if the map is simply 'rgba' then we don't need to do any manual swizzling to get us to
- // a GrPixelConfig format.
- if (memcmp(swizzleMap, "rgba", 4)) {
- // Manually 'swizzle' the swizzle using our mapping
- map_swizzle(swizzleMap, swizzle, mangledSwizzle);
- swizzle = mangledSwizzle;
- }
- }
-
+ // The swizzling occurs using texture params instead of shader-mangling if ARB_texture_swizzle
+ // is available.
+ if (!gpu->glCaps().textureSwizzleSupport() &&
+ (kA_GrColorComponentFlag == configComponentMask)) {
+ char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a';
+ int i;
+ for (i = 0; '\0' != swizzle[i]; ++i) {
+ mangledSwizzle[i] = alphaChar;
+ }
+ mangledSwizzle[i] ='\0';
+ swizzle = mangledSwizzle;
+ }
// For shader prettiness we omit the swizzle rather than appending ".rgba".
if (memcmp(swizzle, "rgba", 4)) {
out->appendf(".%s", swizzle);
}
+}
}
GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program)
@@ -118,10 +97,10 @@
const char* coordName,
GrSLType varyingType) const {
append_texture_lookup(out,
- fProgramBuilder->glslCaps(),
+ fProgramBuilder->gpu(),
fProgramBuilder->getUniformCStr(sampler.fSamplerUniform),
coordName,
- sampler.config(),
+ sampler.configComponentMask(),
sampler.swizzle(),
varyingType);
}
@@ -153,6 +132,19 @@
vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
out->append(";\n");
}
+}
+
+void GrGLShaderBuilder::appendTextureLookup(const char* samplerName,
+ const char* coordName,
+ uint32_t configComponentMask,
+ const char* swizzle) {
+ append_texture_lookup(&this->code(),
+ fProgramBuilder->gpu(),
+ samplerName,
+ coordName,
+ configComponentMask,
+ swizzle,
+ kVec2f_GrSLType);
}
void GrGLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698