More ctype cleanup in SkSL
- Remove ctypes that were entirely unused - Remove explicit selection of default ctypes - After that, only two ctype tokens are needed (SkPMColor4f and SkV4) ... remove all of the others from the parser Change-Id: I2322aab73a19127b3b26850aefdad6140ea0f7e7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410057 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
60e52284d5
commit
1391170bee
@ -52,24 +52,18 @@ struct Layout {
|
||||
};
|
||||
|
||||
enum class CType {
|
||||
kDefault,
|
||||
kBool,
|
||||
kFloat,
|
||||
kFloat2,
|
||||
kFloat3,
|
||||
kFloat4,
|
||||
kInt32,
|
||||
kSkRect,
|
||||
kSkIRect,
|
||||
kDefault, // Default for:
|
||||
kFloat, // float, half
|
||||
kInt32, // int, short
|
||||
kSkRect, // float4, half4
|
||||
kSkIRect, // int4, short4
|
||||
kSkPMColor4f,
|
||||
kSkPMColor,
|
||||
kSkV4,
|
||||
kSkPoint,
|
||||
kSkIPoint,
|
||||
kSkMatrix,
|
||||
kSkM44,
|
||||
kGrSurfaceProxyView,
|
||||
kGrFragmentProcessor,
|
||||
kSkPoint, // float2, half2
|
||||
kSkIPoint, // int2, short2
|
||||
kSkMatrix, // float3x3, half3x3
|
||||
kSkM44, // float4x4, half4x4
|
||||
kGrFragmentProcessor, // fragmentProcessor
|
||||
};
|
||||
|
||||
static const char* CTypeToStr(CType ctype) {
|
||||
@ -86,8 +80,6 @@ struct Layout {
|
||||
return "SkIRect";
|
||||
case CType::kSkPMColor4f:
|
||||
return "SkPMColor4f";
|
||||
case CType::kSkPMColor:
|
||||
return "SkPMColor";
|
||||
case CType::kSkV4:
|
||||
return "SkV4";
|
||||
case CType::kSkPoint:
|
||||
@ -98,8 +90,6 @@ struct Layout {
|
||||
return "SkMatrix";
|
||||
case CType::kSkM44:
|
||||
return "SkM44";
|
||||
case CType::kGrSurfaceProxyView:
|
||||
return "GrSurfaceProxyView";
|
||||
case CType::kGrFragmentProcessor:
|
||||
return "std::unique_ptr<GrFragmentProcessor>";
|
||||
default:
|
||||
|
@ -14,7 +14,7 @@ layout (
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = int)
|
||||
ctype = SkPMColor4f)
|
||||
void on_return() {}
|
||||
|
||||
void on_param(
|
||||
@ -34,4 +34,4 @@ layout (
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = int) float x) {}
|
||||
ctype = SkPMColor4f) float x) {}
|
||||
|
@ -14,7 +14,7 @@ layout (
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = int,
|
||||
ctype = SkPMColor4f,
|
||||
|
||||
origin_upper_left,
|
||||
push_constant,
|
||||
@ -31,5 +31,5 @@ layout (
|
||||
max_vertices = 2,
|
||||
invocations = 2,
|
||||
when = two,
|
||||
ctype = float
|
||||
ctype = SkV4
|
||||
) float x;
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
in fragmentProcessor inputFP;
|
||||
layout(key) in GrClipEdgeType edgeType;
|
||||
layout(ctype=SkRect) in float4 rect;
|
||||
layout(ctype=SkRect) float4 prevRect = float4(-1);
|
||||
in float4 rect;
|
||||
float4 prevRect = float4(-1);
|
||||
uniform float4 rectUniform;
|
||||
|
||||
@optimizationFlags {
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
in fragmentProcessor inputFP;
|
||||
layout(ctype=SkM44) in uniform half4x4 m;
|
||||
in uniform half4x4 m;
|
||||
layout(ctype=SkV4) in uniform half4 v;
|
||||
layout(key) in bool unpremulInput;
|
||||
layout(key) in bool clampRGBOutput;
|
||||
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
|
||||
in fragmentProcessor src;
|
||||
layout(ctype=SkIRect) in int4 bounds;
|
||||
in int4 bounds;
|
||||
uniform float4 boundsUniform;
|
||||
layout(ctype=SkRect) in float4 srcRect;
|
||||
in float4 srcRect;
|
||||
in uniform float xInvZoom;
|
||||
in uniform float yInvZoom;
|
||||
in uniform float xInvInset;
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
in fragmentProcessor inputFP;
|
||||
in float sigma;
|
||||
layout(ctype=SkRect) in float4 rect;
|
||||
in float4 rect;
|
||||
in uniform half cornerRadius;
|
||||
in fragmentProcessor ninePatchFP;
|
||||
layout(ctype=SkRect) uniform float4 proxyRect;
|
||||
uniform float4 proxyRect;
|
||||
uniform half blurRadius;
|
||||
|
||||
@header {
|
||||
|
@ -111,13 +111,6 @@ void Parser::InitLayoutMap() {
|
||||
TOKEN(CTYPE, "ctype");
|
||||
TOKEN(SKPMCOLOR4F, "SkPMColor4f");
|
||||
TOKEN(SKV4, "SkV4");
|
||||
TOKEN(SKRECT, "SkRect");
|
||||
TOKEN(SKIRECT, "SkIRect");
|
||||
TOKEN(SKPMCOLOR, "SkPMColor");
|
||||
TOKEN(SKM44, "SkM44");
|
||||
TOKEN(BOOL, "bool");
|
||||
TOKEN(INT, "int");
|
||||
TOKEN(FLOAT, "float");
|
||||
#undef TOKEN
|
||||
}
|
||||
|
||||
@ -848,20 +841,6 @@ Layout::CType Parser::layoutCType() {
|
||||
return Layout::CType::kSkPMColor4f;
|
||||
case LayoutToken::SKV4:
|
||||
return Layout::CType::kSkV4;
|
||||
case LayoutToken::SKRECT:
|
||||
return Layout::CType::kSkRect;
|
||||
case LayoutToken::SKIRECT:
|
||||
return Layout::CType::kSkIRect;
|
||||
case LayoutToken::SKPMCOLOR:
|
||||
return Layout::CType::kSkPMColor;
|
||||
case LayoutToken::BOOL:
|
||||
return Layout::CType::kBool;
|
||||
case LayoutToken::INT:
|
||||
return Layout::CType::kInt32;
|
||||
case LayoutToken::FLOAT:
|
||||
return Layout::CType::kFloat;
|
||||
case LayoutToken::SKM44:
|
||||
return Layout::CType::kSkM44;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -54,13 +54,6 @@ public:
|
||||
CTYPE,
|
||||
SKPMCOLOR4F,
|
||||
SKV4,
|
||||
SKRECT,
|
||||
SKIRECT,
|
||||
SKPMCOLOR,
|
||||
SKM44,
|
||||
BOOL,
|
||||
INT,
|
||||
FLOAT,
|
||||
};
|
||||
|
||||
Parser(const char* text, size_t length, SymbolTable& symbols, ErrorReporter& errors);
|
||||
|
@ -165,12 +165,6 @@ String CPPCodeGenerator::formatRuntimeValue(const Type& type,
|
||||
}
|
||||
if (type == *fContext.fTypes.fFloat4 || type == *fContext.fTypes.fHalf4) {
|
||||
switch (layout.fCType) {
|
||||
case Layout::CType::kSkPMColor:
|
||||
formatArgs->push_back("SkGetPackedR32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedG32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedB32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedA32(" + cppCode + ") / 255.0");
|
||||
break;
|
||||
case Layout::CType::kSkPMColor4f:
|
||||
formatArgs->push_back(cppCode + ".fR");
|
||||
formatArgs->push_back(cppCode + ".fG");
|
||||
|
@ -156,12 +156,6 @@ String DSLCPPCodeGenerator::formatRuntimeValue(const Type& type,
|
||||
}
|
||||
if (type == *fContext.fTypes.fFloat4 || type == *fContext.fTypes.fHalf4) {
|
||||
switch (layout.fCType) {
|
||||
case Layout::CType::kSkPMColor:
|
||||
formatArgs->push_back("SkGetPackedR32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedG32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedB32(" + cppCode + ") / 255.0");
|
||||
formatArgs->push_back("SkGetPackedA32(" + cppCode + ") / 255.0");
|
||||
break;
|
||||
case Layout::CType::kSkPMColor4f:
|
||||
formatArgs->push_back(cppCode + ".fR");
|
||||
formatArgs->push_back(cppCode + ".fG");
|
||||
|
@ -52,16 +52,13 @@ Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type&
|
||||
}
|
||||
if (type == *context.fTypes.fFloat || type == *context.fTypes.fHalf) {
|
||||
return Layout::CType::kFloat;
|
||||
} else if (type == *context.fTypes.fInt ||
|
||||
type == *context.fTypes.fShort) {
|
||||
} else if (type == *context.fTypes.fInt || type == *context.fTypes.fShort) {
|
||||
return Layout::CType::kInt32;
|
||||
} else if (type == *context.fTypes.fFloat2 || type == *context.fTypes.fHalf2) {
|
||||
return Layout::CType::kSkPoint;
|
||||
} else if (type == *context.fTypes.fInt2 ||
|
||||
type == *context.fTypes.fShort2) {
|
||||
} else if (type == *context.fTypes.fInt2 || type == *context.fTypes.fShort2) {
|
||||
return Layout::CType::kSkIPoint;
|
||||
} else if (type == *context.fTypes.fInt4 ||
|
||||
type == *context.fTypes.fShort4) {
|
||||
} else if (type == *context.fTypes.fInt4 || type == *context.fTypes.fShort4) {
|
||||
return Layout::CType::kSkIRect;
|
||||
} else if (type == *context.fTypes.fFloat4 || type == *context.fTypes.fHalf4) {
|
||||
return Layout::CType::kSkRect;
|
||||
@ -69,8 +66,6 @@ Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type&
|
||||
return Layout::CType::kSkMatrix;
|
||||
} else if (type == *context.fTypes.fFloat4x4 || type == *context.fTypes.fHalf4x4) {
|
||||
return Layout::CType::kSkM44;
|
||||
} else if (type.typeKind() == Type::TypeKind::kSampler) {
|
||||
return Layout::CType::kGrSurfaceProxyView;
|
||||
} else if (type.isFragmentProcessor()) {
|
||||
return Layout::CType::kGrFragmentProcessor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user