28#if defined(DUMP_PROGRAMS)
36 std::optional<SkColor4f> expectedResult) {
40 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(
43 ERRORF(r,
"Unexpected error compiling %s\n%s",
src,
compiler.errorText().c_str());
48 ERRORF(r,
"Program must have a 'main' function");
55 std::unique_ptr<SkSL::RP::Program> rasterProg =
57 if (!rasterProg && !expectedResult.has_value()) {
61 if (!rasterProg && expectedResult.has_value()) {
62 ERRORF(r,
"MakeRasterPipelineProgram failed");
65 if (rasterProg && !expectedResult.has_value()) {
66 ERRORF(r,
"MakeRasterPipelineProgram should have failed, but didn't");
70#if defined(DUMP_PROGRAMS)
79 rasterProg->appendStages(&pipeline, &alloc,
nullptr, uniforms);
84 pipeline.
append(SkRasterPipelineOp::store_8888, &outCtx);
85 pipeline.
run(0, 0, 1, 1);
88 uint32_t expected = expectedResult->toBytes_RGBA();
90 "Got:%02X%02X%02X%02X Expected:%02X%02X%02X%02X",
91 (
out[0] >> 24) & 0xFF,
92 (
out[0] >> 16) & 0xFF,
95 (expected >> 24) & 0xFF,
96 (expected >> 16) & 0xFF,
97 (expected >> 8) & 0xFF,
106DEF_TEST(SkSLRasterPipelineCodeGeneratorNestedTernaryTest, r) {
111 half three = 3, one = 1, two = 2;
112 half result = (three > (one > two ? 2.0 : 5.0)) ? 1.0 : 0.499;
113 return half4(result);
118 SkColor4f{0.499f, 0.499f, 0.499f, 0.499f});
121DEF_TEST(SkSLRasterPipelineCodeGeneratorArithmeticTest, r) {
125 const half4 colorGreen = half4(0,1,0,1), colorRed = half4(1,0,0,1);
127 half a = 3.0, b = 4.0, c = a + b - 2.0;
128 if (a*a + b*b == c*c*c/5.0) {
129 int A = 3, B = 4, C = A + B - 2;
130 if (A*A + B*B == C*C*C/5) {
143DEF_TEST(SkSLRasterPipelineCodeGeneratorCoercedTypeTest, r) {
144 static constexpr float kUniforms[] = {0.0, 1.0, 0.0, 1.0,
148 uniform half4 colorGreen;
149 uniform float4 colorRed;
150 half4 main(half4 color) {
151 return ((colorGreen + colorRed) == float4(1.0, 1.0, 0.0, 2.0)) ? colorGreen
160DEF_TEST(SkSLRasterPipelineCodeGeneratorIdentitySwizzle, r) {
161 static constexpr float kUniforms[] = {0.0, 1.0, 0.0, 1.0,
166uniform half4 colorGreen, colorRed;
168const int SEVEN = 7, TEN = 10;
169const half4x4 MATRIXFIVE = half4x4(5);
171noinline bool verify_const_globals(int seven, int ten, half4x4 matrixFive) {
172 return seven == 7 && ten == 10 && matrixFive == half4x4(5);
176 return verify_const_globals(SEVEN, TEN, MATRIXFIVE) ? colorGreen : colorRed;
186DEF_TEST(SkSLRasterPipelineCodeGeneratorBitwiseNotTest, r) {
187 static constexpr int32_t kUniforms[] = { 0, 12, 3456, 4567890,
188 ~0, ~12, ~3456, ~4567890};
191 uniform int4 value, expected;
192 const half4 colorGreen = half4(0,1,0,1), colorRed = half4(1,0,0,1);
195 return (~value.x == expected.x &&
196 ~value.xy == expected.xy &&
197 ~value.xyz == expected.xyz &&
198 ~value.xyzw == expected.xyzw) ? colorGreen : colorRed;
206DEF_TEST(SkSLRasterPipelineCodeGeneratorComparisonIntrinsicTest, r) {
210 const half4 colorGreen = half4(0,1,0,1), colorRed = half4(1,0,0,1);
211 half4 a = half4(1, 2, 0, 1),
212 b = half4(2, 2, 1, 0);
213 int3 c = int3(1111, 3333, 5555),
214 d = int3(1111, 5555, 3333);
215 uint2 e = uint2(1111111111u, 222),
216 f = uint2(3333333333u, 222);
217 return (lessThan(a, b) == bool4(true, false, true, false) &&
218 lessThan(c, d) == bool3(false, true, false) &&
219 lessThan(e, f) == bool2(true, false) &&
220 greaterThan(a, b) == bool4(false, false, false, true) &&
221 greaterThan(c, d) == bool3(false, false, true) &&
222 greaterThan(e, f) == bool2(false, false) &&
223 lessThanEqual(a, b) == bool4(true, true, true, false) &&
224 lessThanEqual(c, d) == bool3(true, true, false) &&
225 lessThanEqual(e, f) == bool2(true, true) &&
226 greaterThanEqual(a, b) == bool4(false, true, false, true) &&
227 greaterThanEqual(c, d) == bool3(true, false, true) &&
228 greaterThanEqual(e, f) == bool2(false, true) &&
229 equal(a, b) == bool4(false, true, false, false) &&
230 equal(c, d) == bool3(true, false, false) &&
231 equal(e, f) == bool2(false, true) &&
232 notEqual(a, b) == bool4(true, false, true, true) &&
233 notEqual(c, d) == bool3(false, true, true) &&
234 notEqual(e, f) == bool2(true, false) &&
235 max(a, b) == half4(2, 2, 1, 1) &&
236 max(c, d) == int3(1111, 5555, 5555) &&
237 max(e, f) == uint2(3333333333u, 222) &&
238 max(a, 1) == half4(1, 2, 1, 1) &&
239 max(c, 3333) == int3(3333, 3333, 5555) &&
240 max(e, 7777) == uint2(1111111111u, 7777) &&
241 min(a, b) == half4(1, 2, 0, 0) &&
242 min(c, d) == int3(1111, 3333, 3333) &&
243 min(e, f) == uint2(1111111111u, 222) &&
244 min(a, 1) == half4(1, 1, 0, 1) &&
245 min(c, 3333) == int3(1111, 3333, 3333) &&
246 min(e, 7777) == uint2(7777, 222)) ? colorGreen : colorRed;
DEF_TEST(SkSLRasterPipelineCodeGeneratorNestedTernaryTest, r)
static void test(skiatest::Reporter *r, const char *src, SkSpan< const float > uniforms, SkColor4f startingColor, std::optional< SkColor4f > expectedResult)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static constexpr int SkRasterPipeline_kMaxStride_highp
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
#define REPORTER_ASSERT(r, cond,...)
void run(size_t x, size_t y, size_t w, size_t h) const
void append(SkRasterPipelineOp, void *=nullptr)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])
std::unique_ptr< RP::Program > MakeRasterPipelineProgram(const SkSL::Program &program, const FunctionDefinition &function, DebugTracePriv *debugTrace, bool writeTraceOps)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size