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

Commit 71a35d4

Browse files
johnstiles-googleSkia Commit-Bot
authored and
Skia Commit-Bot
committed
Remove double support from SkSL.
Doubles are not supported by Metal or GLSL pre-4.0, are not supported in most backends, and aren't used in any GMs. There isn't any good way to use them in new code as it would just degrade to float on many of our supported platforms. (This is assuming that our backends actually know how to degrade doubles to floats, which is not universally the case.) Change-Id: Ieacc69db4bdacca104a15a6eef33e05f977d1ffa Bug: skia:10299 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292846 Commit-Queue: John Stiles <[email protected]> Commit-Queue: Ethan Nicholas <[email protected]> Reviewed-by: Ethan Nicholas <[email protected]> Auto-Submit: John Stiles <[email protected]>
1 parent 9331ca0 commit 71a35d4

10 files changed

+29
-156
lines changed

src/sksl/SkSLCompiler.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ Compiler::Compiler(Flags flags)
126126
ADD_TYPE(Half2);
127127
ADD_TYPE(Half3);
128128
ADD_TYPE(Half4);
129-
ADD_TYPE(Double);
130-
ADD_TYPE(Double2);
131-
ADD_TYPE(Double3);
132-
ADD_TYPE(Double4);
133129
ADD_TYPE(Int);
134130
ADD_TYPE(Int2);
135131
ADD_TYPE(Int3);
@@ -176,18 +172,8 @@ Compiler::Compiler(Flags flags)
176172
ADD_TYPE(Half4x2);
177173
ADD_TYPE(Half4x3);
178174
ADD_TYPE(Half4x4);
179-
ADD_TYPE(Double2x2);
180-
ADD_TYPE(Double2x3);
181-
ADD_TYPE(Double2x4);
182-
ADD_TYPE(Double3x2);
183-
ADD_TYPE(Double3x3);
184-
ADD_TYPE(Double3x4);
185-
ADD_TYPE(Double4x2);
186-
ADD_TYPE(Double4x3);
187-
ADD_TYPE(Double4x4);
188175
ADD_TYPE(GenType);
189176
ADD_TYPE(GenHType);
190-
ADD_TYPE(GenDType);
191177
ADD_TYPE(GenIType);
192178
ADD_TYPE(GenUType);
193179
ADD_TYPE(GenBType);
@@ -198,7 +184,6 @@ Compiler::Compiler(Flags flags)
198184
ADD_TYPE(GVec3);
199185
ADD_TYPE(GVec4);
200186
ADD_TYPE(HVec);
201-
ADD_TYPE(DVec);
202187
ADD_TYPE(IVec);
203188
ADD_TYPE(UVec);
204189
ADD_TYPE(SVec);

