Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0dd83e1

Browse files
johnstiles-googleSkia Commit-Bot
authored andcommitted
Revert "SkSL: Test/implement "geometric" intrinsics"
This reverts commit 0d5d956. Reason for revert: doesn't compile on Metal, breaks tree Original change's description: > SkSL: Test/implement "geometric" intrinsics > > Bug: skia:10913 > Change-Id: Ie82354b05db141c8ab90b1a615ddfada4f71a98b > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335049 > Commit-Queue: Brian Osman <[email protected]> > Reviewed-by: John Stiles <[email protected]> [email protected],[email protected] Change-Id: I3a44eaf7bafe2fa2d185186c48c39b61116dd2fe No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:10913 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337186 Reviewed-by: John Stiles <[email protected]> Commit-Queue: John Stiles <[email protected]>
1 parent 0758da2 commit 0dd83e1

File tree

6 files changed

+360
-978
lines changed

6 files changed

+360
-978
lines changed

gm/runtimeintrinsics.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ static constexpr int kLabelHeight = 15;
2929
produce a single float. It can reference:
3030
3131
'x' : float in [xMin, xMax]
32-
'p' : float2 in [xMin, xMax] Lerps from (xMax, xMin) to (xMin, xMax)
33-
(helpful for intrinsics with a mix of scalar/vector params)
32+
'p' : float2 in [xMin, xMax] (helpful for intrinsics with a mix of scalar/vector params)
3433
'v1' : float2(1)
3534
'v2' : float2(2)
3635
*/
@@ -41,7 +40,7 @@ static SkString make_unary_sksl_1d(const char* fn) {
4140
"half4 main(float2 p) {"
4241
" float2 v1 = float2(1);"
4342
" float2 v2 = float2(2);"
44-
" p = float2(p.x, 1 - p.x) * xScale + xBias;"
43+
" p = p * xScale + xBias;"
4544
" float x = p.x;"
4645
" float y = %s * yScale + yBias;"
4746
" return y.xxx1;"
@@ -234,38 +233,3 @@ DEF_SIMPLE_GM_BG(runtime_intrinsics_common,
234233
plot(canvas, "smoothstep(1, 2, p).x", 0.5f, 2.5f, -0.5f, 1.5f, "smooth(mixed)" ); col(canvas);
235234
plot(canvas, "smoothstep(v1, v2, p).x", 0.5f, 2.5f, -0.5f, 1.5f, "smooth(vector)"); row(canvas);
236235
}
237-
238-
// The OpenGL ES Shading Language, Version 1.00, Section 8.4
239-
DEF_SIMPLE_GM_BG(runtime_intrinsics_geometric,
240-
canvas,
241-
columns_to_width(4),
242-
rows_to_height(5),
243-
SK_ColorWHITE) {
244-
canvas->translate(kPadding, kPadding);
245-
canvas->save();
246-
247-
plot(canvas, "length(x)", -1.0f, 1.0f, -0.5f, 1.5f); col(canvas);
248-
plot(canvas, "length(p)", 0.0f, 1.0f, 0.5f, 1.5f); col(canvas);
249-
250-
plot(canvas, "distance(x, 0)", -1.0f, 1.0f, -0.5f, 1.5f); col(canvas);
251-
plot(canvas, "distance(p, v1)", 0.0f, 1.0f, 0.5f, 1.5f); row(canvas);
252-
253-
plot(canvas, "dot(x, 2)", -1.0f, 1.0f, -2.5f, 2.5f); col(canvas);
254-
plot(canvas, "dot(p, p.y1)", -1.0f, 1.0f, -2.5f, 0.5f); row(canvas);
255-
256-
plot(canvas, "cross(p.xy1, p.y1x).x", 0.0f, 1.0f, -1.0f, 1.0f); col(canvas);
257-
plot(canvas, "cross(p.xy1, p.y1x).y", 0.0f, 1.0f, -1.0f, 1.0f); col(canvas);
258-
plot(canvas, "cross(p.xy1, p.y1x).z", 0.0f, 1.0f, -1.0f, 1.0f); row(canvas);
259-
260-
plot(canvas, "normalize(x)", -2.0f, 2.0f, -1.5f, 1.5f); col(canvas);
261-
plot(canvas, "normalize(p).x", 0.0f, 2.0f, 0.0f, 1.0f); col(canvas);
262-
plot(canvas, "normalize(p).y", 0.0f, 2.0f, 0.0f, 1.0f); col(canvas);
263-
264-
plot(canvas, "faceforward(v1, p.x0, v1.x0).x", -1.0f, 1.0f, -1.5f, 1.5f, "faceforward"); row(canvas);
265-
266-
plot(canvas, "reflect(p.x1, v1.0x).x", -1.0f, 1.0f, -1.0f, 1.0f, "reflect(horiz)"); col(canvas);
267-
plot(canvas, "reflect(p.x1, normalize(v1)).y", -1.0f, 1.0f, -1.0f, 1.0f, "reflect(diag)" ); col(canvas);
268-
269-
plot(canvas, "refract(v1.x0, v1.0x, x).x", 0.0f, 1.0f, -1.0f, 1.0f, "refract().x"); col(canvas);
270-
plot(canvas, "refract(v1.x0, v1.0x, x).y", 0.0f, 1.0f, -1.0f, 1.0f, "refract().y"); row(canvas);
271-
}

src/sksl/SkSLByteCodeGenerator.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ByteCodeGenerator::ByteCodeGenerator(const Context* context, const Program* prog
5555
{ "ceil", ByteCodeInstruction::kCeil },
5656
{ "clamp", SpecialIntrinsic::kClamp },
5757
{ "cos", ByteCodeInstruction::kCos },
58-
{ "distance", SpecialIntrinsic::kDistance },
5958
{ "dot", SpecialIntrinsic::kDot },
6059
{ "exp", ByteCodeInstruction::kExp },
6160
{ "exp2", ByteCodeInstruction::kExp2 },
@@ -1249,19 +1248,6 @@ void ByteCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
12491248
}
12501249

12511250
if (intrin.is_special) {
1252-
auto doDotProduct = [count, this] {
1253-
this->write(ByteCodeInstruction::kMultiplyF, count);
1254-
for (int i = count - 1; i-- > 0;) {
1255-
this->write(ByteCodeInstruction::kAddF, 1);
1256-
}
1257-
};
1258-
1259-
auto doLength = [count, this, &doDotProduct] {
1260-
this->write(ByteCodeInstruction::kDup, count);
1261-
doDotProduct();
1262-
this->write(ByteCodeInstruction::kSqrt, 1);
1263-
};
1264-
12651251
switch (intrin.special) {
12661252
case SpecialIntrinsic::kAll: {
12671253
for (int i = count-1; i --> 0;) {
@@ -1282,20 +1268,23 @@ void ByteCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
12821268
count);
12831269
} break;
12841270

1285-
case SpecialIntrinsic::kDistance: {
1286-
SkASSERT(nargs == 2 && count == SlotCount(args[1]->type()));
1287-
this->write(ByteCodeInstruction::kSubtractF, count);
1288-
doLength();
1289-
} break;
1290-
12911271
case SpecialIntrinsic::kDot: {
1292-
SkASSERT(nargs == 2 && count == SlotCount(args[1]->type()));
1293-
doDotProduct();
1272+
SkASSERT(nargs == 2);
1273+
SkASSERT(count == SlotCount(args[1]->type()));
1274+
this->write(ByteCodeInstruction::kMultiplyF, count);
1275+
for (int i = count-1; i --> 0;) {
1276+
this->write(ByteCodeInstruction::kAddF, 1);
1277+
}
12941278
} break;
12951279

12961280
case SpecialIntrinsic::kLength: {
12971281
SkASSERT(nargs == 1);
1298-
doLength();
1282+
this->write(ByteCodeInstruction::kDup, count);
1283+
this->write(ByteCodeInstruction::kMultiplyF, count);
1284+
for (int i = count-1; i --> 0;) {
1285+
this->write(ByteCodeInstruction::kAddF, 1);
1286+
}
1287+
this->write(ByteCodeInstruction::kSqrt, 1);
12991288
} break;
13001289

13011290
case SpecialIntrinsic::kMax:
@@ -1345,7 +1334,12 @@ void ByteCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
13451334
case SpecialIntrinsic::kNormalize: {
13461335
SkASSERT(nargs == 1);
13471336
this->write(ByteCodeInstruction::kDup, count);
1348-
doLength();
1337+
this->write(ByteCodeInstruction::kDup, count);
1338+
this->write(ByteCodeInstruction::kMultiplyF, count);
1339+
for (int i = count-1; i --> 0;) {
1340+
this->write(ByteCodeInstruction::kAddF, 1);
1341+
}
1342+
this->write(ByteCodeInstruction::kSqrt, 1);
13491343
dupSmallerType(1);
13501344
this->write(ByteCodeInstruction::kDivideF, count);
13511345
} break;

src/sksl/SkSLByteCodeGenerator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ class ByteCodeGenerator : public CodeGenerator {
140140
kAny,
141141
kATan,
142142
kClamp,
143-
kDistance,
144143
kDot,
145144
kLength,
146145
kMax,

src/sksl/SkSLSPIRVCodeGenerator.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,6 @@ SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, OutputStream
743743
return result;
744744
}
745745
case kSPIRV_IntrinsicKind: {
746-
// GLSL supports dot(float, float), but SPIR-V does not. Convert it to FMul
747-
if (intrinsicId == SpvOpDot &&
748-
arguments[0]->type().typeKind() == Type::TypeKind::kScalar) {
749-
intrinsicId = SpvOpFMul;
750-
}
751746
SpvId result = this->nextId();
752747
std::vector<SpvId> argumentIds;
753748
for (size_t i = 0; i < arguments.size(); i++) {

0 commit comments

Comments
 (0)