Index: src/gpu/gl/builders/GrGLShaderBuilder.cpp |
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.cpp b/src/gpu/gl/builders/GrGLShaderBuilder.cpp |
index 991ac9117657a9a7ed042546dd09ce7836994c12..a7682e205eecf4bf4622ec840840d266ca4ff70c 100644 |
--- a/src/gpu/gl/builders/GrGLShaderBuilder.cpp |
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.cpp |
@@ -6,18 +6,14 @@ |
*/ |
#include "GrGLShaderBuilder.h" |
-#include "GrGLProgramBuilder.h" |
-#include "GrGLShaderStringBuilder.h" |
-#include "gl/GrGLCaps.h" |
-#include "gl/GrGLContext.h" |
-#include "gl/GrGLGpu.h" |
+#include "gl/builders/GrGLProgramBuilder.h" |
#include "glsl/GrGLSLCaps.h" |
#include "glsl/GrGLSLShaderVar.h" |
#include "glsl/GrGLSLTextureSampler.h" |
namespace { |
void append_texture_lookup(SkString* out, |
- GrGLGpu* gpu, |
+ const GrGLSLCaps* glslCaps, |
const char* samplerName, |
const char* coordName, |
uint32_t configComponentMask, |
@@ -26,7 +22,7 @@ void append_texture_lookup(SkString* out, |
SkASSERT(coordName); |
out->appendf("%s(%s, %s)", |
- GrGLSLTexture2DFunctionName(varyingType, gpu->glslGeneration()), |
+ GrGLSLTexture2DFunctionName(varyingType, glslCaps->generation()), |
samplerName, |
coordName); |
@@ -34,9 +30,9 @@ void append_texture_lookup(SkString* out, |
// The swizzling occurs using texture params instead of shader-mangling if ARB_texture_swizzle |
// is available. |
- if (!gpu->glCaps().textureSwizzleSupport() && |
+ if (!glslCaps->textureSwizzleSupport() && |
(kA_GrColorComponentFlag == configComponentMask)) { |
- char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a'; |
+ char alphaChar = glslCaps->textureRedSupport() ? 'r' : 'a'; |
int i; |
for (i = 0; '\0' != swizzle[i]; ++i) { |
mangledSwizzle[i] = alphaChar; |
@@ -100,7 +96,7 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out, |
const char* coordName, |
GrSLType varyingType) const { |
append_texture_lookup(out, |
- fProgramBuilder->gpu(), |
+ fProgramBuilder->glslCaps(), |
fProgramBuilder->getUniformCStr(sampler.fSamplerUniform), |
coordName, |
sampler.configComponentMask(), |
@@ -123,23 +119,6 @@ void GrGLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, |
this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); |
} |
- |
-const GrGLenum* GrGLShaderBuilder::GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps) { |
- if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) { |
- if (caps.textureRedSupport()) { |
- static const GrGLenum gRedSmear[] = { GR_GL_RED, GR_GL_RED, GR_GL_RED, GR_GL_RED }; |
- return gRedSmear; |
- } else { |
- static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA, |
- GR_GL_ALPHA, GR_GL_ALPHA }; |
- return gAlphaSmear; |
- } |
- } else { |
- static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE, GR_GL_ALPHA }; |
- return gStraight; |
- } |
-} |
- |
void GrGLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) { |
if (!(featureBit & fFeaturesAddedMask)) { |
this->extensions().appendf("#extension %s: require\n", extensionName); |
@@ -159,7 +138,7 @@ void GrGLShaderBuilder::appendTextureLookup(const char* samplerName, |
uint32_t configComponentMask, |
const char* swizzle) { |
append_texture_lookup(&this->code(), |
- fProgramBuilder->gpu(), |
+ fProgramBuilder->glslCaps(), |
samplerName, |
coordName, |
configComponentMask, |
@@ -168,8 +147,8 @@ void GrGLShaderBuilder::appendTextureLookup(const char* samplerName, |
} |
void GrGLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) { |
- SkASSERT(fProgramBuilder->gpu()->glslGeneration() >= k330_GrGLSLGeneration || |
- fProgramBuilder->gpu()->glCaps().glslCaps()->mustEnableAdvBlendEqs()); |
+ SkASSERT(fProgramBuilder->glslCaps()->generation() >= k330_GrGLSLGeneration || |
+ fProgramBuilder->glslCaps()->mustEnableAdvBlendEqs()); |
fLayoutParams[interface].push_back() = param; |
} |
@@ -194,9 +173,16 @@ void GrGLShaderBuilder::compileAndAppendLayoutQualifiers() { |
GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQualifier + 1); |
} |
-bool |
-GrGLShaderBuilder::finalize(GrGLuint programId, GrGLenum type, SkTDArray<GrGLuint>* shaderIds) { |
+void GrGLShaderBuilder::finalize(uint32_t visibility) { |
SkASSERT(!fFinalized); |
+ this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString(); |
+ this->compileAndAppendLayoutQualifiers(); |
robertphillips
2015/10/30 16:39:46
\n somewhere ?
egdaniel
2015/10/30 18:24:20
Done.
|
+ fProgramBuilder->appendUniformDecls((GrGLProgramBuilder::ShaderVisibility) visibility, &this->uniforms()); |
+ this->appendDecls(fInputs, &this->inputs()); |
robertphillips
2015/10/30 16:39:46
can this be on one line ?
egdaniel
2015/10/30 18:24:20
sadly no, 101 chars
|
+ SkASSERT(k110_GrGLSLGeneration != fProgramBuilder->glslCaps()->generation() || |
+ fOutputs.empty()); |
+ this->appendDecls(fOutputs, &this->outputs()); |
+ this->onFinalize(); |
// append the 'footer' to code |
this->code().append("}"); |
@@ -205,22 +191,6 @@ GrGLShaderBuilder::finalize(GrGLuint programId, GrGLenum type, SkTDArray<GrGLuin |
fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
} |
- GrGLGpu* gpu = fProgramBuilder->gpu(); |
- GrGLuint shaderId = GrGLCompileAndAttachShader(gpu->glContext(), |
- programId, |
- type, |
- fCompilerStrings.begin(), |
- fCompilerStringLengths.begin(), |
- fCompilerStrings.count(), |
- gpu->stats()); |
- |
fFinalized = true; |
- |
- if (!shaderId) { |
- return false; |
- } |
- |
- *shaderIds->append() = shaderId; |
- |
- return true; |
} |
+ |