src/sksl/SkSLContext.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class Context {
2424
, fNull_Type(new Type("null"))
2525
, fFloatLiteral_Type(new Type("$floatLiteral", Type::kFloat_NumberKind, 3))
2626
, fIntLiteral_Type(new Type("$intLiteral", Type::kSigned_NumberKind, 1))
27-
, fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6, true))
28-
, fDouble2_Type(new Type("double2", *fDouble_Type, 2))
29-
, fDouble3_Type(new Type("double3", *fDouble_Type, 3))
30-
, fDouble4_Type(new Type("double4", *fDouble_Type, 4))
3127
, fFloat_Type(new Type("float", Type::kFloat_NumberKind, 5, true))
3228
, fFloat2_Type(new Type("float2", *fFloat_Type, 2))
3329
, fFloat3_Type(new Type("float3", *fFloat_Type, 3))
@@ -82,15 +78,6 @@ class Context {
8278
, fHalf4x2_Type(new Type("half4x2", *fHalf_Type, 4, 2))
8379
, fHalf4x3_Type(new Type("half4x3", *fHalf_Type, 4, 3))
8480
, fHalf4x4_Type(new Type("half4x4", *fHalf_Type, 4, 4))
85-
, fDouble2x2_Type(new Type("double2x2", *fDouble_Type, 2, 2))
86-
, fDouble2x3_Type(new Type("double2x3", *fDouble_Type, 2, 3))
87-
, fDouble2x4_Type(new Type("double2x4", *fDouble_Type, 2, 4))
88-
, fDouble3x2_Type(new Type("double3x2", *fDouble_Type, 3, 2))
89-
, fDouble3x3_Type(new Type("double3x3", *fDouble_Type, 3, 3))
90-
, fDouble3x4_Type(new Type("double3x4", *fDouble_Type, 3, 4))
91-
, fDouble4x2_Type(new Type("double4x2", *fDouble_Type, 4, 2))
92-
, fDouble4x3_Type(new Type("double4x3", *fDouble_Type, 4, 3))
93-
, fDouble4x4_Type(new Type("double4x4", *fDouble_Type, 4, 4))
9481
, fTexture1D_Type(new Type("texture1D", SpvDim1D, false, false, false, true))
9582
, fTexture2D_Type(new Type("texture2D", SpvDim2D, false, false, false, true))
9683
, fTexture3D_Type(new Type("texture3D", SpvDim3D, false, false, false, true))
@@ -158,8 +145,6 @@ class Context {
158145
fFloat3_Type.get(), fFloat4_Type.get() }))
159146
, fGenHType_Type(new Type("$genHType", { fHalf_Type.get(), fHalf2_Type.get(),
160147
fHalf3_Type.get(), fHalf4_Type.get() }))
161-
, fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDouble2_Type.get(),
162-
fDouble3_Type.get(), fDouble4_Type.get() }))
163148
, fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fInt2_Type.get(),
164149
fInt3_Type.get(), fInt4_Type.get() }))
165150
, fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUInt2_Type.get(),
@@ -188,8 +173,6 @@ class Context {
188173
, fGVec4_Type(new Type("$gfloat4", static_type(*fFloat4_Type)))
189174
, fHVec_Type(new Type("$hvec", { fInvalid_Type.get(), fHalf2_Type.get(),
190175
fHalf3_Type.get(), fHalf4_Type.get() }))
191-
, fDVec_Type(new Type("$dvec", { fInvalid_Type.get(), fDouble2_Type.get(),
192-
fDouble3_Type.get(), fDouble4_Type.get() }))
193176
, fIVec_Type(new Type("$ivec", { fInvalid_Type.get(), fInt2_Type.get(),
194177
fInt3_Type.get(), fInt4_Type.get() }))
195178
, fUVec_Type(new Type("$uvec", { fInvalid_Type.get(), fUInt2_Type.get(),
@@ -219,11 +202,6 @@ class Context {
219202
const std::unique_ptr<Type> fFloatLiteral_Type;
220203
const std::unique_ptr<Type> fIntLiteral_Type;
221204

222-
const std::unique_ptr<Type> fDouble_Type;
223-
const std::unique_ptr<Type> fDouble2_Type;
224-
const std::unique_ptr<Type> fDouble3_Type;
225-
const std::unique_ptr<Type> fDouble4_Type;
226-
227205
const std::unique_ptr<Type> fFloat_Type;
228206
const std::unique_ptr<Type> fFloat2_Type;
229207
const std::unique_ptr<Type> fFloat3_Type;
@@ -353,7 +331,6 @@ class Context {
353331

354332
const std::unique_ptr<Type> fGenType_Type;
355333
const std::unique_ptr<Type> fGenHType_Type;
356-
const std::unique_ptr<Type> fGenDType_Type;
357334
const std::unique_ptr<Type> fGenIType_Type;
358335
const std::unique_ptr<Type> fGenUType_Type;
359336
const std::unique_ptr<Type> fGenBType_Type;

src/sksl/SkSLGLSLCodeGenerator.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ String GLSLCodeGenerator::getTypeName(const Type& type) {
8787
if (component == *fContext.fFloat_Type || component == *fContext.fHalf_Type) {
8888
result = "vec";
8989
}
90-
else if (component == *fContext.fDouble_Type) {
91-
result = "dvec";
92-
}
9390
else if (component.isSigned()) {
9491
result = "ivec";
9592
}
@@ -111,9 +108,6 @@ String GLSLCodeGenerator::getTypeName(const Type& type) {
111108
if (component == *fContext.fFloat_Type || component == *fContext.fHalf_Type) {
112109
result = "mat";
113110
}
114-
else if (component == *fContext.fDouble_Type) {
115-
result = "dmat";
116-
}
117111
else {
118112
ABORT("unsupported matrix type");
119113
}

src/sksl/SkSLSPIRVCodeGenerator.cpp

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ static bool is_float(const Context& context, const Type& type) {
152152
if (type.columns() > 1) {
153153
return is_float(context, type.componentType());
154154
}
155-
return type == *context.fFloat_Type || type == *context.fHalf_Type ||
156-
type == *context.fDouble_Type;
155+
return type == *context.fFloat_Type || type == *context.fHalf_Type;
157156
}
158157

159158
static bool is_signed(const Context& context, const Type& type) {
@@ -491,8 +490,6 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
491490
} else if (type == *fContext.fFloat_Type || type == *fContext.fHalf_Type ||
492491
type == *fContext.fFloatLiteral_Type) {
493492
this->writeInstruction(SpvOpTypeFloat, result, 32, fConstantBuffer);
494-
} else if (type == *fContext.fDouble_Type) {
495-
this->writeInstruction(SpvOpTypeFloat, result, 64, fConstantBuffer);
496493
} else {
497494
SkASSERT(false);
498495
}
@@ -2510,42 +2507,26 @@ SpvId SPIRVCodeGenerator::writeIntLiteral(const IntLiteral& i) {
25102507
}
25112508

25122509
SpvId SPIRVCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
2513-
if (f.fType != *fContext.fDouble_Type) {
2514-
ConstantType type;
2515-
if (f.fType == *fContext.fHalf_Type) {
2516-
type = ConstantType::kHalf;
2517-
} else {
2518-
type = ConstantType::kFloat;
2519-
}
2520-
float value = (float) f.fValue;
2521-
std::pair<ConstantValue, ConstantType> key(f.fValue, type);
2522-
auto entry = fNumberConstants.find(key);
2523-
if (entry == fNumberConstants.end()) {
2524-
SpvId result = this->nextId();
2525-
uint32_t bits;
2526-
SkASSERT(sizeof(bits) == sizeof(value));
2527-
memcpy(&bits, &value, sizeof(bits));
2528-
this->writeInstruction(SpvOpConstant, this->getType(f.fType), result, bits,
2529-
fConstantBuffer);
2530-
fNumberConstants[key] = result;
2531-
return result;
2532-
}
2533-
return entry->second;
2510+
ConstantType type;
2511+
if (f.fType == *fContext.fHalf_Type) {
2512+
type = ConstantType::kHalf;
25342513
} else {
2535-
std::pair<ConstantValue, ConstantType> key(f.fValue, ConstantType::kDouble);
2536-
auto entry = fNumberConstants.find(key);
2537-
if (entry == fNumberConstants.end()) {
2538-
SpvId result = this->nextId();
2539-
uint64_t bits;
2540-
SkASSERT(sizeof(bits) == sizeof(f.fValue));
2541-
memcpy(&bits, &f.fValue, sizeof(bits));
2542-
this->writeInstruction(SpvOpConstant, this->getType(f.fType), result,
2543-
bits & 0xffffffff, bits >> 32, fConstantBuffer);
2544-
fNumberConstants[key] = result;
2545-
return result;
2546-
}
2547-
return entry->second;
2514+
type = ConstantType::kFloat;
25482515
}
2516+
float value = (float) f.fValue;
2517+
std::pair<ConstantValue, ConstantType> key(f.fValue, type);
2518+
auto entry = fNumberConstants.find(key);
2519+
if (entry == fNumberConstants.end()) {
2520+
SpvId result = this->nextId();
2521+
uint32_t bits;
2522+
SkASSERT(sizeof(bits) == sizeof(value));
2523+
memcpy(&bits, &value, sizeof(bits));
2524+
this->writeInstruction(SpvOpConstant, this->getType(f.fType), result, bits,
2525+
fConstantBuffer);
2526+
fNumberConstants[key] = result;
2527+
return result;
2528+
}
2529+
return entry->second;
25492530
}
25502531

25512532
SpvId SPIRVCodeGenerator::writeFunctionStart(const FunctionDeclaration& f, OutputStream& out) {

src/sksl/ir/SkSLIndexExpression.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ static const Type& index_type(const Context& context, const Type& type) {
3333
case 4: return *context.fHalf4_Type;
3434
default: SkASSERT(false);
3535
}
36-
} else {
37-
SkASSERT(type.componentType() == *context.fDouble_Type);
38-
switch (type.rows()) {
39-
case 2: return *context.fDouble2_Type;
40-
case 3: return *context.fDouble3_Type;
41-
case 4: return *context.fDouble4_Type;
42-
default: SkASSERT(false);
43-
}
4436
}
4537
}
4638
return type.componentType();

src/sksl/ir/SkSLSwizzle.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ static const Type& get_type(const Context& context, Expression& value, size_t co
4444
case 3: return *context.fHalf3_Type;
4545
case 4: return *context.fHalf4_Type;
4646
}
47-
} else if (base == *context.fDouble_Type) {
48-
switch (count) {
49-
case 2: return *context.fDouble2_Type;
50-
case 3: return *context.fDouble3_Type;
51-
case 4: return *context.fDouble4_Type;
52-
}
5347
} else if (base == *context.fInt_Type) {
5448
switch (count) {
5549
case 2: return *context.fInt2_Type;

src/sksl/ir/SkSLType.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,38 +116,6 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
116116
}
117117
default: ABORT("unsupported row count (%d)", rows);
118118
}
119-
} else if (*this == *context.fDouble_Type) {
120-
switch (rows) {
121-
case 1:
122-
switch (columns) {
123-
case 2: return *context.fDouble2_Type;
124-
case 3: return *context.fDouble3_Type;
125-
case 4: return *context.fDouble4_Type;
126-
default: ABORT("unsupported vector column count (%d)", columns);
127-
}
128-
case 2:
129-
switch (columns) {
130-
case 2: return *context.fDouble2x2_Type;
131-
case 3: return *context.fDouble3x2_Type;
132-
case 4: return *context.fDouble4x2_Type;
133-
default: ABORT("unsupported matrix column count (%d)", columns);
134-
}
135-
case 3:
136-
switch (columns) {
137-
case 2: return *context.fDouble2x3_Type;
138-
case 3: return *context.fDouble3x3_Type;
139-
case 4: return *context.fDouble4x3_Type;
140-
default: ABORT("unsupported matrix column count (%d)", columns);
141-
}
142-
case 4:
143-
switch (columns) {
144-
case 2: return *context.fDouble2x4_Type;
145-
case 3: return *context.fDouble3x4_Type;
146-
case 4: return *context.fDouble4x4_Type;
147-
default: ABORT("unsupported matrix column count (%d)", columns);
148-
}
149-
default: ABORT("unsupported row count (%d)", rows);
150-
}
151119
} else if (*this == *context.fInt_Type || *this == *context.fIntLiteral_Type) {
152120
switch (rows) {
153121
case 1:

src/sksl/ir/SkSLType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class Type : public Symbol {
269269
}
270270

271271
/**
272-
* Returns true if this is a floating-point scalar type (float, half, or double).
272+
* Returns true if this is a floating-point scalar type (float or half).
273273
*/
274274
bool isFloat() const {
275275
return fNumberKind == kFloat_NumberKind;
@@ -297,7 +297,7 @@ class Type : public Symbol {
297297
}
298298

299299
/**
300-
* Returns the "priority" of a number type, in order of double > float > half > int > short.
300+
* Returns the "priority" of a number type, in order of float > half > int > short.
301301
* When operating on two number types, the result is the higher-priority type.
302302
*/
303303
int priority() const {

src/sksl/sksl_gpu.inc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,12 @@ $genType smoothstep(float edge0, float edge1, $genType x);
104104
$genHType smoothstep($genHType edge0, $genHType edge1, $genHType x);
105105
$genHType smoothstep(half edge0, half edge1, $genHType x);
106106
$genBType isnan($genType x);
107-
$genBType isnan($genDType x);
108107
$genBType isinf($genType x);
109-
$genBType isinf($genDType x);
110108
$genIType floatBitsToInt($genType value);
111109
$genType intBitsTofloat($genIType value);
112110
$genType uintBitsTofloat($genUType value);
113111
$genType fma($genType a, $genType b, $genType c);
114112
$genHType fma($genHType a, $genHType b, $genHType c);
115-
$genDType fma($genDType a, $genDType b, $genDType c);
116113
sk_has_side_effects $genType frexp($genType x, out $genIType exp);
117114
$genType ldexp($genType x, in $genIType exp);
118115
uint packUnorm2x16(float2 v);
@@ -123,34 +120,25 @@ float2 unpackUnorm2x16(uint p);
123120
float2 unpackSnorm2x16(uint p);
124121
float4 unpackUnorm4x8(uint p);
125122
float4 unpackSnorm4x8(uint p);
126-
uint2 unpackDouble2x32(double v);
127123
uint packHalf2x16(float2 v);
128124
float2 unpackHalf2x16(uint v);
129125
float length($genType x);
130126
half length($genHType x);
131-
double length($genDType x);
132127
float distance($genType p0, $genType p1);
133128
half distance($genHType p0, $genHType p1);
134-
double distance($genDType p0, $genDType p1);
135129
float dot($genType x, $genType y);
136130
half dot($genHType x, $genHType y);
137-
double dot($genDType x, $genDType y);
138131
float3 cross(float3 x, float3 y);
139132
half3 cross(half3 x, half3 y);
140-
double3 cross(double3 x, double3 y);
141133
$genType normalize($genType x);
142134
$genHType normalize($genHType x);
143-
$genDType normalize($genDType x);
144135
float4 ftransform();
145136
$genType faceforward($genType N, $genType I, $genType Nref);
146137
$genHType faceforward($genHType N, $genHType I, $genHType Nref);
147-
$genDType faceforward($genDType N, $genDType I, $genDType Nref);
148138
$genType reflect($genType I, $genType N);
149139
$genHType reflect($genHType I, $genHType N);
150-
$genDType reflect($genDType I, $genDType N);
151140
$genType refract($genType I, $genType N, float eta);
152141
$genHType refract($genHType I, $genHType N, float eta);
153-
$genDType refract($genDType I, $genDType N, float eta);
154142
$mat matrixCompMult($mat x, $mat y);
155143
float2x2 outerProduct(float2 c, float2 r);
156144
float3x3 outerProduct(float3 c, float3 r);
@@ -202,43 +190,37 @@ half3x3 inverse(half3x3 m);
202190
half4x4 inverse(half4x4 m);
203191
$bvec lessThan($vec x, $vec y);
204192
$bvec lessThan($hvec x, $hvec y);
205-
$bvec lessThan($dvec x, $dvec y);
206193
$bvec lessThan($ivec x, $ivec y);
207194
$bvec lessThan($svec x, $svec y);
208195
$bvec lessThan($usvec x, $usvec y);
209196
$bvec lessThan($uvec x, $uvec y);
210197
$bvec lessThanEqual($vec x, $vec y);
211198
$bvec lessThanEqual($hvec x, $hvec y);
212-
$bvec lessThanEqual($dvec x, $dvec y);
213199
$bvec lessThanEqual($ivec x, $ivec y);
214200
$bvec lessThanEqual($uvec x, $uvec y);
215201
$bvec lessThanEqual($svec x, $svec y);
216202
$bvec lessThanEqual($usvec x, $usvec y);
217203
$bvec greaterThan($vec x, $vec y);
218204
$bvec greaterThan($hvec x, $hvec y);
219-
$bvec greaterThan($dvec x, $dvec y);
220205
$bvec greaterThan($ivec x, $ivec y);
221206
$bvec greaterThan($uvec x, $uvec y);
222207
$bvec greaterThan($svec x, $svec y);
223208
$bvec greaterThan($usvec x, $usvec y);
224209
$bvec greaterThanEqual($vec x, $vec y);
225210
$bvec greaterThanEqual($hvec x, $hvec y);
226-
$bvec greaterThanEqual($dvec x, $dvec y);
227211
$bvec greaterThanEqual($ivec x, $ivec y);
228212
$bvec greaterThanEqual($uvec x, $uvec y);
229213
$bvec greaterThanEqual($svec x, $svec y);
230214
$bvec greaterThanEqual($usvec x, $usvec y);
231215
$bvec equal($vec x, $vec y);
232216
$bvec equal($hvec x, $hvec y);
233-
$bvec equal($dvec x, $dvec y);
234217
$bvec equal($ivec x, $ivec y);
235218
$bvec equal($uvec x, $uvec y);
236219
$bvec equal($svec x, $svec y);
237220
$bvec equal($usvec x, $usvec y);
238221
$bvec equal($bvec x, $bvec y);
239222
$bvec notEqual($vec x, $vec y);
240223
$bvec notEqual($hvec x, $hvec y);
241-
$bvec notEqual($dvec x, $dvec y);
242224
$bvec notEqual($ivec x, $ivec y);
243225
$bvec notEqual($uvec x, $uvec y);
244226
$bvec notEqual($svec x, $svec y);

0 commit comments

Comments
 (0)