| Index: src/gpu/gl/GrGLShaderBuilder.h
|
| diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h
|
| index a4fd82689d51ebb15273993985e1db858269d031..ad0d87ef31bffd8c5e3cc45a1ec491f313c75412 100644
|
| --- a/src/gpu/gl/GrGLShaderBuilder.h
|
| +++ b/src/gpu/gl/GrGLShaderBuilder.h
|
| @@ -71,7 +71,7 @@ public:
|
| SkASSERT(NULL != builder);
|
| SkString name;
|
| name.printf("Sampler%d", idx);
|
| - fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
| + fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
|
| kSampler2D_GrSLType,
|
| name.c_str());
|
| SkASSERT(fSamplerUniform.isValid());
|
| @@ -97,10 +97,10 @@ public:
|
|
|
| typedef SkTArray<TextureSampler> TextureSamplerArray;
|
|
|
| - enum ShaderType {
|
| - kVertex_ShaderType = 0x1,
|
| - kGeometry_ShaderType = 0x2,
|
| - kFragment_ShaderType = 0x4,
|
| + enum ShaderVisibility {
|
| + kVertex_Visibility = 0x1,
|
| + kGeometry_Visibility = 0x2,
|
| + kFragment_Visibility = 0x4,
|
| };
|
|
|
| GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, const GrGLProgramDesc&);
|
| @@ -127,27 +127,27 @@ public:
|
| void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
|
| va_list args;
|
| va_start(args, format);
|
| - this->codeAppendf(kVertex_ShaderType, format, args);
|
| + fVSCode.appendf(format, args);
|
| va_end(args);
|
| }
|
|
|
| void gsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
|
| va_list args;
|
| va_start(args, format);
|
| - this->codeAppendf(kGeometry_ShaderType, format, args);
|
| + fGSCode.appendf(format, args);
|
| va_end(args);
|
| }
|
|
|
| void fsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
|
| va_list args;
|
| va_start(args, format);
|
| - this->codeAppendf(kFragment_ShaderType, format, args);
|
| + fFSCode.appendf(format, args);
|
| va_end(args);
|
| }
|
|
|
| - void vsCodeAppend(const char* str) { this->codeAppend(kVertex_ShaderType, str); }
|
| - void gsCodeAppend(const char* str) { this->codeAppend(kGeometry_ShaderType, str); }
|
| - void fsCodeAppend(const char* str) { this->codeAppend(kFragment_ShaderType, str); }
|
| + void vsCodeAppend(const char* str) { fVSCode.append(str); }
|
| + void gsCodeAppend(const char* str) { fGSCode.append(str); }
|
| + void fsCodeAppend(const char* str) { fFSCode.append(str); }
|
|
|
| /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
|
| Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
|
| @@ -157,33 +157,28 @@ public:
|
| const char* coordName,
|
| GrSLType coordType = kVec2f_GrSLType) const;
|
|
|
| - /** Version of above that appends the result to the shader code rather than an SkString.
|
| - Currently the shader type must be kFragment */
|
| - void appendTextureLookup(ShaderType,
|
| - const TextureSampler&,
|
| - const char* coordName,
|
| - GrSLType coordType = kVec2f_GrSLType);
|
| + /** Version of above that appends the result to the fragment shader code instead.*/
|
| + void fsAppendTextureLookup(const TextureSampler&,
|
| + const char* coordName,
|
| + GrSLType coordType = kVec2f_GrSLType);
|
|
|
|
|
| /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
|
| always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or
|
| float. If modulation is "" or NULL it this function acts as though appendTextureLookup were
|
| called. */
|
| - void appendTextureLookupAndModulate(ShaderType,
|
| - const char* modulation,
|
| - const TextureSampler&,
|
| - const char* coordName,
|
| - GrSLType coordType = kVec2f_GrSLType);
|
| -
|
| - /** Emits a helper function outside of main(). Currently ShaderType must be
|
| - kFragment_ShaderType. */
|
| - void emitFunction(ShaderType shader,
|
| - GrSLType returnType,
|
| - const char* name,
|
| - int argCnt,
|
| - const GrGLShaderVar* args,
|
| - const char* body,
|
| - SkString* outName);
|
| + void fsAppendTextureLookupAndModulate(const char* modulation,
|
| + const TextureSampler&,
|
| + const char* coordName,
|
| + GrSLType coordType = kVec2f_GrSLType);
|
| +
|
| + /** Emits a helper function outside of main() in the fragment shader. */
|
| + void fsEmitFunction(GrSLType returnType,
|
| + const char* name,
|
| + int argCnt,
|
| + const GrGLShaderVar* args,
|
| + const char* body,
|
| + SkString* outName);
|
|
|
| /** Generates a EffectKey for the shader code based on the texture access parameters and the
|
| capabilities of the GL context. This is useful for keying the shader programs that may
|
| @@ -209,8 +204,8 @@ public:
|
| static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
|
|
|
| /** Add a uniform variable to the current program, that has visibility in one or more shaders.
|
| - visibility is a bitfield of ShaderType values indicating from which shaders the uniform
|
| - should be accessible. At least one bit must be set. Geometry shader uniforms are not
|
| + visibility is a bitfield of ShaderVisibility values indicating from which shaders the
|
| + uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not
|
| supported at this time. The actual uniform name will be mangled. If outName is not NULL then
|
| it will refer to the final uniform name after return. Use the addUniformArray variant to add
|
| an array of uniforms.
|
| @@ -280,7 +275,9 @@ public:
|
| */
|
|
|
| /** Called after building is complete to get the final shader string. */
|
| - void getShader(ShaderType, SkString*) const;
|
| + void vsGetShader(SkString*) const;
|
| + void gsGetShader(SkString*) const;
|
| + void fsGetShader(SkString*) const;
|
|
|
| /**
|
| * Adds code for effects. effectStages contains the effects to add. effectKeys[i] is the key
|
| @@ -330,13 +327,10 @@ public:
|
| const GrGLContextInfo& ctxInfo() const { return fCtxInfo; }
|
|
|
| private:
|
| - void codeAppendf(ShaderType type, const char format[], va_list args);
|
| - void codeAppend(ShaderType type, const char* str);
|
| -
|
| typedef GrTAllocator<GrGLShaderVar> VarArray;
|
|
|
| void appendDecls(const VarArray&, SkString*) const;
|
| - void appendUniformDecls(ShaderType, SkString*) const;
|
| + void appendUniformDecls(ShaderVisibility, SkString*) const;
|
|
|
| typedef GrGLUniformManager::BuilderUniform BuilderUniform;
|
| GrGLUniformManager::BuilderUniformArray fUniforms;
|
| @@ -414,8 +408,8 @@ private:
|
| };
|
| bool enablePrivateFeature(GLSLPrivateFeature);
|
|
|
| - // If we ever have VS/GS features we can expand this to take a bitmask of ShaderType and track
|
| - // the enables separately for each shader.
|
| + // If we ever have VS/GS features we can expand this to take a bitmask of ShaderVisibility and
|
| + // track the enables separately for each shader.
|
| void addFSFeature(uint32_t featureBit, const char* extensionName);
|
|
|
| // Generates a name for a variable. The generated string will be name prefixed by the prefix
|
|
|