skia2/resources/sksl/shared
John Stiles 26487162fe Add support for array-cast syntax in SkSL.
Compiling a program with "allow narrowing conversions" actually fixes up
narrowing casts in the program by inserting casts wherever they would be
needed for type-correctness. For instance, compiling the statement
    `half h = myFloat;`
inserts an appropriate narrowing cast:
    `half h = half(myFloat);`.

The Pipeline stage code generator relies on this behavior, as when it
re-emits a runtime effect into a complete SkSL program, the narrowing-
conversions flag will no longer be set, but that is okay, because the
emitted code now contains typecasts anywhere they would be necessary.

Logically, this implies that anything which supports narrowing
conversions must be castable between high and low precision. In GLSL and
SPIR-V, such a cast is trivial, because the types are the same and the
precision qualifiers are treated as individual hints on each variable.
In Metal, we dodge the issue by only emitting full-precision types. But
we also need to emit raw SkSL from an SkSL program (that is what the
Pipeline stage generator does).

SkSL already supported every typical cast, but GLSL lacked any syntax
for casting an array to a different type. This meant SkSL had no array
casting syntax as well. SkSL now has array-cast syntax, but it is only
allowed for casting low/high-precision arrays to the same base type.
(You can't cast an int array to float, or a signed array to unsigned.)

Change-Id: Ia20933541c3bd4a946c1ea38209f93008acdb9cb
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437687
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +00:00
..
ArrayCast.sksl Add support for array-cast syntax in SkSL. 2021-08-11 12:56:40 +00:00
ArrayComparison.sksl Reland "Fix array-of-matrix/struct comparisons in Metal." 2021-08-10 21:05:20 +00:00
ArrayConstructors.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ArrayIndexTypes.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
ArrayNarrowingConversions.sksl Enable comparison of arrays of different precision types. 2021-08-06 12:57:10 +00:00
ArrayTypes.sksl Fix array-of-struct name mangling in Pipeline stage. 2021-04-28 21:02:36 +00:00
Assignment.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Caps.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
CastsRoundTowardZero.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Clockwise.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
CommaMixedTypes.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
CommaSideEffects.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ComplexDelete.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
ConstantIf.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ConstArray.sksl Enable proper testing of const arrays. 2021-05-14 13:37:12 +00:00
ConstVariableComparison.sksl Cleanup TODO for constant-expression handling. 2021-05-14 13:36:33 +00:00
Control.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
DeadDoWhileLoop.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
DeadIfStatement.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
DeadLoopVariable.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
DeadReturn.sksl Reland "Eliminate unreachable code during optimization." 2021-05-20 20:02:15 +00:00
DeadReturnES3.sksl Reland "Eliminate unreachable code during optimization." 2021-05-20 20:02:15 +00:00
DeadStripFunctions.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
DependentInitializers.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Derivatives.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
DerivativesUnused.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Discard.sksl Optimize @switch statements in SwitchStatement::Make. 2021-02-23 21:36:04 +00:00
DoWhileControlFlow.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
EmptyBlocksES2.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
EmptyBlocksES3.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
ForLoopControlFlow.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ForLoopMultipleInit.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
FragCoords.sksl Reland "Don't key progams/pipelines on origin."" 2021-07-07 14:50:10 +00:00
FunctionArgTypeMatch.sksl Allow function declarations to take (void). 2021-05-21 19:21:23 +00:00
FunctionPrototype.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
FunctionReturnTypeMatch.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Functions.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
GaussianBlur.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
GeometricIntrinsics.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Geometry.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
GeometryExtension.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
GeometryGSInvocations.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
GeometryNoGSInvocations.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
GeometryNoGSInvocationsReorder.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
HelloWorld.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Hex.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
HexUnsigned.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
InstanceID.vert Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
InterfaceBlockNamed.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
InterfaceBlockNamedArray.sksl Add default uniform binding value for Metal/SPIR-V. 2021-01-28 19:23:49 +00:00
Matrices.sksl Fix comma operator support with matrices in Metal. 2021-05-20 18:08:35 +00:00
MatricesNonsquare.sksl Add GLSL workaround for 4x2 diagonal matrix bug. 2021-05-18 22:50:19 +00:00
MatrixEquality.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
MatrixScalarSplat.sksl Enable proper testing of matrix-scalar ops. 2021-05-17 17:36:22 +00:00
MatrixToVectorCast.sksl Shore up matrix/vector conversion tests. 2021-07-12 15:02:51 +00:00
MultipleAssignments.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
NegatedVectorLiteral.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
NoFragCoordsPos.vert Change sksl tests to avoid SPIR-V validation errors 2021-03-16 13:39:53 +00:00
NoFragCoordsPosRT.vert Change sksl tests to avoid SPIR-V validation errors 2021-03-16 13:39:53 +00:00
NormalizationGeo.geom Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
NormalizationVert.vert Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
NumberCasts.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
NumberConversions.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
Offset.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
OperatorsES2.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
OperatorsES3.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
Ossfuzz26167.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Ossfuzz26759.sksl Fix up outdated tests. 2021-03-22 21:11:47 +00:00
Ossfuzz28794.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Ossfuzz28904.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Ossfuzz29085.sksl Fix various fuzzer-generated tests. 2021-04-12 13:44:59 +00:00
Ossfuzz29494.sksl Use unsigned values when constant-folding integer vectors 2021-02-01 21:44:28 +00:00
Ossfuzz36770.sksl Fix for fuzzer-discovered error in SPIR-V with RTFlip. 2021-08-02 17:13:50 +00:00
Ossfuzz36852.sksl Fix fuzzer-discovered error with swizzling matrices. 2021-08-05 21:59:23 +00:00
OutParams.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
OutParamsNoInline.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
OutParamsTricky.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Overflow.sksl Prevent overflow of integral types during constant-folding. 2021-05-27 20:12:57 +00:00
RectangleTexture.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
ResizeMatrix.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ResizeMatrixNonsquare.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ReturnBadTypeFromMain.sksl Support half4 return values from main() in the SPIR-V code generator. 2021-01-27 02:46:03 +00:00
ReturnColorFromMain.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ReturnsValueOnEveryPathES2.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ReturnsValueOnEveryPathES3.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SampleLocations.vert Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
ScalarConversionConstructorsES2.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ScalarConversionConstructorsES3.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
ScopedSymbol.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StackingVectorCasts.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
StaticIf.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
StaticSwitch.sksl Enable additional SkSL tests which require non-ES2 features. 2021-05-17 20:24:50 +00:00
StaticSwitchWithBreak.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StaticSwitchWithBreakInsideBlock.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StaticSwitchWithConditionalBreak.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
StaticSwitchWithConditionalBreakInsideBlock.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
StaticSwitchWithContinue.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
StaticSwitchWithFallthroughA.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StaticSwitchWithFallthroughB.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StaticSwitchWithStaticConditionalBreak.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StaticSwitchWithStaticConditionalBreakInsideBlock.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StructMaxDepth.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Structs.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
StructsInFunctions.sksl Reland "Implement operator== and != for Metal structs and arrays." 2021-04-29 22:55:58 +00:00
Switch.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
SwitchContainingDeadCode.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
SwitchWithFallthrough.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
SwizzleBoolConstants.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleByConstantIndex.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleByIndex.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleConstants.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleLTRB.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleOpt.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SwizzleScalar.sksl Add scalar-swizzling tests for int and bool types. 2021-07-12 19:54:40 +00:00
SwizzleScalarBool.sksl Add scalar-swizzling tests for int and bool types. 2021-07-12 19:54:40 +00:00
SwizzleScalarInt.sksl Add scalar-swizzling tests for int and bool types. 2021-07-12 19:54:40 +00:00
TernaryAsLValueEntirelyFoldable.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
TernaryAsLValueFoldableTest.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
TernaryExpression.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
Texture1D.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
Texture2D.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
TextureSharpen.sksl Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
UnaryPositiveNegative.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
UniformArray.sksl Add default uniform set value to SkSL Program settings. 2021-01-27 00:52:16 +00:00
UniformBuffers.sksl Add default uniform binding value for Metal/SPIR-V. 2021-01-28 19:23:49 +00:00
Uniforms.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
UnusedVariables.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
VectorConstructors.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
VectorScalarMath.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
VectorToMatrixCast.sksl Shore up matrix/vector conversion tests. 2021-07-12 15:02:51 +00:00
VertexEarlyReturn.vert Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
VertexID.vert Migrate SkSL test inputs to the resources/ directory. 2021-01-22 18:57:29 +00:00
WhileLoopControlFlow.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00