switched SkSL's temporary 'highfloat' type back to 'float'
Bug: skia: Change-Id: If0debae7318b6b5b4a7cb85d458996a09931127e Reviewed-on: https://skia-review.googlesource.com/48760 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
b7d42e3c11
commit
8aa4569c13
@ -126,7 +126,7 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
vshaderTxt.append(
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"gl_Position = highfloat4(a_position, 0., 1.);\n"
|
||||
"gl_Position = float4(a_position, 0., 1.);\n"
|
||||
"o_color = a_color;\n"
|
||||
"}\n");
|
||||
|
||||
@ -149,7 +149,7 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
fshaderTxt.appendf(
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"%s = highfloat4(o_color, 1.0);\n"
|
||||
"%s = float4(o_color, 1.0);\n"
|
||||
"}\n", fsOutName);
|
||||
|
||||
return CreateProgram(ctx, vshaderTxt.c_str(), fshaderTxt.c_str());
|
||||
|
@ -119,7 +119,7 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
vshaderTxt.append(
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = highfloat4(a_position, 0.0, 1.0);\n"
|
||||
" gl_Position = float4(a_position, 0.0, 1.0);\n"
|
||||
" o_position = a_position;\n"
|
||||
" o_color = a_color;\n"
|
||||
"}\n");
|
||||
|
@ -69,7 +69,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
const char* version = shaderCaps->versionDeclString();
|
||||
|
||||
// setup vertex shader
|
||||
GrShaderVar aPosition("a_position", kHighFloat4_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar aPosition("a_position", kFloat4_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
SkTArray<GrShaderVar> aVars;
|
||||
SkTArray<GrShaderVar> oVars;
|
||||
|
||||
@ -109,7 +109,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
|
||||
// Passthrough position as a dummy
|
||||
for (uint32_t i = attribs; i < maxAttribs; i++) {
|
||||
vshaderTxt.appendf("%s = highfloat4(0, 0, 0, 1);\n", oVars[i].c_str());
|
||||
vshaderTxt.appendf("%s = float4(0, 0, 0, 1);\n", oVars[i].c_str());
|
||||
}
|
||||
|
||||
vshaderTxt.append("}\n");
|
||||
|
@ -111,13 +111,13 @@ enum GrSLType {
|
||||
kBool_GrSLType,
|
||||
kShort_GrSLType,
|
||||
kUShort_GrSLType,
|
||||
kHighFloat_GrSLType,
|
||||
kHighFloat2_GrSLType,
|
||||
kHighFloat3_GrSLType,
|
||||
kHighFloat4_GrSLType,
|
||||
kHighFloat2x2_GrSLType,
|
||||
kHighFloat3x3_GrSLType,
|
||||
kHighFloat4x4_GrSLType,
|
||||
kFloat_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kFloat3_GrSLType,
|
||||
kFloat4_GrSLType,
|
||||
kFloat2x2_GrSLType,
|
||||
kFloat3x3_GrSLType,
|
||||
kFloat4x4_GrSLType,
|
||||
kHalf_GrSLType,
|
||||
kHalf2_GrSLType,
|
||||
kHalf3_GrSLType,
|
||||
@ -184,13 +184,13 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
|
||||
/** Is the shading language type float (including vectors/matrices)? */
|
||||
static inline bool GrSLTypeIsFloatType(GrSLType type) {
|
||||
switch (type) {
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -234,13 +234,13 @@ static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) {
|
||||
return true;
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -278,13 +278,13 @@ static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
|
||||
return true;
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -318,13 +318,13 @@ static inline bool GrSLTypeIsImageStorage(GrSLType type) {
|
||||
return true;
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -371,13 +371,13 @@ static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -403,13 +403,13 @@ static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) {
|
||||
switch (type) {
|
||||
case kShort_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kHighFloat_GrSLType:
|
||||
case kHighFloat2_GrSLType:
|
||||
case kHighFloat3_GrSLType:
|
||||
case kHighFloat4_GrSLType:
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
@ -511,19 +511,19 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
|
||||
static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
|
||||
switch (type) {
|
||||
case kVec2us_norm_GrVertexAttribType: // fall through
|
||||
return kHighFloat2_GrSLType;
|
||||
return kFloat2_GrSLType;
|
||||
case kVec2us_uint_GrVertexAttribType:
|
||||
return kUint2_GrSLType;
|
||||
case kUByte_GrVertexAttribType: // fall through
|
||||
case kFloat_GrVertexAttribType:
|
||||
return kHighFloat_GrSLType;
|
||||
return kFloat_GrSLType;
|
||||
case kVec2f_GrVertexAttribType:
|
||||
return kHighFloat2_GrSLType;
|
||||
return kFloat2_GrSLType;
|
||||
case kVec3f_GrVertexAttribType:
|
||||
return kHighFloat3_GrSLType;
|
||||
return kFloat3_GrSLType;
|
||||
case kVec4ub_GrVertexAttribType:
|
||||
case kVec4f_GrVertexAttribType:
|
||||
return kHighFloat4_GrSLType;
|
||||
return kFloat4_GrSLType;
|
||||
case kVec2i_GrVertexAttribType:
|
||||
return kInt2_GrSLType;
|
||||
case kVec3i_GrVertexAttribType:
|
||||
|
@ -43,11 +43,10 @@ public:
|
||||
SkString sk_TransformedCoords2D_1 = fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 _tmpVar1;half4 color = %stexture(%s, %s).%s%s;\nhalf4 mask_color = "
|
||||
"texture(%s, %s).%s;\nif (highfloat(mask_color.w) < 0.5) {\n if (color.w > %s) "
|
||||
"{\n half scale = %s / color.w;\n color.xyz *= scale;\n "
|
||||
"color.w = %s;\n }\n} else if (color.w < %s) {\n half scale = highfloat(%s) "
|
||||
"/ max(0.001, highfloat(color.w));\n color.xyz *= scale;\n color.w = "
|
||||
"%s;\n}\n%s = color;\n",
|
||||
"texture(%s, %s).%s;\nif (float(mask_color.w) < 0.5) {\n if (color.w > %s) {\n "
|
||||
" half scale = %s / color.w;\n color.xyz *= scale;\n color.w = "
|
||||
"%s;\n }\n} else if (color.w < %s) {\n half scale = float(%s) / max(0.001, "
|
||||
"float(color.w));\n color.xyz *= scale;\n color.w = %s;\n}\n%s = color;\n",
|
||||
fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "",
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
sk_TransformedCoords2D_0.c_str(),
|
||||
|
@ -266,10 +266,10 @@ public:
|
||||
fCircleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "circleData");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 vec = half2(half((sk_FragCoord.x - highfloat(%s.x)) * highfloat(%s.w)), "
|
||||
"half((sk_FragCoord.y - highfloat(%s.y)) * highfloat(%s.w)));\nhalf dist = "
|
||||
"highfloat(length(vec)) + (0.5 - highfloat(%s.z)) * highfloat(%s.w);\n%s = %s * "
|
||||
"texture(%s, highfloat2(half2(dist, 0.5))).%s.w;\n",
|
||||
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
|
||||
"half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = "
|
||||
"float(length(vec)) + (0.5 - float(%s.z)) * float(%s.w);\n%s = %s * texture(%s, "
|
||||
"float2(half2(dist, 0.5))).%s.w;\n",
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
|
@ -889,10 +889,10 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
const char *rectName;
|
||||
const char *profileSizeName;
|
||||
|
||||
const char* floatType = rbe.precision() == kHigh_GrSLPrecision ? "highfloat" : "half";
|
||||
const char* floatType = rbe.precision() == kHigh_GrSLPrecision ? "float" : "half";
|
||||
fProxyRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
rbe.precision() == kHigh_GrSLPrecision ?
|
||||
kHighFloat4_GrSLType : kHalf4_GrSLType,
|
||||
kFloat4_GrSLType : kHalf4_GrSLType,
|
||||
"proxyRect",
|
||||
&rectName);
|
||||
fProfileSizeUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
|
@ -573,7 +573,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
|
||||
"\t\t%s.rgb = (%s.a < %s) ? half3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
|
||||
dColor, dColor, nearZero, dColor, dColor);
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 %s = %s + %s*(%s.",
|
||||
fragBuilder->codeAppendf("\t\tfloat2 %s = %s + %s*(%s.",
|
||||
cCoords, coords2D.c_str(), scaleUni, dColor);
|
||||
|
||||
switch (displacementMap.xChannelSelector()) {
|
||||
|
@ -1880,7 +1880,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
normalBody.c_str(),
|
||||
&normalName);
|
||||
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppend("\t\thalf m[9];\n");
|
||||
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
@ -2060,7 +2060,7 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHand
|
||||
};
|
||||
SkString lightBody;
|
||||
lightBody.appendf("\thalf3 halfDir = half3(normalize(surfaceToLight + half3(0, 0, 1)));\n");
|
||||
lightBody.appendf("\thighfloat colorScale = %s * pow(dot(normal, halfDir), %s);\n",
|
||||
lightBody.appendf("\tfloat colorScale = %s * pow(dot(normal, halfDir), %s);\n",
|
||||
ks, shininess);
|
||||
lightBody.appendf("\thalf3 color = lightColor * clamp(colorScale, 0.0, 1.0);\n");
|
||||
lightBody.appendf("\treturn half4(color, max(max(color.r, color.g), color.b));\n");
|
||||
|
@ -193,13 +193,13 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 zoom_coord = %s + %s * %s;\n",
|
||||
fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppendf("\t\tfloat2 zoom_coord = %s + %s * %s;\n",
|
||||
uniformHandler->getUniformCStr(fOffsetVar),
|
||||
coords2D.c_str(),
|
||||
uniformHandler->getUniformCStr(fInvZoomVar));
|
||||
const char* bounds = uniformHandler->getUniformCStr(fBoundsVar);
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
|
||||
fragBuilder->codeAppendf("\t\tfloat2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
|
||||
fragBuilder->codeAppendf("\t\tdelta = min(delta, half2(1.0, 1.0) - delta);\n");
|
||||
fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
|
||||
uniformHandler->getUniformCStr(fInvInsetVar));
|
||||
@ -211,11 +211,11 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n");
|
||||
fragBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n");
|
||||
fragBuilder->codeAppend("\t\t} else {\n");
|
||||
fragBuilder->codeAppend("\t\t\thighfloat2 delta_squared = delta * delta;\n");
|
||||
fragBuilder->codeAppend("\t\t\tfloat2 delta_squared = delta * delta;\n");
|
||||
fragBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n");
|
||||
fragBuilder->codeAppend("\t\t}\n");
|
||||
|
||||
fragBuilder->codeAppend("\t\thighfloat2 mix_coord = mix(coord, zoom_coord, weight);\n");
|
||||
fragBuilder->codeAppend("\t\tfloat2 mix_coord = mix(coord, zoom_coord, weight);\n");
|
||||
fragBuilder->codeAppend("\t\thalf4 output_color = ");
|
||||
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "mix_coord", kHalf2_GrSLType,
|
||||
&fColorSpaceHelper);
|
||||
|
@ -214,7 +214,7 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fPixelSizeUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "PixelSize");
|
||||
const char* pixelSizeInc = uniformHandler->getUniformCStr(fPixelSizeUni);
|
||||
fRangeUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHighFloat2_GrSLType, "Range");
|
||||
fRangeUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2_GrSLType, "Range");
|
||||
const char* range = uniformHandler->getUniformCStr(fRangeUni);
|
||||
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -251,12 +251,12 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
|
||||
int width = me.width();
|
||||
|
||||
// float2 coord = coord2D;
|
||||
fragBuilder->codeAppendf("\t\thighfloat2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
|
||||
// coord.x -= radius * pixelSize;
|
||||
fragBuilder->codeAppendf("\t\tcoord.%s -= %d.0 * %s; \n", dir, me.radius(), pixelSizeInc);
|
||||
if (me.useRange()) {
|
||||
// highBound = min(highBound, coord.x + (width-1) * pixelSize);
|
||||
fragBuilder->codeAppendf("\t\thighfloat highBound = min(%s.y, coord.%s + %f * %s);",
|
||||
fragBuilder->codeAppendf("\t\tfloat highBound = min(%s.y, coord.%s + %f * %s);",
|
||||
range, dir, float(width - 1), pixelSizeInc);
|
||||
// coord.x = max(lowBound, coord.x);
|
||||
fragBuilder->codeAppendf("\t\tcoord.%s = max(%s.x, coord.%s);", dir, range, dir);
|
||||
|
@ -122,7 +122,7 @@ void PrimitiveProcessor::emitVertexShader(const GrCCPRCoverageProcessor& proc,
|
||||
const TexelBufferHandle& pointsBuffer,
|
||||
const char* rtAdjust, GrGPArgs* gpArgs) const {
|
||||
v->codeAppendf("int packedoffset = %s[%i];", proc.instanceAttrib(), proc.atlasOffsetIdx());
|
||||
v->codeAppend ("highfloat2 atlasoffset = highfloat2((packedoffset<<16) >> 16, "
|
||||
v->codeAppend ("float2 atlasoffset = float2((packedoffset<<16) >> 16, "
|
||||
"packedoffset >> 16);");
|
||||
|
||||
this->onEmitVertexShader(proc, v, pointsBuffer, "atlasoffset", rtAdjust, gpArgs);
|
||||
@ -135,9 +135,9 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
|
||||
|
||||
SkString emitVertexFn;
|
||||
SkSTArray<2, GrShaderVar> emitArgs;
|
||||
const char* position = emitArgs.emplace_back("position", kHighFloat2_GrSLType,
|
||||
const char* position = emitArgs.emplace_back("position", kFloat2_GrSLType,
|
||||
GrShaderVar::kNonArray).c_str();
|
||||
const char* coverage = emitArgs.emplace_back("coverage", kHighFloat_GrSLType,
|
||||
const char* coverage = emitArgs.emplace_back("coverage", kFloat_GrSLType,
|
||||
GrShaderVar::kNonArray).c_str();
|
||||
g->emitFunction(kVoid_GrSLType, "emitVertex", emitArgs.count(), emitArgs.begin(), [&]() {
|
||||
SkString fnBody;
|
||||
@ -149,12 +149,12 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
|
||||
fnBody.appendf("%s = %s * %s;",
|
||||
fFragCoverageTimesWind.gsOut(), coverage, fGeomWind.c_str());
|
||||
}
|
||||
fnBody.append ("gl_Position = highfloat4(position, 0, 1);");
|
||||
fnBody.append ("gl_Position = float4(position, 0, 1);");
|
||||
fnBody.append ("EmitVertex();");
|
||||
return fnBody;
|
||||
}().c_str(), &emitVertexFn);
|
||||
|
||||
g->codeAppendf("highfloat2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
|
||||
g->codeAppendf("float2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
if (proc.debugVisualizationsEnabled()) {
|
||||
@ -171,7 +171,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
|
||||
SkASSERT(numSides >= 3);
|
||||
|
||||
if (!midpoint) {
|
||||
g->codeAppendf("highfloat2 midpoint = %s * highfloat%i(%f);",
|
||||
g->codeAppendf("float2 midpoint = %s * float%i(%f);",
|
||||
polygonPts, numSides, 1.0 / numSides);
|
||||
midpoint = "midpoint";
|
||||
}
|
||||
@ -180,42 +180,42 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
|
||||
"nextidx = (%s + 1) %% %i;",
|
||||
wedgeIdx, numSides - 1, numSides, wedgeIdx, numSides);
|
||||
|
||||
g->codeAppendf("highfloat2 self = %s[%s];"
|
||||
g->codeAppendf("float2 self = %s[%s];"
|
||||
"int leftidx = %s > 0 ? previdx : nextidx;"
|
||||
"int rightidx = %s > 0 ? nextidx : previdx;",
|
||||
polygonPts, wedgeIdx, fGeomWind.c_str(), fGeomWind.c_str());
|
||||
|
||||
// Which quadrant does the vector from self -> right fall into?
|
||||
g->codeAppendf("highfloat2 right = %s[rightidx];", polygonPts);
|
||||
g->codeAppendf("float2 right = %s[rightidx];", polygonPts);
|
||||
if (3 == numSides) {
|
||||
// TODO: evaluate perf gains.
|
||||
g->codeAppend ("highfloat2 qsr = sign(right - self);");
|
||||
g->codeAppend ("float2 qsr = sign(right - self);");
|
||||
} else {
|
||||
SkASSERT(4 == numSides);
|
||||
g->codeAppendf("highfloat2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
|
||||
g->codeAppend ("highfloat2 qsr = sign((right != self ? right : diag) - self);");
|
||||
g->codeAppendf("float2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
|
||||
g->codeAppend ("float2 qsr = sign((right != self ? right : diag) - self);");
|
||||
}
|
||||
|
||||
// Which quadrant does the vector from left -> self fall into?
|
||||
g->codeAppendf("highfloat2 qls = sign(self - %s[leftidx]);", polygonPts);
|
||||
g->codeAppendf("float2 qls = sign(self - %s[leftidx]);", polygonPts);
|
||||
|
||||
// d2 just helps us reduce triangle counts with orthogonal, axis-aligned lines.
|
||||
// TODO: evaluate perf gains.
|
||||
const char* dr2 = "dr";
|
||||
if (3 == numSides) {
|
||||
// TODO: evaluate perf gains.
|
||||
g->codeAppend ("highfloat2 dr = highfloat2(qsr.y != 0 ? +qsr.y : +qsr.x, "
|
||||
g->codeAppend ("float2 dr = float2(qsr.y != 0 ? +qsr.y : +qsr.x, "
|
||||
"qsr.x != 0 ? -qsr.x : +qsr.y);");
|
||||
g->codeAppend ("highfloat2 dr2 = highfloat2(qsr.y != 0 ? +qsr.y : -qsr.x, "
|
||||
g->codeAppend ("float2 dr2 = float2(qsr.y != 0 ? +qsr.y : -qsr.x, "
|
||||
"qsr.x != 0 ? -qsr.x : -qsr.y);");
|
||||
g->codeAppend ("highfloat2 dl = highfloat2(qls.y != 0 ? +qls.y : +qls.x, "
|
||||
g->codeAppend ("float2 dl = float2(qls.y != 0 ? +qls.y : +qls.x, "
|
||||
"qls.x != 0 ? -qls.x : +qls.y);");
|
||||
dr2 = "dr2";
|
||||
} else {
|
||||
g->codeAppend ("highfloat2 dr = highfloat2(qsr.y != 0 ? +qsr.y : 1, "
|
||||
g->codeAppend ("float2 dr = float2(qsr.y != 0 ? +qsr.y : 1, "
|
||||
"qsr.x != 0 ? -qsr.x : 1);");
|
||||
g->codeAppend ("highfloat2 dl = (qls == highfloat2(0)) ? dr : "
|
||||
"highfloat2(qls.y != 0 ? +qls.y : 1, qls.x != 0 ? -qls.x : 1);");
|
||||
g->codeAppend ("float2 dl = (qls == float2(0)) ? dr : "
|
||||
"float2(qls.y != 0 ? +qls.y : 1, qls.x != 0 ? -qls.x : 1);");
|
||||
}
|
||||
g->codeAppendf("bool2 dnotequal = notEqual(%s, dl);", dr2);
|
||||
|
||||
@ -228,7 +228,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
|
||||
g->codeAppendf( "%s(self + bloat * dl, 1);", emitVertexFn);
|
||||
g->codeAppend ("}");
|
||||
g->codeAppend ("if (all(dnotequal)) {");
|
||||
g->codeAppendf( "%s(self + bloat * highfloat2(-dl.y, dl.x), 1);", emitVertexFn);
|
||||
g->codeAppendf( "%s(self + bloat * float2(-dl.y, dl.x), 1);", emitVertexFn);
|
||||
g->codeAppend ("}");
|
||||
g->codeAppend ("EndPrimitive();");
|
||||
|
||||
@ -239,18 +239,18 @@ int PrimitiveProcessor::emitEdgeGeometry(GrGLSLGeometryBuilder* g, const char* e
|
||||
const char* leftPt, const char* rightPt,
|
||||
const char* distanceEquation) const {
|
||||
if (!distanceEquation) {
|
||||
this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highfloat3 edge_distance_equation");
|
||||
this->emitEdgeDistanceEquation(g, leftPt, rightPt, "float3 edge_distance_equation");
|
||||
distanceEquation = "edge_distance_equation";
|
||||
}
|
||||
|
||||
// qlr is defined in emitEdgeDistanceEquation.
|
||||
g->codeAppendf("highfloat2x2 endpts = highfloat2x2(%s - bloat * qlr, %s + bloat * qlr);",
|
||||
g->codeAppendf("float2x2 endpts = float2x2(%s - bloat * qlr, %s + bloat * qlr);",
|
||||
leftPt, rightPt);
|
||||
g->codeAppendf("half2 endpts_coverage = %s.xy * endpts + %s.z;",
|
||||
distanceEquation, distanceEquation);
|
||||
|
||||
// d1 is defined in emitEdgeDistanceEquation.
|
||||
g->codeAppend ("highfloat2 d2 = d1;");
|
||||
g->codeAppend ("float2 d2 = d1;");
|
||||
g->codeAppend ("bool aligned = qlr.x == 0 || qlr.y == 0;");
|
||||
g->codeAppend ("if (aligned) {");
|
||||
g->codeAppend ( "d1 -= qlr;");
|
||||
@ -279,25 +279,25 @@ void PrimitiveProcessor::emitEdgeDistanceEquation(GrGLSLGeometryBuilder* g,
|
||||
const char* leftPt, const char* rightPt,
|
||||
const char* outputDistanceEquation) const {
|
||||
// Which quadrant does the vector from left -> right fall into?
|
||||
g->codeAppendf("highfloat2 qlr = sign(%s - %s);", rightPt, leftPt);
|
||||
g->codeAppend ("highfloat2 d1 = highfloat2(qlr.y, -qlr.x);");
|
||||
g->codeAppendf("float2 qlr = sign(%s - %s);", rightPt, leftPt);
|
||||
g->codeAppend ("float2 d1 = float2(qlr.y, -qlr.x);");
|
||||
|
||||
g->codeAppendf("highfloat2 n = highfloat2(%s.y - %s.y, %s.x - %s.x);",
|
||||
g->codeAppendf("float2 n = float2(%s.y - %s.y, %s.x - %s.x);",
|
||||
rightPt, leftPt, leftPt, rightPt);
|
||||
g->codeAppendf("highfloat2 kk = n * highfloat2x2(%s + bloat * d1, %s - bloat * d1);",
|
||||
g->codeAppendf("float2 kk = n * float2x2(%s + bloat * d1, %s - bloat * d1);",
|
||||
leftPt, leftPt);
|
||||
// Clamp for when n=0. wind=0 when n=0 so as long as we don't get Inf or NaN we are fine.
|
||||
g->codeAppendf("highfloat scale = 1 / max(kk[0] - kk[1], 1e-30);");
|
||||
g->codeAppendf("float scale = 1 / max(kk[0] - kk[1], 1e-30);");
|
||||
|
||||
g->codeAppendf("%s = half3(-n, kk[1]) * scale;", outputDistanceEquation);
|
||||
}
|
||||
|
||||
int PrimitiveProcessor::emitCornerGeometry(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
|
||||
const char* pt) const {
|
||||
g->codeAppendf("%s(%s + highfloat2(-bloat.x, -bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + highfloat2(-bloat.x, +bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + highfloat2(+bloat.x, -bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + highfloat2(+bloat.x, +bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + float2(-bloat.x, -bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + float2(-bloat.x, +bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + float2(+bloat.x, -bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppendf("%s(%s + float2(+bloat.x, +bloat.y), 1);", emitVertexFn, pt);
|
||||
g->codeAppend ("EndPrimitive();");
|
||||
|
||||
return 4;
|
||||
@ -332,17 +332,17 @@ int PrimitiveProcessor::defineSoftSampleLocations(GrGLSLFragmentBuilder* f,
|
||||
const char* samplesName) const {
|
||||
// Standard DX11 sample locations.
|
||||
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
|
||||
f->defineConstant("highfloat2[8]", samplesName, "highfloat2[8]("
|
||||
"highfloat2(+1, -3)/16, highfloat2(-1, +3)/16, highfloat2(+5, +1)/16, highfloat2(-3, -5)/16, "
|
||||
"highfloat2(-5, +5)/16, highfloat2(-7, -1)/16, highfloat2(+3, +7)/16, highfloat2(+7, -7)/16."
|
||||
f->defineConstant("float2[8]", samplesName, "float2[8]("
|
||||
"float2(+1, -3)/16, float2(-1, +3)/16, float2(+5, +1)/16, float2(-3, -5)/16, "
|
||||
"float2(-5, +5)/16, float2(-7, -1)/16, float2(+3, +7)/16, float2(+7, -7)/16."
|
||||
")");
|
||||
return 8;
|
||||
#else
|
||||
f->defineConstant("highfloat2[16]", samplesName, "highfloat2[16]("
|
||||
"highfloat2(+1, +1)/16, highfloat2(-1, -3)/16, highfloat2(-3, +2)/16, highfloat2(+4, -1)/16, "
|
||||
"highfloat2(-5, -2)/16, highfloat2(+2, +5)/16, highfloat2(+5, +3)/16, highfloat2(+3, -5)/16, "
|
||||
"highfloat2(-2, +6)/16, highfloat2( 0, -7)/16, highfloat2(-4, -6)/16, highfloat2(-6, +4)/16, "
|
||||
"highfloat2(-8, 0)/16, highfloat2(+7, -4)/16, highfloat2(+6, +7)/16, highfloat2(-7, -8)/16."
|
||||
f->defineConstant("float2[16]", samplesName, "float2[16]("
|
||||
"float2(+1, +1)/16, float2(-1, -3)/16, float2(-3, +2)/16, float2(+4, -1)/16, "
|
||||
"float2(-5, -2)/16, float2(+2, +5)/16, float2(+5, +3)/16, float2(+3, -5)/16, "
|
||||
"float2(-2, +6)/16, float2( 0, -7)/16, float2(-4, -6)/16, float2(-6, +4)/16, "
|
||||
"float2(-8, 0)/16, float2(+7, -4)/16, float2(+6, +7)/16, float2(-7, -8)/16."
|
||||
")");
|
||||
return 16;
|
||||
#endif
|
||||
|
@ -16,18 +16,18 @@ void GrCCPRCubicProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor& pro
|
||||
const TexelBufferHandle& pointsBuffer,
|
||||
const char* atlasOffset, const char* rtAdjust,
|
||||
GrGPArgs* gpArgs) const {
|
||||
v->codeAppend ("highfloat2 self = ");
|
||||
v->codeAppend ("float2 self = ");
|
||||
v->appendTexelFetch(pointsBuffer,
|
||||
SkStringPrintf("%s.x + sk_VertexID", proc.instanceAttrib()).c_str());
|
||||
v->codeAppendf(".xy + %s;", atlasOffset);
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "self");
|
||||
}
|
||||
|
||||
void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
|
||||
const char* outputWind) const {
|
||||
// We will define bezierpts in onEmitGeometryShader.
|
||||
g->codeAppend ("highfloat area_times_2 = "
|
||||
"determinant(highfloat3x3(1, bezierpts[0], "
|
||||
g->codeAppend ("float area_times_2 = "
|
||||
"determinant(float3x3(1, bezierpts[0], "
|
||||
"1, bezierpts[2], "
|
||||
"0, bezierpts[3] - bezierpts[1]));");
|
||||
// Drop curves that are nearly flat. The KLM math becomes unstable in this case.
|
||||
@ -46,59 +46,59 @@ void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdju
|
||||
void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
|
||||
const char* wind, const char* rtAdjust) const {
|
||||
// Prepend bezierpts at the start of the shader.
|
||||
g->codePrependf("highfloat4x2 bezierpts = highfloat4x2(sk_in[0].gl_Position.xy, "
|
||||
g->codePrependf("float4x2 bezierpts = float4x2(sk_in[0].gl_Position.xy, "
|
||||
"sk_in[1].gl_Position.xy, "
|
||||
"sk_in[2].gl_Position.xy, "
|
||||
"sk_in[3].gl_Position.xy);");
|
||||
|
||||
// Evaluate the cubic at T=.5 for an mid-ish point.
|
||||
g->codeAppendf("highfloat2 midpoint = bezierpts * highfloat4(.125, .375, .375, .125);");
|
||||
g->codeAppendf("float2 midpoint = bezierpts * float4(.125, .375, .375, .125);");
|
||||
|
||||
// Find the cubic's power basis coefficients.
|
||||
g->codeAppend ("highfloat2x4 C = highfloat4x4(-1, 3, -3, 1, "
|
||||
g->codeAppend ("float2x4 C = float4x4(-1, 3, -3, 1, "
|
||||
" 3, -6, 3, 0, "
|
||||
"-3, 3, 0, 0, "
|
||||
" 1, 0, 0, 0) * transpose(bezierpts);");
|
||||
|
||||
// Find the cubic's inflection function.
|
||||
g->codeAppend ("highfloat D3 = +determinant(highfloat2x2(C[0].yz, C[1].yz));");
|
||||
g->codeAppend ("highfloat D2 = -determinant(highfloat2x2(C[0].xz, C[1].xz));");
|
||||
g->codeAppend ("highfloat D1 = +determinant(highfloat2x2(C));");
|
||||
g->codeAppend ("float D3 = +determinant(float2x2(C[0].yz, C[1].yz));");
|
||||
g->codeAppend ("float D2 = -determinant(float2x2(C[0].xz, C[1].xz));");
|
||||
g->codeAppend ("float D1 = +determinant(float2x2(C));");
|
||||
|
||||
// Calculate the KLM matrix.
|
||||
g->declareGlobal(fKLMMatrix);
|
||||
g->codeAppend ("highfloat4 K, L, M;");
|
||||
g->codeAppend ("highfloat2 l, m;");
|
||||
g->codeAppend ("highfloat discr = 3*D2*D2 - 4*D1*D3;");
|
||||
g->codeAppend ("float4 K, L, M;");
|
||||
g->codeAppend ("float2 l, m;");
|
||||
g->codeAppend ("float discr = 3*D2*D2 - 4*D1*D3;");
|
||||
if (CubicType::kSerpentine == fCubicType) {
|
||||
// This math also works out for the "cusp" and "cusp at infinity" cases.
|
||||
g->codeAppend ("highfloat q = 3*D2 + sign(D2) * sqrt(max(3*discr, 0));");
|
||||
g->codeAppend ("l.ts = normalize(highfloat2(q, 6*D1));");
|
||||
g->codeAppend ("m.ts = discr <= 0 ? l.ts : normalize(highfloat2(2*D3, q));");
|
||||
g->codeAppend ("K = highfloat4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
|
||||
g->codeAppend ("L = highfloat4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
|
||||
g->codeAppend ("M = highfloat4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
|
||||
g->codeAppend ("float q = 3*D2 + sign(D2) * sqrt(max(3*discr, 0));");
|
||||
g->codeAppend ("l.ts = normalize(float2(q, 6*D1));");
|
||||
g->codeAppend ("m.ts = discr <= 0 ? l.ts : normalize(float2(2*D3, q));");
|
||||
g->codeAppend ("K = float4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
|
||||
g->codeAppend ("L = float4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
|
||||
g->codeAppend ("M = float4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
|
||||
} else {
|
||||
g->codeAppend ("highfloat q = D2 + sign(D2) * sqrt(max(-discr, 0));");
|
||||
g->codeAppend ("l.ts = normalize(highfloat2(q, 2*D1));");
|
||||
g->codeAppend ("m.ts = discr >= 0 ? l.ts : normalize(highfloat2(2 * (D2*D2 - D3*D1), D1*q));");
|
||||
g->codeAppend ("highfloat4 lxm = highfloat4(l.s * m.s, l.s * m.t, l.t * m.s, l.t * m.t);");
|
||||
g->codeAppend ("K = highfloat4(0, lxm.x, -lxm.y - lxm.z, lxm.w);");
|
||||
g->codeAppend ("L = highfloat4(-1,1,-1,1) * l.sstt * (lxm.xyzw + highfloat4(0, 2*lxm.zy, 0));");
|
||||
g->codeAppend ("M = highfloat4(-1,1,-1,1) * m.sstt * (lxm.xzyw + highfloat4(0, 2*lxm.yz, 0));");
|
||||
g->codeAppend ("float q = D2 + sign(D2) * sqrt(max(-discr, 0));");
|
||||
g->codeAppend ("l.ts = normalize(float2(q, 2*D1));");
|
||||
g->codeAppend ("m.ts = discr >= 0 ? l.ts : normalize(float2(2 * (D2*D2 - D3*D1), D1*q));");
|
||||
g->codeAppend ("float4 lxm = float4(l.s * m.s, l.s * m.t, l.t * m.s, l.t * m.t);");
|
||||
g->codeAppend ("K = float4(0, lxm.x, -lxm.y - lxm.z, lxm.w);");
|
||||
g->codeAppend ("L = float4(-1,1,-1,1) * l.sstt * (lxm.xyzw + float4(0, 2*lxm.zy, 0));");
|
||||
g->codeAppend ("M = float4(-1,1,-1,1) * m.sstt * (lxm.xzyw + float4(0, 2*lxm.yz, 0));");
|
||||
}
|
||||
g->codeAppend ("short middlerow = abs(D2) > abs(D1) ? 2 : 1;");
|
||||
g->codeAppend ("highfloat3x3 CI = inverse(highfloat3x3(C[0][0], C[0][middlerow], C[0][3], "
|
||||
g->codeAppend ("float3x3 CI = inverse(float3x3(C[0][0], C[0][middlerow], C[0][3], "
|
||||
"C[1][0], C[1][middlerow], C[1][3], "
|
||||
" 0, 0, 1));");
|
||||
g->codeAppendf("%s = CI * highfloat3x3(K[0], K[middlerow], K[3], "
|
||||
g->codeAppendf("%s = CI * float3x3(K[0], K[middlerow], K[3], "
|
||||
"L[0], L[middlerow], L[3], "
|
||||
"M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
|
||||
|
||||
// Orient the KLM matrix so we fill the correct side of the curve.
|
||||
g->codeAppendf("half2 orientation = sign(half3(midpoint, 1) * half2x3(%s[1], %s[2]));",
|
||||
fKLMMatrix.c_str(), fKLMMatrix.c_str());
|
||||
g->codeAppendf("%s *= highfloat3x3(orientation[0] * orientation[1], 0, 0, "
|
||||
g->codeAppendf("%s *= float3x3(orientation[0] * orientation[1], 0, 0, "
|
||||
"0, orientation[0], 0, "
|
||||
"0, 0, orientation[1]);", fKLMMatrix.c_str());
|
||||
|
||||
@ -113,8 +113,8 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
|
||||
// Determine the amount of additional coverage to subtract out for the flat edge (P3 -> P0).
|
||||
g->declareGlobal(fEdgeDistanceEquation);
|
||||
g->codeAppendf("short edgeidx0 = %s > 0 ? 3 : 0;", wind);
|
||||
g->codeAppendf("highfloat2 edgept0 = bezierpts[edgeidx0];");
|
||||
g->codeAppendf("highfloat2 edgept1 = bezierpts[3 - edgeidx0];");
|
||||
g->codeAppendf("float2 edgept0 = bezierpts[edgeidx0];");
|
||||
g->codeAppendf("float2 edgept1 = bezierpts[3 - edgeidx0];");
|
||||
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
|
||||
|
||||
this->emitCubicGeometry(g, emitVertexFn, wind, rtAdjust);
|
||||
@ -123,10 +123,10 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
|
||||
void GrCCPRCubicProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
|
||||
const char* /*coverage*/,
|
||||
const char* /*wind*/) const {
|
||||
fnBody->appendf("highfloat3 klm = highfloat3(%s, 1) * %s;", position, fKLMMatrix.c_str());
|
||||
fnBody->appendf("highfloat d = dot(highfloat3(%s, 1), %s);",
|
||||
fnBody->appendf("float3 klm = float3(%s, 1) * %s;", position, fKLMMatrix.c_str());
|
||||
fnBody->appendf("float d = dot(float3(%s, 1), %s);",
|
||||
position, fEdgeDistanceEquation.c_str());
|
||||
fnBody->appendf("%s = highfloat4(klm, d);", fKLMD.gsOut());
|
||||
fnBody->appendf("%s = float4(klm, d);", fKLMD.gsOut());
|
||||
this->onEmitPerVertexGeometryCode(fnBody);
|
||||
}
|
||||
|
||||
@ -150,10 +150,10 @@ void GrCCPRCubicHullProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) con
|
||||
|
||||
void GrCCPRCubicHullProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
|
||||
const char* outputCoverage) const {
|
||||
f->codeAppendf("highfloat k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
|
||||
f->codeAppendf("float k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
|
||||
fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn());
|
||||
f->codeAppend ("highfloat f = k*k*k - l*m;");
|
||||
f->codeAppendf("highfloat2 grad_f = %s * highfloat2(k, 1);", fGradMatrix.fsIn());
|
||||
f->codeAppend ("float f = k*k*k - l*m;");
|
||||
f->codeAppendf("float2 grad_f = %s * float2(k, 1);", fGradMatrix.fsIn());
|
||||
f->codeAppendf("%s = clamp(0.5 - f * inversesqrt(dot(grad_f, grad_f)), 0, 1);", outputCoverage);
|
||||
f->codeAppendf("%s += min(d, 0);", outputCoverage); // Flat closing edge.
|
||||
}
|
||||
@ -166,7 +166,7 @@ void GrCCPRCubicCornerProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
|
||||
g->codeAppendf("%s = %s.xy * %s.xz;",
|
||||
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
|
||||
|
||||
g->codeAppendf("highfloat2 corner = bezierpts[sk_InvocationID * 3];");
|
||||
g->codeAppendf("float2 corner = bezierpts[sk_InvocationID * 3];");
|
||||
int numVertices = this->emitCornerGeometry(g, emitVertexFn, "corner");
|
||||
|
||||
g->configure(GrGLSLGeometryBuilder::InputType::kLinesAdjacency,
|
||||
@ -174,10 +174,10 @@ void GrCCPRCubicCornerProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
|
||||
}
|
||||
|
||||
void GrCCPRCubicCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
|
||||
fnBody->appendf("%s = highfloat4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
|
||||
fnBody->appendf("%s = float4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
|
||||
fdKLMDdx.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
|
||||
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
|
||||
fnBody->appendf("%s = highfloat4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
|
||||
fnBody->appendf("%s = float4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
|
||||
fdKLMDdy.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
|
||||
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
|
||||
|
||||
@ -187,25 +187,25 @@ void GrCCPRCubicCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) c
|
||||
|
||||
void GrCCPRCubicCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
|
||||
const char* outputCoverage) const {
|
||||
f->codeAppendf("highfloat2x4 grad_klmd = highfloat2x4(%s, %s);",
|
||||
f->codeAppendf("float2x4 grad_klmd = float2x4(%s, %s);",
|
||||
fdKLMDdx.fsIn(), fdKLMDdy.fsIn());
|
||||
|
||||
// Erase what the previous hull shader wrote. We don't worry about the two corners falling on
|
||||
// the same pixel because those cases should have been weeded out by this point.
|
||||
f->codeAppendf("highfloat k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
|
||||
f->codeAppendf("float k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
|
||||
fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn());
|
||||
f->codeAppend ("highfloat f = k*k*k - l*m;");
|
||||
f->codeAppend ("highfloat2 grad_f = highfloat3(3*k*k, -m, -l) * highfloat2x3(grad_klmd);");
|
||||
f->codeAppend ("float f = k*k*k - l*m;");
|
||||
f->codeAppend ("float2 grad_f = float3(3*k*k, -m, -l) * float2x3(grad_klmd);");
|
||||
f->codeAppendf("%s = -clamp(0.5 - f * inversesqrt(dot(grad_f, grad_f)), 0, 1);",
|
||||
outputCoverage);
|
||||
f->codeAppendf("%s -= d;", outputCoverage);
|
||||
|
||||
// Use software msaa to estimate actual coverage at the corner pixels.
|
||||
const int sampleCount = this->defineSoftSampleLocations(f, "samples");
|
||||
f->codeAppendf("highfloat4 klmd_center = highfloat4(%s.xyz, %s.w + 0.5);",
|
||||
f->codeAppendf("float4 klmd_center = float4(%s.xyz, %s.w + 0.5);",
|
||||
fKLMD.fsIn(), fKLMD.fsIn());
|
||||
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
|
||||
f->codeAppend ( "highfloat4 klmd = grad_klmd * samples[i] + klmd_center;");
|
||||
f->codeAppend ( "float4 klmd = grad_klmd * samples[i] + klmd_center;");
|
||||
f->codeAppend ( "half f = klmd.y * klmd.z - klmd.x * klmd.x * klmd.x;");
|
||||
f->codeAppendf( "%s += all(greaterThan(half4(f, klmd.y, klmd.z, klmd.w), "
|
||||
"half4(0))) ? %f : 0;",
|
||||
|
@ -33,12 +33,12 @@ public:
|
||||
GrCCPRCubicProcessor(CubicType cubicType)
|
||||
: INHERITED(CoverageType::kShader)
|
||||
, fCubicType(cubicType)
|
||||
, fKLMMatrix("klm_matrix", kHighFloat3x3_GrSLType, GrShaderVar::kNonArray,
|
||||
, fKLMMatrix("klm_matrix", kFloat3x3_GrSLType, GrShaderVar::kNonArray,
|
||||
kHigh_GrSLPrecision)
|
||||
, fKLMDerivatives("klm_derivatives", kHighFloat2_GrSLType, 3, kHigh_GrSLPrecision)
|
||||
, fEdgeDistanceEquation("edge_distance_equation", kHighFloat3_GrSLType,
|
||||
, fKLMDerivatives("klm_derivatives", kFloat2_GrSLType, 3, kHigh_GrSLPrecision)
|
||||
, fEdgeDistanceEquation("edge_distance_equation", kFloat3_GrSLType,
|
||||
GrShaderVar::kNonArray, kHigh_GrSLPrecision)
|
||||
, fKLMD(kHighFloat4_GrSLType) {}
|
||||
, fKLMD(kFloat4_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
varyingHandler->addVarying("klmd", &fKLMD, kHigh_GrSLPrecision);
|
||||
@ -71,7 +71,7 @@ class GrCCPRCubicHullProcessor : public GrCCPRCubicProcessor {
|
||||
public:
|
||||
GrCCPRCubicHullProcessor(CubicType cubicType)
|
||||
: INHERITED(cubicType)
|
||||
, fGradMatrix(kHighFloat2x2_GrSLType) {}
|
||||
, fGradMatrix(kFloat2x2_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
this->INHERITED::resetVaryings(varyingHandler);
|
||||
@ -93,10 +93,10 @@ class GrCCPRCubicCornerProcessor : public GrCCPRCubicProcessor {
|
||||
public:
|
||||
GrCCPRCubicCornerProcessor(CubicType cubicType)
|
||||
: INHERITED(cubicType)
|
||||
, fEdgeDistanceDerivatives("edge_distance_derivatives", kHighFloat2_GrSLType,
|
||||
, fEdgeDistanceDerivatives("edge_distance_derivatives", kFloat2_GrSLType,
|
||||
GrShaderVar::kNonArray, kHigh_GrSLPrecision)
|
||||
, fdKLMDdx(kHighFloat4_GrSLType)
|
||||
, fdKLMDdy(kHighFloat4_GrSLType) {}
|
||||
, fdKLMDdx(kFloat4_GrSLType)
|
||||
, fdKLMDdy(kFloat4_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
this->INHERITED::resetVaryings(varyingHandler);
|
||||
|
@ -121,11 +121,11 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const char* atlasAdjust;
|
||||
fAtlasAdjustUniform = uniHandler->addUniform(
|
||||
kVertex_GrShaderFlag,
|
||||
kHighFloat2_GrSLType, "atlas_adjust", &atlasAdjust);
|
||||
kFloat2_GrSLType, "atlas_adjust", &atlasAdjust);
|
||||
|
||||
varyingHandler->emitAttributes(proc);
|
||||
|
||||
GrGLSLVertToFrag texcoord(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag texcoord(kFloat2_GrSLType);
|
||||
GrGLSLVertToFrag color(kHalf4_GrSLType);
|
||||
varyingHandler->addVarying("texcoord", &texcoord, kHigh_GrSLPrecision);
|
||||
varyingHandler->addFlatPassThroughAttribute(&proc.getInstanceAttrib(InstanceAttribs::kColor),
|
||||
@ -137,41 +137,41 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
// Find the intersections of (bloated) devBounds and devBounds45 in order to come up with an
|
||||
// octagon that circumscribes the (bloated) path. A vertex is the intersection of two lines:
|
||||
// one edge from the path's bounding box and one edge from its 45-degree bounding box.
|
||||
v->codeAppendf("highfloat2x2 N = highfloat2x2(%s);", proc.getEdgeNormsAttrib().fName);
|
||||
v->codeAppendf("float2x2 N = float2x2(%s);", proc.getEdgeNormsAttrib().fName);
|
||||
|
||||
// N[0] is the normal for the edge we are intersecting from the regular bounding box, pointing
|
||||
// out of the octagon.
|
||||
v->codeAppendf("highfloat2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
|
||||
v->codeAppendf("float2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
|
||||
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName,
|
||||
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName);
|
||||
v->codeAppendf("refpt += N[0] * %f;", kAABloatRadius); // bloat for AA.
|
||||
|
||||
// N[1] is the normal for the edge we are intersecting from the 45-degree bounding box, pointing
|
||||
// out of the octagon.
|
||||
v->codeAppendf("highfloat2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
|
||||
v->codeAppendf("float2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
|
||||
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName,
|
||||
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName);
|
||||
v->codeAppendf("refpt45 *= highfloat2x2(.5,.5,-.5,.5);"); // transform back to device space.
|
||||
v->codeAppendf("refpt45 *= float2x2(.5,.5,-.5,.5);"); // transform back to device space.
|
||||
v->codeAppendf("refpt45 += N[1] * %f;", kAABloatRadius); // bloat for AA.
|
||||
|
||||
v->codeAppend ("highfloat2 K = highfloat2(dot(N[0], refpt), dot(N[1], refpt45));");
|
||||
v->codeAppendf("highfloat2 octocoord = K * inverse(N);");
|
||||
v->codeAppend ("float2 K = float2(dot(N[0], refpt), dot(N[1], refpt45));");
|
||||
v->codeAppendf("float2 octocoord = K * inverse(N);");
|
||||
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "octocoord");
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "octocoord");
|
||||
|
||||
// Convert to atlas coordinates in order to do our texture lookup.
|
||||
v->codeAppendf("highfloat2 atlascoord = octocoord + highfloat2(%s);",
|
||||
v->codeAppendf("float2 atlascoord = octocoord + float2(%s);",
|
||||
proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
|
||||
if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
|
||||
v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
|
||||
} else {
|
||||
SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlasProxy()->origin());
|
||||
v->codeAppendf("%s = highfloat2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
|
||||
v->codeAppendf("%s = float2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
|
||||
texcoord.vsOut(), atlasAdjust, atlasAdjust);
|
||||
}
|
||||
|
||||
// Convert to (local) path cordinates.
|
||||
v->codeAppendf("highfloat2 pathcoord = inverse(highfloat2x2(%s)) * (octocoord - %s);",
|
||||
v->codeAppendf("float2 pathcoord = inverse(float2x2(%s)) * (octocoord - %s);",
|
||||
proc.getInstanceAttrib(InstanceAttribs::kViewMatrix).fName,
|
||||
proc.getInstanceAttrib(InstanceAttribs::kViewTranslate).fName);
|
||||
|
||||
@ -182,7 +182,7 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
|
||||
|
||||
f->codeAppend ("half coverage_count = ");
|
||||
f->appendTextureLookup(args.fTexSamplers[0], texcoord.fsIn(), kHighFloat2_GrSLType);
|
||||
f->appendTextureLookup(args.fTexSamplers[0], texcoord.fsIn(), kFloat2_GrSLType);
|
||||
f->codeAppend (".a;");
|
||||
|
||||
if (SkPath::kWinding_FillType == proc.fillType()) {
|
||||
|
@ -16,19 +16,18 @@ void GrCCPRQuadraticProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
|
||||
const TexelBufferHandle& pointsBuffer,
|
||||
const char* atlasOffset, const char* rtAdjust,
|
||||
GrGPArgs* gpArgs) const {
|
||||
v->codeAppend ("highfloat2 self = ");
|
||||
v->codeAppend ("float2 self = ");
|
||||
v->appendTexelFetch(pointsBuffer,
|
||||
SkStringPrintf("%s.x + sk_VertexID", proc.instanceAttrib()).c_str());
|
||||
v->codeAppendf(".xy + %s;", atlasOffset);
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "self");
|
||||
}
|
||||
|
||||
void GrCCPRQuadraticProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
|
||||
const char* outputWind) const {
|
||||
// We will define bezierpts in onEmitGeometryShader.
|
||||
g->codeAppend ("highfloat area_times_2 = "
|
||||
"determinant(highfloat2x2(bezierpts[1] - bezierpts[0], "
|
||||
"bezierpts[2] - bezierpts[0]));");
|
||||
g->codeAppend ("float area_times_2 = determinant(float2x2(bezierpts[1] - bezierpts[0], "
|
||||
"bezierpts[2] - bezierpts[0]));");
|
||||
// Drop curves that are nearly flat, in favor of the higher quality triangle antialiasing.
|
||||
g->codeAppendf("if (2 * abs(area_times_2) < length((bezierpts[2] - bezierpts[0]) * %s.zx)) {",
|
||||
rtAdjust);
|
||||
@ -46,26 +45,26 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
|
||||
const char* emitVertexFn, const char* wind,
|
||||
const char* rtAdjust) const {
|
||||
// Prepend bezierpts at the start of the shader.
|
||||
g->codePrependf("highfloat3x2 bezierpts = highfloat3x2(sk_in[0].gl_Position.xy, "
|
||||
"sk_in[1].gl_Position.xy, "
|
||||
"sk_in[2].gl_Position.xy);");
|
||||
g->codePrependf("float3x2 bezierpts = float3x2(sk_in[0].gl_Position.xy, "
|
||||
"sk_in[1].gl_Position.xy, "
|
||||
"sk_in[2].gl_Position.xy);");
|
||||
|
||||
g->declareGlobal(fCanonicalMatrix);
|
||||
g->codeAppendf("%s = highfloat3x3(0.0, 0, 1, "
|
||||
"0.5, 0, 1, "
|
||||
"1.0, 1, 1) * "
|
||||
"inverse(highfloat3x3(bezierpts[0], 1, "
|
||||
"bezierpts[1], 1, "
|
||||
"bezierpts[2], 1));",
|
||||
g->codeAppendf("%s = float3x3(0.0, 0, 1, "
|
||||
"0.5, 0, 1, "
|
||||
"1.0, 1, 1) * "
|
||||
"inverse(float3x3(bezierpts[0], 1, "
|
||||
"bezierpts[1], 1, "
|
||||
"bezierpts[2], 1));",
|
||||
fCanonicalMatrix.c_str());
|
||||
|
||||
g->declareGlobal(fCanonicalDerivatives);
|
||||
g->codeAppendf("%s = highfloat2x2(%s) * highfloat2x2(%s.x, 0, 0, %s.z);",
|
||||
g->codeAppendf("%s = float2x2(%s) * float2x2(%s.x, 0, 0, %s.z);",
|
||||
fCanonicalDerivatives.c_str(), fCanonicalMatrix.c_str(), rtAdjust, rtAdjust);
|
||||
|
||||
g->declareGlobal(fEdgeDistanceEquation);
|
||||
g->codeAppendf("highfloat2 edgept0 = bezierpts[%s > 0 ? 2 : 0];", wind);
|
||||
g->codeAppendf("highfloat2 edgept1 = bezierpts[%s > 0 ? 0 : 2];", wind);
|
||||
g->codeAppendf("float2 edgept0 = bezierpts[%s > 0 ? 2 : 0];", wind);
|
||||
g->codeAppendf("float2 edgept1 = bezierpts[%s > 0 ? 0 : 2];", wind);
|
||||
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
|
||||
|
||||
this->emitQuadraticGeometry(g, emitVertexFn, rtAdjust);
|
||||
@ -74,7 +73,7 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
|
||||
void GrCCPRQuadraticProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
|
||||
const char* /*coverage*/,
|
||||
const char* /*wind*/) const {
|
||||
fnBody->appendf("%s.xy = (%s * highfloat3(%s, 1)).xy;",
|
||||
fnBody->appendf("%s.xy = (%s * float3(%s, 1)).xy;",
|
||||
fXYD.gsOut(), fCanonicalMatrix.c_str(), position);
|
||||
fnBody->appendf("%s.z = dot(%s.xy, %s) + %s.z;",
|
||||
fXYD.gsOut(), fEdgeDistanceEquation.c_str(), position,
|
||||
@ -87,18 +86,18 @@ void GrCCPRQuadraticHullProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder*
|
||||
const char* /*rtAdjust*/) const {
|
||||
// Find the t value whose tangent is halfway between the tangents at the endpionts.
|
||||
// (We defined bezierpts in onEmitGeometryShader.)
|
||||
g->codeAppend ("highfloat2 tan0 = bezierpts[1] - bezierpts[0];");
|
||||
g->codeAppend ("highfloat2 tan1 = bezierpts[2] - bezierpts[1];");
|
||||
g->codeAppend ("highfloat2 midnorm = normalize(tan0) - normalize(tan1);");
|
||||
g->codeAppend ("highfloat2 T = midnorm * highfloat2x2(tan0 - tan1, tan0);");
|
||||
g->codeAppend ("highfloat t = clamp(T.t / T.s, 0, 1);"); // T.s=0 is weeded out by this point.
|
||||
g->codeAppend ("float2 tan0 = bezierpts[1] - bezierpts[0];");
|
||||
g->codeAppend ("float2 tan1 = bezierpts[2] - bezierpts[1];");
|
||||
g->codeAppend ("float2 midnorm = normalize(tan0) - normalize(tan1);");
|
||||
g->codeAppend ("float2 T = midnorm * float2x2(tan0 - tan1, tan0);");
|
||||
g->codeAppend ("float t = clamp(T.t / T.s, 0, 1);"); // T.s=0 is weeded out by this point.
|
||||
|
||||
// Clip the bezier triangle by the tangent at our new t value. This is a simple application for
|
||||
// De Casteljau's algorithm.
|
||||
g->codeAppendf("highfloat4x2 quadratic_hull = highfloat4x2(bezierpts[0], "
|
||||
"bezierpts[0] + tan0 * t, "
|
||||
"bezierpts[1] + tan1 * t, "
|
||||
"bezierpts[2]);");
|
||||
g->codeAppendf("float4x2 quadratic_hull = float4x2(bezierpts[0], "
|
||||
"bezierpts[0] + tan0 * t, "
|
||||
"bezierpts[1] + tan1 * t, "
|
||||
"bezierpts[2]);");
|
||||
|
||||
int maxVerts = this->emitHullGeometry(g, emitVertexFn, "quadratic_hull", 4, "sk_InvocationID");
|
||||
|
||||
@ -108,13 +107,13 @@ void GrCCPRQuadraticHullProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder*
|
||||
}
|
||||
|
||||
void GrCCPRQuadraticHullProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
|
||||
fnBody->appendf("%s = highfloat2(2 * %s.x, -1) * %s;",
|
||||
fnBody->appendf("%s = float2(2 * %s.x, -1) * %s;",
|
||||
fGradXY.gsOut(), fXYD.gsOut(), fCanonicalDerivatives.c_str());
|
||||
}
|
||||
|
||||
void GrCCPRQuadraticHullProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
|
||||
const char* outputCoverage) const {
|
||||
f->codeAppendf("highfloat d = (%s.x * %s.x - %s.y) * inversesqrt(dot(%s, %s));",
|
||||
f->codeAppendf("float d = (%s.x * %s.x - %s.y) * inversesqrt(dot(%s, %s));",
|
||||
fXYD.fsIn(), fXYD.fsIn(), fXYD.fsIn(), fGradXY.fsIn(), fGradXY.fsIn());
|
||||
f->codeAppendf("%s = clamp(0.5 - d, 0, 1);", outputCoverage);
|
||||
f->codeAppendf("%s += min(%s.z, 0);", outputCoverage, fXYD.fsIn()); // Flat closing edge.
|
||||
@ -127,7 +126,7 @@ void GrCCPRQuadraticCornerProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder
|
||||
g->codeAppendf("%s = %s.xy * %s.xz;",
|
||||
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
|
||||
|
||||
g->codeAppendf("highfloat2 corner = bezierpts[sk_InvocationID * 2];");
|
||||
g->codeAppendf("float2 corner = bezierpts[sk_InvocationID * 2];");
|
||||
int numVertices = this->emitCornerGeometry(g, emitVertexFn, "corner");
|
||||
|
||||
g->configure(GrGLSLGeometryBuilder::InputType::kTriangles,
|
||||
@ -135,35 +134,35 @@ void GrCCPRQuadraticCornerProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder
|
||||
}
|
||||
|
||||
void GrCCPRQuadraticCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
|
||||
fnBody->appendf("%s = highfloat3(%s[0].x, %s[0].y, %s.x);",
|
||||
fnBody->appendf("%s = float3(%s[0].x, %s[0].y, %s.x);",
|
||||
fdXYDdx.gsOut(), fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
|
||||
fEdgeDistanceDerivatives.c_str());
|
||||
fnBody->appendf("%s = highfloat3(%s[1].x, %s[1].y, %s.y);",
|
||||
fnBody->appendf("%s = float3(%s[1].x, %s[1].y, %s.y);",
|
||||
fdXYDdy.gsOut(), fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
|
||||
fEdgeDistanceDerivatives.c_str());
|
||||
}
|
||||
|
||||
void GrCCPRQuadraticCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
|
||||
const char* outputCoverage) const {
|
||||
f->codeAppendf("highfloat x = %s.x, y = %s.y, d = %s.z;",
|
||||
f->codeAppendf("float x = %s.x, y = %s.y, d = %s.z;",
|
||||
fXYD.fsIn(), fXYD.fsIn(), fXYD.fsIn());
|
||||
f->codeAppendf("highfloat2x3 grad_xyd = highfloat2x3(%s, %s);", fdXYDdx.fsIn(), fdXYDdy.fsIn());
|
||||
f->codeAppendf("float2x3 grad_xyd = float2x3(%s, %s);", fdXYDdx.fsIn(), fdXYDdy.fsIn());
|
||||
|
||||
// Erase what the previous hull shader wrote. We don't worry about the two corners falling on
|
||||
// the same pixel because those cases should have been weeded out by this point.
|
||||
f->codeAppend ("highfloat f = x*x - y;");
|
||||
f->codeAppend ("highfloat2 grad_f = highfloat2(2*x, -1) * highfloat2x2(grad_xyd);");
|
||||
f->codeAppend ("float f = x*x - y;");
|
||||
f->codeAppend ("float2 grad_f = float2(2*x, -1) * float2x2(grad_xyd);");
|
||||
f->codeAppendf("%s = -(0.5 - f * inversesqrt(dot(grad_f, grad_f)));", outputCoverage);
|
||||
f->codeAppendf("%s -= d;", outputCoverage);
|
||||
|
||||
// Use software msaa to approximate coverage at the corner pixels.
|
||||
int sampleCount = this->defineSoftSampleLocations(f, "samples");
|
||||
f->codeAppendf("highfloat3 xyd_center = highfloat3(%s.xy, %s.z + 0.5);",
|
||||
f->codeAppendf("float3 xyd_center = float3(%s.xy, %s.z + 0.5);",
|
||||
fXYD.fsIn(), fXYD.fsIn());
|
||||
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
|
||||
f->codeAppend ( "highfloat3 xyd = grad_xyd * samples[i] + xyd_center;");
|
||||
f->codeAppend ( "float3 xyd = grad_xyd * samples[i] + xyd_center;");
|
||||
f->codeAppend ( "half f = xyd.y - xyd.x * xyd.x;"); // f > 0 -> inside curve.
|
||||
f->codeAppendf( "%s += all(greaterThan(highfloat2(f,xyd.z), highfloat2(0))) ? %f : 0;",
|
||||
f->codeAppendf( "%s += all(greaterThan(float2(f,xyd.z), float2(0))) ? %f : 0;",
|
||||
outputCoverage, 1.0 / sampleCount);
|
||||
f->codeAppendf("}");
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ class GrCCPRQuadraticProcessor : public GrCCPRCoverageProcessor::PrimitiveProces
|
||||
public:
|
||||
GrCCPRQuadraticProcessor()
|
||||
: INHERITED(CoverageType::kShader)
|
||||
, fCanonicalMatrix("canonical_matrix", kHighFloat3x3_GrSLType, GrShaderVar::kNonArray)
|
||||
, fCanonicalDerivatives("canonical_derivatives", kHighFloat2x2_GrSLType,
|
||||
, fCanonicalMatrix("canonical_matrix", kFloat3x3_GrSLType, GrShaderVar::kNonArray)
|
||||
, fCanonicalDerivatives("canonical_derivatives", kFloat2x2_GrSLType,
|
||||
GrShaderVar::kNonArray)
|
||||
, fEdgeDistanceEquation("edge_distance_equation", kHighFloat3_GrSLType,
|
||||
, fEdgeDistanceEquation("edge_distance_equation", kFloat3_GrSLType,
|
||||
GrShaderVar::kNonArray)
|
||||
, fXYD(kHighFloat3_GrSLType) {}
|
||||
, fXYD(kFloat3_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
varyingHandler->addVarying("xyd", &fXYD, kHigh_GrSLPrecision);
|
||||
@ -66,7 +66,7 @@ protected:
|
||||
class GrCCPRQuadraticHullProcessor : public GrCCPRQuadraticProcessor {
|
||||
public:
|
||||
GrCCPRQuadraticHullProcessor()
|
||||
: fGradXY(kHighFloat2_GrSLType) {}
|
||||
: fGradXY(kFloat2_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
this->INHERITED::resetVaryings(varyingHandler);
|
||||
@ -90,10 +90,10 @@ private:
|
||||
class GrCCPRQuadraticCornerProcessor : public GrCCPRQuadraticProcessor {
|
||||
public:
|
||||
GrCCPRQuadraticCornerProcessor()
|
||||
: fEdgeDistanceDerivatives("edge_distance_derivatives", kHighFloat2_GrSLType,
|
||||
: fEdgeDistanceDerivatives("edge_distance_derivatives", kFloat2_GrSLType,
|
||||
GrShaderVar::kNonArray)
|
||||
, fdXYDdx(kHighFloat3_GrSLType)
|
||||
, fdXYDdy(kHighFloat3_GrSLType) {}
|
||||
, fdXYDdx(kFloat3_GrSLType)
|
||||
, fdXYDdy(kFloat3_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
this->INHERITED::resetVaryings(varyingHandler);
|
||||
|
@ -16,25 +16,25 @@ void GrCCPRTriangleProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
|
||||
const TexelBufferHandle& pointsBuffer,
|
||||
const char* atlasOffset, const char* rtAdjust,
|
||||
GrGPArgs* gpArgs) const {
|
||||
v->codeAppend ("highfloat2 self = ");
|
||||
v->codeAppend ("float2 self = ");
|
||||
v->appendTexelFetch(pointsBuffer,
|
||||
SkStringPrintf("%s[sk_VertexID]", proc.instanceAttrib()).c_str());
|
||||
v->codeAppendf(".xy + %s;", atlasOffset);
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "self");
|
||||
}
|
||||
|
||||
void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) const {
|
||||
// Prepend in_vertices at the start of the shader.
|
||||
g->codePrependf("highfloat3x2 in_vertices = highfloat3x2(sk_in[0].gl_Position.xy, "
|
||||
"sk_in[1].gl_Position.xy, "
|
||||
"sk_in[2].gl_Position.xy);");
|
||||
g->codePrependf("float3x2 in_vertices = float3x2(sk_in[0].gl_Position.xy, "
|
||||
"sk_in[1].gl_Position.xy, "
|
||||
"sk_in[2].gl_Position.xy);");
|
||||
}
|
||||
|
||||
void GrCCPRTriangleProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* /*rtAdjust*/,
|
||||
const char* outputWind) const {
|
||||
// We will define in_vertices in defineInputVertices.
|
||||
g->codeAppendf("%s = sign(determinant(highfloat2x2(in_vertices[1] - in_vertices[0], "
|
||||
"in_vertices[2] - in_vertices[0])));",
|
||||
g->codeAppendf("%s = sign(determinant(float2x2(in_vertices[1] - in_vertices[0], "
|
||||
"in_vertices[2] - in_vertices[0])));",
|
||||
outputWind);
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ void GrCCPRTriangleHullAndEdgeProcessor::onEmitGeometryShader(GrGLSLGeometryBuil
|
||||
if (GeometryType::kHulls != fGeometryType) {
|
||||
g->codeAppend ("int edgeidx0 = sk_InvocationID, "
|
||||
"edgeidx1 = (edgeidx0 + 1) % 3;");
|
||||
g->codeAppendf("highfloat2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
|
||||
g->codeAppendf("highfloat2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
|
||||
g->codeAppendf("float2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
|
||||
g->codeAppendf("float2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
|
||||
|
||||
maxOutputVertices += this->emitEdgeGeometry(g, emitVertexFn, "edgept0", "edgept1");
|
||||
}
|
||||
@ -69,24 +69,23 @@ void GrCCPRTriangleCornerProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder*
|
||||
const char* rtAdjust) const {
|
||||
this->defineInputVertices(g);
|
||||
|
||||
g->codeAppend ("highfloat2 corner = in_vertices[sk_InvocationID];");
|
||||
g->codeAppend ("highfloat2x2 vectors = highfloat2x2("
|
||||
"corner - in_vertices[(sk_InvocationID + 2) % 3], "
|
||||
"corner - in_vertices[(sk_InvocationID + 1) % 3]);");
|
||||
g->codeAppend ("float2 corner = in_vertices[sk_InvocationID];");
|
||||
g->codeAppend ("float2x2 vectors = float2x2(corner - in_vertices[(sk_InvocationID + 2) % 3], "
|
||||
"corner - in_vertices[(sk_InvocationID + 1) % 3]);");
|
||||
|
||||
// Make sure neither vector is 0 in order to avoid a divide-by-zero. Wind will be zero anyway if
|
||||
// this is the case, so whatever we output won't have any effect as long it isn't NaN or Inf.
|
||||
g->codeAppendf("for (int i = 0; i < 2; ++i) {");
|
||||
g->codeAppendf( "vectors[i] = any(notEqual(vectors[i], highfloat2(0))) ? "
|
||||
"vectors[i] : highfloat2(1);");
|
||||
g->codeAppendf( "vectors[i] = any(notEqual(vectors[i], float2(0))) ? "
|
||||
"vectors[i] : float2(1);");
|
||||
g->codeAppendf("}");
|
||||
|
||||
// Find the vector that bisects the region outside the incoming edges. Each edge is responsible
|
||||
// to subtract the outside region on its own the side of the bisector.
|
||||
g->codeAppendf("highfloat2 leftdir = normalize(vectors[%s > 0 ? 0 : 1]);", wind);
|
||||
g->codeAppendf("highfloat2 rightdir = normalize(vectors[%s > 0 ? 1 : 0]);", wind);
|
||||
g->codeAppendf("highfloat2 bisect = dot(leftdir, rightdir) >= 0 ? leftdir + rightdir : "
|
||||
"highfloat2(leftdir.y - rightdir.y, rightdir.x - leftdir.x);");
|
||||
g->codeAppendf("float2 leftdir = normalize(vectors[%s > 0 ? 0 : 1]);", wind);
|
||||
g->codeAppendf("float2 rightdir = normalize(vectors[%s > 0 ? 1 : 0]);", wind);
|
||||
g->codeAppendf("float2 bisect = dot(leftdir, rightdir) >= 0 ? leftdir + rightdir : "
|
||||
"float2(leftdir.y - rightdir.y, rightdir.x - leftdir.x);");
|
||||
|
||||
// In ccpr we don't calculate exact geometric pixel coverage. What the distance-to-edge method
|
||||
// actually finds is coverage inside a logical "AA box", one that is rotated inline with the
|
||||
@ -98,8 +97,8 @@ void GrCCPRTriangleCornerProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder*
|
||||
g->declareGlobal(fGeoShaderBisects);
|
||||
g->codeAppendf("for (int i = 0; i < 2; ++i) {");
|
||||
// The X component runs parallel to the edge (i.e. distance to the corner).
|
||||
g->codeAppendf( "highfloat2 n = -vectors[%s > 0 ? i : 1 - i];", wind);
|
||||
g->codeAppendf( "highfloat nwidth = dot(abs(n), bloat) * 2;");
|
||||
g->codeAppendf( "float2 n = -vectors[%s > 0 ? i : 1 - i];", wind);
|
||||
g->codeAppendf( "float nwidth = dot(abs(n), bloat) * 2;");
|
||||
g->codeAppendf( "n /= nwidth;"); // nwidth != 0 because both vectors != 0.
|
||||
g->codeAppendf( "%s[i][0] = n;", fAABoxMatrices.c_str());
|
||||
g->codeAppendf( "%s[i][0] = -dot(n, corner) + .5;", fAABoxTranslates.c_str());
|
||||
@ -107,7 +106,7 @@ void GrCCPRTriangleCornerProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder*
|
||||
// The Y component runs perpendicular to the edge (i.e. distance-to-edge).
|
||||
// NOTE: once we are back in device space and bloat.x == bloat.y, we will not need to find and
|
||||
// divide by nwidth a second time.
|
||||
g->codeAppendf( "n = (i == 0) ? highfloat2(-n.y, n.x) : highfloat2(n.y, -n.x);");
|
||||
g->codeAppendf( "n = (i == 0) ? float2(-n.y, n.x) : float2(n.y, -n.x);");
|
||||
g->codeAppendf( "nwidth = dot(abs(n), bloat) * 2;");
|
||||
g->codeAppendf( "n /= nwidth;");
|
||||
g->codeAppendf( "%s[i][1] = n;", fAABoxMatrices.c_str());
|
||||
|
@ -72,11 +72,11 @@ class GrCCPRTriangleCornerProcessor : public GrCCPRTriangleProcessor {
|
||||
public:
|
||||
GrCCPRTriangleCornerProcessor()
|
||||
: INHERITED(CoverageType::kShader)
|
||||
, fAABoxMatrices("aa_box_matrices", kHighFloat2x2_GrSLType, 2)
|
||||
, fAABoxTranslates("aa_box_translates", kHighFloat2_GrSLType, 2)
|
||||
, fGeoShaderBisects("bisects", kHighFloat2_GrSLType, 2)
|
||||
, fCornerLocationInAABoxes(kHighFloat2x2_GrSLType)
|
||||
, fBisectInAABoxes(kHighFloat2x2_GrSLType) {}
|
||||
, fAABoxMatrices("aa_box_matrices", kFloat2x2_GrSLType, 2)
|
||||
, fAABoxTranslates("aa_box_translates", kFloat2_GrSLType, 2)
|
||||
, fGeoShaderBisects("bisects", kFloat2_GrSLType, 2)
|
||||
, fCornerLocationInAABoxes(kFloat2x2_GrSLType)
|
||||
, fBisectInAABoxes(kFloat2x2_GrSLType) {}
|
||||
|
||||
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
|
||||
this->INHERITED::resetVaryings(varyingHandler);
|
||||
|
@ -50,12 +50,12 @@ static void append_multitexture_lookup(GrGLSLPrimitiveProcessor::EmitArgs& args,
|
||||
for (int i = 0; i < numTextureSamplers-1; ++i) {
|
||||
args.fFragBuilder->codeAppendf("if (%s == %d) { %s = ", texIdx.fsIn(), i, colorName);
|
||||
args.fFragBuilder->appendTextureLookup(args.fTexSamplers[i], coordName,
|
||||
kHighFloat2_GrSLType);
|
||||
kFloat2_GrSLType);
|
||||
args.fFragBuilder->codeAppend("; } else ");
|
||||
}
|
||||
args.fFragBuilder->codeAppendf("{ %s = ", colorName);
|
||||
args.fFragBuilder->appendTextureLookup(args.fTexSamplers[numTextureSamplers-1], coordName,
|
||||
kHighFloat2_GrSLType);
|
||||
kFloat2_GrSLType);
|
||||
args.fFragBuilder->codeAppend("; }");
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(gp);
|
||||
|
||||
GrGLSLVertToFrag v(kHighFloat4_GrSLType);
|
||||
GrGLSLVertToFrag v(kFloat4_GrSLType);
|
||||
varyingHandler->addVarying("ConicCoeffs", &v, kHigh_GrSLPrecision);
|
||||
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
|
||||
|
||||
@ -106,14 +106,14 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
// that suffices. Additionally we should assert that the upstream code only lets us get here if
|
||||
// either float or half provides the required number of bits.
|
||||
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar dklmdx("dklmdx", kHighFloat3_GrSLType, 0);
|
||||
GrShaderVar dklmdy("dklmdy", kHighFloat3_GrSLType, 0);
|
||||
GrShaderVar dfdx("dfdx", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar dfdy("dfdy", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar gF("gF", kHighFloat2_GrSLType, 0);
|
||||
GrShaderVar gFM("gFM", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar func("func", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0);
|
||||
GrShaderVar dklmdx("dklmdx", kFloat3_GrSLType, 0);
|
||||
GrShaderVar dklmdy("dklmdy", kFloat3_GrSLType, 0);
|
||||
GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0);
|
||||
GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0);
|
||||
GrShaderVar gF("gF", kFloat2_GrSLType, 0);
|
||||
GrShaderVar gFM("gFM", kFloat_GrSLType, 0);
|
||||
GrShaderVar func("func", kFloat_GrSLType, 0);
|
||||
|
||||
fragBuilder->declAppend(edgeAlpha);
|
||||
fragBuilder->declAppend(dklmdx);
|
||||
@ -138,7 +138,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
v.fsIn(), dklmdy.c_str(),
|
||||
v.fsIn(), dklmdy.c_str(),
|
||||
v.fsIn(), dklmdy.c_str());
|
||||
fragBuilder->codeAppendf("%s = highfloat2(%s, %s);", gF.c_str(), dfdx.c_str(),
|
||||
fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(),
|
||||
dfdy.c_str());
|
||||
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
|
||||
gFM.c_str(), gF.c_str(), gF.c_str());
|
||||
@ -168,7 +168,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
v.fsIn(), dklmdy.c_str(),
|
||||
v.fsIn(), dklmdy.c_str(),
|
||||
v.fsIn(), dklmdy.c_str());
|
||||
fragBuilder->codeAppendf("%s = highfloat2(%s, %s);", gF.c_str(), dfdx.c_str(),
|
||||
fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(),
|
||||
dfdy.c_str());
|
||||
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
|
||||
gFM.c_str(), gF.c_str(), gF.c_str());
|
||||
@ -185,7 +185,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
case kFillBW_GrProcessorEdgeType: {
|
||||
fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
|
||||
edgeAlpha.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
|
||||
fragBuilder->codeAppendf("%s = highfloat(%s < 0.0);",
|
||||
fragBuilder->codeAppendf("%s = float(%s < 0.0);",
|
||||
edgeAlpha.c_str(), edgeAlpha.c_str());
|
||||
break;
|
||||
}
|
||||
@ -197,7 +197,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
if (gp.coverageScale() != 0xff) {
|
||||
const char* coverageScale;
|
||||
fCoverageScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHighFloat_GrSLType,
|
||||
kFloat_GrSLType,
|
||||
"Coverage",
|
||||
&coverageScale);
|
||||
fragBuilder->codeAppendf("%s = half4(%s * %s);",
|
||||
@ -554,25 +554,25 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
|
||||
// Setup KLM
|
||||
const char* devkLMMatrixName;
|
||||
fDevKLMUniform = uniformHandler->addUniform(kVertex_GrShaderFlag, kHighFloat3x3_GrSLType, "KLM",
|
||||
fDevKLMUniform = uniformHandler->addUniform(kVertex_GrShaderFlag, kFloat3x3_GrSLType, "KLM",
|
||||
&devkLMMatrixName);
|
||||
GrGLSLVertToFrag v(kHighFloat3_GrSLType);
|
||||
GrGLSLVertToFrag v(kFloat3_GrSLType);
|
||||
varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
|
||||
vertBuilder->codeAppendf("%s = %s * highfloat3(%s, 1);",
|
||||
vertBuilder->codeAppendf("%s = %s * float3(%s, 1);",
|
||||
v.vsOut(), devkLMMatrixName, gpArgs->fPositionVar.c_str());
|
||||
|
||||
|
||||
GrGLSLVertToFrag gradCoeffs(kHighFloat4_GrSLType);
|
||||
GrGLSLVertToFrag gradCoeffs(kFloat4_GrSLType);
|
||||
if (kFillAA_GrProcessorEdgeType == fEdgeType || kHairlineAA_GrProcessorEdgeType == fEdgeType) {
|
||||
varyingHandler->addVarying("GradCoeffs", &gradCoeffs, kHigh_GrSLPrecision);
|
||||
vertBuilder->codeAppendf("highfloat k = %s[0], l = %s[1], m = %s[2];",
|
||||
vertBuilder->codeAppendf("float k = %s[0], l = %s[1], m = %s[2];",
|
||||
v.vsOut(), v.vsOut(), v.vsOut());
|
||||
vertBuilder->codeAppendf("highfloat2 gk = highfloat2(%s[0][0], %s[1][0]), "
|
||||
"gl = highfloat2(%s[0][1], %s[1][1]), "
|
||||
"gm = highfloat2(%s[0][2], %s[1][2]);",
|
||||
vertBuilder->codeAppendf("float2 gk = float2(%s[0][0], %s[1][0]), "
|
||||
"gl = float2(%s[0][1], %s[1][1]), "
|
||||
"gm = float2(%s[0][2], %s[1][2]);",
|
||||
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName,
|
||||
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName);
|
||||
vertBuilder->codeAppendf("%s = highfloat4(3 * k * gk, -m * gl - l * gm);",
|
||||
vertBuilder->codeAppendf("%s = float4(3 * k * gk, -m * gl - l * gm);",
|
||||
gradCoeffs.vsOut());
|
||||
}
|
||||
|
||||
@ -585,9 +585,9 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar gF("gF", kHighFloat2_GrSLType, 0);
|
||||
GrShaderVar func("func", kHighFloat_GrSLType, 0);
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0);
|
||||
GrShaderVar gF("gF", kFloat2_GrSLType, 0);
|
||||
GrShaderVar func("func", kFloat_GrSLType, 0);
|
||||
|
||||
fragBuilder->declAppend(edgeAlpha);
|
||||
fragBuilder->declAppend(gF);
|
||||
@ -639,7 +639,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
}
|
||||
|
||||
|
||||
fragBuilder->codeAppendf("%s = highfloat4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
|
||||
fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
|
||||
}
|
||||
|
||||
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
|
@ -75,21 +75,21 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
"-9.0 / 18.0, 0.0 / 18.0, 9.0 / 18.0, 0.0 / 18.0,"
|
||||
"15.0 / 18.0, -36.0 / 18.0, 27.0 / 18.0, -6.0 / 18.0,"
|
||||
"-7.0 / 18.0, 21.0 / 18.0, -21.0 / 18.0, 7.0 / 18.0);");
|
||||
fragBuilder->codeAppendf("highfloat2 coord = %s - %s * highfloat2(0.5);", coords2D.c_str(), imgInc);
|
||||
fragBuilder->codeAppendf("float2 coord = %s - %s * float2(0.5);", coords2D.c_str(), imgInc);
|
||||
// We unnormalize the coord in order to determine our fractional offset (f) within the texel
|
||||
// We then snap coord to a texel center and renormalize. The snap prevents cases where the
|
||||
// starting coords are near a texel boundary and accumulations of imgInc would cause us to skip/
|
||||
// double hit a texel.
|
||||
fragBuilder->codeAppendf("coord /= %s;", imgInc);
|
||||
fragBuilder->codeAppend("highfloat2 f = fract(coord);");
|
||||
fragBuilder->codeAppendf("coord = (coord - f + highfloat2(0.5)) * %s;", imgInc);
|
||||
fragBuilder->codeAppend("float2 f = fract(coord);");
|
||||
fragBuilder->codeAppendf("coord = (coord - f + float2(0.5)) * %s;", imgInc);
|
||||
fragBuilder->codeAppend("half4 wx = kMitchellCoefficients * half4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
|
||||
fragBuilder->codeAppend("half4 wy = kMitchellCoefficients * half4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
|
||||
fragBuilder->codeAppend("half4 rowColors[4];");
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
SkString coord;
|
||||
coord.printf("coord + %s * highfloat2(%d, %d)", imgInc, x - 1, y - 1);
|
||||
coord.printf("coord + %s * float2(%d, %d)", imgInc, x - 1, y - 1);
|
||||
SkString sampleVar;
|
||||
sampleVar.printf("rowColors[%d]", x);
|
||||
fDomain.sampleTexture(fragBuilder,
|
||||
|
@ -32,12 +32,12 @@ public:
|
||||
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
|
||||
GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag uv(kFloat2_GrSLType);
|
||||
GrGLSLVertToFrag texIdx(kHalf_GrSLType);
|
||||
append_index_uv_varyings(args, btgp.inTextureCoords()->fName, atlasSizeInvName,
|
||||
&uv, &texIdx, nullptr);
|
||||
|
@ -25,10 +25,10 @@ public:
|
||||
args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
|
||||
(void)_outer;
|
||||
fragBuilder->codeAppendf(
|
||||
"half factor = half(1.0 - highfloat(%s.w));\n@switch (%d) {\n case 0:\n "
|
||||
"factor = half(exp(highfloat(highfloat(-factor * factor) * 4.0)) - "
|
||||
"half factor = half(1.0 - float(%s.w));\n@switch (%d) {\n case 0:\n "
|
||||
"factor = half(exp(float(float(-factor * factor) * 4.0)) - "
|
||||
"0.017999999999999999);\n break;\n case 1:\n factor = "
|
||||
"half(smoothstep(1.0, 0.0, highfloat(factor)));\n break;\n}\n%s = "
|
||||
"half(smoothstep(1.0, 0.0, float(factor)));\n break;\n}\n%s = "
|
||||
"half4(factor);\n",
|
||||
args.fInputColor ? args.fInputColor : "half4(1)", _outer.mode(), args.fOutputColor);
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ public:
|
||||
kDefault_GrSLPrecision, "circle");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
|
||||
" d = (highfloat(length((%s.xy - half2(sk_FragCoord.xy)) * %s.w)) - 1.0) * "
|
||||
"%s.z;\n} else {\n d = half((1.0 - highfloat(length((%s.xy - "
|
||||
"half2(sk_FragCoord.xy)) * %s.w))) * highfloat(%s.z));\n}\n@if ((%d == 1 || %d == "
|
||||
"3) || %d == 4) {\n d = half(clamp(highfloat(d), 0.0, 1.0));\n} else {\n d = "
|
||||
"half(highfloat(d) > 0.5 ? 1.0 : 0.0);\n}\n%s = %s * d;\n",
|
||||
" d = (float(length((%s.xy - half2(sk_FragCoord.xy)) * %s.w)) - 1.0) * %s.z;\n} "
|
||||
"else {\n d = half((1.0 - float(length((%s.xy - half2(sk_FragCoord.xy)) * "
|
||||
"%s.w))) * float(%s.z));\n}\n@if ((%d == 1 || %d == 3) || %d == 4) {\n d = "
|
||||
"half(clamp(float(d), 0.0, 1.0));\n} else {\n d = half(float(d) > 0.5 ? 1.0 : "
|
||||
"0.0);\n}\n%s = %s * d;\n",
|
||||
prevRadius, _outer.edgeType(), _outer.edgeType(),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
@ -77,9 +77,9 @@ public:
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
// add varyings
|
||||
GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag uv(kFloat2_GrSLType);
|
||||
GrGLSLVertToFrag texIdx(kHalf_GrSLType);
|
||||
GrGLSLVertToFrag st(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag st(kFloat2_GrSLType);
|
||||
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
|
||||
&uv, &texIdx, &st);
|
||||
|
||||
@ -92,7 +92,7 @@ public:
|
||||
SkToBool(dfTexEffect.getFlags() & kAliased_DistanceFieldEffectFlag);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
|
||||
fragBuilder->codeAppendf("float2 uv = %s;\n", uv.fsIn());
|
||||
fragBuilder->codeAppend("half4 texColor;");
|
||||
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
|
||||
texIdx, "uv", "texColor");
|
||||
@ -340,14 +340,14 @@ public:
|
||||
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
|
||||
GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag uv(kFloat2_GrSLType);
|
||||
GrGLSLVertToFrag texIdx(kHalf_GrSLType);
|
||||
GrGLSLVertToFrag st(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag st(kFloat2_GrSLType);
|
||||
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
|
||||
&uv, &texIdx, &st);
|
||||
|
||||
@ -371,7 +371,7 @@ public:
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fragBuilder->codeAppendf("highfloat2 uv = %s;", uv.fsIn());
|
||||
fragBuilder->codeAppendf("float2 uv = %s;", uv.fsIn());
|
||||
fragBuilder->codeAppend("half4 texColor;");
|
||||
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
|
||||
texIdx, "uv", "texColor");
|
||||
@ -599,7 +599,7 @@ public:
|
||||
|
||||
const char* atlasSizeInvName;
|
||||
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kHigh_GrSLPrecision,
|
||||
"AtlasSizeInv",
|
||||
&atlasSizeInvName);
|
||||
@ -626,13 +626,13 @@ public:
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
// set up varyings
|
||||
GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag uv(kFloat2_GrSLType);
|
||||
GrGLSLVertToFrag texIdx(kHalf_GrSLType);
|
||||
GrGLSLVertToFrag st(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag st(kFloat2_GrSLType);
|
||||
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
|
||||
&uv, &texIdx, &st);
|
||||
|
||||
GrGLSLVertToFrag delta(kHighFloat_GrSLType);
|
||||
GrGLSLVertToFrag delta(kFloat_GrSLType);
|
||||
varyingHandler->addVarying("Delta", &delta, kHigh_GrSLPrecision);
|
||||
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
|
||||
vertBuilder->codeAppendf("%s = -%s.x/3.0;", delta.vsOut(), atlasSizeInvName);
|
||||
@ -649,7 +649,7 @@ public:
|
||||
|
||||
// create LCD offset adjusted by inverse of transform
|
||||
// Use highp to work around aliasing issues
|
||||
fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
|
||||
fragBuilder->codeAppendf("float2 uv = %s;\n", uv.fsIn());
|
||||
|
||||
if (isUniformScale) {
|
||||
#ifdef SK_VULKAN
|
||||
|
@ -30,12 +30,12 @@ public:
|
||||
"0.066666666666666666;\n break;\n}\n@if (sk_Caps.integerSupport) {\n "
|
||||
"uint x = uint(sk_FragCoord.x);\n uint y = uint(sk_FragCoord.y);\n uint m = "
|
||||
"(((((y & 1) << 5 | (x & 1) << 4) | (y & 2) << 2) | (x & 2) << 1) | (y & 4) >> 1) "
|
||||
"| (x & 4) >> 2;\n value = highfloat(highfloat(half(m)) / 64.0) - 0.4921875;\n} "
|
||||
"else {\n half4 modValues = half4(mod(sk_FragCoord.xyxy, highfloat4(half4(2.0, "
|
||||
"2.0, 4.0, 4.0))));\n half4 stepValues = half4(step(highfloat4(modValues), "
|
||||
"highfloat4(half4(1.0, 1.0, 2.0, 2.0))));\n value = highfloat(dot(stepValues, "
|
||||
"half4(0.5, 0.25, 0.125, 0.0625))) - 0.46875;\n}\n%s = "
|
||||
"half4(clamp(highfloat3(%s.xyz + value * range), 0.0, highfloat(%s.w)), %s.w);\n",
|
||||
"| (x & 4) >> 2;\n value = float(float(half(m)) / 64.0) - 0.4921875;\n} else "
|
||||
"{\n half4 modValues = half4(mod(sk_FragCoord.xyxy, float4(half4(2.0, 2.0, 4.0, "
|
||||
"4.0))));\n half4 stepValues = half4(step(float4(modValues), float4(half4(1.0, "
|
||||
"1.0, 2.0, 2.0))));\n value = float(dot(stepValues, half4(0.5, 0.25, 0.125, "
|
||||
"0.0625))) - 0.46875;\n}\n%s = half4(clamp(float3(%s.xyz + value * range), 0.0, "
|
||||
"float(%s.w)), %s.w);\n",
|
||||
_outer.rangeType(), args.fOutputColor,
|
||||
args.fInputColor ? args.fInputColor : "half4(1)",
|
||||
args.fInputColor ? args.fInputColor : "half4(1)",
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
(void)_outer;
|
||||
prevRadii = half2(-1.0);
|
||||
useScale = sk_Caps.floatPrecisionVaries;
|
||||
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHighFloat4_GrSLType,
|
||||
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kDefault_GrSLPrecision, "ellipse");
|
||||
if (useScale) {
|
||||
fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
|
||||
@ -35,15 +35,14 @@ public:
|
||||
"half2 prevCenter;\nhalf2 prevRadii = half2(%f, %f);\nbool useScale = %s;\nhalf2 d "
|
||||
"= half2(sk_FragCoord.xy - %s.xy);\n@if (useScale) {\n d *= %s.y;\n}\nhalf2 Z = "
|
||||
"d * half2(%s.zw);\nhalf implicit = dot(Z, d) - 1.0;\nhalf grad_dot = 4.0 * dot(Z, "
|
||||
"Z);\ngrad_dot = half(max(highfloat(grad_dot), 0.0001));\nhalf approx_dist = "
|
||||
"highfloat(implicit) * inversesqrt(highfloat(grad_dot));\n@if (useScale) {\n "
|
||||
"Z);\ngrad_dot = half(max(float(grad_dot), 0.0001));\nhalf approx_dist = "
|
||||
"float(implicit) * inversesqrt(float(grad_dot));\n@if (useScale) {\n "
|
||||
"approx_dist *= %s.x;\n}\nhalf alpha;\n@switch (%d) {\n case 0:\n alpha "
|
||||
"= half(highfloat(approx_dist) > 0.0 ? 0.0 : 1.0);\n break;\n case 1:\n "
|
||||
" alpha = half(clamp(0.5 - highfloat(approx_dist), 0.0, 1.0));\n "
|
||||
"break;\n case 2:\n alpha = half(highfloat(approx_dist) > 0.0 ? 1.0 : "
|
||||
"0.0);\n break;\n case 3:\n alpha = half(clamp(0.5 + "
|
||||
"highfloat(approx_dist), 0.0, 1.0));\n break;\n default:\n "
|
||||
"discard;\n}\n%s = %s * alpha;\n",
|
||||
"= half(float(approx_dist) > 0.0 ? 0.0 : 1.0);\n break;\n case 1:\n "
|
||||
" alpha = half(clamp(0.5 - float(approx_dist), 0.0, 1.0));\n break;\n "
|
||||
"case 2:\n alpha = half(float(approx_dist) > 0.0 ? 1.0 : 0.0);\n "
|
||||
"break;\n case 3:\n alpha = half(clamp(0.5 + float(approx_dist), 0.0, "
|
||||
"1.0));\n break;\n default:\n discard;\n}\n%s = %s * alpha;\n",
|
||||
prevRadii.fX, prevRadii.fY, (useScale ? "true" : "false"),
|
||||
args.fUniformHandler->getUniformCStr(fEllipseVar),
|
||||
fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "half2(0)",
|
||||
|
@ -13,7 +13,7 @@ half2 prevCenter;
|
||||
half2 prevRadii = half2(-1);
|
||||
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
|
||||
// The last two terms can underflow with halfs, so we use floats.
|
||||
uniform highfloat4 ellipse;
|
||||
uniform float4 ellipse;
|
||||
|
||||
bool useScale = sk_Caps.floatPrecisionVaries;
|
||||
layout(when=useScale) uniform half2 scale;
|
||||
|
@ -64,8 +64,8 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
const GrShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
|
||||
fragBuilder->codeAppendf("highfloat2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
|
||||
fragBuilder->codeAppend("highfloat2 coordSampled = half2(0, 0);");
|
||||
fragBuilder->codeAppendf("float2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
|
||||
fragBuilder->codeAppend("float2 coordSampled = half2(0, 0);");
|
||||
|
||||
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
|
||||
const char* kVecSuffix[4] = {".x", ".y", ".z", ".w"};
|
||||
|
@ -66,7 +66,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppend("half4 sum = half4(0, 0, 0, 0);");
|
||||
fragBuilder->codeAppendf("highfloat2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
|
||||
fragBuilder->codeAppendf("float2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
|
||||
fragBuilder->codeAppend("half4 c;");
|
||||
|
||||
const char* kVecSuffix[4] = { ".x", ".y", ".z", ".w" };
|
||||
|
@ -87,7 +87,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
case kIgnore_Mode: {
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kHighFloat2_GrSLType, colorXformHelper);
|
||||
kFloat2_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
@ -98,7 +98,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
|
||||
kHighFloat2_GrSLType, colorXformHelper);
|
||||
kFloat2_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
@ -117,11 +117,11 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
builder->codeAppend("half4 outside = half4(0.0, 0.0, 0.0, 0.0);");
|
||||
builder->codeAppend("half4 inside = ");
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kHighFloat2_GrSLType, colorXformHelper);
|
||||
kFloat2_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
|
||||
builder->codeAppendf("highfloat x = (%s).x;", inCoords.c_str());
|
||||
builder->codeAppendf("highfloat y = (%s).y;", inCoords.c_str());
|
||||
builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
|
||||
builder->codeAppendf("float y = (%s).y;", inCoords.c_str());
|
||||
|
||||
builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0);",
|
||||
domain, domain, domain);
|
||||
@ -138,7 +138,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
builder->codeAppendf("%s = any(outside) ? half4(0.0, 0.0, 0.0, 0.0) : ",
|
||||
outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kHighFloat2_GrSLType, colorXformHelper);
|
||||
kFloat2_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
}
|
||||
break;
|
||||
@ -151,7 +151,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
|
||||
kHighFloat2_GrSLType, colorXformHelper);
|
||||
kFloat2_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
|
@ -3748,7 +3748,7 @@ bool GrGLGpu::createStencilClipClearProgram() {
|
||||
vshaderTxt.append(
|
||||
"// Stencil Clip Clear Program VS\n"
|
||||
"void main() {"
|
||||
" gl_Position = highfloat4(a_vertex.x, a_vertex.y, 0, 1);"
|
||||
" gl_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
|
||||
"}");
|
||||
|
||||
SkString fshaderTxt(version);
|
||||
|
@ -94,7 +94,7 @@ void GrGLProgramDataManager::set1iv(UniformHandle u,
|
||||
|
||||
void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fLocation, v0));
|
||||
@ -105,7 +105,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||
// This assert fires in some instances of the two-pt gradient for its VSParams.
|
||||
@ -119,7 +119,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
|
||||
|
||||
void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fLocation, v0, v1));
|
||||
@ -130,7 +130,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
@ -140,7 +140,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
|
||||
|
||||
void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fLocation, v0, v1, v2));
|
||||
@ -151,7 +151,7 @@ void GrGLProgramDataManager::set3fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
@ -165,7 +165,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
|
||||
float v2,
|
||||
float v3) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fLocation, v0, v1, v2, v3));
|
||||
@ -176,7 +176,7 @@ void GrGLProgramDataManager::set4fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
@ -214,7 +214,7 @@ template<int N> inline void GrGLProgramDataManager::setMatrices(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float matrices[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2x2_GrSLType + (N - 2) ||
|
||||
SkASSERT(uni.fType == kFloat2x2_GrSLType + (N - 2) ||
|
||||
uni.fType == kHalf2x2_GrSLType + (N - 2));
|
||||
SkASSERT(arrayCount > 0);
|
||||
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
|
||||
@ -247,9 +247,9 @@ void GrGLProgramDataManager::setPathFragmentInputTransform(VaryingHandle u,
|
||||
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
|
||||
const PathProcVarying& fragmentInput = fPathProcVaryings[u.toIndex()];
|
||||
|
||||
SkASSERT((components == 2 && (fragmentInput.fType == kHighFloat2_GrSLType ||
|
||||
SkASSERT((components == 2 && (fragmentInput.fType == kFloat2_GrSLType ||
|
||||
fragmentInput.fType == kHalf2_GrSLType)) ||
|
||||
(components == 3 && (fragmentInput.fType == kHighFloat3_GrSLType ||
|
||||
(components == 3 && (fragmentInput.fType == kFloat3_GrSLType ||
|
||||
fragmentInput.fType == kHalf3_GrSLType)));
|
||||
|
||||
fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID,
|
||||
|
@ -38,20 +38,20 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
|
||||
return "half3";
|
||||
case kHalf4_GrSLType:
|
||||
return "half4";
|
||||
case kHighFloat_GrSLType:
|
||||
return "highfloat";
|
||||
case kHighFloat2_GrSLType:
|
||||
return "highfloat2";
|
||||
case kHighFloat3_GrSLType:
|
||||
return "highfloat3";
|
||||
case kHighFloat4_GrSLType:
|
||||
return "highfloat4";
|
||||
case kFloat_GrSLType:
|
||||
return "float";
|
||||
case kFloat2_GrSLType:
|
||||
return "float2";
|
||||
case kFloat3_GrSLType:
|
||||
return "float3";
|
||||
case kFloat4_GrSLType:
|
||||
return "float4";
|
||||
case kUint2_GrSLType:
|
||||
if (shaderCaps->integerSupport()) {
|
||||
return "uint2";
|
||||
} else {
|
||||
// uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
|
||||
return "highfloat2";
|
||||
return "float2";
|
||||
}
|
||||
case kInt2_GrSLType:
|
||||
return "int2";
|
||||
@ -59,12 +59,12 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
|
||||
return "int3";
|
||||
case kInt4_GrSLType:
|
||||
return "int4";
|
||||
case kHighFloat2x2_GrSLType:
|
||||
return "highfloat2x2";
|
||||
case kHighFloat3x3_GrSLType:
|
||||
return "highfloat3x3";
|
||||
case kHighFloat4x4_GrSLType:
|
||||
return "highfloat4x4";
|
||||
case kFloat2x2_GrSLType:
|
||||
return "float2x2";
|
||||
case kFloat3x3_GrSLType:
|
||||
return "float3x3";
|
||||
case kFloat4x4_GrSLType:
|
||||
return "float4x4";
|
||||
case kHalf2x2_GrSLType:
|
||||
return "half2x2";
|
||||
case kHalf3x3_GrSLType:
|
||||
|
@ -146,7 +146,7 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
|
||||
GrShaderVar getLumArgs[] = {
|
||||
GrShaderVar("color", kHalf3_GrSLType),
|
||||
};
|
||||
SkString getLumBody("return dot(highfloat3(0.3, 0.59, 0.11), color);");
|
||||
SkString getLumBody("return dot(float3(0.3, 0.59, 0.11), color);");
|
||||
fsBuilder->emitFunction(kHalf_GrSLType,
|
||||
"luminance",
|
||||
SK_ARRAY_COUNT(getLumArgs), getLumArgs,
|
||||
|
@ -112,14 +112,14 @@ bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
|
||||
}
|
||||
|
||||
SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) {
|
||||
if (kHighFloat3_GrSLType != coords.getType() && kHalf3_GrSLType != coords.getType()) {
|
||||
SkASSERT(kHighFloat2_GrSLType == coords.getType() || kHalf2_GrSLType == coords.getType());
|
||||
if (kFloat3_GrSLType != coords.getType() && kHalf3_GrSLType != coords.getType()) {
|
||||
SkASSERT(kFloat2_GrSLType == coords.getType() || kHalf2_GrSLType == coords.getType());
|
||||
return coords.getName();
|
||||
}
|
||||
|
||||
SkString coords2D;
|
||||
coords2D.printf("%s_ensure2D", coords.c_str());
|
||||
this->codeAppendf("\thighfloat2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
|
||||
this->codeAppendf("\tfloat2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
|
||||
coords.c_str());
|
||||
return coords2D;
|
||||
}
|
||||
@ -298,9 +298,9 @@ void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, cons
|
||||
SkSTArray<16, SkPoint, true> offsets;
|
||||
offsets.push_back_n(specs.fEffectiveSampleCnt);
|
||||
m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleCnt);
|
||||
this->definitions().appendf("const highfloat2 %s[] = highfloat2[](", name);
|
||||
this->definitions().appendf("const float2 %s[] = float2[](", name);
|
||||
for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
|
||||
this->definitions().appendf("highfloat2(%f, %f)", offsets[i].x(), offsets[i].y());
|
||||
this->definitions().appendf("float2(%f, %f)", offsets[i].x(), offsets[i].y());
|
||||
this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : ");\n");
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) {
|
||||
GrGPArgs gpArgs;
|
||||
this->onEmitCode(args, &gpArgs);
|
||||
vBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar, args.fRTAdjustName);
|
||||
if (kHighFloat2_GrSLType == gpArgs.fPositionVar.getType() ||
|
||||
if (kFloat2_GrSLType == gpArgs.fPositionVar.getType() ||
|
||||
kHalf2_GrSLType == gpArgs.fPositionVar.getType()) {
|
||||
args.fVaryingHandler->setNoPerspective();
|
||||
}
|
||||
@ -40,13 +40,13 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
uint32_t type = coordTransform->getMatrix().getType();
|
||||
type |= localMatrix.getType();
|
||||
|
||||
varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kHighFloat3_GrSLType :
|
||||
kHighFloat2_GrSLType;
|
||||
varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kFloat3_GrSLType :
|
||||
kFloat2_GrSLType;
|
||||
const char* uniName;
|
||||
|
||||
|
||||
fInstalledTransforms.push_back().fHandle = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat3x3_GrSLType,
|
||||
kFloat3x3_GrSLType,
|
||||
strUniName.c_str(),
|
||||
&uniName).toIndex();
|
||||
SkString strVaryingName;
|
||||
@ -55,13 +55,13 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
GrGLSLVertToFrag v(varyingType);
|
||||
varyingHandler->addVarying(strVaryingName.c_str(), &v, kHigh_GrSLPrecision);
|
||||
|
||||
SkASSERT(kHighFloat2_GrSLType == varyingType || kHighFloat3_GrSLType == varyingType);
|
||||
SkASSERT(kFloat2_GrSLType == varyingType || kFloat3_GrSLType == varyingType);
|
||||
handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
|
||||
|
||||
if (kHighFloat2_GrSLType == varyingType) {
|
||||
vb->codeAppendf("%s = (%s * highfloat3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
|
||||
if (kFloat2_GrSLType == varyingType) {
|
||||
vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
|
||||
} else {
|
||||
vb->codeAppendf("%s = %s * highfloat3(%s, 1);", v.vsOut(), uniName, localCoords);
|
||||
vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoords);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
@ -85,8 +85,8 @@ void GrGLSLGeometryProcessor::setTransformDataHelper(const SkMatrix& localMatrix
|
||||
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName) {
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("highfloat2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
@ -96,21 +96,21 @@ void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuild
|
||||
const SkMatrix& mat,
|
||||
UniformHandle* viewMatrixUniform) {
|
||||
if (mat.isIdentity()) {
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("highfloat2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
} else {
|
||||
const char* viewMatrixName;
|
||||
*viewMatrixUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
|
||||
kHighFloat3x3_GrSLType,
|
||||
kFloat3x3_GrSLType,
|
||||
"uViewM",
|
||||
&viewMatrixName);
|
||||
if (!mat.hasPerspective()) {
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("highfloat2 %s = (%s * highfloat3(%s, 1)).xy;",
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("float2 %s = (%s * float3(%s, 1)).xy;",
|
||||
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
|
||||
} else {
|
||||
gpArgs->fPositionVar.set(kHighFloat3_GrSLType, "pos3");
|
||||
vertBuilder->codeAppendf("highfloat3 %s = %s * highfloat3(%s, 1);",
|
||||
gpArgs->fPositionVar.set(kFloat3_GrSLType, "pos3");
|
||||
vertBuilder->codeAppendf("float3 %s = %s * float3(%s, 1);",
|
||||
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
|
||||
rtAdjustVisibility |= kGeometry_GrShaderFlag;
|
||||
}
|
||||
fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform(rtAdjustVisibility,
|
||||
kHighFloat4_GrSLType,
|
||||
kFloat4_GrSLType,
|
||||
"rtAdjustment");
|
||||
const char* rtAdjustName =
|
||||
this->uniformHandler()->getUniformCStr(fUniformHandles.fRTAdjustmentUni);
|
||||
|
@ -18,25 +18,25 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
|
||||
const char* rtAdjustName) {
|
||||
// setup RT Uniform
|
||||
if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) {
|
||||
if (kHighFloat3_GrSLType == posVar.getType()) {
|
||||
if (kFloat3_GrSLType == posVar.getType()) {
|
||||
const char* p = posVar.c_str();
|
||||
this->codeAppendf("{highfloat2 _posTmp = highfloat2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
|
||||
this->codeAppendf("{float2 _posTmp = float2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
|
||||
} else {
|
||||
SkASSERT(kHighFloat2_GrSLType == posVar.getType());
|
||||
this->codeAppendf("{highfloat2 _posTmp = %s;", posVar.c_str());
|
||||
SkASSERT(kFloat2_GrSLType == posVar.getType());
|
||||
this->codeAppendf("{float2 _posTmp = %s;", posVar.c_str());
|
||||
}
|
||||
this->codeAppendf("_posTmp = floor(_posTmp) + half2(0.5, 0.5);"
|
||||
"gl_Position = highfloat4(_posTmp.x * %s.x + %s.y,"
|
||||
"gl_Position = float4(_posTmp.x * %s.x + %s.y,"
|
||||
"_posTmp.y * %s.z + %s.w, 0, 1);}",
|
||||
rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName);
|
||||
} else if (kHighFloat3_GrSLType == posVar.getType()) {
|
||||
this->codeAppendf("gl_Position = highfloat4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
|
||||
} else if (kFloat3_GrSLType == posVar.getType()) {
|
||||
this->codeAppendf("gl_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
|
||||
posVar.c_str(), rtAdjustName,
|
||||
posVar.c_str(), rtAdjustName,
|
||||
posVar.c_str());
|
||||
} else {
|
||||
SkASSERT(kHighFloat2_GrSLType == posVar.getType());
|
||||
this->codeAppendf("gl_Position = highfloat4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
|
||||
SkASSERT(kFloat2_GrSLType == posVar.getType());
|
||||
this->codeAppendf("gl_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
|
||||
posVar.c_str(), rtAdjustName, rtAdjustName,
|
||||
posVar.c_str(), rtAdjustName, rtAdjustName);
|
||||
}
|
||||
|
@ -115,11 +115,11 @@ public:
|
||||
void fetchNextParam(const GrShaderCaps* shaderCaps, GrSLType type = kHalf4_GrSLType) const {
|
||||
SkASSERT(fParamsBuffer.isValid());
|
||||
switch (type) {
|
||||
case kHighFloat2_GrSLType: // fall through
|
||||
case kHighFloat3_GrSLType: // fall through
|
||||
case kHighFloat4_GrSLType: // fall through
|
||||
case kHalf2_GrSLType: // fall through
|
||||
case kHalf3_GrSLType: // fall through
|
||||
case kFloat2_GrSLType: // fall through
|
||||
case kFloat3_GrSLType: // fall through
|
||||
case kFloat4_GrSLType: // fall through
|
||||
case kHalf2_GrSLType: // fall through
|
||||
case kHalf3_GrSLType: // fall through
|
||||
case kHalf4_GrSLType:
|
||||
break;
|
||||
default:
|
||||
@ -127,15 +127,15 @@ public:
|
||||
}
|
||||
fVertexBuilder->appendTexelFetch(fParamsBuffer, "paramsIdx++");
|
||||
switch (type) {
|
||||
case kHighFloat2_GrSLType: // fall through
|
||||
case kFloat2_GrSLType: // fall through
|
||||
case kHalf2_GrSLType:
|
||||
fVertexBuilder->codeAppend(".xy");
|
||||
break;
|
||||
case kHighFloat3_GrSLType: // fall through
|
||||
case kFloat3_GrSLType: // fall through
|
||||
case kHalf3_GrSLType:
|
||||
fVertexBuilder->codeAppend(".xyz");
|
||||
break;
|
||||
case kHighFloat4_GrSLType: // fall through
|
||||
case kFloat4_GrSLType: // fall through
|
||||
case kHalf4_GrSLType:
|
||||
break;
|
||||
default:
|
||||
@ -401,8 +401,8 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
v->codeAppend("}");
|
||||
}
|
||||
|
||||
GrSLType positionType = ip.opInfo().fHasPerspective ? kHighFloat3_GrSLType : kHighFloat2_GrSLType;
|
||||
v->codeAppendf("%s deviceCoords = highfloat3(%s, 1) * shapeMatrix;",
|
||||
GrSLType positionType = ip.opInfo().fHasPerspective ? kFloat3_GrSLType : kFloat2_GrSLType;
|
||||
v->codeAppendf("%s deviceCoords = float3(%s, 1) * shapeMatrix;",
|
||||
GrGLSLTypeString(args.fShaderCaps, positionType), backend->outShapeCoords());
|
||||
gpArgs->fPositionVar.set(positionType, "deviceCoords");
|
||||
|
||||
@ -1048,11 +1048,11 @@ void GLSLInstanceProcessor::BackendCoverage::emitArc(GrGLSLPPFragmentBuilder* f,
|
||||
ellipseCoords = "ellipseClampedCoords";
|
||||
}
|
||||
// ellipseCoords are in pixel space and ellipseName is 1 / rx^2, 1 / ry^2.
|
||||
f->codeAppendf("highfloat2 Z = %s * %s;", ellipseCoords, ellipseName);
|
||||
f->codeAppendf("float2 Z = %s * %s;", ellipseCoords, ellipseName);
|
||||
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
|
||||
f->codeAppendf("highfloat implicit = dot(Z, %s) - 1.0;", ellipseCoords);
|
||||
f->codeAppendf("float implicit = dot(Z, %s) - 1.0;", ellipseCoords);
|
||||
// gradDot is the squared length of the gradient of the implicit.
|
||||
f->codeAppendf("highfloat gradDot = 4.0 * dot(Z, Z);");
|
||||
f->codeAppendf("float gradDot = 4.0 * dot(Z, Z);");
|
||||
f->codeAppend ("half approxDist = implicit * inversesqrt(gradDot);");
|
||||
f->codeAppendf("%s = clamp(0.5 - approxDist, 0.0, 1.0);", outCoverage);
|
||||
}
|
||||
@ -1205,7 +1205,7 @@ void GLSLInstanceProcessor::BackendMultisample::setupRect(GrGLSLVertexBuilder* v
|
||||
}
|
||||
if (fArcTest.vsOut()) {
|
||||
// Pick a value that is not > 0.
|
||||
v->codeAppendf("%s = highfloat2(0);", fArcTest.vsOut());
|
||||
v->codeAppendf("%s = float2(0);", fArcTest.vsOut());
|
||||
}
|
||||
if (fTriangleIsArc.vsOut()) {
|
||||
v->codeAppendf("%s = 0;", fTriangleIsArc.vsOut());
|
||||
@ -1325,7 +1325,7 @@ GLSLInstanceProcessor::BackendMultisample::onInitInnerShape(GrGLSLVaryingHandler
|
||||
if (!fOpInfo.fHasPerspective) {
|
||||
varyingHandler->addFlatVarying("innerShapeInverseMatrix", &fInnerShapeInverseMatrix,
|
||||
kHigh_GrSLPrecision);
|
||||
v->codeAppendf("%s = shapeInverseMatrix * highfloat2x2(outer2Inner.x, 0, 0, outer2Inner.y);",
|
||||
v->codeAppendf("%s = shapeInverseMatrix * float2x2(outer2Inner.x, 0, 0, outer2Inner.y);",
|
||||
fInnerShapeInverseMatrix.vsOut());
|
||||
varyingHandler->addFlatVarying("fragInnerShapeHalfSpan", &fFragInnerShapeHalfSpan,
|
||||
kHigh_GrSLPrecision);
|
||||
@ -1370,7 +1370,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
|
||||
}
|
||||
|
||||
if (kRect_ShapeFlag != (fOpInfo.fShapeTypes | fOpInfo.fInnerShapeTypes)) {
|
||||
GrShaderVar x("x", kHighFloat2_GrSLType, GrShaderVar::kNonArray);
|
||||
GrShaderVar x("x", kFloat2_GrSLType, GrShaderVar::kNonArray);
|
||||
f->emitFunction(kHalf_GrSLType, "square", 1, &x, "return dot(x, x);", &fSquareFun);
|
||||
}
|
||||
|
||||
@ -1393,7 +1393,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
|
||||
if (fOpInfo.fHasPerspective && fOpInfo.fInnerShapeTypes) {
|
||||
// This determines if the fragment should consider the inner shape in its sample mask.
|
||||
// We take the derivative early in case discards may occur before we get to the inner shape.
|
||||
f->codeAppendf("highfloat2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
|
||||
f->codeAppendf("float2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
|
||||
fInnerShapeCoords.fsIn());
|
||||
}
|
||||
|
||||
@ -1410,7 +1410,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
|
||||
if (arcTest && fOpInfo.fHasPerspective) {
|
||||
// The non-perspective version accounts for fwidth() in the vertex shader.
|
||||
// We make sure to take the derivative here, before a neighbor pixel may early accept.
|
||||
f->codeAppendf("highfloat2 arcTest = %s - 0.5 * fwidth(%s);",
|
||||
f->codeAppendf("float2 arcTest = %s - 0.5 * fwidth(%s);",
|
||||
fArcTest.fsIn(), fArcTest.fsIn());
|
||||
arcTest = "arcTest";
|
||||
}
|
||||
@ -1421,7 +1421,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
|
||||
if (arcTest) {
|
||||
// At this point, if the sample mask is all set it means we are inside an arc triangle.
|
||||
f->codeAppendf("if (gl_SampleMaskIn[0] == SAMPLE_MASK_ALL || "
|
||||
"all(greaterThan(%s, highfloat2(0)))) {", arcTest);
|
||||
"all(greaterThan(%s, float2(0)))) {", arcTest);
|
||||
this->emitArc(f, arcCoords, false, clampArcCoords, opts);
|
||||
f->codeAppend ("} else {");
|
||||
this->emitRect(f, shapeCoords, opts);
|
||||
@ -1494,10 +1494,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitRect(GrGLSLPPFragmentBuilder
|
||||
}
|
||||
f->codeAppend ("int rectMask = 0;");
|
||||
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
|
||||
f->codeAppend ( "highfloat2 pt = ");
|
||||
f->codeAppend ( "float2 pt = ");
|
||||
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
|
||||
f->codeAppend ( ";");
|
||||
f->codeAppend ( "if (all(lessThan(abs(pt), highfloat2(1)))) rectMask |= (1 << i);");
|
||||
f->codeAppend ( "if (all(lessThan(abs(pt), float2(1)))) rectMask |= (1 << i);");
|
||||
f->codeAppend ("}");
|
||||
this->acceptCoverageMask(f, "rectMask", opts);
|
||||
if (coords.fFragHalfSpan) {
|
||||
@ -1529,12 +1529,12 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
|
||||
}
|
||||
f->codeAppend ( "int arcMask = 0;");
|
||||
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
|
||||
f->codeAppend ( "highfloat2 pt = ");
|
||||
f->codeAppend ( "float2 pt = ");
|
||||
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
|
||||
f->codeAppend ( ";");
|
||||
if (clampCoords) {
|
||||
SkASSERT(!coordsMayBeNegative);
|
||||
f->codeAppend ( "pt = max(pt, highfloat2(0));");
|
||||
f->codeAppend ( "pt = max(pt, float2(0));");
|
||||
}
|
||||
f->codeAppendf( "if (%s(pt) < 1.0) arcMask |= (1 << i);", fSquareFun.c_str());
|
||||
f->codeAppend ( "}");
|
||||
@ -1548,31 +1548,31 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
|
||||
const EmitShapeCoords& coords,
|
||||
const char* rrect,
|
||||
const EmitShapeOpts& opts) {
|
||||
f->codeAppendf("highfloat2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
|
||||
f->codeAppendf("float2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
|
||||
rrect);
|
||||
f->codeAppend ("if (any(lessThan(distanceToArcEdge, highfloat2(0)))) {");
|
||||
f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(0)))) {");
|
||||
this->emitRect(f, coords, opts);
|
||||
f->codeAppend ("} else {");
|
||||
if (coords.fInverseMatrix && coords.fFragHalfSpan) {
|
||||
f->codeAppendf("highfloat2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
|
||||
f->codeAppendf("highfloat2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
|
||||
f->codeAppendf("float2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
|
||||
f->codeAppendf("float2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
|
||||
f->codeAppendf("if (%s(rrectCoords + fragRRectHalfSpan) <= 1.0) {", fSquareFun.c_str());
|
||||
// The entire pixel is inside the round rect.
|
||||
this->acceptOrRejectWholeFragment(f, true, opts);
|
||||
f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, highfloat2(0))) >= 1.0) {",
|
||||
f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, float2(0))) >= 1.0) {",
|
||||
fSquareFun.c_str());
|
||||
// The entire pixel is outside the round rect.
|
||||
this->acceptOrRejectWholeFragment(f, false, opts);
|
||||
f->codeAppend ("} else {");
|
||||
f->codeAppendf( "highfloat2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
|
||||
f->codeAppendf( "highfloat2x2 innerRRectInverseMatrix = %s * "
|
||||
"highfloat2x2(s.x, 0, 0, s.y);", coords.fInverseMatrix);
|
||||
f->codeAppendf( "float2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
|
||||
f->codeAppendf( "float2x2 innerRRectInverseMatrix = %s * "
|
||||
"float2x2(s.x, 0, 0, s.y);", coords.fInverseMatrix);
|
||||
f->codeAppend ( "highp int rrectMask = 0;");
|
||||
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
|
||||
f->codeAppend ( "highfloat2 pt = rrectCoords + ");
|
||||
f->codeAppend ( "float2 pt = rrectCoords + ");
|
||||
f->appendOffsetToSample("i", GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates);
|
||||
f->codeAppend ( "* innerRRectInverseMatrix;");
|
||||
f->codeAppendf( "if (%s(max(pt, highfloat2(0))) < 1.0) rrectMask |= (1 << i);",
|
||||
f->codeAppendf( "if (%s(max(pt, float2(0))) < 1.0) rrectMask |= (1 << i);",
|
||||
fSquareFun.c_str());
|
||||
f->codeAppend ( "}");
|
||||
this->acceptCoverageMask(f, "rrectMask", opts);
|
||||
@ -1580,10 +1580,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
|
||||
} else {
|
||||
f->codeAppend ("int rrectMask = 0;");
|
||||
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
|
||||
f->codeAppend ( "highfloat2 shapePt = ");
|
||||
f->codeAppend ( "float2 shapePt = ");
|
||||
this->interpolateAtSample(f, *coords.fVarying, "i", nullptr);
|
||||
f->codeAppend ( ";");
|
||||
f->codeAppendf( "highfloat2 rrectPt = max(abs(shapePt) - %s.xy, highfloat2(0)) * %s.zw;",
|
||||
f->codeAppendf( "float2 rrectPt = max(abs(shapePt) - %s.xy, float2(0)) * %s.zw;",
|
||||
rrect, rrect);
|
||||
f->codeAppendf( "if (%s(rrectPt) < 1.0) rrectMask |= (1 << i);", fSquareFun.c_str());
|
||||
f->codeAppend ("}");
|
||||
|
@ -1092,13 +1092,13 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
varyingHandler->emitAttributes(de);
|
||||
|
||||
// XY refers to dashPos, Z is the dash interval length
|
||||
GrGLSLVertToFrag inDashParams(kHighFloat3_GrSLType);
|
||||
GrGLSLVertToFrag inDashParams(kFloat3_GrSLType);
|
||||
varyingHandler->addVarying("DashParams", &inDashParams, GrSLPrecision::kHigh_GrSLPrecision);
|
||||
vertBuilder->codeAppendf("%s = %s;", inDashParams.vsOut(), de.inDashParams()->fName);
|
||||
|
||||
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
|
||||
// respectively.
|
||||
GrGLSLVertToFrag inRectParams(kHighFloat4_GrSLType);
|
||||
GrGLSLVertToFrag inRectParams(kFloat4_GrSLType);
|
||||
varyingHandler->addVarying("RectParams", &inRectParams, GrSLPrecision::kHigh_GrSLPrecision);
|
||||
vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
varyingHandler->emitAttributes(qp);
|
||||
varyingHandler->addPassThroughAttribute(qp.inColor(), args.fOutputColor);
|
||||
|
||||
GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
|
||||
GrGLSLVertToFrag uv(kFloat2_GrSLType);
|
||||
varyingHandler->addVarying("uv", &uv, kHigh_GrSLPrecision);
|
||||
vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
|
||||
|
||||
|
@ -119,7 +119,7 @@ private:
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(cgp);
|
||||
fragBuilder->codeAppend("highfloat4 circleEdge;");
|
||||
fragBuilder->codeAppend("float4 circleEdge;");
|
||||
varyingHandler->addPassThroughAttribute(cgp.fInCircleEdge, "circleEdge",
|
||||
kHigh_GrSLPrecision);
|
||||
if (cgp.fInClipPlane) {
|
||||
@ -152,7 +152,7 @@ private:
|
||||
cgp.fLocalMatrix,
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
fragBuilder->codeAppend("highfloat d = length(circleEdge.xy);");
|
||||
fragBuilder->codeAppend("float d = length(circleEdge.xy);");
|
||||
fragBuilder->codeAppend("half distanceToOuterEdge = circleEdge.z * (1.0 - d);");
|
||||
fragBuilder->codeAppend("half edgeAlpha = clamp(distanceToOuterEdge, 0.0, 1.0);");
|
||||
if (cgp.fStroke) {
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
args.fVaryingHandler->addPassThroughAttribute(&textureGP.fColors,
|
||||
args.fOutputColor);
|
||||
}
|
||||
args.fFragBuilder->codeAppend("highfloat2 texCoord;");
|
||||
args.fFragBuilder->codeAppend("float2 texCoord;");
|
||||
args.fVaryingHandler->addPassThroughAttribute(&textureGP.fTextureCoords, "texCoord",
|
||||
kHigh_GrSLPrecision);
|
||||
if (textureGP.numTextureSamplers() > 1) {
|
||||
@ -134,7 +134,7 @@ public:
|
||||
args.fFragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
|
||||
args.fTexSamplers[i],
|
||||
"texCoord",
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
&fColorSpaceXformHelper);
|
||||
args.fFragBuilder->codeAppend("; break;");
|
||||
}
|
||||
@ -144,11 +144,11 @@ public:
|
||||
args.fFragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
|
||||
args.fTexSamplers[0],
|
||||
"texCoord",
|
||||
kHighFloat2_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
&fColorSpaceXformHelper);
|
||||
}
|
||||
args.fFragBuilder->codeAppend(";");
|
||||
args.fFragBuilder->codeAppendf("%s = highfloat4(1);", args.fOutputCoverage);
|
||||
args.fFragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
|
||||
}
|
||||
GrGLSLColorSpaceXformHelper fColorSpaceXformHelper;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
|
||||
"half4 uPosXform;"
|
||||
"half4 uTexCoordXform;"
|
||||
"};"
|
||||
"layout(location = 0) in highfloat2 inPosition;"
|
||||
"layout(location = 0) in float2 inPosition;"
|
||||
"layout(location = 1) out half2 vTexCoord;"
|
||||
|
||||
"// Copy Program VS\n"
|
||||
|
@ -85,7 +85,7 @@ void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
|
||||
|
||||
void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -96,7 +96,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat_GrSLType || uni.fType == kHalf_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
@ -112,7 +112,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
|
||||
|
||||
void GrVkPipelineStateDataManager::set2f(UniformHandle u, float v0, float v1) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -124,7 +124,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
@ -140,7 +140,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
|
||||
|
||||
void GrVkPipelineStateDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -152,7 +152,7 @@ void GrVkPipelineStateDataManager::set3fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
@ -172,7 +172,7 @@ void GrVkPipelineStateDataManager::set4f(UniformHandle u,
|
||||
float v2,
|
||||
float v3) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -184,7 +184,7 @@ void GrVkPipelineStateDataManager::set4fv(UniformHandle u,
|
||||
int arrayCount,
|
||||
const float v[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(uni.fType == kFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
@ -230,7 +230,7 @@ template<int N> inline void GrVkPipelineStateDataManager::setMatrices(UniformHan
|
||||
int arrayCount,
|
||||
const float matrices[]) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kHighFloat2x2_GrSLType + (N - 2) ||
|
||||
SkASSERT(uni.fType == kFloat2x2_GrSLType + (N - 2) ||
|
||||
uni.fType == kHalf2x2_GrSLType + (N - 2));
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
|
@ -23,16 +23,16 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
case kUint_GrSLType:
|
||||
return 0x3;
|
||||
case kHalf_GrSLType: // fall through
|
||||
case kHighFloat_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
return 0x3;
|
||||
case kHalf2_GrSLType: // fall through
|
||||
case kHighFloat2_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
return 0x7;
|
||||
case kHalf3_GrSLType: // fall through
|
||||
case kHighFloat3_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
return 0xF;
|
||||
case kHalf4_GrSLType: // fall through
|
||||
case kHighFloat4_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
return 0xF;
|
||||
case kUint2_GrSLType:
|
||||
return 0x3;
|
||||
@ -43,13 +43,13 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
case kInt4_GrSLType:
|
||||
return 0xF;
|
||||
case kHalf2x2_GrSLType: // fall through
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
return 0x7;
|
||||
case kHalf3x3_GrSLType: // fall through
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
return 0xF;
|
||||
case kHalf4x4_GrSLType: // fall through
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
return 0xF;
|
||||
|
||||
// This query is only valid for certain types.
|
||||
@ -82,16 +82,16 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
|
||||
case kUint_GrSLType:
|
||||
return sizeof(int32_t);
|
||||
case kHalf_GrSLType: // fall through
|
||||
case kHighFloat_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
return sizeof(float);
|
||||
case kHalf2_GrSLType: // fall through
|
||||
case kHighFloat2_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
return 2 * sizeof(float);
|
||||
case kHalf3_GrSLType: // fall through
|
||||
case kHighFloat3_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
return 3 * sizeof(float);
|
||||
case kHalf4_GrSLType: // fall through
|
||||
case kHighFloat4_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
return 4 * sizeof(float);
|
||||
case kUint2_GrSLType:
|
||||
return 2 * sizeof(uint16_t);
|
||||
@ -102,14 +102,14 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
|
||||
case kInt4_GrSLType:
|
||||
return 4 * sizeof(int32_t);
|
||||
case kHalf2x2_GrSLType: // fall through
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
//TODO: this will be 4 * szof(float) on std430.
|
||||
return 8 * sizeof(float);
|
||||
case kHalf3x3_GrSLType: // fall through
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
return 12 * sizeof(float);
|
||||
case kHalf4x4_GrSLType: // fall through
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
return 16 * sizeof(float);
|
||||
|
||||
// This query is only valid for certain types.
|
||||
@ -140,7 +140,7 @@ void get_ubo_aligned_offset(uint32_t* uniformOffset,
|
||||
int arrayCount) {
|
||||
uint32_t alignmentMask = grsltype_to_alignment_mask(type);
|
||||
// We want to use the std140 layout here, so we must make arrays align to 16 bytes.
|
||||
if (arrayCount || type == kHighFloat2x2_GrSLType) {
|
||||
if (arrayCount || type == kFloat2x2_GrSLType) {
|
||||
alignmentMask = 0xF;
|
||||
}
|
||||
uint32_t offsetDiff = *currentOffset & alignmentMask;
|
||||
|
@ -13,16 +13,16 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
switch(type) {
|
||||
case kVoid_GrSLType:
|
||||
return 0;
|
||||
case kHighFloat_GrSLType: // fall through
|
||||
case kFloat_GrSLType: // fall through
|
||||
case kHalf_GrSLType:
|
||||
return 1;
|
||||
case kHighFloat2_GrSLType: // fall through
|
||||
case kFloat2_GrSLType: // fall through
|
||||
case kHalf2_GrSLType:
|
||||
return 1;
|
||||
case kHighFloat3_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
return 1;
|
||||
case kHighFloat4_GrSLType:
|
||||
case kFloat4_GrSLType:
|
||||
case kHalf4_GrSLType:
|
||||
return 1;
|
||||
case kUint2_GrSLType:
|
||||
@ -33,13 +33,13 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
return 1;
|
||||
case kInt4_GrSLType:
|
||||
return 1;
|
||||
case kHighFloat2x2_GrSLType:
|
||||
case kFloat2x2_GrSLType:
|
||||
case kHalf2x2_GrSLType:
|
||||
return 2;
|
||||
case kHighFloat3x3_GrSLType:
|
||||
case kFloat3x3_GrSLType:
|
||||
case kHalf3x3_GrSLType:
|
||||
return 3;
|
||||
case kHighFloat4x4_GrSLType:
|
||||
case kFloat4x4_GrSLType:
|
||||
case kHalf4x4_GrSLType:
|
||||
return 4;
|
||||
case kTexture2DSampler_GrSLType:
|
||||
|
@ -1258,7 +1258,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
SkString permCode("return ");
|
||||
// FIXME even though I'm creating these textures with kRepeat_TileMode, they're clamped. Not
|
||||
// sure why. Using fract() (here and the next texture lookup) as a workaround.
|
||||
fragBuilder->appendTextureLookup(&permCode, args.fTexSamplers[0], "highfloat2(fract(x / 256.0), 0.0)",
|
||||
fragBuilder->appendTextureLookup(&permCode, args.fTexSamplers[0], "float2(fract(x / 256.0), 0.0)",
|
||||
kHalf2_GrSLType);
|
||||
permCode.append(".r * 255.0;");
|
||||
fragBuilder->emitFunction(kHalf_GrSLType, "perm", SK_ARRAY_COUNT(permArgs), permArgs,
|
||||
@ -1271,9 +1271,9 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
};
|
||||
SkString gradFuncName;
|
||||
SkString gradCode("return dot(");
|
||||
fragBuilder->appendTextureLookup(&gradCode, args.fTexSamplers[1], "highfloat2(fract(x / 16.0), 0.0)",
|
||||
fragBuilder->appendTextureLookup(&gradCode, args.fTexSamplers[1], "float2(fract(x / 16.0), 0.0)",
|
||||
kHalf2_GrSLType);
|
||||
gradCode.append(".rgb * 255.0 - highfloat3(1.0), p);");
|
||||
gradCode.append(".rgb * 255.0 - float3(1.0), p);");
|
||||
fragBuilder->emitFunction(kHalf_GrSLType, "grad", SK_ARRAY_COUNT(gradArgs), gradArgs,
|
||||
gradCode.c_str(), &gradFuncName);
|
||||
|
||||
|
@ -1359,7 +1359,7 @@ void GrGradientEffect::GLSLProcessor::emitUniforms(GrGLSLUniformHandler* uniform
|
||||
"Colors",
|
||||
colorCount);
|
||||
if (kSingleHardStop_ColorType == ge.fColorType || kThree_ColorType == ge.fColorType) {
|
||||
fExtraStopT = uniformHandler->addUniform(kFragment_GrShaderFlag, kHighFloat4_GrSLType,
|
||||
fExtraStopT = uniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
kHigh_GrSLPrecision, "ExtraStopT");
|
||||
}
|
||||
} else {
|
||||
@ -1684,7 +1684,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
|
||||
fragBuilder->codeAppendf("half2 coord = half2(%s, %s);", gradientTValue, fsyuni);
|
||||
fragBuilder->codeAppendf("%s = ", outputColor);
|
||||
fragBuilder->appendTextureLookupAndModulate(inputColor, texSamplers[0], "coord",
|
||||
kHighFloat2_GrSLType, &fColorSpaceHelper);
|
||||
kFloat2_GrSLType, &fColorSpaceHelper);
|
||||
fragBuilder->codeAppend(";");
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,9 @@ before handing it over to the graphics driver.
|
||||
Differences from GLSL
|
||||
=====================
|
||||
|
||||
* Precision modifiers are not used. 'float', 'int', and 'uint' are always high
|
||||
precision. New types 'half', 'short', and 'ushort' are medium precision (we
|
||||
do not use low precision).
|
||||
* Vector types are named <base type><columns>, so float2 instead of vec2 and
|
||||
bool4 instead of bvec4
|
||||
* Matrix types are named <base type><columns>x<rows>, so float2x3 instead of
|
||||
@ -38,8 +41,6 @@ Differences from GLSL
|
||||
* use sk_VertexID instead of gl_VertexID
|
||||
* the fragment coordinate is sk_FragCoord, and is always relative to the upper
|
||||
left.
|
||||
* lowp, mediump, and highp are always permitted (but will only be respected if
|
||||
you run on a device which supports them)
|
||||
* you do not need to include ".0" to make a number a float (meaning that
|
||||
"float2x, y) * 4" is perfectly legal in SkSL, unlike GLSL where it would often
|
||||
have to be expressed "float2x, y) * 4.0". There is no performance penalty for
|
||||
|
@ -344,20 +344,20 @@ void CPPCodeGenerator::addUniform(const Variable& var) {
|
||||
}
|
||||
const char* type;
|
||||
if (var.fType == *fContext.fFloat_Type) {
|
||||
type = "kHighFloat_GrSLType";
|
||||
type = "kFloat_GrSLType";
|
||||
} else if (var.fType == *fContext.fHalf_Type) {
|
||||
type = "kHalf_GrSLType";
|
||||
} else if (var.fType == *fContext.fFloat2_Type) {
|
||||
type = "kHighFloat2_GrSLType";
|
||||
type = "kFloat2_GrSLType";
|
||||
} else if (var.fType == *fContext.fHalf2_Type) {
|
||||
type = "kHalf2_GrSLType";
|
||||
} else if (var.fType == *fContext.fFloat4_Type) {
|
||||
type = "kHighFloat4_GrSLType";
|
||||
type = "kFloat4_GrSLType";
|
||||
} else if (var.fType == *fContext.fHalf4_Type) {
|
||||
type = "kHalf4_GrSLType";
|
||||
} else if (var.fType == *fContext.fFloat4x4_Type ||
|
||||
var.fType == *fContext.fColorSpaceXform_Type) {
|
||||
type = "kHighFloat4x4_GrSLType";
|
||||
type = "kFloat4x4_GrSLType";
|
||||
} else if (var.fType == *fContext.fHalf4x4_Type) {
|
||||
type = "kHalf4x4_GrSLType";
|
||||
} else {
|
||||
|
@ -25,10 +25,10 @@ public:
|
||||
, fDouble2_Type(new Type("double2", *fDouble_Type, 2))
|
||||
, fDouble3_Type(new Type("double3", *fDouble_Type, 3))
|
||||
, fDouble4_Type(new Type("double4", *fDouble_Type, 4))
|
||||
, fFloat_Type(new Type("highfloat", Type::kFloat_NumberKind, 3))
|
||||
, fFloat2_Type(new Type("highfloat2", *fFloat_Type, 2))
|
||||
, fFloat3_Type(new Type("highfloat3", *fFloat_Type, 3))
|
||||
, fFloat4_Type(new Type("highfloat4", *fFloat_Type, 4))
|
||||
, fFloat_Type(new Type("float", Type::kFloat_NumberKind, 3))
|
||||
, fFloat2_Type(new Type("float2", *fFloat_Type, 2))
|
||||
, fFloat3_Type(new Type("float3", *fFloat_Type, 3))
|
||||
, fFloat4_Type(new Type("float4", *fFloat_Type, 4))
|
||||
, fHalf_Type(new Type("half", Type::kFloat_NumberKind, 2))
|
||||
, fHalf2_Type(new Type("half2", *fHalf_Type, 2))
|
||||
, fHalf3_Type(new Type("half3", *fHalf_Type, 3))
|
||||
@ -53,15 +53,15 @@ public:
|
||||
, fBool2_Type(new Type("bool2", *fBool_Type, 2))
|
||||
, fBool3_Type(new Type("bool3", *fBool_Type, 3))
|
||||
, fBool4_Type(new Type("bool4", *fBool_Type, 4))
|
||||
, fFloat2x2_Type(new Type("highfloat2x2", *fFloat_Type, 2, 2))
|
||||
, fFloat2x3_Type(new Type("highfloat2x3", *fFloat_Type, 2, 3))
|
||||
, fFloat2x4_Type(new Type("highfloat2x4", *fFloat_Type, 2, 4))
|
||||
, fFloat3x2_Type(new Type("highfloat3x2", *fFloat_Type, 3, 2))
|
||||
, fFloat3x3_Type(new Type("highfloat3x3", *fFloat_Type, 3, 3))
|
||||
, fFloat3x4_Type(new Type("highfloat3x4", *fFloat_Type, 3, 4))
|
||||
, fFloat4x2_Type(new Type("highfloat4x2", *fFloat_Type, 4, 2))
|
||||
, fFloat4x3_Type(new Type("highfloat4x3", *fFloat_Type, 4, 3))
|
||||
, fFloat4x4_Type(new Type("highfloat4x4", *fFloat_Type, 4, 4))
|
||||
, fFloat2x2_Type(new Type("float2x2", *fFloat_Type, 2, 2))
|
||||
, fFloat2x3_Type(new Type("float2x3", *fFloat_Type, 2, 3))
|
||||
, fFloat2x4_Type(new Type("float2x4", *fFloat_Type, 2, 4))
|
||||
, fFloat3x2_Type(new Type("float3x2", *fFloat_Type, 3, 2))
|
||||
, fFloat3x3_Type(new Type("float3x3", *fFloat_Type, 3, 3))
|
||||
, fFloat3x4_Type(new Type("float3x4", *fFloat_Type, 3, 4))
|
||||
, fFloat4x2_Type(new Type("float4x2", *fFloat_Type, 4, 2))
|
||||
, fFloat4x3_Type(new Type("float4x3", *fFloat_Type, 4, 3))
|
||||
, fFloat4x4_Type(new Type("float4x4", *fFloat_Type, 4, 4))
|
||||
, fHalf2x2_Type(new Type("half2x2", *fHalf_Type, 2, 2))
|
||||
, fHalf2x3_Type(new Type("half2x3", *fHalf_Type, 2, 3))
|
||||
, fHalf2x4_Type(new Type("half2x4", *fHalf_Type, 2, 4))
|
||||
|
@ -136,10 +136,6 @@ String GLSLCodeGenerator::getTypeName(const Type& type) {
|
||||
else if (type == *fContext.fUShort_Type) {
|
||||
return "uint";
|
||||
}
|
||||
else if (type == *fContext.fFloat_Type) {
|
||||
// FIXME: temporary, this goes away when highfloat is renamed back to float
|
||||
return "float";
|
||||
}
|
||||
else {
|
||||
return type.name();
|
||||
}
|
||||
|
@ -23,15 +23,15 @@ HCodeGenerator::HCodeGenerator(const Program* program, ErrorReporter* errors, St
|
||||
, fSectionAndParameterHelper(*program, *errors) {}
|
||||
|
||||
String HCodeGenerator::ParameterType(const Type& type) {
|
||||
if (type.name() == "highfloat" || type.name() == "half") {
|
||||
if (type.name() == "float" || type.name() == "half") {
|
||||
return "float";
|
||||
} else if (type.name() == "highfloat2" || type.name() == "half2") {
|
||||
} else if (type.name() == "float2" || type.name() == "half2") {
|
||||
return "SkPoint";
|
||||
} else if (type.name() == "int4" || type.name() == "short4") {
|
||||
return "SkIRect";
|
||||
} else if (type.name() == "highfloat4" || type.name() == "half4") {
|
||||
} else if (type.name() == "float4" || type.name() == "half4") {
|
||||
return "SkRect";
|
||||
} else if (type.name() == "highfloat4x4" || type.name() == "half4x4") {
|
||||
} else if (type.name() == "float4x4" || type.name() == "half4x4") {
|
||||
return "SkMatrix44";
|
||||
} else if (type.kind() == Type::kSampler_Kind) {
|
||||
return "sk_sp<GrTextureProxy>";
|
||||
|
@ -43,14 +43,14 @@ $genType ceil($genType x);
|
||||
//$genDType ceil($genDType x);
|
||||
$genType fract($genType x);
|
||||
//$genDType fract($genDType x);
|
||||
$genType mod($genType x, highfloat y);
|
||||
$genType mod($genType x, float y);
|
||||
$genType mod($genType x, $genType y);
|
||||
//$genDType mod($genDType x, double y);
|
||||
//$genDType mod($genDType x, $genDType y);
|
||||
$genType modf($genType x, out $genType i);
|
||||
//$genDType modf($genDType x, out $genDType i);
|
||||
$genType min($genType x, $genType y);
|
||||
$genType min($genType x, highfloat y);
|
||||
$genType min($genType x, float y);
|
||||
//$genDType min($genDType x, $genDType y);
|
||||
//$genDType min($genDType x, double y);
|
||||
$genIType min($genIType x, $genIType y);
|
||||
@ -58,7 +58,7 @@ $genIType min($genIType x, int y);
|
||||
//$genUType min($genUType x, $genUType y);
|
||||
//$genUType min($genUType x, uint y);
|
||||
$genType max($genType x, $genType y);
|
||||
$genType max($genType x, highfloat y);
|
||||
$genType max($genType x, float y);
|
||||
//$genDType max($genDType x, $genDType y);
|
||||
//$genDType max($genDType x, double y);
|
||||
$genIType max($genIType x, $genIType y);
|
||||
@ -66,7 +66,7 @@ $genIType max($genIType x, int y);
|
||||
//$genUType max($genUType x, $genUType y);
|
||||
//$genUType max($genUType x, uint y);
|
||||
$genType clamp($genType x, $genType minVal, $genType maxVal);
|
||||
$genType clamp($genType x, highfloat minVal, highfloat maxVal);
|
||||
$genType clamp($genType x, float minVal, float maxVal);
|
||||
//$genDType clamp($genDType x, $genDType minVal, $genDType maxVal);
|
||||
//$genDType clamp($genDType x, double minVal, double maxVal);
|
||||
$genIType clamp($genIType x, $genIType minVal, $genIType maxVal);
|
||||
@ -74,7 +74,7 @@ $genIType clamp($genIType x, int minVal, int maxVal);
|
||||
//$genUType clamp($genUType x, $genUType minVal, $genUType maxVal);
|
||||
//$genUType clamp($genUType x, uint minVal, uint maxVal);
|
||||
$genType mix($genType x, $genType y, $genType a);
|
||||
$genType mix($genType x, $genType y, highfloat a);
|
||||
$genType mix($genType x, $genType y, float a);
|
||||
//$genDType mix($genDType x, $genDType y, $genDType a);
|
||||
//$genDType mix($genDType x, $genDType y, double a);
|
||||
$genType mix($genType x, $genType y, $genBType a);
|
||||
@ -83,21 +83,21 @@ $genIType mix($genIType x, $genIType y, $genBType a);
|
||||
//$genUType mix($genUType x, $genUType y, $genBType a);
|
||||
$genBType mix($genBType x, $genBType y, $genBType a);
|
||||
$genType step($genType edge, $genType x);
|
||||
$genType step(highfloat edge, $genType x);
|
||||
$genType step(float edge, $genType x);
|
||||
//$genDType step($genDType edge, $genDType x);
|
||||
//$genDType step(double edge, $genDType x);
|
||||
$genType smoothstep($genType edge0, $genType edge1, $genType x);
|
||||
$genType smoothstep(highfloat edge0, highfloat edge1, $genType x);
|
||||
$genType smoothstep(float edge0, float edge1, $genType x);
|
||||
//$genDType smoothstep($genDType edge0, $genDType edge1, $genDType x);
|
||||
//$genDType smoothstep(double edge0, double edge1, $genDType x);
|
||||
$genBType isnan($genType x);
|
||||
$genBType isnan($genDType x);
|
||||
$genBType isinf($genType x);
|
||||
$genBType isinf($genDType x);
|
||||
$genIType highfloatBitsToInt($genType value);
|
||||
//$genUType highfloatBitsToUint($genType value);
|
||||
$genType intBitsTohighfloat($genIType value);
|
||||
$genType uintBitsTohighfloat($genUType value);
|
||||
$genIType floatBitsToInt($genType value);
|
||||
//$genUType floatBitsToUint($genType value);
|
||||
$genType intBitsTofloat($genIType value);
|
||||
$genType uintBitsTofloat($genUType value);
|
||||
$genType fma($genType a, $genType b, $genType c);
|
||||
$genHType fma($genHType a, $genHType b, $genHType c);
|
||||
$genDType fma($genDType a, $genDType b, $genDType c);
|
||||
@ -106,68 +106,68 @@ $genType frexp($genType x, out $genIType exp);
|
||||
//$genDType frexp($genDType x, out $genIType exp);
|
||||
$genType ldexp($genType x, in $genIType exp);
|
||||
//$genDType ldexp($genDType x, in $genIType exp);
|
||||
uint packUnorm2x16(highfloat2 v);
|
||||
uint packSnorm2x16(highfloat2 v);
|
||||
uint packUnorm4x8(highfloat4 v);
|
||||
uint packSnorm4x8(highfloat4 v);
|
||||
highfloat2 unpackUnorm2x16(uint p);
|
||||
highfloat2 unpackSnorm2x16(uint p);
|
||||
highfloat4 unpackUnorm4x8(uint p);
|
||||
highfloat4 unpackSnorm4x8(uint p);
|
||||
uint packUnorm2x16(float2 v);
|
||||
uint packSnorm2x16(float2 v);
|
||||
uint packUnorm4x8(float4 v);
|
||||
uint packSnorm4x8(float4 v);
|
||||
float2 unpackUnorm2x16(uint p);
|
||||
float2 unpackSnorm2x16(uint p);
|
||||
float4 unpackUnorm4x8(uint p);
|
||||
float4 unpackSnorm4x8(uint p);
|
||||
//double packDouble2x32(uint2 v);
|
||||
uint2 unpackDouble2x32(double v);
|
||||
uint packHalf2x16(highfloat2 v);
|
||||
highfloat2 unpackHalf2x16(uint v);
|
||||
highfloat length($genType x);
|
||||
uint packHalf2x16(float2 v);
|
||||
float2 unpackHalf2x16(uint v);
|
||||
float length($genType x);
|
||||
half length($genHType x);
|
||||
double length($genDType x);
|
||||
highfloat distance($genType p0, $genType p1);
|
||||
float distance($genType p0, $genType p1);
|
||||
half distance($genHType p0, $genHType p1);
|
||||
double distance($genDType p0, $genDType p1);
|
||||
highfloat dot($genType x, $genType y);
|
||||
float dot($genType x, $genType y);
|
||||
half dot($genHType x, $genHType y);
|
||||
double dot($genDType x, $genDType y);
|
||||
highfloat3 cross(highfloat3 x, highfloat3 y);
|
||||
float3 cross(float3 x, float3 y);
|
||||
half3 cross(half3 x, half3 y);
|
||||
double3 cross(double3 x, double3 y);
|
||||
$genType normalize($genType x);
|
||||
$genHType normalize($genHType x);
|
||||
$genDType normalize($genDType x);
|
||||
highfloat4 ftransform();
|
||||
float4 ftransform();
|
||||
$genType faceforward($genType N, $genType I, $genType Nref);
|
||||
$genHType faceforward($genHType N, $genHType I, $genHType Nref);
|
||||
$genDType faceforward($genDType N, $genDType I, $genDType Nref);
|
||||
$genType reflect($genType I, $genType N);
|
||||
$genHType reflect($genHType I, $genHType N);
|
||||
$genDType reflect($genDType I, $genDType N);
|
||||
$genType refract($genType I, $genType N, highfloat eta);
|
||||
$genHType refract($genHType I, $genHType N, highfloat eta);
|
||||
$genDType refract($genDType I, $genDType N, highfloat eta);
|
||||
$genType refract($genType I, $genType N, float eta);
|
||||
$genHType refract($genHType I, $genHType N, float eta);
|
||||
$genDType refract($genDType I, $genDType N, float eta);
|
||||
$mat matrixCompMult($mat x, $mat y);
|
||||
highfloat2x2 outerProduct(highfloat2 c, highfloat2 r);
|
||||
highfloat3x3 outerProduct(highfloat3 c, highfloat3 r);
|
||||
highfloat4x3 outerProduct(highfloat4 c, highfloat4 r);
|
||||
highfloat2x3 outerProduct(highfloat3 c, highfloat2 r);
|
||||
highfloat3x2 outerProduct(highfloat2 c, highfloat3 r);
|
||||
highfloat2x4 outerProduct(highfloat4 c, highfloat2 r);
|
||||
highfloat4x2 outerProduct(highfloat2 c, highfloat4 r);
|
||||
highfloat3x4 outerProduct(highfloat4 c, highfloat3 r);
|
||||
highfloat4x3 outerProduct(highfloat3 c, highfloat4 r);
|
||||
highfloat2x2 transpose(highfloat2x2 m);
|
||||
highfloat3x3 transpose(highfloat3x3 m);
|
||||
highfloat4x4 transpose(highfloat4x4 m);
|
||||
highfloat2x3 transpose(highfloat3x2 m);
|
||||
highfloat3x2 transpose(highfloat2x3 m);
|
||||
highfloat2x4 transpose(highfloat4x2 m);
|
||||
highfloat4x2 transpose(highfloat2x4 m);
|
||||
highfloat3x4 transpose(highfloat4x3 m);
|
||||
highfloat4x3 transpose(highfloat3x4 m);
|
||||
highfloat determinant(highfloat2x2 m);
|
||||
highfloat determinant(highfloat3x3 m);
|
||||
highfloat determinant(highfloat4x4 m);
|
||||
highfloat2x2 inverse(highfloat2x2 m);
|
||||
highfloat3x3 inverse(highfloat3x3 m);
|
||||
highfloat4x4 inverse(highfloat4x4 m);
|
||||
float2x2 outerProduct(float2 c, float2 r);
|
||||
float3x3 outerProduct(float3 c, float3 r);
|
||||
float4x3 outerProduct(float4 c, float4 r);
|
||||
float2x3 outerProduct(float3 c, float2 r);
|
||||
float3x2 outerProduct(float2 c, float3 r);
|
||||
float2x4 outerProduct(float4 c, float2 r);
|
||||
float4x2 outerProduct(float2 c, float4 r);
|
||||
float3x4 outerProduct(float4 c, float3 r);
|
||||
float4x3 outerProduct(float3 c, float4 r);
|
||||
float2x2 transpose(float2x2 m);
|
||||
float3x3 transpose(float3x3 m);
|
||||
float4x4 transpose(float4x4 m);
|
||||
float2x3 transpose(float3x2 m);
|
||||
float3x2 transpose(float2x3 m);
|
||||
float2x4 transpose(float4x2 m);
|
||||
float4x2 transpose(float2x4 m);
|
||||
float3x4 transpose(float4x3 m);
|
||||
float4x3 transpose(float3x4 m);
|
||||
float determinant(float2x2 m);
|
||||
float determinant(float3x3 m);
|
||||
float determinant(float4x4 m);
|
||||
float2x2 inverse(float2x2 m);
|
||||
float3x3 inverse(float3x3 m);
|
||||
float4x4 inverse(float4x4 m);
|
||||
$bvec lessThan($vec x, $vec y);
|
||||
$bvec lessThan($hvec x, $hvec y);
|
||||
$bvec lessThan($dvec x, $dvec y);
|
||||
@ -254,19 +254,19 @@ int3 textureSize(sampler2DArrayShadow sampler, int lod);
|
||||
int textureSize($gsamplerBuffer sampler);
|
||||
int2 textureSize($gsampler2DMS sampler);
|
||||
int3 textureSize($gsampler2DMSArray sampler);
|
||||
highfloat2 textureQueryLod($gsampler1D sampler, highfloat P);
|
||||
highfloat2 textureQueryLod($gsampler2D sampler, highfloat2 P);
|
||||
highfloat2 textureQueryLod($gsampler3D sampler, highfloat3 P);
|
||||
highfloat2 textureQueryLod($gsamplerCube sampler, highfloat3 P);
|
||||
highfloat2 textureQueryLod($gsampler1DArray sampler, highfloat P);
|
||||
highfloat2 textureQueryLod($gsampler2DArray sampler, highfloat2 P);
|
||||
highfloat2 textureQueryLod($gsamplerCubeArray sampler, highfloat3 P);
|
||||
highfloat2 textureQueryLod(sampler1DShadow sampler, highfloat P);
|
||||
highfloat2 textureQueryLod(sampler2DShadow sampler, highfloat2 P);
|
||||
highfloat2 textureQueryLod(samplerCubeShadow sampler, highfloat3 P);
|
||||
highfloat2 textureQueryLod(sampler1DArrayShadow sampler, highfloat P);
|
||||
highfloat2 textureQueryLod(sampler2DArrayShadow sampler, highfloat2 P);
|
||||
highfloat2 textureQueryLod(samplerCubeArrayShadow sampler, highfloat3 P);
|
||||
float2 textureQueryLod($gsampler1D sampler, float P);
|
||||
float2 textureQueryLod($gsampler2D sampler, float2 P);
|
||||
float2 textureQueryLod($gsampler3D sampler, float3 P);
|
||||
float2 textureQueryLod($gsamplerCube sampler, float3 P);
|
||||
float2 textureQueryLod($gsampler1DArray sampler, float P);
|
||||
float2 textureQueryLod($gsampler2DArray sampler, float2 P);
|
||||
float2 textureQueryLod($gsamplerCubeArray sampler, float3 P);
|
||||
float2 textureQueryLod(sampler1DShadow sampler, float P);
|
||||
float2 textureQueryLod(sampler2DShadow sampler, float2 P);
|
||||
float2 textureQueryLod(samplerCubeShadow sampler, float3 P);
|
||||
float2 textureQueryLod(sampler1DArrayShadow sampler, float P);
|
||||
float2 textureQueryLod(sampler2DArrayShadow sampler, float2 P);
|
||||
float2 textureQueryLod(samplerCubeArrayShadow sampler, float3 P);
|
||||
int textureQueryLevels($gsampler1D sampler);
|
||||
int textureQueryLevels($gsampler2D sampler);
|
||||
int textureQueryLevels($gsampler3D sampler);
|
||||
@ -282,50 +282,50 @@ int textureQueryLevels(sampler2DArrayShadow sampler);
|
||||
int textureQueryLevels(samplerCubeArrayShadow sampler);
|
||||
*/
|
||||
|
||||
half4 texture($gsampler1D sampler, highfloat P);
|
||||
half4 texture($gsampler1D sampler, highfloat P, highfloat bias);
|
||||
half4 texture($gsampler2D sampler, highfloat2 P);
|
||||
half4 texture($gsampler1D sampler, float P);
|
||||
half4 texture($gsampler1D sampler, float P, float bias);
|
||||
half4 texture($gsampler2D sampler, float2 P);
|
||||
// The above currently only expand to handle the float/fixed case. So we also declare this integer
|
||||
// version of texture().
|
||||
int4 texture(isampler2D sampler, highfloat2 P);
|
||||
half4 texture(samplerExternalOES sampler, highfloat2 P, highfloat bias);
|
||||
half4 texture(samplerExternalOES sampler, highfloat2 P);
|
||||
int4 texture(isampler2D sampler, float2 P);
|
||||
half4 texture(samplerExternalOES sampler, float2 P, float bias);
|
||||
half4 texture(samplerExternalOES sampler, float2 P);
|
||||
|
||||
/*
|
||||
$gfloat4 texture($gsampler2D sampler, highfloat2 P, highfloat bias);
|
||||
$gfloat4 texture($gsampler3D sampler, highfloat3 P);
|
||||
$gfloat4 texture($gsampler3D sampler, highfloat3 P, highfloat bias);
|
||||
$gfloat4 texture($gsamplerCube sampler, highfloat3 P);
|
||||
$gfloat4 texture($gsamplerCube sampler, highfloat3 P, highfloat bias);
|
||||
highfloat texture(sampler1DShadow sampler, highfloat3 P);
|
||||
highfloat texture(sampler1DShadow sampler, highfloat3 P, highfloat bias);
|
||||
highfloat texture(sampler2DShadow sampler, highfloat3 P);
|
||||
highfloat texture(sampler2DShadow sampler, highfloat3 P, highfloat bias);
|
||||
highfloat texture(samplerCubeShadow sampler, highfloat4 P);
|
||||
highfloat texture(samplerCubeShadow sampler, highfloat4 P, highfloat bias);
|
||||
$gfloat4 texture($gsampler1DArray sampler, highfloat2 P);
|
||||
$gfloat4 texture($gsampler1DArray sampler, highfloat2 P, highfloat bias);
|
||||
$gfloat4 texture($gsampler2DArray sampler, highfloat3 P);
|
||||
$gfloat4 texture($gsampler2DArray sampler, highfloat3 P, highfloat bias);
|
||||
$gfloat4 texture($gsamplerCubeArray sampler, highfloat4 P);
|
||||
$gfloat4 texture($gsamplerCubeArray sampler, highfloat4 P, highfloat bias);
|
||||
highfloat texture(sampler1DArrayShadow sampler, highfloat3 P);
|
||||
highfloat texture(sampler1DArrayShadow sampler, highfloat3 P, highfloat bias);
|
||||
highfloat texture(sampler2DArrayShadow sampler, highfloat4 P);
|
||||
$gfloat4 texture($gsampler2D sampler, float2 P, float bias);
|
||||
$gfloat4 texture($gsampler3D sampler, float3 P);
|
||||
$gfloat4 texture($gsampler3D sampler, float3 P, float bias);
|
||||
$gfloat4 texture($gsamplerCube sampler, float3 P);
|
||||
$gfloat4 texture($gsamplerCube sampler, float3 P, float bias);
|
||||
float texture(sampler1DShadow sampler, float3 P);
|
||||
float texture(sampler1DShadow sampler, float3 P, float bias);
|
||||
float texture(sampler2DShadow sampler, float3 P);
|
||||
float texture(sampler2DShadow sampler, float3 P, float bias);
|
||||
float texture(samplerCubeShadow sampler, float4 P);
|
||||
float texture(samplerCubeShadow sampler, float4 P, float bias);
|
||||
$gfloat4 texture($gsampler1DArray sampler, float2 P);
|
||||
$gfloat4 texture($gsampler1DArray sampler, float2 P, float bias);
|
||||
$gfloat4 texture($gsampler2DArray sampler, float3 P);
|
||||
$gfloat4 texture($gsampler2DArray sampler, float3 P, float bias);
|
||||
$gfloat4 texture($gsamplerCubeArray sampler, float4 P);
|
||||
$gfloat4 texture($gsamplerCubeArray sampler, float4 P, float bias);
|
||||
float texture(sampler1DArrayShadow sampler, float3 P);
|
||||
float texture(sampler1DArrayShadow sampler, float3 P, float bias);
|
||||
float texture(sampler2DArrayShadow sampler, float4 P);
|
||||
*/
|
||||
|
||||
half4 texture($gsampler2DRect sampler, highfloat2 P);
|
||||
half4 texture($gsampler2DRect sampler, highfloat3 P);
|
||||
half4 texture($gsampler2DRect sampler, float2 P);
|
||||
half4 texture($gsampler2DRect sampler, float3 P);
|
||||
|
||||
/*
|
||||
highfloat texture(sampler2DRectShadow sampler, highfloat3 P);
|
||||
highfloat texture($gsamplerCubeArrayShadow sampler, highfloat4 P, highfloat compare);
|
||||
float texture(sampler2DRectShadow sampler, float3 P);
|
||||
float texture($gsamplerCubeArrayShadow sampler, float4 P, float compare);
|
||||
*/
|
||||
|
||||
// Currently we do not support the generic types of loading subpassInput so we have some explicit
|
||||
// versions that we currently use
|
||||
highfloat4 subpassLoad(subpassInput subpass);
|
||||
highfloat4 subpassLoad(subpassInputMS subpass, int sample);
|
||||
float4 subpassLoad(subpassInput subpass);
|
||||
float4 subpassLoad(subpassInputMS subpass, int sample);
|
||||
/*
|
||||
$gfloat4subpassLoad(gsubpassInput subpass);
|
||||
$gfloat4subpassLoad(gsubpassInputMS subpass, int sample);
|
||||
@ -336,50 +336,50 @@ $gfloat4subpassLoad(gsubpassInputMS subpass, int sample);
|
||||
|
||||
STRINGIFY(
|
||||
|
||||
half4 texture($gsampler1D sampler, highfloat2 P);
|
||||
half4 texture($gsampler1D sampler, highfloat2 P, highfloat bias);
|
||||
half4 texture($gsampler2D sampler, highfloat3 P);
|
||||
half4 texture($gsampler2D sampler, highfloat3 P, highfloat bias);
|
||||
half4 texture($gsampler1D sampler, float2 P);
|
||||
half4 texture($gsampler1D sampler, float2 P, float bias);
|
||||
half4 texture($gsampler2D sampler, float3 P);
|
||||
half4 texture($gsampler2D sampler, float3 P, float bias);
|
||||
/*
|
||||
$gfloat4 textureProj($gsampler3D sampler, highfloat4 P);
|
||||
$gfloat4 textureProj($gsampler3D sampler, highfloat4 P, highfloat bias);
|
||||
highfloat textureProj(sampler1DShadow sampler, highfloat4 P);
|
||||
highfloat textureProj(sampler1DShadow sampler, highfloat4 P, highfloat bias);
|
||||
highfloat textureProj(sampler2DShadow sampler, highfloat4 P);
|
||||
highfloat textureProj(sampler2DShadow sampler, highfloat4 P, highfloat bias);
|
||||
$gfloat4 textureProj($gsampler2DRect sampler, highfloat4 P);
|
||||
highfloat textureProj(sampler2DRectShadow sampler, highfloat4 P);
|
||||
$gfloat4 textureLod($gsampler1D sampler, highfloat P, highfloat lod);
|
||||
$gfloat4 textureLod($gsampler2D sampler, highfloat2 P, highfloat lod);
|
||||
$gfloat4 textureLod($gsampler3D sampler, highfloat3 P, highfloat lod);
|
||||
$gfloat4 textureLod($gsamplerCube sampler, highfloat3 P, highfloat lod);
|
||||
highfloat textureLod(sampler1DShadow sampler, highfloat3 P, highfloat lod);
|
||||
highfloat textureLod(sampler2DShadow sampler, highfloat3 P, highfloat lod);
|
||||
$gfloat4 textureLod($gsampler1DArray sampler, highfloat2 P, highfloat lod);
|
||||
$gfloat4 textureLod($gsampler2DArray sampler, highfloat3 P, highfloat lod);
|
||||
highfloat textureLod(sampler1DArrayShadow sampler, highfloat3 P, highfloat lod);
|
||||
$gfloat4 textureLod($gsamplerCubeArray sampler, highfloat4 P, highfloat lod);
|
||||
$gfloat4 textureOffset($gsampler1D sampler, highfloat P, int offset);
|
||||
$gfloat4 textureOffset($gsampler1D sampler, highfloat P, int offset, highfloat bias);
|
||||
$gfloat4 textureOffset($gsampler2D sampler, highfloat2 P, int2 offset);
|
||||
$gfloat4 textureOffset($gsampler2D sampler, highfloat2 P, int2 offset, highfloat bias);
|
||||
$gfloat4 textureOffset($gsampler3D sampler, highfloat3 P, int3 offset);
|
||||
$gfloat4 textureOffset($gsampler3D sampler, highfloat3 P, int3 offset, highfloat bias);
|
||||
$gfloat4 textureOffset($gsampler2DRect sampler, highfloat2 P, int2 offset);
|
||||
highfloat textureOffset(sampler2DRectShadow sampler, highfloat3 P, int2 offset);
|
||||
highfloat textureOffset(sampler1DShadow sampler, highfloat3 P, int offset);
|
||||
highfloat textureOffset(sampler1DShadow sampler, highfloat3 P, int offset, highfloat bias);
|
||||
highfloat textureOffset(sampler2DShadow sampler, highfloat3 P, int2 offset);
|
||||
highfloat textureOffset(sampler2DShadow sampler, highfloat3 P, int2 offset, highfloat bias);
|
||||
$gfloat4 textureOffset($gsampler1DArray sampler, highfloat2 P, int offset);
|
||||
$gfloat4 textureOffset($gsampler1DArray sampler, highfloat2 P, int offset, highfloat bias);
|
||||
$gfloat4 textureOffset($gsampler2DArray sampler, highfloat3 P, int2 offset);
|
||||
$gfloat4 textureOffset($gsampler2DArray sampler, highfloat3 P, int2 offset, highfloat bias);
|
||||
highfloat textureOffset(sampler1DArrayShadow sampler, highfloat3 P, int offset);
|
||||
highfloat textureOffset(sampler1DArrayShadow sampler, highfloat3 P, int offset, highfloat bias);
|
||||
highfloat textureOffset(sampler2DArrayShadow sampler, highfloat4 P, int2 offset);
|
||||
$gfloat4 textureProj($gsampler3D sampler, float4 P);
|
||||
$gfloat4 textureProj($gsampler3D sampler, float4 P, float bias);
|
||||
float textureProj(sampler1DShadow sampler, float4 P);
|
||||
float textureProj(sampler1DShadow sampler, float4 P, float bias);
|
||||
float textureProj(sampler2DShadow sampler, float4 P);
|
||||
float textureProj(sampler2DShadow sampler, float4 P, float bias);
|
||||
$gfloat4 textureProj($gsampler2DRect sampler, float4 P);
|
||||
float textureProj(sampler2DRectShadow sampler, float4 P);
|
||||
$gfloat4 textureLod($gsampler1D sampler, float P, float lod);
|
||||
$gfloat4 textureLod($gsampler2D sampler, float2 P, float lod);
|
||||
$gfloat4 textureLod($gsampler3D sampler, float3 P, float lod);
|
||||
$gfloat4 textureLod($gsamplerCube sampler, float3 P, float lod);
|
||||
float textureLod(sampler1DShadow sampler, float3 P, float lod);
|
||||
float textureLod(sampler2DShadow sampler, float3 P, float lod);
|
||||
$gfloat4 textureLod($gsampler1DArray sampler, float2 P, float lod);
|
||||
$gfloat4 textureLod($gsampler2DArray sampler, float3 P, float lod);
|
||||
float textureLod(sampler1DArrayShadow sampler, float3 P, float lod);
|
||||
$gfloat4 textureLod($gsamplerCubeArray sampler, float4 P, float lod);
|
||||
$gfloat4 textureOffset($gsampler1D sampler, float P, int offset);
|
||||
$gfloat4 textureOffset($gsampler1D sampler, float P, int offset, float bias);
|
||||
$gfloat4 textureOffset($gsampler2D sampler, float2 P, int2 offset);
|
||||
$gfloat4 textureOffset($gsampler2D sampler, float2 P, int2 offset, float bias);
|
||||
$gfloat4 textureOffset($gsampler3D sampler, float3 P, int3 offset);
|
||||
$gfloat4 textureOffset($gsampler3D sampler, float3 P, int3 offset, float bias);
|
||||
$gfloat4 textureOffset($gsampler2DRect sampler, float2 P, int2 offset);
|
||||
float textureOffset(sampler2DRectShadow sampler, float3 P, int2 offset);
|
||||
float textureOffset(sampler1DShadow sampler, float3 P, int offset);
|
||||
float textureOffset(sampler1DShadow sampler, float3 P, int offset, float bias);
|
||||
float textureOffset(sampler2DShadow sampler, float3 P, int2 offset);
|
||||
float textureOffset(sampler2DShadow sampler, float3 P, int2 offset, float bias);
|
||||
$gfloat4 textureOffset($gsampler1DArray sampler, float2 P, int offset);
|
||||
$gfloat4 textureOffset($gsampler1DArray sampler, float2 P, int offset, float bias);
|
||||
$gfloat4 textureOffset($gsampler2DArray sampler, float3 P, int2 offset);
|
||||
$gfloat4 textureOffset($gsampler2DArray sampler, float3 P, int2 offset, float bias);
|
||||
float textureOffset(sampler1DArrayShadow sampler, float3 P, int offset);
|
||||
float textureOffset(sampler1DArrayShadow sampler, float3 P, int offset, float bias);
|
||||
float textureOffset(sampler2DArrayShadow sampler, float4 P, int2 offset);
|
||||
*/
|
||||
highfloat4 texelFetch(samplerBuffer sampler, int P);
|
||||
float4 texelFetch(samplerBuffer sampler, int P);
|
||||
|
||||
$gfloat4 texelFetch($gsampler1D sampler, int P, int lod);
|
||||
$gfloat4 texelFetch($gsampler2D sampler, int2 P, int lod);
|
||||
@ -396,123 +396,123 @@ $gfloat4 texelFetchOffset($gsampler3D sampler, int3 P, int lod, int3 offset);
|
||||
$gfloat4 texelFetchOffset($gsampler2DRect sampler, int2 P, int2 offset);
|
||||
$gfloat4 texelFetchOffset($gsampler1DArray sampler, int2 P, int lod, int offset);
|
||||
$gfloat4 texelFetchOffset($gsampler2DArray sampler, int3 P, int lod, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, highfloat2 P, int offset);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, highfloat2 P, int offset, highfloat bias);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, highfloat4 P, int offset);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, highfloat4 P, int offset, highfloat bias);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, highfloat3 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, highfloat3 P, int2 offset, highfloat bias);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, highfloat4 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, highfloat4 P, int2 offset, highfloat bias);
|
||||
$gfloat4 textureProjOffset($gsampler3D sampler, highfloat4 P, int3 offset);
|
||||
$gfloat4 textureProjOffset($gsampler3D sampler, highfloat4 P, int3 offset, highfloat bias);
|
||||
$gfloat4 textureProjOffset($gsampler2DRect sampler, highfloat3 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2DRect sampler, highfloat4 P, int2 offset);
|
||||
highfloat textureProjOffset(sampler2DRectShadow sampler, highfloat4 P, int2 offset);
|
||||
highfloat textureProjOffset(sampler1DShadow sampler, highfloat4 P, int offset);
|
||||
highfloat textureProjOffset(sampler1DShadow sampler, highfloat4 P, int offset, highfloat bias);
|
||||
highfloat textureProjOffset(sampler2DShadow sampler, highfloat4 P, int2 offset);
|
||||
highfloat textureProjOffset(sampler2DShadow sampler, highfloat4 P, int2 offset, highfloat bias);
|
||||
$gfloat4 textureLodOffset($gsampler1D sampler, highfloat P, highfloat lod, int offset);
|
||||
$gfloat4 textureLodOffset($gsampler2D sampler, highfloat2 P, highfloat lod, int2 offset);
|
||||
$gfloat4 textureLodOffset($gsampler3D sampler, highfloat3 P, highfloat lod, int3 offset);
|
||||
highfloat textureLodOffset(sampler1DShadow sampler, highfloat3 P, highfloat lod, int offset);
|
||||
highfloat textureLodOffset(sampler2DShadow sampler, highfloat3 P, highfloat lod, int2 offset);
|
||||
$gfloat4 textureLodOffset($gsampler1DArray sampler, highfloat2 P, highfloat lod, int offset);
|
||||
$gfloat4 textureLodOffset($gsampler2DArray sampler, highfloat3 P, highfloat lod, int2 offset);
|
||||
highfloat textureLodOffset(sampler1DArrayShadow sampler, highfloat3 P, highfloat lod, int offset);
|
||||
$gfloat4 textureProjLod($gsampler1D sampler, highfloat2 P, highfloat lod);
|
||||
$gfloat4 textureProjLod($gsampler1D sampler, highfloat4 P, highfloat lod);
|
||||
$gfloat4 textureProjLod($gsampler2D sampler, highfloat3 P, highfloat lod);
|
||||
$gfloat4 textureProjLod($gsampler2D sampler, highfloat4 P, highfloat lod);
|
||||
$gfloat4 textureProjLod($gsampler3D sampler, highfloat4 P, highfloat lod);
|
||||
highfloat textureProjLod(sampler1DShadow sampler, highfloat4 P, highfloat lod);
|
||||
highfloat textureProjLod(sampler2DShadow sampler, highfloat4 P, highfloat lod);
|
||||
$gfloat4 textureProjLodOffset($gsampler1D sampler, highfloat2 P, highfloat lod, int offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler1D sampler, highfloat4 P, highfloat lod, int offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler2D sampler, highfloat3 P, highfloat lod, int2 offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler2D sampler, highfloat4 P, highfloat lod, int2 offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler3D sampler, highfloat4 P, highfloat lod, int3 offset);
|
||||
highfloat textureProjLodOffset(sampler1DShadow sampler, highfloat4 P, highfloat lod, int offset);
|
||||
highfloat textureProjLodOffset(sampler2DShadow sampler, highfloat4 P, highfloat lod, int2 offset);
|
||||
$gfloat4 textureGrad($gsampler1D sampler, highfloat P, highfloat dPdx, highfloat dPdy);
|
||||
$gfloat4 textureGrad($gsampler2D sampler, highfloat2 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureGrad($gsampler3D sampler, highfloat3 P, highfloat3 dPdx, highfloat3 dPdy);
|
||||
$gfloat4 textureGrad($gsamplerCube sampler, highfloat3 P, highfloat3 dPdx, highfloat3 dPdy);
|
||||
$gfloat4 textureGrad($gsampler2DRect sampler, highfloat2 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureGrad(sampler2DRectShadow sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureGrad(sampler1DShadow sampler, highfloat3 P, highfloat dPdx, highfloat dPdy);
|
||||
highfloat textureGrad(sampler2DShadow sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureGrad(samplerCubeShadow sampler, highfloat4 P, highfloat3 dPdx, highfloat3 dPdy);
|
||||
$gfloat4 textureGrad($gsampler1DArray sampler, highfloat2 P, highfloat dPdx, highfloat dPdy);
|
||||
$gfloat4 textureGrad($gsampler2DArray sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureGrad(sampler1DArrayShadow sampler, highfloat3 P, highfloat dPdx, highfloat dPdy);
|
||||
highfloat textureGrad(sampler2DArrayShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureGrad($gsamplerCubeArray sampler, highfloat4 P, highfloat3 dPdx, highfloat3 dPdy);
|
||||
$gfloat4 textureGradOffset($gsampler1D sampler, highfloat P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
$gfloat4 textureGradOffset($gsampler2D sampler, highfloat2 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureGradOffset($gsampler3D sampler, highfloat3 P, highfloat3 dPdx, highfloat3 dPdy, int3 offset);
|
||||
$gfloat4 textureGradOffset($gsampler2DRect sampler, highfloat2 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
highfloat textureGradOffset(sampler2DRectShadow sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
highfloat textureGradOffset(sampler1DShadow sampler, highfloat3 P, highfloat dPdx, highfloat dPdy, int offset );
|
||||
highfloat textureGradOffset(sampler2DShadow sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureGradOffset($gsampler1DArray sampler, highfloat2 P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
$gfloat4 textureGradOffset($gsampler2DArray sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
highfloat textureGradOffset(sampler1DArrayShadow sampler, highfloat3 P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
highfloat textureGradOffset(sampler2DArrayShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGrad($gsampler1D sampler, highfloat2 P, highfloat dPdx, highfloat dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler1D sampler, highfloat4 P, highfloat dPdx, highfloat dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2D sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2D sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler3D sampler, highfloat4 P, highfloat3 dPdx, highfloat3 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2DRect sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2DRect sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureProjGrad(sampler2DRectShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
highfloat textureProjGrad(sampler1DShadow sampler, highfloat4 P, highfloat dPdx, highfloat dPdy);
|
||||
highfloat textureProjGrad(sampler2DShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy);
|
||||
$gfloat4 textureProjGradOffset($gsampler1D sampler, highfloat2 P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler1D sampler, highfloat4 P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2D sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2D sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2DRect sampler, highfloat3 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2DRect sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
highfloat textureProjGradOffset(sampler2DRectShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler3D sampler, highfloat4 P, highfloat3 dPdx, highfloat3 dPdy, int3 offset);
|
||||
highfloat textureProjGradOffset(sampler1DShadow sampler, highfloat4 P, highfloat dPdx, highfloat dPdy, int offset);
|
||||
highfloat textureProjGradOffset(sampler2DShadow sampler, highfloat4 P, highfloat2 dPdx, highfloat2 dPdy, int2 offset);
|
||||
$gfloat4 textureGather($gsampler2D sampler, highfloat2 P);
|
||||
$gfloat4 textureGather($gsampler2D sampler, highfloat2 P, int comp);
|
||||
$gfloat4 textureGather($gsampler2DArray sampler, highfloat3 P);
|
||||
$gfloat4 textureGather($gsampler2DArray sampler, highfloat3 P, int comp);
|
||||
$gfloat4 textureGather($gsamplerCube sampler, highfloat3 P);
|
||||
$gfloat4 textureGather($gsamplerCube sampler, highfloat3 P, int comp);
|
||||
$gfloat4 textureGather($gsamplerCubeArray sampler, highfloat4 P);
|
||||
$gfloat4 textureGather($gsamplerCubeArray sampler, highfloat4 P, int comp);
|
||||
$gfloat4 textureGather($gsampler2DRect sampler, highfloat2 P);
|
||||
$gfloat4 textureGather($gsampler2DRect sampler, highfloat2 P, int comp);
|
||||
highfloat4 textureGather(sampler2DShadow sampler, highfloat2 P, highfloat refZ);
|
||||
highfloat4 textureGather(sampler2DArrayShadow sampler, highfloat3 P, highfloat refZ);
|
||||
highfloat4 textureGather(samplerCubeShadow sampler, highfloat3 P, highfloat refZ);
|
||||
highfloat4 textureGather(samplerCubeArrayShadow sampler, highfloat4 P, highfloat refZ);
|
||||
highfloat4 textureGather(sampler2DRectShadow sampler, highfloat2 P, highfloat refZ);
|
||||
$gfloat4 textureGatherOffset($gsampler2D sampler, highfloat2 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2D sampler, highfloat2 P, int2 offset, int comp);
|
||||
$gfloat4 textureGatherOffset($gsampler2DArray sampler, highfloat3 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2DArray sampler, highfloat3 P, int2 offset, int comp);
|
||||
$gfloat4 textureGatherOffset($gsampler2DRect sampler, highfloat2 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2DRect sampler, highfloat2 P, int2 offset, int comp);
|
||||
highfloat4 textureGatherOffset(sampler2DShadow sampler, highfloat2 P, highfloat refZ, int2 offset);
|
||||
highfloat4 textureGatherOffset(sampler2DArrayShadow sampler, highfloat3 P, highfloat refZ, int2 offset);
|
||||
highfloat4 textureGatherOffset(sampler2DRectShadow sampler, highfloat2 P, highfloat refZ, int2 offset);
|
||||
$gfloat4 textureGatherOffsets($gsampler2D sampler, highfloat2 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2D sampler, highfloat2 P, int2 offsets[4], int comp);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DArray sampler, highfloat3 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DArray sampler, highfloat3 P, int2 offsets[4], int comp);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DRect sampler, highfloat2 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DRect sampler, highfloat2 P, int2 offsets[4], int comp);
|
||||
highfloat4 textureGatherOffsets(sampler2DShadow sampler, highfloat2 P, highfloat refZ, int2 offsets[4]);
|
||||
highfloat4 textureGatherOffsets(sampler2DArrayShadow sampler, highfloat3 P, highfloat refZ, int2 offsets[4]);
|
||||
highfloat4 textureGatherOffsets(sampler2DRectShadow sampler, highfloat2 P, highfloat refZ, int2 offsets[4]);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, float2 P, int offset);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, float2 P, int offset, float bias);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, float4 P, int offset);
|
||||
$gfloat4 textureProjOffset($gsampler1D sampler, float4 P, int offset, float bias);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, float3 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, float3 P, int2 offset, float bias);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, float4 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2D sampler, float4 P, int2 offset, float bias);
|
||||
$gfloat4 textureProjOffset($gsampler3D sampler, float4 P, int3 offset);
|
||||
$gfloat4 textureProjOffset($gsampler3D sampler, float4 P, int3 offset, float bias);
|
||||
$gfloat4 textureProjOffset($gsampler2DRect sampler, float3 P, int2 offset);
|
||||
$gfloat4 textureProjOffset($gsampler2DRect sampler, float4 P, int2 offset);
|
||||
float textureProjOffset(sampler2DRectShadow sampler, float4 P, int2 offset);
|
||||
float textureProjOffset(sampler1DShadow sampler, float4 P, int offset);
|
||||
float textureProjOffset(sampler1DShadow sampler, float4 P, int offset, float bias);
|
||||
float textureProjOffset(sampler2DShadow sampler, float4 P, int2 offset);
|
||||
float textureProjOffset(sampler2DShadow sampler, float4 P, int2 offset, float bias);
|
||||
$gfloat4 textureLodOffset($gsampler1D sampler, float P, float lod, int offset);
|
||||
$gfloat4 textureLodOffset($gsampler2D sampler, float2 P, float lod, int2 offset);
|
||||
$gfloat4 textureLodOffset($gsampler3D sampler, float3 P, float lod, int3 offset);
|
||||
float textureLodOffset(sampler1DShadow sampler, float3 P, float lod, int offset);
|
||||
float textureLodOffset(sampler2DShadow sampler, float3 P, float lod, int2 offset);
|
||||
$gfloat4 textureLodOffset($gsampler1DArray sampler, float2 P, float lod, int offset);
|
||||
$gfloat4 textureLodOffset($gsampler2DArray sampler, float3 P, float lod, int2 offset);
|
||||
float textureLodOffset(sampler1DArrayShadow sampler, float3 P, float lod, int offset);
|
||||
$gfloat4 textureProjLod($gsampler1D sampler, float2 P, float lod);
|
||||
$gfloat4 textureProjLod($gsampler1D sampler, float4 P, float lod);
|
||||
$gfloat4 textureProjLod($gsampler2D sampler, float3 P, float lod);
|
||||
$gfloat4 textureProjLod($gsampler2D sampler, float4 P, float lod);
|
||||
$gfloat4 textureProjLod($gsampler3D sampler, float4 P, float lod);
|
||||
float textureProjLod(sampler1DShadow sampler, float4 P, float lod);
|
||||
float textureProjLod(sampler2DShadow sampler, float4 P, float lod);
|
||||
$gfloat4 textureProjLodOffset($gsampler1D sampler, float2 P, float lod, int offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler1D sampler, float4 P, float lod, int offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler2D sampler, float3 P, float lod, int2 offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler2D sampler, float4 P, float lod, int2 offset);
|
||||
$gfloat4 textureProjLodOffset($gsampler3D sampler, float4 P, float lod, int3 offset);
|
||||
float textureProjLodOffset(sampler1DShadow sampler, float4 P, float lod, int offset);
|
||||
float textureProjLodOffset(sampler2DShadow sampler, float4 P, float lod, int2 offset);
|
||||
$gfloat4 textureGrad($gsampler1D sampler, float P, float dPdx, float dPdy);
|
||||
$gfloat4 textureGrad($gsampler2D sampler, float2 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureGrad($gsampler3D sampler, float3 P, float3 dPdx, float3 dPdy);
|
||||
$gfloat4 textureGrad($gsamplerCube sampler, float3 P, float3 dPdx, float3 dPdy);
|
||||
$gfloat4 textureGrad($gsampler2DRect sampler, float2 P, float2 dPdx, float2 dPdy);
|
||||
float textureGrad(sampler2DRectShadow sampler, float3 P, float2 dPdx, float2 dPdy);
|
||||
float textureGrad(sampler1DShadow sampler, float3 P, float dPdx, float dPdy);
|
||||
float textureGrad(sampler2DShadow sampler, float3 P, float2 dPdx, float2 dPdy);
|
||||
float textureGrad(samplerCubeShadow sampler, float4 P, float3 dPdx, float3 dPdy);
|
||||
$gfloat4 textureGrad($gsampler1DArray sampler, float2 P, float dPdx, float dPdy);
|
||||
$gfloat4 textureGrad($gsampler2DArray sampler, float3 P, float2 dPdx, float2 dPdy);
|
||||
float textureGrad(sampler1DArrayShadow sampler, float3 P, float dPdx, float dPdy);
|
||||
float textureGrad(sampler2DArrayShadow sampler, float4 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureGrad($gsamplerCubeArray sampler, float4 P, float3 dPdx, float3 dPdy);
|
||||
$gfloat4 textureGradOffset($gsampler1D sampler, float P, float dPdx, float dPdy, int offset);
|
||||
$gfloat4 textureGradOffset($gsampler2D sampler, float2 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureGradOffset($gsampler3D sampler, float3 P, float3 dPdx, float3 dPdy, int3 offset);
|
||||
$gfloat4 textureGradOffset($gsampler2DRect sampler, float2 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
float textureGradOffset(sampler2DRectShadow sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
float textureGradOffset(sampler1DShadow sampler, float3 P, float dPdx, float dPdy, int offset );
|
||||
float textureGradOffset(sampler2DShadow sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureGradOffset($gsampler1DArray sampler, float2 P, float dPdx, float dPdy, int offset);
|
||||
$gfloat4 textureGradOffset($gsampler2DArray sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
float textureGradOffset(sampler1DArrayShadow sampler, float3 P, float dPdx, float dPdy, int offset);
|
||||
float textureGradOffset(sampler2DArrayShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGrad($gsampler1D sampler, float2 P, float dPdx, float dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler1D sampler, float4 P, float dPdx, float dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2D sampler, float3 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2D sampler, float4 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler3D sampler, float4 P, float3 dPdx, float3 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2DRect sampler, float3 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureProjGrad($gsampler2DRect sampler, float4 P, float2 dPdx, float2 dPdy);
|
||||
float textureProjGrad(sampler2DRectShadow sampler, float4 P, float2 dPdx, float2 dPdy);
|
||||
float textureProjGrad(sampler1DShadow sampler, float4 P, float dPdx, float dPdy);
|
||||
float textureProjGrad(sampler2DShadow sampler, float4 P, float2 dPdx, float2 dPdy);
|
||||
$gfloat4 textureProjGradOffset($gsampler1D sampler, float2 P, float dPdx, float dPdy, int offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler1D sampler, float4 P, float dPdx, float dPdy, int offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2D sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2D sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2DRect sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler2DRect sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
float textureProjGradOffset(sampler2DRectShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureProjGradOffset($gsampler3D sampler, float4 P, float3 dPdx, float3 dPdy, int3 offset);
|
||||
float textureProjGradOffset(sampler1DShadow sampler, float4 P, float dPdx, float dPdy, int offset);
|
||||
float textureProjGradOffset(sampler2DShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
|
||||
$gfloat4 textureGather($gsampler2D sampler, float2 P);
|
||||
$gfloat4 textureGather($gsampler2D sampler, float2 P, int comp);
|
||||
$gfloat4 textureGather($gsampler2DArray sampler, float3 P);
|
||||
$gfloat4 textureGather($gsampler2DArray sampler, float3 P, int comp);
|
||||
$gfloat4 textureGather($gsamplerCube sampler, float3 P);
|
||||
$gfloat4 textureGather($gsamplerCube sampler, float3 P, int comp);
|
||||
$gfloat4 textureGather($gsamplerCubeArray sampler, float4 P);
|
||||
$gfloat4 textureGather($gsamplerCubeArray sampler, float4 P, int comp);
|
||||
$gfloat4 textureGather($gsampler2DRect sampler, float2 P);
|
||||
$gfloat4 textureGather($gsampler2DRect sampler, float2 P, int comp);
|
||||
float4 textureGather(sampler2DShadow sampler, float2 P, float refZ);
|
||||
float4 textureGather(sampler2DArrayShadow sampler, float3 P, float refZ);
|
||||
float4 textureGather(samplerCubeShadow sampler, float3 P, float refZ);
|
||||
float4 textureGather(samplerCubeArrayShadow sampler, float4 P, float refZ);
|
||||
float4 textureGather(sampler2DRectShadow sampler, float2 P, float refZ);
|
||||
$gfloat4 textureGatherOffset($gsampler2D sampler, float2 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2D sampler, float2 P, int2 offset, int comp);
|
||||
$gfloat4 textureGatherOffset($gsampler2DArray sampler, float3 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2DArray sampler, float3 P, int2 offset, int comp);
|
||||
$gfloat4 textureGatherOffset($gsampler2DRect sampler, float2 P, int2 offset);
|
||||
$gfloat4 textureGatherOffset($gsampler2DRect sampler, float2 P, int2 offset, int comp);
|
||||
float4 textureGatherOffset(sampler2DShadow sampler, float2 P, float refZ, int2 offset);
|
||||
float4 textureGatherOffset(sampler2DArrayShadow sampler, float3 P, float refZ, int2 offset);
|
||||
float4 textureGatherOffset(sampler2DRectShadow sampler, float2 P, float refZ, int2 offset);
|
||||
$gfloat4 textureGatherOffsets($gsampler2D sampler, float2 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2D sampler, float2 P, int2 offsets[4], int comp);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DArray sampler, float3 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DArray sampler, float3 P, int2 offsets[4], int comp);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DRect sampler, float2 P, int2 offsets[4]);
|
||||
$gfloat4 textureGatherOffsets($gsampler2DRect sampler, float2 P, int2 offsets[4], int comp);
|
||||
float4 textureGatherOffsets(sampler2DShadow sampler, float2 P, float refZ, int2 offsets[4]);
|
||||
float4 textureGatherOffsets(sampler2DArrayShadow sampler, float3 P, float refZ, int2 offsets[4]);
|
||||
float4 textureGatherOffsets(sampler2DRectShadow sampler, float2 P, float refZ, int2 offsets[4]);
|
||||
uint atomicCounterIncrement(atomic_uint c);
|
||||
uint atomicCounter(atomic_uint c);
|
||||
uint atomicAdd(inout uint mem, uint data);
|
||||
@ -534,18 +534,18 @@ int atomicCompSwap(inout int mem, int compare, int data);
|
||||
*/
|
||||
// section 8.12 Additional Image Functions will go here if and when we add
|
||||
// support for them
|
||||
highfloat4 imageLoad(image2D image, int2 P);
|
||||
float4 imageLoad(image2D image, int2 P);
|
||||
int4 imageLoad(iimage2D image, int2 P);
|
||||
$genType dFdx($genType p);
|
||||
$genType dFdy($genType p);
|
||||
highfloat interpolateAtSample(highfloat interpolant, int sample);
|
||||
highfloat2 interpolateAtSample(highfloat2 interpolant, int sample);
|
||||
highfloat3 interpolateAtSample(highfloat3 interpolant, int sample);
|
||||
highfloat4 interpolateAtSample(highfloat4 interpolant, int sample);
|
||||
highfloat interpolateAtOffset(highfloat interpolant, highfloat2 offset);
|
||||
highfloat2 interpolateAtOffset(highfloat2 interpolant, highfloat2 offset);
|
||||
highfloat3 interpolateAtOffset(highfloat3 interpolant, highfloat2 offset);
|
||||
highfloat4 interpolateAtOffset(highfloat4 interpolant, highfloat2 offset);
|
||||
float interpolateAtSample(float interpolant, int sample);
|
||||
float2 interpolateAtSample(float2 interpolant, int sample);
|
||||
float3 interpolateAtSample(float3 interpolant, int sample);
|
||||
float4 interpolateAtSample(float4 interpolant, int sample);
|
||||
float interpolateAtOffset(float interpolant, float2 offset);
|
||||
float2 interpolateAtOffset(float2 interpolant, float2 offset);
|
||||
float3 interpolateAtOffset(float3 interpolant, float2 offset);
|
||||
float4 interpolateAtOffset(float4 interpolant, float2 offset);
|
||||
|
||||
/*
|
||||
$genType fwidth($genType p);
|
||||
|
@ -2,14 +2,14 @@ STRINGIFY(
|
||||
|
||||
// defines built-in interfaces supported by SkiaSL fragment shaders
|
||||
|
||||
layout(builtin=15) in highfloat4 sk_FragCoord;
|
||||
layout(builtin=3) highfloat sk_ClipDistance[1];
|
||||
layout(builtin=15) in float4 sk_FragCoord;
|
||||
layout(builtin=3) float sk_ClipDistance[1];
|
||||
|
||||
// 9999 is a temporary value that causes us to ignore these declarations beyond
|
||||
// adding them to the symbol table. This works fine in GLSL (where they do not
|
||||
// require any further handling) but will fail in SPIR-V. We'll have a better
|
||||
// solution for this soon.
|
||||
layout(builtin=9999) highfloat4 gl_LastFragData[1];
|
||||
layout(builtin=9999) float4 gl_LastFragData[1];
|
||||
layout(builtin=9999) half4 gl_LastFragColor;
|
||||
layout(builtin=9999) half4 gl_LastFragColorARM;
|
||||
layout(builtin=9999) int gl_SampleMaskIn[1];
|
||||
@ -18,7 +18,7 @@ layout(builtin=9999) half4 gl_SecondaryFragColorEXT;
|
||||
|
||||
layout(builtin=10003) half4 sk_InColor;
|
||||
layout(builtin=10004) out half4 sk_OutColor;
|
||||
layout(builtin=10005) highfloat2[] sk_TransformedCoords2D;
|
||||
layout(builtin=10005) float2[] sk_TransformedCoords2D;
|
||||
layout(builtin=10006) sampler2D[] sk_TextureSamplers;
|
||||
|
||||
half4 COLORSPACE(half4 color, colorSpaceXform colorSpace);
|
||||
|
@ -2,14 +2,14 @@ STRINGIFY(
|
||||
|
||||
// defines built-in interfaces supported by SkiaSL fragment shaders
|
||||
|
||||
layout(builtin=15) in highfloat4 sk_FragCoord;
|
||||
layout(builtin=3) highfloat sk_ClipDistance[1];
|
||||
layout(builtin=15) in float4 sk_FragCoord;
|
||||
layout(builtin=3) float sk_ClipDistance[1];
|
||||
|
||||
// 9999 is a temporary value that causes us to ignore these declarations beyond
|
||||
// adding them to the symbol table. This works fine in GLSL (where they do not
|
||||
// require any further handling) but will fail in SPIR-V. We'll have a better
|
||||
// solution for this soon.
|
||||
layout(builtin=9999) highfloat4 gl_LastFragData[1];
|
||||
layout(builtin=9999) float4 gl_LastFragData[1];
|
||||
layout(builtin=9999) half4 gl_LastFragColor;
|
||||
layout(builtin=9999) half4 gl_LastFragColorARM;
|
||||
layout(builtin=9999) int gl_SampleMaskIn[1];
|
||||
|
@ -3,15 +3,15 @@ STRINGIFY(
|
||||
// defines built-in interfaces supported by SkiaSL geometry shaders
|
||||
|
||||
layout(builtin=10002) in sk_PerVertex {
|
||||
layout(builtin=0) highfloat4 gl_Position;
|
||||
layout(builtin=1) highfloat gl_PointSize;
|
||||
layout(builtin=3) highfloat sk_ClipDistance[];
|
||||
layout(builtin=0) float4 gl_Position;
|
||||
layout(builtin=1) float gl_PointSize;
|
||||
layout(builtin=3) float sk_ClipDistance[];
|
||||
} sk_in[];
|
||||
|
||||
out sk_PerVertex {
|
||||
layout(builtin=0) highfloat4 gl_Position;
|
||||
layout(builtin=1) highfloat gl_PointSize;
|
||||
layout(builtin=3) highfloat sk_ClipDistance[];
|
||||
layout(builtin=0) float4 gl_Position;
|
||||
layout(builtin=1) float gl_PointSize;
|
||||
layout(builtin=3) float sk_ClipDistance[];
|
||||
};
|
||||
|
||||
layout(builtin=8) int sk_InvocationID;
|
||||
|
@ -3,9 +3,9 @@ STRINGIFY(
|
||||
// defines built-in interfaces supported by SkiaSL vertex shaders
|
||||
|
||||
out sk_PerVertex {
|
||||
layout(builtin=0) highfloat4 gl_Position;
|
||||
layout(builtin=1) highfloat gl_PointSize;
|
||||
layout(builtin=3) highfloat sk_ClipDistance[1];
|
||||
layout(builtin=0) float4 gl_Position;
|
||||
layout(builtin=1) float gl_PointSize;
|
||||
layout(builtin=3) float sk_ClipDistance[1];
|
||||
};
|
||||
|
||||
layout(builtin=5) in int sk_VertexID;
|
||||
|
@ -328,17 +328,17 @@ class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor {
|
||||
|
||||
GrGLSLVertexBuilder* v = args.fVertBuilder;
|
||||
if (!mp.fInstanceLocation) {
|
||||
v->codeAppendf("highfloat2 vertex = %s;", mp.fVertex->fName);
|
||||
v->codeAppendf("float2 vertex = %s;", mp.fVertex->fName);
|
||||
} else {
|
||||
if (mp.fVertex) {
|
||||
v->codeAppendf("highfloat2 offset = %s;", mp.fVertex->fName);
|
||||
v->codeAppendf("float2 offset = %s;", mp.fVertex->fName);
|
||||
} else {
|
||||
v->codeAppend ("highfloat2 offset = highfloat2(sk_VertexID / 2, sk_VertexID % 2);");
|
||||
v->codeAppend ("float2 offset = float2(sk_VertexID / 2, sk_VertexID % 2);");
|
||||
}
|
||||
v->codeAppendf("highfloat2 vertex = %s + offset * %i;",
|
||||
v->codeAppendf("float2 vertex = %s + offset * %i;",
|
||||
mp.fInstanceLocation->fName, kBoxSize);
|
||||
}
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "vertex");
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
|
||||
|
||||
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
|
||||
f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
|
||||
|
@ -91,8 +91,8 @@ class GLSLPipelineDynamicStateTestProcessor : public GrGLSLGeometryProcessor {
|
||||
varyingHandler->addPassThroughAttribute(&mp.fColor, args.fOutputColor);
|
||||
|
||||
GrGLSLVertexBuilder* v = args.fVertBuilder;
|
||||
v->codeAppendf("highfloat2 vertex = %s;", mp.fVertex.fName);
|
||||
gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "vertex");
|
||||
v->codeAppendf("float2 vertex = %s;", mp.fVertex.fName);
|
||||
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
|
||||
|
||||
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
|
||||
f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
|
||||
|
@ -58,7 +58,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
|
||||
const TestFP& tfp = args.fFp.cast<TestFP>();
|
||||
GrGLSLFPFragmentBuilder* fb = args.fFragBuilder;
|
||||
SkString imageLoadStr;
|
||||
fb->codeAppend("highfloat2 coord = sk_FragCoord.xy;");
|
||||
fb->codeAppend("float2 coord = sk_FragCoord.xy;");
|
||||
fb->appendImageStorageLoad(&imageLoadStr, args.fImageStorages[0],
|
||||
"int2(coord)");
|
||||
if (GrPixelConfigIsSint(tfp.fImageStorageAccess.peekTexture()->config())) {
|
||||
|
@ -37,7 +37,7 @@ static void test_success(skiatest::Reporter* r, const char* src) {
|
||||
|
||||
DEF_TEST(SkSLUndefinedSymbol, r) {
|
||||
test_failure(r,
|
||||
"void main() { x = highfloat2(1); }",
|
||||
"void main() { x = float2(1); }",
|
||||
"error: 1: unknown identifier 'x'\n1 error\n");
|
||||
}
|
||||
|
||||
@ -49,27 +49,27 @@ DEF_TEST(SkSLUndefinedFunction, r) {
|
||||
|
||||
DEF_TEST(SkSLGenericArgumentMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = sin(1, 2); }",
|
||||
"void main() { float x = sin(1, 2); }",
|
||||
"error: 1: call to 'sin' expected 1 argument, but found 2\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = sin(true); }",
|
||||
"void main() { float x = sin(true); }",
|
||||
"error: 1: no match for sin(bool)\n1 error\n");
|
||||
test_success(r,
|
||||
"void main() { highfloat x = sin(1); }");
|
||||
"void main() { float x = sin(1); }");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLArgumentCountMismatch, r) {
|
||||
test_failure(r,
|
||||
"highfloat foo(highfloat x) { return x * x; }"
|
||||
"void main() { highfloat x = foo(1, 2); }",
|
||||
"float foo(float x) { return x * x; }"
|
||||
"void main() { float x = foo(1, 2); }",
|
||||
"error: 1: call to 'foo' expected 1 argument, but found 2\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLArgumentMismatch, r) {
|
||||
test_failure(r,
|
||||
"highfloat foo(highfloat x) { return x * x; }"
|
||||
"void main() { highfloat x = foo(true); }",
|
||||
"error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
|
||||
"float foo(float x) { return x * x; }"
|
||||
"void main() { float x = foo(true); }",
|
||||
"error: 1: expected 'float', but found 'bool'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLIfTypeMismatch, r) {
|
||||
@ -80,14 +80,14 @@ DEF_TEST(SkSLIfTypeMismatch, r) {
|
||||
|
||||
DEF_TEST(SkSLDoTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { do { } while (highfloat2(1)); }",
|
||||
"error: 1: expected 'bool', but found 'highfloat2'\n1 error\n");
|
||||
"void main() { do { } while (float2(1)); }",
|
||||
"error: 1: expected 'bool', but found 'float2'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLWhileTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { while (highfloat3(1)) { } }",
|
||||
"error: 1: expected 'bool', but found 'highfloat3'\n1 error\n");
|
||||
"void main() { while (float3(1)) { } }",
|
||||
"error: 1: expected 'bool', but found 'float3'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLForTypeMismatch, r) {
|
||||
@ -98,14 +98,14 @@ DEF_TEST(SkSLForTypeMismatch, r) {
|
||||
|
||||
DEF_TEST(SkSLConstructorTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat2 x = highfloat2(1.0, false); }",
|
||||
"error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
|
||||
"void main() { float2 x = float2(1.0, false); }",
|
||||
"error: 1: expected 'float', but found 'bool'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat2 x = highfloat2(bool2(false)); }",
|
||||
"error: 1: 'bool2' is not a valid parameter to 'highfloat2' constructor\n1 error\n");
|
||||
"void main() { float2 x = float2(bool2(false)); }",
|
||||
"error: 1: 'bool2' is not a valid parameter to 'float2' constructor\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { bool2 x = bool2(highfloat2(1)); }",
|
||||
"error: 1: 'highfloat2' is not a valid parameter to 'bool2' constructor\n1 error\n");
|
||||
"void main() { bool2 x = bool2(float2(1)); }",
|
||||
"error: 1: 'float2' is not a valid parameter to 'bool2' constructor\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { bool x = bool(1.0); }",
|
||||
"error: 1: cannot construct 'bool'\n1 error\n");
|
||||
@ -113,69 +113,69 @@ DEF_TEST(SkSLConstructorTypeMismatch, r) {
|
||||
"struct foo { int x; }; void main() { foo x = foo(5); }",
|
||||
"error: 1: cannot construct 'foo'\n1 error\n");
|
||||
test_failure(r,
|
||||
"struct foo { int x; } foo; void main() { highfloat x = highfloat(foo); }",
|
||||
"error: 1: invalid argument to 'highfloat' constructor (expected a number or bool, but found 'foo')\n1 error\n");
|
||||
"struct foo { int x; } foo; void main() { float x = float(foo); }",
|
||||
"error: 1: invalid argument to 'float' constructor (expected a number or bool, but found 'foo')\n1 error\n");
|
||||
test_failure(r,
|
||||
"struct foo { int x; } foo; void main() { highfloat2 x = highfloat2(foo); }",
|
||||
"error: 1: 'foo' is not a valid parameter to 'highfloat2' constructor\n1 error\n");
|
||||
"struct foo { int x; } foo; void main() { float2 x = float2(foo); }",
|
||||
"error: 1: 'foo' is not a valid parameter to 'float2' constructor\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat2x2 x = highfloat2x2(true); }",
|
||||
"error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
|
||||
"void main() { float2x2 x = float2x2(true); }",
|
||||
"error: 1: expected 'float', but found 'bool'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLConstructorArgumentCount, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat3 x = highfloat3(1.0, 2.0); }",
|
||||
"error: 1: invalid arguments to 'highfloat3' constructor (expected 3 scalars, but "
|
||||
"void main() { float3 x = float3(1.0, 2.0); }",
|
||||
"error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but "
|
||||
"found 2)\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat3 x = highfloat3(1.0, 2.0, 3.0, 4.0); }",
|
||||
"error: 1: invalid arguments to 'highfloat3' constructor (expected 3 scalars, but found "
|
||||
"void main() { float3 x = float3(1.0, 2.0, 3.0, 4.0); }",
|
||||
"error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but found "
|
||||
"4)\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleScalar, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = 1; highfloat y = x.y; }",
|
||||
"error: 1: cannot swizzle value of type 'highfloat'\n1 error\n");
|
||||
"void main() { float x = 1; float y = x.y; }",
|
||||
"error: 1: cannot swizzle value of type 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleMatrix, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat2x2 x = highfloat2x2(1); highfloat y = x.y; }",
|
||||
"error: 1: cannot swizzle value of type 'highfloat2x2'\n1 error\n");
|
||||
"void main() { float2x2 x = float2x2(1); float y = x.y; }",
|
||||
"error: 1: cannot swizzle value of type 'float2x2'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleOutOfBounds, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat3 test = highfloat2(1).xyz; }",
|
||||
"void main() { float3 test = float2(1).xyz; }",
|
||||
"error: 1: invalid swizzle component 'z'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleTooManyComponents, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat4 test = highfloat2(1).xxxxx; }",
|
||||
"void main() { float4 test = float2(1).xxxxx; }",
|
||||
"error: 1: too many components in swizzle mask 'xxxxx'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleDuplicateOutput, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat4 test = highfloat4(1); test.xyyz = highfloat4(1); }",
|
||||
"void main() { float4 test = float4(1); test.xyyz = float4(1); }",
|
||||
"error: 1: cannot write to the same swizzle field more than once\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLAssignmentTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { int x = 1.0; }",
|
||||
"error: 1: expected 'int', but found 'highfloat'\n1 error\n");
|
||||
"error: 1: expected 'int', but found 'float'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { int x; x = 1.0; }",
|
||||
"error: 1: type mismatch: '=' cannot operate on 'int', 'highfloat'\n1 error\n");
|
||||
"error: 1: type mismatch: '=' cannot operate on 'int', 'float'\n1 error\n");
|
||||
test_success(r,
|
||||
"void main() { highfloat3 x = highfloat3(0); x *= 1.0; }");
|
||||
"void main() { float3 x = float3(0); x *= 1.0; }");
|
||||
test_failure(r,
|
||||
"void main() { int3 x = int3(0); x *= 1.0; }",
|
||||
"error: 1: type mismatch: '*=' cannot operate on 'int3', 'highfloat'\n1 error\n");
|
||||
"error: 1: type mismatch: '*=' cannot operate on 'int3', 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLReturnFromVoid, r) {
|
||||
@ -193,7 +193,7 @@ DEF_TEST(SkSLReturnMissingValue, r) {
|
||||
DEF_TEST(SkSLReturnTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"int foo() { return 1.0; } void main() { }",
|
||||
"error: 1: expected 'int', but found 'highfloat'\n1 error\n");
|
||||
"error: 1: expected 'int', but found 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLDuplicateFunction, r) {
|
||||
@ -240,32 +240,32 @@ DEF_TEST(SkSLDuplicateSymbol, r) {
|
||||
|
||||
DEF_TEST(SkSLBinaryTypeMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = 3 * true; }",
|
||||
"void main() { float x = 3 * true; }",
|
||||
"error: 1: type mismatch: '*' cannot operate on 'int', 'bool'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { bool x = 1 || 2.0; }",
|
||||
"error: 1: type mismatch: '||' cannot operate on 'int', 'highfloat'\n1 error\n");
|
||||
"error: 1: type mismatch: '||' cannot operate on 'int', 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLCallNonFunction, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = 3; x(); }",
|
||||
"void main() { float x = 3; x(); }",
|
||||
"error: 1: 'x' is not a function\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLInvalidUnary, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat4x4 x = highfloat4x4(1); ++x; }",
|
||||
"error: 1: '++' cannot operate on 'highfloat4x4'\n1 error\n");
|
||||
"void main() { float4x4 x = float4x4(1); ++x; }",
|
||||
"error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat3 x = highfloat3(1); --x; }",
|
||||
"error: 1: '--' cannot operate on 'highfloat3'\n1 error\n");
|
||||
"void main() { float3 x = float3(1); --x; }",
|
||||
"error: 1: '--' cannot operate on 'float3'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat4x4 x = highfloat4x4(1); x++; }",
|
||||
"error: 1: '++' cannot operate on 'highfloat4x4'\n1 error\n");
|
||||
"void main() { float4x4 x = float4x4(1); x++; }",
|
||||
"error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat3 x = highfloat3(1); x--; }",
|
||||
"error: 1: '--' cannot operate on 'highfloat3'\n1 error\n");
|
||||
"void main() { float3 x = float3(1); x--; }",
|
||||
"error: 1: '--' cannot operate on 'float3'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { int x = !12; }",
|
||||
"error: 1: '!' cannot operate on 'int'\n1 error\n");
|
||||
@ -276,7 +276,7 @@ DEF_TEST(SkSLInvalidUnary, r) {
|
||||
"struct foo { } bar; void main() { foo x = -bar; }",
|
||||
"error: 1: '-' cannot operate on 'foo'\n1 error\n");
|
||||
test_success(r,
|
||||
"void main() { highfloat2 x = highfloat2(1, 1); x = +x; x = -x; }");
|
||||
"void main() { float2 x = float2(1, 1); x = +x; x = -x; }");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLInvalidAssignment, r) {
|
||||
@ -296,17 +296,17 @@ DEF_TEST(SkSLBadIndex, r) {
|
||||
"void main() { int x = 2[0]; }",
|
||||
"error: 1: expected array, but found 'int'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat2 x = highfloat2(0); int y = x[0][0]; }",
|
||||
"error: 1: expected array, but found 'highfloat'\n1 error\n");
|
||||
"void main() { float2 x = float2(0); int y = x[0][0]; }",
|
||||
"error: 1: expected array, but found 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLTernaryMismatch, r) {
|
||||
test_failure(r,
|
||||
"void main() { int x = 5 > 2 ? true : 1.0; }",
|
||||
"error: 1: ternary operator result mismatch: 'bool', 'highfloat'\n1 error\n");
|
||||
"error: 1: ternary operator result mismatch: 'bool', 'float'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { int x = 5 > 2 ? highfloat3(1) : 1.0; }",
|
||||
"error: 1: ternary operator result mismatch: 'highfloat3', 'highfloat'\n1 error\n");
|
||||
"void main() { int x = 5 > 2 ? float3(1) : 1.0; }",
|
||||
"error: 1: ternary operator result mismatch: 'float3', 'float'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) {
|
||||
@ -333,7 +333,7 @@ DEF_TEST(SkSLUseWithoutInitialize, r) {
|
||||
"error: 1: 'x' has not been assigned\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { int x; switch (3) { case 0: x = 0; case 1: x = 1; }"
|
||||
"sk_FragColor = highfloat4(x); }",
|
||||
"sk_FragColor = float4(x); }",
|
||||
"error: 1: 'x' has not been assigned\n1 error\n");
|
||||
}
|
||||
|
||||
@ -403,32 +403,32 @@ DEF_TEST(SkSLDivByZero, r) {
|
||||
"int x = 1 / 0;",
|
||||
"error: 1: division by zero\n1 error\n");
|
||||
test_failure(r,
|
||||
"highfloat x = 1 / 0;",
|
||||
"float x = 1 / 0;",
|
||||
"error: 1: division by zero\n1 error\n");
|
||||
test_failure(r,
|
||||
"highfloat x = 1.0 / 0.0;",
|
||||
"float x = 1.0 / 0.0;",
|
||||
"error: 1: division by zero\n1 error\n");
|
||||
test_failure(r,
|
||||
"highfloat x = -67.0 / (3.0 - 3);",
|
||||
"float x = -67.0 / (3.0 - 3);",
|
||||
"error: 1: division by zero\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLUnsupportedGLSLIdentifiers, r) {
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = gl_FragCoord.x; };",
|
||||
"void main() { float x = gl_FragCoord.x; };",
|
||||
"error: 1: unknown identifier 'gl_FragCoord'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { highfloat r = gl_FragColor.r; };",
|
||||
"void main() { float r = gl_FragColor.r; };",
|
||||
"error: 1: unknown identifier 'gl_FragColor'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLWrongSwitchTypes, r) {
|
||||
test_failure(r,
|
||||
"void main() { switch (highfloat2(1)) { case 1: break; } }",
|
||||
"error: 1: expected 'int', but found 'highfloat2'\n1 error\n");
|
||||
"void main() { switch (float2(1)) { case 1: break; } }",
|
||||
"error: 1: expected 'int', but found 'float2'\n1 error\n");
|
||||
test_failure(r,
|
||||
"void main() { switch (1) { case highfloat2(1): break; } }",
|
||||
"error: 1: expected 'int', but found 'highfloat2'\n1 error\n");
|
||||
"void main() { switch (1) { case float2(1): break; } }",
|
||||
"error: 1: expected 'int', but found 'float2'\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLNonConstantCase, r) {
|
||||
@ -445,18 +445,18 @@ DEF_TEST(SkSLDuplicateCase, r) {
|
||||
|
||||
DEF_TEST(SkSLFieldAfterRuntimeArray, r) {
|
||||
test_failure(r,
|
||||
"buffer broken { highfloat x[]; highfloat y; };",
|
||||
"buffer broken { float x[]; float y; };",
|
||||
"error: 1: only the last entry in an interface block may be a runtime-sized "
|
||||
"array\n1 error\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLStaticIf, r) {
|
||||
test_success(r,
|
||||
"void main() { highfloat x = 5; highfloat y = 10;"
|
||||
"@if (x < y) { sk_FragColor = highfloat4(1); } }");
|
||||
"void main() { float x = 5; float y = 10;"
|
||||
"@if (x < y) { sk_FragColor = float4(1); } }");
|
||||
test_failure(r,
|
||||
"void main() { highfloat x = sqrt(25); highfloat y = 10;"
|
||||
"@if (x < y) { sk_FragColor = highfloat4(1); } }",
|
||||
"void main() { float x = sqrt(25); float y = 10;"
|
||||
"@if (x < y) { sk_FragColor = float4(1); } }",
|
||||
"error: 1: static if has non-static test\n1 error\n");
|
||||
}
|
||||
|
||||
@ -465,16 +465,16 @@ DEF_TEST(SkSLStaticSwitch, r) {
|
||||
"void main() {"
|
||||
"int x = 1;"
|
||||
"@switch (x) {"
|
||||
"case 1: sk_FragColor = highfloat4(1); break;"
|
||||
"default: sk_FragColor = highfloat4(0);"
|
||||
"case 1: sk_FragColor = float4(1); break;"
|
||||
"default: sk_FragColor = float4(0);"
|
||||
"}"
|
||||
"}");
|
||||
test_failure(r,
|
||||
"void main() {"
|
||||
"int x = int(sqrt(1));"
|
||||
"@switch (x) {"
|
||||
"case 1: sk_FragColor = highfloat4(1); break;"
|
||||
"default: sk_FragColor = highfloat4(0);"
|
||||
"case 1: sk_FragColor = float4(1); break;"
|
||||
"default: sk_FragColor = float4(0);"
|
||||
"}"
|
||||
"}",
|
||||
"error: 1: static switch has non-static test\n1 error\n");
|
||||
@ -482,8 +482,8 @@ DEF_TEST(SkSLStaticSwitch, r) {
|
||||
"void main() {"
|
||||
"int x = 1;"
|
||||
"@switch (x) {"
|
||||
"case 1: sk_FragColor = highfloat4(1); if (sqrt(0) < sqrt(1)) break;"
|
||||
"default: sk_FragColor = highfloat4(0);"
|
||||
"case 1: sk_FragColor = float4(1); if (sqrt(0) < sqrt(1)) break;"
|
||||
"default: sk_FragColor = float4(0);"
|
||||
"}"
|
||||
"}",
|
||||
"error: 1: static switch contains non-static conditional break\n1 error\n");
|
||||
|
@ -250,9 +250,9 @@ DEF_TEST(SkSLFPSections, r) {
|
||||
{"cpp section"});
|
||||
test(r,
|
||||
"@constructorParams { int x, float y, std::vector<float> z }"
|
||||
"in highfloat w;"
|
||||
"in float w;"
|
||||
"void main() {"
|
||||
"sk_OutColor = highfloat4(1);"
|
||||
"sk_OutColor = float4(1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
{
|
||||
@ -353,7 +353,7 @@ DEF_TEST(SkSLFPColorSpaceXform, r) {
|
||||
"in uniform sampler2D image;"
|
||||
"in uniform colorSpaceXform colorXform;"
|
||||
"void main() {"
|
||||
"sk_OutColor = sk_InColor * texture(image, highfloat2(0, 0), colorXform);"
|
||||
"sk_OutColor = sk_InColor * texture(image, float2(0, 0), colorXform);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
{
|
||||
@ -364,7 +364,7 @@ DEF_TEST(SkSLFPColorSpaceXform, r) {
|
||||
},
|
||||
{
|
||||
"fragBuilder->codeAppendf(\"half4 _tmpVar1;%s = %s * %stexture(%s, "
|
||||
"highfloat2(0.0, 0.0)).%s%s;\\n\", args.fOutputColor, args.fInputColor ? args.fInputColor : "
|
||||
"float2(0.0, 0.0)).%s%s;\\n\", args.fOutputColor, args.fInputColor ? args.fInputColor : "
|
||||
"\"half4(1)\", fColorSpaceHelper.isValid() ? \"(_tmpVar1 = \" : \"\", "
|
||||
"fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(), "
|
||||
"fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(), "
|
||||
|
@ -51,7 +51,7 @@ static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& cap
|
||||
|
||||
DEF_TEST(SkSLHelloWorld, r) {
|
||||
test(r,
|
||||
"void main() { sk_FragColor = highfloat4(0.75); }",
|
||||
"void main() { sk_FragColor = float4(0.75); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -63,7 +63,7 @@ DEF_TEST(SkSLHelloWorld, r) {
|
||||
DEF_TEST(SkSLControl, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"if (sqrt(2) > 5) { sk_FragColor = highfloat4(0.75); } else { discard; }"
|
||||
"if (sqrt(2) > 5) { sk_FragColor = float4(0.75); } else { discard; }"
|
||||
"int i = 0;"
|
||||
"while (i < 10) { sk_FragColor *= 0.5; i++; }"
|
||||
"do { sk_FragColor += 0.01; } while (sk_FragColor.x < 0.75);"
|
||||
@ -98,9 +98,9 @@ DEF_TEST(SkSLControl, r) {
|
||||
|
||||
DEF_TEST(SkSLFunctions, r) {
|
||||
test(r,
|
||||
"highfloat foo(highfloat v[2]) { return v[0] * v[1]; }"
|
||||
"void bar(inout highfloat x) { highfloat y[2], z; y[0] = x; y[1] = x * 2; z = foo(y); x = z; }"
|
||||
"void main() { highfloat x = 10; bar(x); sk_FragColor = highfloat4(x); }",
|
||||
"float foo(float v[2]) { return v[0] * v[1]; }"
|
||||
"void bar(inout float x) { float y[2], z; y[0] = x; y[1] = x * 2; z = foo(y); x = z; }"
|
||||
"void main() { float x = 10; bar(x); sk_FragColor = float4(x); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -124,7 +124,7 @@ DEF_TEST(SkSLFunctions, r) {
|
||||
DEF_TEST(SkSLOperators, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat x = 1, y = 2;"
|
||||
"float x = 1, y = 2;"
|
||||
"int z = 3;"
|
||||
"x = x - x + y * z * x * (y - z);"
|
||||
"y = x / y / z;"
|
||||
@ -142,8 +142,8 @@ DEF_TEST(SkSLOperators, r) {
|
||||
"z >>= 2;"
|
||||
"z <<= 4;"
|
||||
"z %= 5;"
|
||||
"x = (highfloat2(sqrt(1)) , 6);"
|
||||
"z = (highfloat2(sqrt(1)) , 6);"
|
||||
"x = (float2(sqrt(1)) , 6);"
|
||||
"z = (float2(sqrt(1)) , 6);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -175,12 +175,12 @@ DEF_TEST(SkSLOperators, r) {
|
||||
DEF_TEST(SkSLMatrices, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat2x4 x = highfloat2x4(1);"
|
||||
"highfloat3x2 y = highfloat3x2(1, 0, 0, 1, highfloat2(2, 2));"
|
||||
"highfloat3x4 z = x * y;"
|
||||
"highfloat3 v1 = highfloat3x3(1) * highfloat3(2);"
|
||||
"highfloat3 v2 = highfloat3(2) * highfloat3x3(1);"
|
||||
"sk_FragColor = highfloat4(z[0].x, v1 + v2);"
|
||||
"float2x4 x = float2x4(1);"
|
||||
"float3x2 y = float3x2(1, 0, 0, 1, float2(2, 2));"
|
||||
"float3x4 z = x * y;"
|
||||
"float3 v1 = float3x3(1) * float3(2);"
|
||||
"float3 v2 = float3(2) * float3x3(1);"
|
||||
"sk_FragColor = float4(z[0].x, v1 + v2);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -218,7 +218,7 @@ DEF_TEST(SkSLInterfaceBlock, r) {
|
||||
"}\n");
|
||||
test(r,
|
||||
"uniform testBlock {"
|
||||
"highfloat x;"
|
||||
"float x;"
|
||||
"} test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = half4(test.x);"
|
||||
@ -234,7 +234,7 @@ DEF_TEST(SkSLInterfaceBlock, r) {
|
||||
"}\n");
|
||||
test(r,
|
||||
"uniform testBlock {"
|
||||
"highfloat x;"
|
||||
"float x;"
|
||||
"} test[2];"
|
||||
"void main() {"
|
||||
" sk_FragColor = half4(test[1].x);"
|
||||
@ -258,8 +258,8 @@ DEF_TEST(SkSLStructs, r) {
|
||||
"} a1, a2;"
|
||||
"A a3;"
|
||||
"struct B {"
|
||||
"highfloat x;"
|
||||
"highfloat y[2];"
|
||||
"float x;"
|
||||
"float y[2];"
|
||||
"layout(binding=1) A z;"
|
||||
"};"
|
||||
"B b1, b2, b3;"
|
||||
@ -284,7 +284,7 @@ DEF_TEST(SkSLStructs, r) {
|
||||
|
||||
DEF_TEST(SkSLVersion, r) {
|
||||
test(r,
|
||||
"in highfloat test; void main() { sk_FragColor = highfloat4(0.75); }",
|
||||
"in float test; void main() { sk_FragColor = float4(0.75); }",
|
||||
*SkSL::ShaderCapsFactory::Version450Core(),
|
||||
"#version 450 core\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -293,7 +293,7 @@ DEF_TEST(SkSLVersion, r) {
|
||||
" sk_FragColor = vec4(0.75);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"in highfloat test; void main() { sk_FragColor = highfloat4(0.75); }",
|
||||
"in float test; void main() { sk_FragColor = float4(0.75); }",
|
||||
*SkSL::ShaderCapsFactory::Version110(),
|
||||
"#version 110\n"
|
||||
"varying float test;\n"
|
||||
@ -304,7 +304,7 @@ DEF_TEST(SkSLVersion, r) {
|
||||
|
||||
DEF_TEST(SkSLUsesPrecisionModifiers, r) {
|
||||
test(r,
|
||||
"void main() { half x = 0.75; highfloat y = 1; x++; y++;"
|
||||
"void main() { half x = 0.75; float y = 1; x++; y++;"
|
||||
"sk_FragColor.rg = half2(x, y); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -317,7 +317,7 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) {
|
||||
" sk_FragColor.xy = vec2(x, y);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() { half x = 0.75; highfloat y = 1; x++; y++;"
|
||||
"void main() { half x = 0.75; float y = 1; x++; y++;"
|
||||
"sk_FragColor.rg = half2(x, y); }",
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
@ -335,7 +335,7 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) {
|
||||
DEF_TEST(SkSLMinAbs, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat x = -5;"
|
||||
"float x = -5;"
|
||||
"sk_FragColor.r = min(abs(x), 6);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
@ -347,7 +347,7 @@ DEF_TEST(SkSLMinAbs, r) {
|
||||
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat x = -5.0;"
|
||||
"float x = -5.0;"
|
||||
"sk_FragColor.r = min(abs(x), 6.0);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::CannotUseMinAndAbsTogether(),
|
||||
@ -364,7 +364,7 @@ DEF_TEST(SkSLMinAbs, r) {
|
||||
DEF_TEST(SkSLFractNegative, r) {
|
||||
static constexpr char input[] =
|
||||
"void main() {"
|
||||
"highfloat x = -42.0;"
|
||||
"float x = -42.0;"
|
||||
"sk_FragColor.r = fract(x);"
|
||||
"}";
|
||||
static constexpr char output_default[] =
|
||||
@ -386,7 +386,7 @@ DEF_TEST(SkSLFractNegative, r) {
|
||||
|
||||
DEF_TEST(SkSLNegatedAtan, r) {
|
||||
test(r,
|
||||
"void main() { highfloat2 x = highfloat2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
|
||||
"void main() { float2 x = float2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -395,7 +395,7 @@ DEF_TEST(SkSLNegatedAtan, r) {
|
||||
" sk_FragColor.x = atan(x.x, -x.y);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() { highfloat2 x = highfloat2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
|
||||
"void main() { float2 x = float2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
|
||||
*SkSL::ShaderCapsFactory::MustForceNegatedAtanParamToFloat(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -466,13 +466,13 @@ DEF_TEST(SkSLHex, r) {
|
||||
|
||||
DEF_TEST(SkSLVectorConstructors, r) {
|
||||
test(r,
|
||||
"highfloat2 v1 = highfloat2(1);"
|
||||
"highfloat2 v2 = highfloat2(1, 2);"
|
||||
"highfloat2 v3 = highfloat2(highfloat2(1));"
|
||||
"highfloat3 v4 = highfloat3(highfloat2(1), 1.0);"
|
||||
"float2 v1 = float2(1);"
|
||||
"float2 v2 = float2(1, 2);"
|
||||
"float2 v3 = float2(float2(1));"
|
||||
"float3 v4 = float3(float2(1), 1.0);"
|
||||
"int2 v5 = int2(1);"
|
||||
"int2 v6 = int2(highfloat2(1, 2));"
|
||||
"highfloat2 v7 = highfloat2(int2(1, 2));",
|
||||
"int2 v6 = int2(float2(1, 2));"
|
||||
"float2 v7 = float2(int2(1, 2));",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -487,9 +487,9 @@ DEF_TEST(SkSLVectorConstructors, r) {
|
||||
|
||||
DEF_TEST(SkSLArrayConstructors, r) {
|
||||
test(r,
|
||||
"highfloat test1[] = highfloat[](1, 2, 3, 4);"
|
||||
"highfloat2 test2[] = highfloat2[](highfloat2(1, 2), highfloat2(3, 4));"
|
||||
"highfloat4x4 test3[] = highfloat4x4[]();",
|
||||
"float test1[] = float[](1, 2, 3, 4);"
|
||||
"float2 test2[] = float2[](float2(1, 2), float2(3, 4));"
|
||||
"float4x4 test3[] = float4x4[]();",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -717,55 +717,55 @@ DEF_TEST(SkSLBoolFolding, r) {
|
||||
DEF_TEST(SkSLVecFolding, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"sk_FragColor.r = highfloat4(0.5, 1, 1, 1).x;"
|
||||
"sk_FragColor = highfloat4(highfloat2(1), highfloat2(2, 3)) + highfloat4(5, 6, 7, 8);"
|
||||
"sk_FragColor = highfloat4(8, highfloat3(10)) - highfloat4(1);"
|
||||
"sk_FragColor = highfloat4(2) * highfloat4(1, 2, 3, 4);"
|
||||
"sk_FragColor = highfloat4(12) / highfloat4(1, 2, 3, 4);"
|
||||
"sk_FragColor.r = (highfloat4(12) / highfloat4(1, 2, 3, 4)).y;"
|
||||
"sk_FragColor.x = highfloat4(1) == highfloat4(1) ? 1.0 : -1.0;"
|
||||
"sk_FragColor.x = highfloat4(1) == highfloat4(2) ? 2.0 : -2.0;"
|
||||
"sk_FragColor.x = highfloat2(1) == highfloat2(1, 1) ? 3.0 : -3.0;"
|
||||
"sk_FragColor.x = highfloat2(1, 1) == highfloat2(1, 1) ? 4.0 : -4.0;"
|
||||
"sk_FragColor.x = highfloat2(1) == highfloat2(1, 0) ? 5.0 : -5.0;"
|
||||
"sk_FragColor.x = highfloat4(1) == highfloat4(highfloat2(1), highfloat2(1)) ? 6.0 : -6.0;"
|
||||
"sk_FragColor.x = highfloat4(highfloat3(1), 1) == highfloat4(highfloat2(1), highfloat2(1)) ? 7.0 : -7.0;"
|
||||
"sk_FragColor.x = highfloat4(highfloat3(1), 1) == highfloat4(highfloat2(1), 1, 0) ? 8.0 : -8.0;"
|
||||
"sk_FragColor.x = highfloat2(1) != highfloat2(1, 0) ? 9.0 : -9.0;"
|
||||
"sk_FragColor.x = highfloat4(1) != highfloat4(highfloat2(1), highfloat2(1)) ? 10.0 : -10.0;"
|
||||
"sk_FragColor = highfloat4(sqrt(1)) * highfloat4(1);"
|
||||
"sk_FragColor = highfloat4(1) * highfloat4(sqrt(2));"
|
||||
"sk_FragColor = highfloat4(0) * highfloat4(sqrt(3));"
|
||||
"sk_FragColor = highfloat4(sqrt(4)) * highfloat4(0);"
|
||||
"sk_FragColor = highfloat4(0) / highfloat4(sqrt(5));"
|
||||
"sk_FragColor = highfloat4(0) + highfloat4(sqrt(6));"
|
||||
"sk_FragColor = highfloat4(sqrt(7)) + highfloat4(0);"
|
||||
"sk_FragColor = highfloat4(sqrt(8)) - highfloat4(0);"
|
||||
"sk_FragColor = highfloat4(0) + sqrt(9);"
|
||||
"sk_FragColor = highfloat4(0) * sqrt(10);"
|
||||
"sk_FragColor = highfloat4(0) / sqrt(11);"
|
||||
"sk_FragColor = highfloat4(1) * sqrt(12);"
|
||||
"sk_FragColor = 0 + highfloat4(sqrt(13));"
|
||||
"sk_FragColor = 0 * highfloat4(sqrt(14));"
|
||||
"sk_FragColor = 0 / highfloat4(sqrt(15));"
|
||||
"sk_FragColor = 1 * highfloat4(sqrt(16));"
|
||||
"sk_FragColor = highfloat4(sqrt(17)) + 0;"
|
||||
"sk_FragColor = highfloat4(sqrt(18)) * 0;"
|
||||
"sk_FragColor = highfloat4(sqrt(19)) * 1;"
|
||||
"sk_FragColor = highfloat4(sqrt(19.5)) - 0;"
|
||||
"sk_FragColor = sqrt(20) * highfloat4(1);"
|
||||
"sk_FragColor = sqrt(21) + highfloat4(0);"
|
||||
"sk_FragColor = sqrt(22) - highfloat4(0);"
|
||||
"sk_FragColor = sqrt(23) / highfloat4(1);"
|
||||
"sk_FragColor = highfloat4(sqrt(24)) / 1;"
|
||||
"sk_FragColor += highfloat4(1);"
|
||||
"sk_FragColor += highfloat4(0);"
|
||||
"sk_FragColor -= highfloat4(1);"
|
||||
"sk_FragColor -= highfloat4(0);"
|
||||
"sk_FragColor *= highfloat4(1);"
|
||||
"sk_FragColor *= highfloat4(2);"
|
||||
"sk_FragColor /= highfloat4(1);"
|
||||
"sk_FragColor /= highfloat4(2);"
|
||||
"sk_FragColor.r = float4(0.5, 1, 1, 1).x;"
|
||||
"sk_FragColor = float4(float2(1), float2(2, 3)) + float4(5, 6, 7, 8);"
|
||||
"sk_FragColor = float4(8, float3(10)) - float4(1);"
|
||||
"sk_FragColor = float4(2) * float4(1, 2, 3, 4);"
|
||||
"sk_FragColor = float4(12) / float4(1, 2, 3, 4);"
|
||||
"sk_FragColor.r = (float4(12) / float4(1, 2, 3, 4)).y;"
|
||||
"sk_FragColor.x = float4(1) == float4(1) ? 1.0 : -1.0;"
|
||||
"sk_FragColor.x = float4(1) == float4(2) ? 2.0 : -2.0;"
|
||||
"sk_FragColor.x = float2(1) == float2(1, 1) ? 3.0 : -3.0;"
|
||||
"sk_FragColor.x = float2(1, 1) == float2(1, 1) ? 4.0 : -4.0;"
|
||||
"sk_FragColor.x = float2(1) == float2(1, 0) ? 5.0 : -5.0;"
|
||||
"sk_FragColor.x = float4(1) == float4(float2(1), float2(1)) ? 6.0 : -6.0;"
|
||||
"sk_FragColor.x = float4(float3(1), 1) == float4(float2(1), float2(1)) ? 7.0 : -7.0;"
|
||||
"sk_FragColor.x = float4(float3(1), 1) == float4(float2(1), 1, 0) ? 8.0 : -8.0;"
|
||||
"sk_FragColor.x = float2(1) != float2(1, 0) ? 9.0 : -9.0;"
|
||||
"sk_FragColor.x = float4(1) != float4(float2(1), float2(1)) ? 10.0 : -10.0;"
|
||||
"sk_FragColor = float4(sqrt(1)) * float4(1);"
|
||||
"sk_FragColor = float4(1) * float4(sqrt(2));"
|
||||
"sk_FragColor = float4(0) * float4(sqrt(3));"
|
||||
"sk_FragColor = float4(sqrt(4)) * float4(0);"
|
||||
"sk_FragColor = float4(0) / float4(sqrt(5));"
|
||||
"sk_FragColor = float4(0) + float4(sqrt(6));"
|
||||
"sk_FragColor = float4(sqrt(7)) + float4(0);"
|
||||
"sk_FragColor = float4(sqrt(8)) - float4(0);"
|
||||
"sk_FragColor = float4(0) + sqrt(9);"
|
||||
"sk_FragColor = float4(0) * sqrt(10);"
|
||||
"sk_FragColor = float4(0) / sqrt(11);"
|
||||
"sk_FragColor = float4(1) * sqrt(12);"
|
||||
"sk_FragColor = 0 + float4(sqrt(13));"
|
||||
"sk_FragColor = 0 * float4(sqrt(14));"
|
||||
"sk_FragColor = 0 / float4(sqrt(15));"
|
||||
"sk_FragColor = 1 * float4(sqrt(16));"
|
||||
"sk_FragColor = float4(sqrt(17)) + 0;"
|
||||
"sk_FragColor = float4(sqrt(18)) * 0;"
|
||||
"sk_FragColor = float4(sqrt(19)) * 1;"
|
||||
"sk_FragColor = float4(sqrt(19.5)) - 0;"
|
||||
"sk_FragColor = sqrt(20) * float4(1);"
|
||||
"sk_FragColor = sqrt(21) + float4(0);"
|
||||
"sk_FragColor = sqrt(22) - float4(0);"
|
||||
"sk_FragColor = sqrt(23) / float4(1);"
|
||||
"sk_FragColor = float4(sqrt(24)) / 1;"
|
||||
"sk_FragColor += float4(1);"
|
||||
"sk_FragColor += float4(0);"
|
||||
"sk_FragColor -= float4(1);"
|
||||
"sk_FragColor -= float4(0);"
|
||||
"sk_FragColor *= float4(1);"
|
||||
"sk_FragColor *= float4(2);"
|
||||
"sk_FragColor /= float4(1);"
|
||||
"sk_FragColor /= float4(2);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -822,24 +822,24 @@ DEF_TEST(SkSLVecFolding, r) {
|
||||
DEF_TEST(SkSLMatFolding, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) == "
|
||||
"highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 1 : -1;"
|
||||
"sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), highfloat2(1.0, 1.0)) == "
|
||||
"highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 2 : -2;"
|
||||
"sk_FragColor.x = highfloat2x2(1) == highfloat2x2(1) ? 3 : -3;"
|
||||
"sk_FragColor.x = highfloat2x2(1) == highfloat2x2(0) ? 4 : -4;"
|
||||
"sk_FragColor.x = highfloat2x2(1) == highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 5 : -5;"
|
||||
"sk_FragColor.x = highfloat2x2(2) == highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 6 : -6;"
|
||||
"sk_FragColor.x = highfloat3x2(2) == highfloat3x2(highfloat2(2.0, 0.0), highfloat2(0.0, 2.0), highfloat2(0.0))"
|
||||
"sk_FragColor.x = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) == "
|
||||
"float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 1 : -1;"
|
||||
"sk_FragColor.x = float2x2(float2(1.0, 0.0), float2(1.0, 1.0)) == "
|
||||
"float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 2 : -2;"
|
||||
"sk_FragColor.x = float2x2(1) == float2x2(1) ? 3 : -3;"
|
||||
"sk_FragColor.x = float2x2(1) == float2x2(0) ? 4 : -4;"
|
||||
"sk_FragColor.x = float2x2(1) == float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 5 : -5;"
|
||||
"sk_FragColor.x = float2x2(2) == float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 6 : -6;"
|
||||
"sk_FragColor.x = float3x2(2) == float3x2(float2(2.0, 0.0), float2(0.0, 2.0), float2(0.0))"
|
||||
"? 7 : -7;"
|
||||
"sk_FragColor.x = highfloat2x2(1) != highfloat2x2(1) ? 8 : -8;"
|
||||
"sk_FragColor.x = highfloat2x2(1) != highfloat2x2(0) ? 9 : -9;"
|
||||
"sk_FragColor.x = highfloat3x3(highfloat3(1.0, 0.0, 0.0), highfloat3(0.0, 1.0, 0.0), "
|
||||
"highfloat3(0.0, 0.0, 0.0)) == highfloat3x3(highfloat2x2(1.0)) ? 10 : -10;"
|
||||
"sk_FragColor.x = highfloat2x2(highfloat3x3(1.0)) == highfloat2x2(1.0) ? 11 : -11;"
|
||||
"sk_FragColor.x = highfloat2x2(highfloat4(1.0, 0.0, 0.0, 1.0)) == highfloat2x2(1.0) ? 12 : -12;"
|
||||
"sk_FragColor.x = highfloat2x2(1.0, 0.0, highfloat2(0.0, 1.0)) == highfloat2x2(1.0) ? 13 : -13;"
|
||||
"sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), 0.0, 1.0) == highfloat2x2(1.0) ? 14 : -14;"
|
||||
"sk_FragColor.x = float2x2(1) != float2x2(1) ? 8 : -8;"
|
||||
"sk_FragColor.x = float2x2(1) != float2x2(0) ? 9 : -9;"
|
||||
"sk_FragColor.x = float3x3(float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), "
|
||||
"float3(0.0, 0.0, 0.0)) == float3x3(float2x2(1.0)) ? 10 : -10;"
|
||||
"sk_FragColor.x = float2x2(float3x3(1.0)) == float2x2(1.0) ? 11 : -11;"
|
||||
"sk_FragColor.x = float2x2(float4(1.0, 0.0, 0.0, 1.0)) == float2x2(1.0) ? 12 : -12;"
|
||||
"sk_FragColor.x = float2x2(1.0, 0.0, float2(0.0, 1.0)) == float2x2(1.0) ? 13 : -13;"
|
||||
"sk_FragColor.x = float2x2(float2(1.0, 0.0), 0.0, 1.0) == float2x2(1.0) ? 14 : -14;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -906,10 +906,10 @@ DEF_TEST(SkSLTexture, r) {
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"highfloat4 a = texture(one, 0);"
|
||||
"highfloat4 b = texture(two, highfloat2(0));"
|
||||
"highfloat4 c = texture(one, highfloat2(0));"
|
||||
"highfloat4 d = texture(two, highfloat3(0));"
|
||||
"float4 a = texture(one, 0);"
|
||||
"float4 b = texture(two, float2(0));"
|
||||
"float4 c = texture(one, float2(0));"
|
||||
"float4 d = texture(two, float3(0));"
|
||||
"sk_FragColor = half4(a.x, b.x, c.x, d.x);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
@ -928,10 +928,10 @@ DEF_TEST(SkSLTexture, r) {
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"highfloat4 a = texture(one, 0);"
|
||||
"highfloat4 b = texture(two, highfloat2(0));"
|
||||
"highfloat4 c = texture(one, highfloat2(0));"
|
||||
"highfloat4 d = texture(two, highfloat3(0));"
|
||||
"float4 a = texture(one, 0);"
|
||||
"float4 b = texture(two, float2(0));"
|
||||
"float4 c = texture(one, float2(0));"
|
||||
"float4 d = texture(two, float3(0));"
|
||||
"sk_FragColor = half4(a.x, b.x, c.x, d.x);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Version110(),
|
||||
@ -1058,9 +1058,9 @@ DEF_TEST(SkSLClipDistance, r) {
|
||||
|
||||
DEF_TEST(SkSLArrayTypes, r) {
|
||||
test(r,
|
||||
"void main() { highfloat2 x[2] = highfloat2[2](highfloat2(1), highfloat2(2));"
|
||||
"highfloat2[2] y = highfloat2[2](highfloat2(3), highfloat2(4));"
|
||||
"sk_FragColor = highfloat4(x[0], y[1]); }",
|
||||
"void main() { float2 x[2] = float2[2](float2(1), float2(2));"
|
||||
"float2[2] y = float2[2](float2(3), float2(4));"
|
||||
"sk_FragColor = float4(x[0], y[1]); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
@ -1076,9 +1076,9 @@ DEF_TEST(SkSLGeometry, r) {
|
||||
"layout(invocations = 2) in;"
|
||||
"layout(line_strip, max_vertices = 2) out;"
|
||||
"void main() {"
|
||||
"gl_Position = sk_in[0].gl_Position + highfloat4(-0.5, 0, 0, sk_InvocationID);"
|
||||
"gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
|
||||
"EmitVertex();"
|
||||
"gl_Position = sk_in[0].gl_Position + highfloat4(0.5, 0, 0, sk_InvocationID);"
|
||||
"gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
|
||||
"EmitVertex();"
|
||||
"EndPrimitive();"
|
||||
"}",
|
||||
@ -1101,7 +1101,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// basic "does a switch even work" test
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x;"
|
||||
" float x;"
|
||||
" switch (int(sqrt(1))) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1112,7 +1112,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
" default:"
|
||||
" x = 2.0;"
|
||||
" }"
|
||||
" sk_FragColor = highfloat4(x);"
|
||||
" sk_FragColor = float4(x);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1134,7 +1134,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// dead code inside of switch
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x;"
|
||||
" float x;"
|
||||
" switch (int(sqrt(2))) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1162,7 +1162,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// non-static test w/ fallthrough
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (int(sqrt(3))) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1187,7 +1187,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// static test w/ fallthrough
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (0) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1205,7 +1205,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// static test w/ fallthrough, different entry point
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (1) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1223,7 +1223,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// static test w/ break
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (0) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1242,7 +1242,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// static test w/ static conditional break
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (0) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1261,7 +1261,7 @@ DEF_TEST(SkSLSwitch, r) {
|
||||
// static test w/ non-static conditional break
|
||||
test(r,
|
||||
"void main() {"
|
||||
" highfloat x = 0.0;"
|
||||
" float x = 0.0;"
|
||||
" switch (0) {"
|
||||
" case 0:"
|
||||
" x = 0.0;"
|
||||
@ -1291,7 +1291,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler2D test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = texture(test, highfloat2(0.5));"
|
||||
" sk_FragColor = texture(test, float2(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1303,7 +1303,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler2DRect test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = texture(test, highfloat2(0.5));"
|
||||
" sk_FragColor = texture(test, float2(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1315,7 +1315,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler2DRect test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = texture(test, highfloat3(0.5));"
|
||||
" sk_FragColor = texture(test, float3(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1329,12 +1329,12 @@ DEF_TEST(SkSLRectangleTexture, r) {
|
||||
DEF_TEST(SkSLUnusedVars, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat a = 1, b = 2, c = 3;"
|
||||
"highfloat d = c;"
|
||||
"highfloat e = d;"
|
||||
"float a = 1, b = 2, c = 3;"
|
||||
"float d = c;"
|
||||
"float e = d;"
|
||||
"b++;"
|
||||
"d++;"
|
||||
"sk_FragColor = highfloat4(b, b, d, d);"
|
||||
"sk_FragColor = float4(b, b, d, d);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1351,11 +1351,11 @@ DEF_TEST(SkSLUnusedVars, r) {
|
||||
DEF_TEST(SkSLMultipleAssignments, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat x;"
|
||||
"highfloat y;"
|
||||
"float x;"
|
||||
"float y;"
|
||||
"int z;"
|
||||
"x = y = z = 1;"
|
||||
"sk_FragColor = highfloat4(z);"
|
||||
"sk_FragColor = float4(z);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1367,13 +1367,13 @@ DEF_TEST(SkSLMultipleAssignments, r) {
|
||||
|
||||
DEF_TEST(SkSLComplexDelete, r) {
|
||||
test(r,
|
||||
"uniform highfloat4x4 colorXform;"
|
||||
"uniform float4x4 colorXform;"
|
||||
"uniform sampler2D sampler;"
|
||||
"void main() {"
|
||||
"highfloat4 tmpColor;"
|
||||
"sk_FragColor = highfloat4(1.0) * (tmpColor = texture(sampler, highfloat2(1)) , "
|
||||
"colorXform != highfloat4x4(1.0) ? highfloat4(clamp((highfloat4x4(colorXform) * "
|
||||
"highfloat4(tmpColor.xyz, 1.0)).xyz, "
|
||||
"float4 tmpColor;"
|
||||
"sk_FragColor = float4(1.0) * (tmpColor = texture(sampler, float2(1)) , "
|
||||
"colorXform != float4x4(1.0) ? float4(clamp((float4x4(colorXform) * "
|
||||
"float4(tmpColor.xyz, 1.0)).xyz, "
|
||||
"0.0, tmpColor.w), tmpColor.w) : tmpColor);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
@ -1392,8 +1392,8 @@ DEF_TEST(SkSLComplexDelete, r) {
|
||||
DEF_TEST(SkSLDependentInitializers, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"highfloat x = 0.5, y = x * 2;"
|
||||
"sk_FragColor = highfloat4(y);"
|
||||
"float x = 0.5, y = x * 2;"
|
||||
"sk_FragColor = float4(y);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
@ -1427,11 +1427,11 @@ DEF_TEST(SkSLInvocations, r) {
|
||||
"layout(invocations = 2) in;"
|
||||
"layout(line_strip, max_vertices = 2) out;"
|
||||
"void test() {"
|
||||
"gl_Position = sk_in[0].gl_Position + highfloat4(0.5, 0, 0, sk_InvocationID);"
|
||||
"gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
|
||||
"EmitVertex();"
|
||||
"}"
|
||||
"void main() {"
|
||||
"gl_Position = sk_in[0].gl_Position + highfloat4(-0.5, 0, 0, sk_InvocationID);"
|
||||
"gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
|
||||
"EmitVertex();"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::MustImplementGSInvocationsWithLoop(),
|
||||
@ -1458,13 +1458,13 @@ DEF_TEST(SkSLInvocations, r) {
|
||||
|
||||
DEF_TEST(SkSLTypePrecision, r) {
|
||||
test(r,
|
||||
"highfloat f = 1;"
|
||||
"float f = 1;"
|
||||
"half h = 2;"
|
||||
"double d = 3;"
|
||||
"highfloat2 f2 = highfloat2(1, 2);"
|
||||
"float2 f2 = float2(1, 2);"
|
||||
"half3 h3 = half3(1, 2, 3);"
|
||||
"double4 d4 = double4(1, 2, 3, 4);"
|
||||
"highfloat2x2 f22 = highfloat2x2(1, 2, 3, 4);"
|
||||
"float2x2 f22 = float2x2(1, 2, 3, 4);"
|
||||
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);"
|
||||
"double4x2 d42 = double4x2(1, 2, 3, 4, 5, 6, 7, 8);",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
@ -1480,11 +1480,11 @@ DEF_TEST(SkSLTypePrecision, r) {
|
||||
"mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n"
|
||||
"dmat4x2 d42 = dmat4x2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n");
|
||||
test(r,
|
||||
"highfloat f = 1;"
|
||||
"float f = 1;"
|
||||
"half h = 2;"
|
||||
"highfloat2 f2 = highfloat2(1, 2);"
|
||||
"float2 f2 = float2(1, 2);"
|
||||
"half3 h3 = half3(1, 2, 3);"
|
||||
"highfloat2x2 f22 = highfloat2x2(1, 2, 3, 4);"
|
||||
"float2x2 f22 = float2x2(1, 2, 3, 4);"
|
||||
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);",
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
@ -1505,7 +1505,7 @@ DEF_TEST(SkSLNumberConversions, r) {
|
||||
"ushort us = ushort(sqrt(1));"
|
||||
"uint ui = uint(sqrt(1));"
|
||||
"half h = sqrt(1);"
|
||||
"highfloat f = sqrt(1);"
|
||||
"float f = sqrt(1);"
|
||||
"short s2s = s;"
|
||||
"short i2s = i;"
|
||||
"short us2s = short(us);"
|
||||
@ -1530,12 +1530,12 @@ DEF_TEST(SkSLNumberConversions, r) {
|
||||
"uint ui2ui = ui;"
|
||||
"uint h2ui = uint(h);"
|
||||
"uint f2ui = uint(f);"
|
||||
"highfloat s2f = s;"
|
||||
"highfloat i2f = i;"
|
||||
"highfloat us2f = us;"
|
||||
"highfloat ui2f = ui;"
|
||||
"highfloat h2f = h;"
|
||||
"highfloat f2f = f;",
|
||||
"float s2f = s;"
|
||||
"float i2f = i;"
|
||||
"float us2f = us;"
|
||||
"float ui2f = ui;"
|
||||
"float h2f = h;"
|
||||
"float f2f = f;",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
|
Loading…
Reference in New Issue
Block a user