Move GrGLShaderVar to GrGLSL
BUG=skia: Review URL: https://codereview.chromium.org/1417123002
This commit is contained in:
parent
3d9d7a7213
commit
0d3f061262
@ -14,9 +14,9 @@
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
/*
|
||||
* This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this
|
||||
@ -110,9 +110,9 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
const char* version = GrGLGetGLSLVersionDecl(*ctx);
|
||||
|
||||
// setup vertex shader
|
||||
GrGLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
@ -132,7 +132,7 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
const GrGLInterface* gl = ctx->interface();
|
||||
|
||||
// setup fragment shader
|
||||
GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
|
||||
&fshaderTxt);
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -100,10 +100,10 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
// corner of the screen than the previous circle.
|
||||
|
||||
// set up vertex shader; this is a trivial vertex shader that passes through position and color
|
||||
GrGLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLSLShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
@ -130,7 +130,7 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
// coded center and compare that to some hard-coded circle radius to compute a coverage.
|
||||
// Then, this coverage is mixed with the coverage from the previous stage and passed to the
|
||||
// next stage.
|
||||
GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
|
||||
&fshaderTxt);
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
@ -68,9 +68,9 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
const char* version = GrGLGetGLSLVersionDecl(*ctx);
|
||||
|
||||
// setup vertex shader
|
||||
GrGLShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
SkTArray<GrGLShaderVar> aVars;
|
||||
SkTArray<GrGLShaderVar> oVars;
|
||||
GrGLSLShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
SkTArray<GrGLSLShaderVar> aVars;
|
||||
SkTArray<GrGLSLShaderVar> oVars;
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
@ -79,7 +79,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
for (uint32_t i = 0; i < attribs; i++) {
|
||||
SkString aname;
|
||||
aname.appendf("a_color_%d", i);
|
||||
aVars.push_back(GrGLShaderVar(aname.c_str(),
|
||||
aVars.push_back(GrGLSLShaderVar(aname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kAttribute_TypeModifier));
|
||||
aVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
@ -90,7 +90,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
for (uint32_t i = 0; i < maxAttribs; i++) {
|
||||
SkString oname;
|
||||
oname.appendf("o_color_%d", i);
|
||||
oVars.push_back(GrGLShaderVar(oname.c_str(),
|
||||
oVars.push_back(GrGLSLShaderVar(oname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kVaryingOut_TypeModifier));
|
||||
oVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
@ -116,7 +116,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
const GrGLInterface* gl = ctx->interface();
|
||||
|
||||
// setup fragment shader
|
||||
GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
|
||||
&fshaderTxt);
|
||||
|
@ -332,7 +332,6 @@
|
||||
'<(skia_src_path)/gpu/gl/GrGLProgramDataManager.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.cpp',
|
||||
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLShaderVar.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLStencilAttachment.cpp',
|
||||
'<(skia_src_path)/gpu/gl/GrGLStencilAttachment.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLTexture.cpp',
|
||||
@ -364,11 +363,12 @@
|
||||
'<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.h',
|
||||
|
||||
# GLSL
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSL.cpp',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSL.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSL_impl.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h',
|
||||
|
||||
# Sk files
|
||||
'<(skia_include_path)/gpu/SkGr.h',
|
||||
|
@ -721,8 +721,8 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
const char *rectName;
|
||||
const char *profileSizeName;
|
||||
|
||||
const char* precisionString = GrGLShaderVar::PrecisionString(args.fBuilder->glslCaps(),
|
||||
fPrecision);
|
||||
const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fBuilder->glslCaps(),
|
||||
fPrecision);
|
||||
fProxyRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
fPrecision,
|
||||
|
@ -1658,14 +1658,14 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
fLight->emitLightColorUniform(args.fBuilder);
|
||||
SkString lightFunc;
|
||||
this->emitLightFunc(args.fBuilder, &lightFunc);
|
||||
static const GrGLShaderVar gSobelArgs[] = {
|
||||
GrGLShaderVar("a", kFloat_GrSLType),
|
||||
GrGLShaderVar("b", kFloat_GrSLType),
|
||||
GrGLShaderVar("c", kFloat_GrSLType),
|
||||
GrGLShaderVar("d", kFloat_GrSLType),
|
||||
GrGLShaderVar("e", kFloat_GrSLType),
|
||||
GrGLShaderVar("f", kFloat_GrSLType),
|
||||
GrGLShaderVar("scale", kFloat_GrSLType),
|
||||
static const GrGLSLShaderVar gSobelArgs[] = {
|
||||
GrGLSLShaderVar("a", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("b", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("c", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("d", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("e", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("f", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("scale", kFloat_GrSLType),
|
||||
};
|
||||
SkString sobelFuncName;
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
@ -1677,10 +1677,10 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
gSobelArgs,
|
||||
"\treturn (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;\n",
|
||||
&sobelFuncName);
|
||||
static const GrGLShaderVar gPointToNormalArgs[] = {
|
||||
GrGLShaderVar("x", kFloat_GrSLType),
|
||||
GrGLShaderVar("y", kFloat_GrSLType),
|
||||
GrGLShaderVar("scale", kFloat_GrSLType),
|
||||
static const GrGLSLShaderVar gPointToNormalArgs[] = {
|
||||
GrGLSLShaderVar("x", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("y", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("scale", kFloat_GrSLType),
|
||||
};
|
||||
SkString pointToNormalName;
|
||||
fsBuilder->emitFunction(kVec3f_GrSLType,
|
||||
@ -1690,9 +1690,9 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
"\treturn normalize(vec3(-x * scale, -y * scale, 1));\n",
|
||||
&pointToNormalName);
|
||||
|
||||
static const GrGLShaderVar gInteriorNormalArgs[] = {
|
||||
GrGLShaderVar("m", kFloat_GrSLType, 9),
|
||||
GrGLShaderVar("surfaceScale", kFloat_GrSLType),
|
||||
static const GrGLSLShaderVar gInteriorNormalArgs[] = {
|
||||
GrGLSLShaderVar("m", kFloat_GrSLType, 9),
|
||||
GrGLSLShaderVar("surfaceScale", kFloat_GrSLType),
|
||||
};
|
||||
SkString normalBody = emitNormalFunc(fBoundaryMode,
|
||||
pointToNormalName.c_str(),
|
||||
@ -1767,10 +1767,10 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString*
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"KD", &kd);
|
||||
|
||||
static const GrGLShaderVar gLightArgs[] = {
|
||||
GrGLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
static const GrGLSLShaderVar gLightArgs[] = {
|
||||
GrGLSLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightBody;
|
||||
lightBody.appendf("\tfloat colorScale = %s * dot(normal, surfaceToLight);\n", kd);
|
||||
@ -1855,10 +1855,10 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString*
|
||||
"Shininess",
|
||||
&shininess);
|
||||
|
||||
static const GrGLShaderVar gLightArgs[] = {
|
||||
GrGLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
static const GrGLSLShaderVar gLightArgs[] = {
|
||||
GrGLSLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightBody;
|
||||
lightBody.appendf("\tvec3 halfDir = vec3(normalize(surfaceToLight + vec3(0, 0, 1)));\n");
|
||||
@ -1987,8 +1987,8 @@ void GrGLSpotLight::emitLightColor(GrGLFPBuilder* builder,
|
||||
fSUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
|
||||
|
||||
static const GrGLShaderVar gLightColorArgs[] = {
|
||||
GrGLShaderVar("surfaceToLight", kVec3f_GrSLType)
|
||||
static const GrGLSLShaderVar gLightColorArgs[] = {
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightColorBody;
|
||||
lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s);
|
||||
|
@ -658,15 +658,15 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
|
||||
const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
|
||||
|
||||
// Add noise function
|
||||
static const GrGLShaderVar gPerlinNoiseArgs[] = {
|
||||
GrGLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
static const GrGLSLShaderVar gPerlinNoiseArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
static const GrGLShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrGLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrGLShaderVar(stitchData, kVec2f_GrSLType)
|
||||
static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrGLSLShaderVar(stitchData, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
SkString noiseCode;
|
||||
|
@ -708,7 +708,7 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
// this is the distance along x-axis from the end center to focal point in
|
||||
// transformed coordinates
|
||||
GrGLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni);
|
||||
GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
@ -954,11 +954,11 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
@ -1184,11 +1184,11 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
|
@ -501,14 +501,14 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
|
||||
GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
|
||||
fsBuilder->declAppend(edgeAlpha);
|
||||
fsBuilder->declAppend(dklmdx);
|
||||
|
@ -62,13 +62,13 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
SkString cubicBlendName;
|
||||
|
||||
static const GrGLShaderVar gCubicBlendArgs[] = {
|
||||
GrGLShaderVar("coefficients", kMat44f_GrSLType),
|
||||
GrGLShaderVar("t", kFloat_GrSLType),
|
||||
GrGLShaderVar("c0", kVec4f_GrSLType),
|
||||
GrGLShaderVar("c1", kVec4f_GrSLType),
|
||||
GrGLShaderVar("c2", kVec4f_GrSLType),
|
||||
GrGLShaderVar("c3", kVec4f_GrSLType),
|
||||
static const GrGLSLShaderVar gCubicBlendArgs[] = {
|
||||
GrGLSLShaderVar("coefficients", kMat44f_GrSLType),
|
||||
GrGLSLShaderVar("t", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("c0", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c1", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c2", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c3", kVec4f_GrSLType),
|
||||
};
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs& args) override {
|
||||
// Using highp for GLES here in order to avoid some precision issues on specific GPUs.
|
||||
GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
SkString tmpDecl;
|
||||
tmpVar.appendDecl(args.fBuilder->glslCaps(), &tmpDecl);
|
||||
|
||||
|
@ -65,7 +65,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputColor);
|
||||
|
||||
int width = this->width();
|
||||
const GrGLShaderVar& kernel = args.fBuilder->getUniformVariable(fKernelUni);
|
||||
const GrGLSLShaderVar& kernel = args.fBuilder->getUniformVariable(fKernelUni);
|
||||
const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
|
||||
|
||||
fsBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(), fRadius, imgInc);
|
||||
|
@ -90,7 +90,8 @@ public:
|
||||
dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(pb->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
|
||||
|
||||
fsBuilder->codeAppend("\tfloat texColor = ");
|
||||
@ -319,7 +320,8 @@ public:
|
||||
"TextureSize", &textureSizeUniName);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(pb->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;", v.fsIn());
|
||||
|
||||
fsBuilder->codeAppend("float texColor = ");
|
||||
@ -330,7 +332,8 @@ public:
|
||||
fsBuilder->codeAppend("float distance = "
|
||||
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
|
||||
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(pb->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 st = uv*%s;", textureSizeUniName);
|
||||
fsBuilder->codeAppend("float afwidth;");
|
||||
if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) {
|
||||
@ -544,9 +547,11 @@ public:
|
||||
|
||||
// create LCD offset adjusted by inverse of transform
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(pb->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(pb->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
|
||||
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
|
||||
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
|
||||
|
@ -100,11 +100,11 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
|
||||
inCoords.c_str());
|
||||
builder->codeAppend(";");
|
||||
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppend(GrGLSLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppend(GrGLSLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppendf("float y = (%s).y;", inCoords.c_str());
|
||||
|
||||
builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0);",
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "GrGLGLSL.h"
|
||||
#include "GrGLContext.h"
|
||||
#include "GrGLShaderVar.h"
|
||||
#include "GrGLUtil.h"
|
||||
#include "SkString.h"
|
||||
|
||||
|
@ -2811,13 +2811,13 @@ bool GrGLGpu::onCopySurface(GrSurface* dst,
|
||||
void GrGLGpu::createCopyProgram() {
|
||||
const char* version = GrGLGetGLSLVersionDecl(this->ctxInfo());
|
||||
|
||||
GrGLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
|
||||
GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GrGLGeometryProcessor.h"
|
||||
#include "GrGLGpu.h"
|
||||
#include "GrGLPathRendering.h"
|
||||
#include "GrGLShaderVar.h"
|
||||
#include "GrGLXferProcessor.h"
|
||||
#include "GrPathProcessor.h"
|
||||
#include "GrPipeline.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
|
||||
SkASSERT(arrayCount <= uni.fArrayCount || \
|
||||
(1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCount))
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount))
|
||||
|
||||
GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
const UniformInfoArray& uniforms,
|
||||
@ -23,7 +23,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
for (int i = 0; i < count; i++) {
|
||||
Uniform& uniform = fUniforms[i];
|
||||
const UniformInfo& builderUniform = uniforms[i];
|
||||
SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
|
||||
builderUniform.fVariable.getArrayCount() > 0);
|
||||
SkDEBUGCODE(
|
||||
uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
|
||||
@ -50,7 +50,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
|
||||
SeparableVarying& separableVarying = fSeparableVaryings[i];
|
||||
const SeparableVaryingInfo& builderSeparableVarying = separableVaryings[i];
|
||||
SkASSERT(GrGLShaderVar::kNonArray == builderSeparableVarying.fVariable.getArrayCount() ||
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == builderSeparableVarying.fVariable.getArrayCount() ||
|
||||
builderSeparableVarying.fVariable.getArrayCount() > 0);
|
||||
SkDEBUGCODE(
|
||||
separableVarying.fArrayCount = builderSeparableVarying.fVariable.getArrayCount();
|
||||
@ -63,7 +63,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kSampler2D_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
// FIXME: We still insert a single sampler uniform for every stage. If the shader does not
|
||||
// reference the sampler then the compiler may have optimized it out. Uncomment this assert
|
||||
// once stages insert their own samplers.
|
||||
@ -79,7 +79,7 @@ void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
|
||||
void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kFloat_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0));
|
||||
@ -111,7 +111,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
|
||||
void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec2f_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1));
|
||||
@ -140,7 +140,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
|
||||
void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec3f_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2));
|
||||
@ -173,7 +173,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
|
||||
GrGLfloat v3) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec4f_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v3));
|
||||
@ -202,7 +202,7 @@ void GrGLProgramDataManager::set4fv(UniformHandle u,
|
||||
void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kMat33f_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation, 1, false, matrix));
|
||||
@ -215,7 +215,7 @@ void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix
|
||||
void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kMat44f_GrSLType);
|
||||
SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fFSLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, false, matrix));
|
||||
|
@ -9,8 +9,8 @@
|
||||
#define GrGLProgramDataManager_DEFINED
|
||||
|
||||
#include "GrAllocator.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "gl/GrGLTypes.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
#include "SkTArray.h"
|
||||
|
||||
@ -49,17 +49,17 @@ public:
|
||||
typedef ShaderResourceHandle UniformHandle;
|
||||
|
||||
struct UniformInfo {
|
||||
GrGLShaderVar fVariable;
|
||||
uint32_t fVisibility;
|
||||
GrGLint fLocation;
|
||||
GrGLSLShaderVar fVariable;
|
||||
uint32_t fVisibility;
|
||||
GrGLint fLocation;
|
||||
};
|
||||
|
||||
struct SeparableVaryingInfo {
|
||||
GrGLShaderVar fVariable;
|
||||
GrGLint fLocation;
|
||||
GrGLSLShaderVar fVariable;
|
||||
GrGLint fLocation;
|
||||
};
|
||||
|
||||
// This uses an allocator rather than array so that the GrGLShaderVars don't move in memory
|
||||
// This uses an allocator rather than array so that the GrGLSLShaderVars don't move in memory
|
||||
// after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
|
||||
// name strings. Otherwise, we'd have to hand out copies.
|
||||
typedef GrTAllocator<UniformInfo> UniformInfoArray;
|
||||
|
@ -122,8 +122,8 @@ static void soft_light_component_pos_dst_alpha(GrGLFragmentBuilder* fsBuilder,
|
||||
static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
|
||||
// Emit a helper that gets the luminance of a color.
|
||||
SkString getFunction;
|
||||
GrGLShaderVar getLumArgs[] = {
|
||||
GrGLShaderVar("color", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar getLumArgs[] = {
|
||||
GrGLSLShaderVar("color", kVec3f_GrSLType),
|
||||
};
|
||||
SkString getLumBody("return dot(vec3(0.3, 0.59, 0.11), color);");
|
||||
fsBuilder->emitFunction(kFloat_GrSLType,
|
||||
@ -133,10 +133,10 @@ static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFun
|
||||
&getFunction);
|
||||
|
||||
// Emit the set luminance function.
|
||||
GrGLShaderVar setLumArgs[] = {
|
||||
GrGLShaderVar("hueSat", kVec3f_GrSLType),
|
||||
GrGLShaderVar("alpha", kFloat_GrSLType),
|
||||
GrGLShaderVar("lumColor", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar setLumArgs[] = {
|
||||
GrGLSLShaderVar("hueSat", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("alpha", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("lumColor", kVec3f_GrSLType),
|
||||
};
|
||||
SkString setLumBody;
|
||||
setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
|
||||
@ -167,7 +167,7 @@ static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFun
|
||||
static void add_sat_function(GrGLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
|
||||
// Emit a helper that gets the saturation of a color
|
||||
SkString getFunction;
|
||||
GrGLShaderVar getSatArgs[] = { GrGLShaderVar("color", kVec3f_GrSLType) };
|
||||
GrGLSLShaderVar getSatArgs[] = { GrGLSLShaderVar("color", kVec3f_GrSLType) };
|
||||
SkString getSatBody;
|
||||
getSatBody.printf("return max(max(color.r, color.g), color.b) - "
|
||||
"min(min(color.r, color.g), color.b);");
|
||||
@ -182,11 +182,11 @@ static void add_sat_function(GrGLFragmentBuilder* fsBuilder, SkString* setSatFun
|
||||
// problems on PowerVR drivers. So instead it returns a vec3 where r, g ,b are the
|
||||
// adjusted min, mid, and max inputs, respectively.
|
||||
SkString helperFunction;
|
||||
GrGLShaderVar helperArgs[] = {
|
||||
GrGLShaderVar("minComp", kFloat_GrSLType),
|
||||
GrGLShaderVar("midComp", kFloat_GrSLType),
|
||||
GrGLShaderVar("maxComp", kFloat_GrSLType),
|
||||
GrGLShaderVar("sat", kFloat_GrSLType),
|
||||
GrGLSLShaderVar helperArgs[] = {
|
||||
GrGLSLShaderVar("minComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("midComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("maxComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("sat", kFloat_GrSLType),
|
||||
};
|
||||
static const char kHelperBody[] = "if (minComp < maxComp) {"
|
||||
"vec3 result;"
|
||||
@ -203,9 +203,9 @@ static void add_sat_function(GrGLFragmentBuilder* fsBuilder, SkString* setSatFun
|
||||
kHelperBody,
|
||||
&helperFunction);
|
||||
|
||||
GrGLShaderVar setSatArgs[] = {
|
||||
GrGLShaderVar("hueLumColor", kVec3f_GrSLType),
|
||||
GrGLShaderVar("satColor", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar setSatArgs[] = {
|
||||
GrGLSLShaderVar("hueLumColor", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("satColor", kVec3f_GrSLType),
|
||||
};
|
||||
const char* helpFunc = helperFunction.c_str();
|
||||
SkString setSatBody;
|
||||
|
@ -151,10 +151,10 @@ const char* GrGLFragmentShaderBuilder::fragmentPosition() {
|
||||
"GL_ARB_fragment_coord_conventions");
|
||||
}
|
||||
fInputs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLShaderVar::kIn_TypeModifier,
|
||||
GrGLSLShaderVar::kIn_TypeModifier,
|
||||
"gl_FragCoord",
|
||||
kDefault_GrSLPrecision,
|
||||
GrGLShaderVar::kUpperLeft_Origin);
|
||||
GrGLSLShaderVar::kUpperLeft_Origin);
|
||||
fSetupFragPosition = true;
|
||||
}
|
||||
return "gl_FragCoord";
|
||||
@ -232,7 +232,7 @@ void GrGLFragmentShaderBuilder::enableCustomOutput() {
|
||||
fHasCustomColorOutput = true;
|
||||
fCustomColorOutputIndex = fOutputs.count();
|
||||
fOutputs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLShaderVar::kOut_TypeModifier,
|
||||
GrGLSLShaderVar::kOut_TypeModifier,
|
||||
declared_color_output_name());
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ void GrGLFragmentShaderBuilder::enableSecondaryOutput() {
|
||||
// requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
|
||||
const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
|
||||
if (caps.mustDeclareFragmentShaderOutput()) {
|
||||
fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier,
|
||||
fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
|
||||
declared_secondary_color_output_name());
|
||||
}
|
||||
}
|
||||
@ -298,7 +298,7 @@ void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
|
||||
if (v->fGsOut) {
|
||||
v->fFsIn = v->fGsOut;
|
||||
}
|
||||
fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
|
||||
fInputs.push_back().set(v->fType, GrGLSLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
|
||||
}
|
||||
|
||||
void GrGLFragmentBuilder::onBeforeChildProcEmitCode() {
|
||||
|
@ -20,7 +20,7 @@ void GrGLGeometryBuilder::addVarying(const char* name, GrSLPrecision precision,
|
||||
if (v->vsVarying()) {
|
||||
fInputs.push_back();
|
||||
fInputs.back().setType(v->fType);
|
||||
fInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier);
|
||||
fInputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingIn_TypeModifier);
|
||||
fInputs.back().setPrecision(precision);
|
||||
fInputs.back().setUnsizedArray();
|
||||
*fInputs.back().accessName() = v->fVsOut;
|
||||
@ -30,7 +30,7 @@ void GrGLGeometryBuilder::addVarying(const char* name, GrSLPrecision precision,
|
||||
if (v->fsVarying()) {
|
||||
fOutputs.push_back();
|
||||
fOutputs.back().setType(v->fType);
|
||||
fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier);
|
||||
fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
|
||||
fOutputs.back().setPrecision(precision);
|
||||
fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name);
|
||||
v->fGsOut = fOutputs.back().getName().c_str();
|
||||
|
@ -133,7 +133,7 @@ GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
uni.fVariable.setType(type);
|
||||
uni.fVariable.setTypeModifier(GrGLShaderVar::kUniform_TypeModifier);
|
||||
uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
|
||||
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
|
||||
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
int arrayCount,
|
||||
const char** outName = nullptr) = 0;
|
||||
|
||||
virtual const GrGLShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
|
||||
/**
|
||||
* Shortcut for getUniformVariable(u).c_str()
|
||||
@ -243,7 +243,7 @@ public:
|
||||
int arrayCount,
|
||||
const char** outName) override;
|
||||
|
||||
const GrGLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
return fUniforms[u.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "gl/GrGLCaps.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
namespace {
|
||||
void append_texture_lookup(SkString* out,
|
||||
@ -67,7 +67,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program)
|
||||
this->main() = "void main() {";
|
||||
}
|
||||
|
||||
void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) {
|
||||
void GrGLShaderBuilder::declAppend(const GrGLSLShaderVar& var) {
|
||||
SkString tempDecl;
|
||||
var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
|
||||
this->codeAppendf("%s;", tempDecl.c_str());
|
||||
@ -76,7 +76,7 @@ void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) {
|
||||
void GrGLShaderBuilder::emitFunction(GrSLType returnType,
|
||||
const char* name,
|
||||
int argCnt,
|
||||
const GrGLShaderVar* args,
|
||||
const GrGLSLShaderVar* args,
|
||||
const char* body,
|
||||
SkString* outName) {
|
||||
this->functions().append(GrGLSLTypeString(returnType));
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
|
||||
GrGLShaderBuilder(GrGLProgramBuilder* program);
|
||||
|
||||
void addInput(GrGLShaderVar i) { fInputs.push_back(i); }
|
||||
void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); }
|
||||
void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
|
||||
void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); }
|
||||
|
||||
/*
|
||||
* We put texture lookups in the base class because it is TECHNICALLY possible to do texture
|
||||
@ -92,13 +92,13 @@ public:
|
||||
/**
|
||||
* Appends a variable declaration to one of the shaders
|
||||
*/
|
||||
void declAppend(const GrGLShaderVar& var);
|
||||
void declAppend(const GrGLSLShaderVar& var);
|
||||
|
||||
/** Emits a helper function outside of main() in the fragment shader. */
|
||||
void emitFunction(GrSLType returnType,
|
||||
const char* name,
|
||||
int argCnt,
|
||||
const GrGLShaderVar* args,
|
||||
const GrGLSLShaderVar* args,
|
||||
const char* body,
|
||||
SkString* outName);
|
||||
|
||||
@ -125,7 +125,7 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
typedef GrTAllocator<GrGLShaderVar> VarArray;
|
||||
typedef GrTAllocator<GrGLSLShaderVar> VarArray;
|
||||
void appendDecls(const VarArray& vars, SkString* out) const;
|
||||
|
||||
/*
|
||||
|
@ -21,7 +21,7 @@ GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program)
|
||||
void GrGLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, GrGLVarying* v) {
|
||||
fOutputs.push_back();
|
||||
fOutputs.back().setType(v->fType);
|
||||
fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier);
|
||||
fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
|
||||
fOutputs.back().setPrecision(precision);
|
||||
fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name);
|
||||
v->fVsOut = fOutputs.back().getName().c_str();
|
||||
@ -100,7 +100,7 @@ GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuin
|
||||
bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) {
|
||||
SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
|
||||
for (int i = 0; i < fInputs.count(); ++i) {
|
||||
const GrGLShaderVar& attr = fInputs[i];
|
||||
const GrGLSLShaderVar& attr = fInputs[i];
|
||||
// if attribute already added, don't add it again
|
||||
if (attr.getName().equals(var.getName())) {
|
||||
return false;
|
||||
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrGLShaderVar_DEFINED
|
||||
#define GrGLShaderVar_DEFINED
|
||||
#ifndef GrGLSLShaderVar_DEFINED
|
||||
#define GrGLSLShaderVar_DEFINED
|
||||
|
||||
#include "GrShaderVar.h"
|
||||
#include "../glsl/GrGLSL.h"
|
||||
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Represents a variable in a shader
|
||||
*/
|
||||
class GrGLShaderVar : public GrShaderVar {
|
||||
class GrGLSLShaderVar : public GrShaderVar {
|
||||
public:
|
||||
/**
|
||||
* See GL_ARB_fragment_coord_conventions.
|
||||
@ -30,14 +30,14 @@ public:
|
||||
/**
|
||||
* Defaults to a float with no precision specifier
|
||||
*/
|
||||
GrGLShaderVar()
|
||||
GrGLSLShaderVar()
|
||||
: GrShaderVar()
|
||||
, fOrigin(kDefault_Origin)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
}
|
||||
|
||||
GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrGLSLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: GrShaderVar(name, type, arrayCount, precision)
|
||||
, fOrigin(kDefault_Origin)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
@ -46,22 +46,22 @@ public:
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrGLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
GrGLSLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: GrShaderVar(name, type, typeModifier, arrayCount, precision)
|
||||
, fOrigin(kDefault_Origin)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrGLShaderVar(const GrShaderVar& var)
|
||||
GrGLSLShaderVar(const GrShaderVar& var)
|
||||
: GrShaderVar(var)
|
||||
, fOrigin(kDefault_Origin)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != var.getType());
|
||||
}
|
||||
|
||||
GrGLShaderVar(const GrGLShaderVar& var)
|
||||
GrGLSLShaderVar(const GrGLSLShaderVar& var)
|
||||
: GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(),
|
||||
var.getArrayCount(), var.getPrecision())
|
||||
, fOrigin(var.fOrigin)
|
Loading…
Reference in New Issue
Block a user