Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
SkSLBench.cpp File Reference
#include "bench/Benchmark.h"
#include "bench/ResultsWriter.h"
#include "bench/SkSLBench.h"
#include "include/core/SkCanvas.h"
#include "src/base/SkArenaAlloc.h"
#include "src/core/SkRasterPipeline.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/mock/GrMockCaps.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLModuleLoader.h"
#include "src/sksl/SkSLParser.h"
#include "src/sksl/codegen/SkSLGLSLCodeGenerator.h"
#include "src/sksl/codegen/SkSLMetalCodeGenerator.h"
#include "src/sksl/codegen/SkSLRasterPipelineBuilder.h"
#include "src/sksl/codegen/SkSLRasterPipelineCodeGenerator.h"
#include "src/sksl/codegen/SkSLSPIRVCodeGenerator.h"
#include "src/sksl/codegen/SkSLWGSLCodeGenerator.h"
#include "src/sksl/ir/SkSLFunctionDeclaration.h"
#include "src/sksl/ir/SkSLProgram.h"
#include <regex>
#include "src/sksl/generated/sksl_shared.minified.sksl"
#include "src/sksl/generated/sksl_compute.minified.sksl"
#include "src/sksl/generated/sksl_frag.minified.sksl"
#include "src/sksl/generated/sksl_gpu.minified.sksl"
#include "src/sksl/generated/sksl_public.minified.sksl"
#include "src/sksl/generated/sksl_rt_shader.minified.sksl"
#include "src/sksl/generated/sksl_vert.minified.sksl"
#include "src/sksl/generated/sksl_graphite_frag.minified.sksl"
#include "src/sksl/generated/sksl_graphite_vert.minified.sksl"
#include "src/sksl/generated/sksl_graphite_frag_es2.minified.sksl"
#include "src/sksl/generated/sksl_graphite_vert_es2.minified.sksl"

Go to the source code of this file.

Classes

class  SkSLCompilerStartupBench
 
class  SkSLCompileBench
 
class  SkSLModuleLoaderBench
 

Macros

#define COMPILER_BENCH(name, text)
 
#define GRAPHITE_BENCH(name, text)
 

Enumerations

enum class  Output {
  kNone , kGLSL , kMetal , kSPIRV ,
  kSkRP , kGrMtl , kGrWGSL
}
 

Functions

 COMPILER_BENCH (large, R"( uniform half4 uthresholds1_7_S1_c0_c0_c0; uniform half4 uthresholds9_13_S1_c0_c0_c0; uniform float4 uscale_S1_c0_c0_c0[4]; uniform float4 ubias_S1_c0_c0_c0[4]; uniform half uinvR1_S1_c0_c0_c1_c0; uniform half ufx_S1_c0_c0_c1_c0; uniform float3x3 umatrix_S1_c0_c0_c1; uniform half4 uleftBorderColor_S1_c0_c0; uniform half4 urightBorderColor_S1_c0_c0; uniform float3x3 umatrix_S1_c1; uniform half urange_S1; sampler2D uTextureSampler_0_S1; flat in half4 vcolor_S0; noperspective in float2 vTransformedCoords_6_S0; half4 UnrolledBinaryColorizer_S1_c0_c0_c0(half4 _input, float2 _coords) { half4 _tmp_0_inColor = _input; float2 _tmp_1_coords = _coords; half t = half(_tmp_1_coords.x); float4 s; float4 b; { if (t < uthresholds1_7_S1_c0_c0_c0.y) { if (t < uthresholds1_7_S1_c0_c0_c0.x) { s = uscale_S1_c0_c0_c0[0]; b = ubias_S1_c0_c0_c0[0]; } else { s = uscale_S1_c0_c0_c0[1]; b = ubias_S1_c0_c0_c0[1]; } } else { if (t < uthresholds1_7_S1_c0_c0_c0.z) { s = uscale_S1_c0_c0_c0[2]; b = ubias_S1_c0_c0_c0[2]; } else { s = uscale_S1_c0_c0_c0[3]; b = ubias_S1_c0_c0_c0[3]; } } } return half4(half4(float(t) * s + b)); } half4 TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(half4 _input) { half4 _tmp_2_inColor = _input; float2 _tmp_3_coords = vTransformedCoords_6_S0; float t = -1.0; half v = 1.0; float x_t = -1.0; if (bool(int(0))) { x_t = dot(_tmp_3_coords, _tmp_3_coords) / _tmp_3_coords.x; } else if (bool(int(0))) { x_t = length(_tmp_3_coords) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } else { float temp = _tmp_3_coords.x * _tmp_3_coords.x - _tmp_3_coords.y * _tmp_3_coords.y; if (temp >= 0.0) { if (bool(int(0)) || !bool(int(1))) { x_t = -sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } else { x_t = sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } } } if (!bool(int(0))) { if (x_t <= 0.0) { v = -1.0; } } if (bool(int(1))) { if (bool(int(0))) { t = x_t; } else { t = x_t + float(ufx_S1_c0_c0_c1_c0); } } else { if (bool(int(0))) { t = -x_t; } else { t = -x_t + float(ufx_S1_c0_c0_c1_c0); } } if (bool(int(0))) { t = 1.0 - t; } return half4(half4(half(t), v, 0.0, 0.0)); } half4 MatrixEffect_S1_c0_c0_c1(half4 _input) { return TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(_input); } half4 ClampedGradient_S1_c0_c0(half4 _input) { half4 _tmp_4_inColor = _input; half4 t = MatrixEffect_S1_c0_c0_c1(_tmp_4_inColor); half4 outColor; if (!bool(int(0)) && t.y < 0.0) { outColor = half4(0.0); } else if (t.x < 0.0) { outColor = uleftBorderColor_S1_c0_c0; } else if (t.x > 1.0) { outColor = urightBorderColor_S1_c0_c0; } else { outColor = UnrolledBinaryColorizer_S1_c0_c0_c0(_tmp_4_inColor, float2(half2(t.x, 0.0))); } return half4(outColor); } half4 DisableCoverageAsAlpha_S1_c0(half4 _input) { _input = ClampedGradient_S1_c0_c0(_input); half4 _tmp_5_inColor = _input; return half4(_input); } half4 TextureEffect_S1_c1_c0(half4 _input, float2 _coords) { return sample(uTextureSampler_0_S1, _coords).000r; } half4 MatrixEffect_S1_c1(half4 _input, float2 _coords) { return TextureEffect_S1_c1_c0(_input, float3x2(umatrix_S1_c1) * _coords.xy1); } half4 Dither_S1(half4 _input) { half4 _tmp_6_inColor = _input; half4 color = DisableCoverageAsAlpha_S1_c0(_tmp_6_inColor); half value = MatrixEffect_S1_c1(_tmp_6_inColor, sk_FragCoord.xy).w - 0.5; return half4(half4(clamp(color.xyz + value * urange_S1, 0.0, color.w), color.w)); } void main() { // Stage 0, QuadPerEdgeAAGeometryProcessor half4 outputColor_S0; outputColor_S0 = vcolor_S0; const half4 outputCoverage_S0 = half4(1); half4 output_S1; output_S1 = Dither_S1(outputColor_S0); { // Xfer Processor: Porter Duff sk_FragColor = output_S1 * outputCoverage_S0; } } )")
 
 COMPILER_BENCH (medium, R"( uniform float3x3 umatrix_S1_c0; uniform float3x3 umatrix_S2_c0_c0; uniform float4 urect_S2_c0; sampler2D uTextureSampler_0_S1; sampler2D uTextureSampler_0_S2; flat in half4 vcolor_S0; noperspective in float2 vTransformedCoords_3_S0; half4 TextureEffect_S1_c0_c0(half4 _input) { return sample(uTextureSampler_0_S1, vTransformedCoords_3_S0); } half4 MatrixEffect_S1_c0(half4 _input) { return TextureEffect_S1_c0_c0(_input); } half4 DisableCoverageAsAlpha_S1(half4 _input) { _input = MatrixEffect_S1_c0(_input); half4 _tmp_0_inColor = _input; return half4(_input); } half4 TextureEffect_S2_c0_c0_c0(half4 _input, float2 _coords) { return sample(uTextureSampler_0_S2, _coords).000r; } half4 MatrixEffect_S2_c0_c0(half4 _input, float2 _coords) { return TextureEffect_S2_c0_c0_c0(_input, float3x2(umatrix_S2_c0_c0) * _coords.xy1); } half4 RectBlur_S2_c0(half4 _input, float2 _coords) { half4 _tmp_1_inColor = _input; float2 _tmp_2_coords = _coords; half xCoverage; half yCoverage; if (bool(int(1))) { half2 xy = max(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw)); xCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.x, 0.5))).w; yCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.y, 0.5))).w; } else { half4 rect = half4(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw)); xCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.x, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.z, 0.5))).w; yCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.y, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.w, 0.5))).w; } return half4((_input * xCoverage) * yCoverage); } half4 DeviceSpace_S2(half4 _input) { return RectBlur_S2_c0(_input, sk_FragCoord.xy); } void main() { // Stage 0, QuadPerEdgeAAGeometryProcessor half4 outputColor_S0; outputColor_S0 = vcolor_S0; const half4 outputCoverage_S0 = half4(1); half4 output_S1; output_S1 = DisableCoverageAsAlpha_S1(outputColor_S0); half4 output_S2; output_S2 = DeviceSpace_S2(outputCoverage_S0); { // Xfer Processor: Porter Duff sk_FragColor = output_S1 * output_S2; } } )")
 
 COMPILER_BENCH (small, R"( sampler2D uTextureSampler_0_S0; noperspective in float2 vTextureCoords_S0; flat in float vTexIndex_S0; noperspective in half4 vinColor_S0; void main() { // Stage 0, BitmapText half4 outputColor_S0; outputColor_S0 = vinColor_S0; half4 texColor; { texColor = sample(uTextureSampler_0_S0, vTextureCoords_S0).rrrr; } half4 outputCoverage_S0 = texColor; { // Xfer Processor: Porter Duff sk_FragColor = outputColor_S0 * outputCoverage_S0; } } )")
 
 COMPILER_BENCH (tiny, "void main() { sk_FragColor = half4(1); }")
 
 GRAPHITE_BENCH (graphite_large, R"( layout(location=0) in flat int shadingSsboIndexVar; layout(location=1) in float2 localCoordsVar; layout(location=2) in float4 jacobian; layout(location=3) in float4 edgeDistances; layout(location=4) in float4 xRadii; layout(location=5) in float4 yRadii; layout(location=6) in float2 strokeParams; layout(location=7) in float2 perPixelControl; struct FSUniformData { // 0 - SolidColor uniforms float4 color_0; // 2 - ConicalGradient8 uniforms float4 colors_2[8]; float4 offsets_2[2]; float2 point0_2; float2 point1_2; float radius0_2; float radius1_2; int tilemode_2; int colorSpace_2; int doUnPremul_2; // 3 - ColorSpaceTransform uniforms int flags_3; int srcKind_3; half3x3 gamutTransform_3; int dstKind_3; half4x4 csXformCoeffs_3; // 4 - DitherShader uniforms half range_4; } ; layout (binding=2) buffer FSUniforms { FSUniformData fsUniformData[]; } ; // 4 - DitherShader samplers layout(binding=0) sampler2D sampler_4; // [1] 1: ColorFilterShader half4 ColorFilterShader_1(half4 inColor, half4 destColor, float2 coords) { return sk_color_space_transform(sk_conical_grad_8_shader(coords, fsUniformData[shadingSsboIndexVar].colors_2, fsUniformData[shadingSsboIndexVar].offsets_2, fsUniformData[shadingSsboIndexVar].point0_2, fsUniformData[shadingSsboIndexVar].point1_2, fsUniformData[shadingSsboIndexVar].radius0_2, fsUniformData[shadingSsboIndexVar].radius1_2, fsUniformData[shadingSsboIndexVar].tilemode_2, fsUniformData[shadingSsboIndexVar].colorSpace_2, fsUniformData[shadingSsboIndexVar].doUnPremul_2), fsUniformData[shadingSsboIndexVar].flags_3, fsUniformData[shadingSsboIndexVar].srcKind_3, fsUniformData[shadingSsboIndexVar].gamutTransform_3, fsUniformData[shadingSsboIndexVar].dstKind_3, fsUniformData[shadingSsboIndexVar].csXformCoeffs_3); } void main() { half4 initialColor = half4(0); // [0] SolidColor half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0); // [1] ColorFilterShader half4 outColor_1 = ColorFilterShader_1(outColor_0, half4(1), localCoordsVar); // [4] DitherShader half4 outColor_4 = sk_dither_shader(outColor_1, localCoordsVar, fsUniformData[shadingSsboIndexVar].range_4, sampler_4); // [5] SrcOver half4 outColor_5 = outColor_4; half4 outputCoverage; outputCoverage = analytic_rrect_coverage_fn(sk_FragCoord, jacobian, edgeDistances, xRadii, yRadii, strokeParams, perPixelControl); sk_FragColor = outColor_5 * outputCoverage; } )")
 
 GRAPHITE_BENCH (graphite_small, R"( layout(location=0) in flat int shadingSsboIndexVar; layout(location=1) in float2 textureCoords; layout(location=2) in half texIndex; layout(location=3) in half maskFormat; layout (binding=1) uniform StepUniforms { layout(offset=0) float4x4 subRunDeviceMatrix; layout(offset=64) float4x4 deviceToLocal; layout(offset=128) float2 atlasSizeInv; } ; struct FSUniformData { // 0 - SolidColor uniforms float4 color_0; } ; layout (binding=2) buffer FSUniforms { FSUniformData fsUniformData[]; } ; layout(binding=0) sampler2D text_atlas_0; layout(binding=1) sampler2D text_atlas_1; layout(binding=2) sampler2D text_atlas_2; layout(binding=3) sampler2D text_atlas_3; void main() { half4 initialColor = half4(0); // [0] SolidColor half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0); // [1] SrcOver half4 outColor_1 = outColor_0; half4 outputCoverage; outputCoverage = bitmap_text_coverage_fn(sample_indexed_atlas(textureCoords, int(texIndex), text_atlas_0, text_atlas_1, text_atlas_2, text_atlas_3), int(maskFormat)); sk_FragColor = outColor_1 * outputCoverage; } )")
 
static int64_t heap_bytes_used ()
 
static void bench (NanoJSONResultsWriter *log, const char *name, int bytes)
 
void RunSkSLModuleBenchmarks (NanoJSONResultsWriter *log)
 
 DEF_BENCH (return new SkSLModuleLoaderBench("sksl_module_loader_ganesh", { SkSL::ProgramKind::kVertex, SkSL::ProgramKind::kFragment, SkSL::ProgramKind::kRuntimeColorFilter, SkSL::ProgramKind::kRuntimeShader, SkSL::ProgramKind::kRuntimeBlender, SkSL::ProgramKind::kPrivateRuntimeColorFilter, SkSL::ProgramKind::kPrivateRuntimeShader, SkSL::ProgramKind::kPrivateRuntimeBlender, SkSL::ProgramKind::kCompute, });) DEF_BENCH(return new SkSLModuleLoaderBench("sksl_module_loader_graphite"
 

Macro Definition Documentation

◆ COMPILER_BENCH

#define COMPILER_BENCH (   name,
  text 
)
Value:
static constexpr char name ## _SRC[] = text; \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/false, Output::kNone);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kNone);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGLSL);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kMetal);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSPIRV);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSkRP);)
#define DEF_BENCH(code)
Definition Benchmark.h:20
const char * name
Definition fuchsia.cc:50
std::u16string text

Definition at line 228 of file SkSLBench.cpp.

254{
255 half4 _tmp_0_inColor = _input;
256 float2 _tmp_1_coords = _coords;
257 half t = half(_tmp_1_coords.x);
258 float4 s;
259 float4 b;
260 {
261 if (t < uthresholds1_7_S1_c0_c0_c0.y)
262 {
263 if (t < uthresholds1_7_S1_c0_c0_c0.x)
264 {
265 s = uscale_S1_c0_c0_c0[0];
266 b = ubias_S1_c0_c0_c0[0];
267 }
268 else
269 {
270 s = uscale_S1_c0_c0_c0[1];
271 b = ubias_S1_c0_c0_c0[1];
272 }
273 }
274 else
275 {
276 if (t < uthresholds1_7_S1_c0_c0_c0.z)
277 {
278 s = uscale_S1_c0_c0_c0[2];
279 b = ubias_S1_c0_c0_c0[2];
280 }
281 else
282 {
283 s = uscale_S1_c0_c0_c0[3];
284 b = ubias_S1_c0_c0_c0[3];
285 }
286 }
287 }
288 return half4(half4(float(t) * s + b));
289}
290half4 TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(half4 _input)
291{
292 half4 _tmp_2_inColor = _input;
293 float2 _tmp_3_coords = vTransformedCoords_6_S0;
294 float t = -1.0;
295 half v = 1.0;
296 float x_t = -1.0;
297 if (bool(int(0)))
298 {
299 x_t = dot(_tmp_3_coords, _tmp_3_coords) / _tmp_3_coords.x;
300 }
301 else if (bool(int(0)))
302 {
303 x_t = length(_tmp_3_coords) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
304 }
305 else
306 {
307 float temp = _tmp_3_coords.x * _tmp_3_coords.x - _tmp_3_coords.y * _tmp_3_coords.y;
308 if (temp >= 0.0)
309 {
310 if (bool(int(0)) || !bool(int(1)))
311 {
312 x_t = -sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
313 }
314 else
315 {
316 x_t = sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
317 }
318 }
319 }
320 if (!bool(int(0)))
321 {
322 if (x_t <= 0.0)
323 {
324 v = -1.0;
325 }
326 }
327 if (bool(int(1)))
328 {
329 if (bool(int(0)))
330 {
331 t = x_t;
332 }
333 else
334 {
335 t = x_t + float(ufx_S1_c0_c0_c1_c0);
336 }
337 }
338 else
339 {
340 if (bool(int(0)))
341 {
342 t = -x_t;
343 }
344 else
345 {
346 t = -x_t + float(ufx_S1_c0_c0_c1_c0);
347 }
348 }
349 if (bool(int(0)))
350 {
351 t = 1.0 - t;
352 }
353 return half4(half4(half(t), v, 0.0, 0.0));
354}
355half4 MatrixEffect_S1_c0_c0_c1(half4 _input)
356{
357 return TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(_input);
358}
359half4 ClampedGradient_S1_c0_c0(half4 _input)
360{
361 half4 _tmp_4_inColor = _input;
362 half4 t = MatrixEffect_S1_c0_c0_c1(_tmp_4_inColor);
363 half4 outColor;
364 if (!bool(int(0)) && t.y < 0.0)
365 {
366 outColor = half4(0.0);
367 }
368 else if (t.x < 0.0)
369 {
370 outColor = uleftBorderColor_S1_c0_c0;
371 }
372 else if (t.x > 1.0)
373 {
374 outColor = urightBorderColor_S1_c0_c0;
375 }
376 else
377 {
378 outColor = UnrolledBinaryColorizer_S1_c0_c0_c0(_tmp_4_inColor, float2(half2(t.x, 0.0)));
379 }
380 return half4(outColor);
381}
382half4 DisableCoverageAsAlpha_S1_c0(half4 _input)
383{
384 _input = ClampedGradient_S1_c0_c0(_input);
385 half4 _tmp_5_inColor = _input;
386 return half4(_input);
387}
388half4 TextureEffect_S1_c1_c0(half4 _input, float2 _coords)
389{
390 return sample(uTextureSampler_0_S1, _coords).000r;
391}
392half4 MatrixEffect_S1_c1(half4 _input, float2 _coords)
393{
394 return TextureEffect_S1_c1_c0(_input, float3x2(umatrix_S1_c1) * _coords.xy1);
395}
396half4 Dither_S1(half4 _input)
397{
398 half4 _tmp_6_inColor = _input;
399 half4 color = DisableCoverageAsAlpha_S1_c0(_tmp_6_inColor);
400 half value = MatrixEffect_S1_c1(_tmp_6_inColor, sk_FragCoord.xy).w - 0.5;
401 return half4(half4(clamp(color.xyz + value * urange_S1, 0.0, color.w), color.w));
402}
403void main()
404{
405 // Stage 0, QuadPerEdgeAAGeometryProcessor
406 half4 outputColor_S0;
407 outputColor_S0 = vcolor_S0;
408 const half4 outputCoverage_S0 = half4(1);
409 half4 output_S1;
410 output_S1 = Dither_S1(outputColor_S0);
411 {
412 // Xfer Processor: Porter Duff
413 sk_FragColor = output_S1 * outputCoverage_S0;
414 }
415}
416)");
417
418// This fragment shader is taken from GM_BlurDrawImage.
419COMPILER_BENCH(medium, R"(
420uniform float3x3 umatrix_S1_c0;
421uniform float3x3 umatrix_S2_c0_c0;
422uniform float4 urect_S2_c0;
423sampler2D uTextureSampler_0_S1;
424sampler2D uTextureSampler_0_S2;
425flat in half4 vcolor_S0;
426noperspective in float2 vTransformedCoords_3_S0;
427half4 TextureEffect_S1_c0_c0(half4 _input)
428{
429 return sample(uTextureSampler_0_S1, vTransformedCoords_3_S0);
430}
431half4 MatrixEffect_S1_c0(half4 _input)
432{
433 return TextureEffect_S1_c0_c0(_input);
434}
435half4 DisableCoverageAsAlpha_S1(half4 _input)
436{
437 _input = MatrixEffect_S1_c0(_input);
438 half4 _tmp_0_inColor = _input;
439 return half4(_input);
440}
441half4 TextureEffect_S2_c0_c0_c0(half4 _input, float2 _coords)
442{
443 return sample(uTextureSampler_0_S2, _coords).000r;
444}
445half4 MatrixEffect_S2_c0_c0(half4 _input, float2 _coords)
446{
447 return TextureEffect_S2_c0_c0_c0(_input, float3x2(umatrix_S2_c0_c0) * _coords.xy1);
448}
449half4 RectBlur_S2_c0(half4 _input, float2 _coords)
450{
451 half4 _tmp_1_inColor = _input;
452 float2 _tmp_2_coords = _coords;
453 half xCoverage;
454 half yCoverage;
455 if (bool(int(1)))
456 {
457 half2 xy = max(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw));
458 xCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.x, 0.5))).w;
459 yCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.y, 0.5))).w;
460 }
461 else
462 {
463 half4 rect = half4(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw));
464 xCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.x, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.z, 0.5))).w;
465 yCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.y, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.w, 0.5))).w;
466 }
467 return half4((_input * xCoverage) * yCoverage);
468}
469half4 DeviceSpace_S2(half4 _input)
470{
471 return RectBlur_S2_c0(_input, sk_FragCoord.xy);
472}
473void main()
474{
475 // Stage 0, QuadPerEdgeAAGeometryProcessor
476 half4 outputColor_S0;
477 outputColor_S0 = vcolor_S0;
478 const half4 outputCoverage_S0 = half4(1);
479 half4 output_S1;
480 output_S1 = DisableCoverageAsAlpha_S1(outputColor_S0);
481 half4 output_S2;
482 output_S2 = DeviceSpace_S2(outputCoverage_S0);
483 {
484 // Xfer Processor: Porter Duff
485 sk_FragColor = output_S1 * output_S2;
486 }
487}
488)");
489
490// This fragment shader is taken from GM_lcdtext.
491COMPILER_BENCH(small, R"(
492sampler2D uTextureSampler_0_S0;
493noperspective in float2 vTextureCoords_S0;
494flat in float vTexIndex_S0;
495noperspective in half4 vinColor_S0;
496void main()
497{
498 // Stage 0, BitmapText
499 half4 outputColor_S0;
500 outputColor_S0 = vinColor_S0;
501 half4 texColor;
502 {
503 texColor = sample(uTextureSampler_0_S0, vTextureCoords_S0).rrrr;
504 }
505 half4 outputCoverage_S0 = texColor;
506 {
507 // Xfer Processor: Porter Duff
508 sk_FragColor = outputColor_S0 * outputCoverage_S0;
509 }
510}
511)");
512
513COMPILER_BENCH(tiny, "void main() { sk_FragColor = half4(1); }");
514
515#define GRAPHITE_BENCH(name, text) \
516 static constexpr char name##_SRC[] = text; \
517 DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGrMtl);) \
518 DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGrWGSL);)
519
520// This fragment shader is from the third tile on the top row of GM_gradients_2pt_conical_outside.
521GRAPHITE_BENCH(graphite_large, R"(
522layout(location=0) in flat int shadingSsboIndexVar;
523layout(location=1) in float2 localCoordsVar;
524layout(location=2) in float4 jacobian;
525layout(location=3) in float4 edgeDistances;
526layout(location=4) in float4 xRadii;
527layout(location=5) in float4 yRadii;
528layout(location=6) in float2 strokeParams;
529layout(location=7) in float2 perPixelControl;
530struct FSUniformData
531{
532 // 0 - SolidColor uniforms
533 float4 color_0;
534 // 2 - ConicalGradient8 uniforms
535 float4 colors_2[8];
536 float4 offsets_2[2];
537 float2 point0_2;
538 float2 point1_2;
539 float radius0_2;
540 float radius1_2;
541 int tilemode_2;
542 int colorSpace_2;
543 int doUnPremul_2;
544 // 3 - ColorSpaceTransform uniforms
545 int flags_3;
546 int srcKind_3;
547 half3x3 gamutTransform_3;
548 int dstKind_3;
549 half4x4 csXformCoeffs_3;
550 // 4 - DitherShader uniforms
551 half range_4;
552}
553;
554layout (binding=2) buffer FSUniforms
555{
556 FSUniformData fsUniformData[];
557}
558;
559// 4 - DitherShader samplers
560layout(binding=0) sampler2D sampler_4;
561// [1] 1: ColorFilterShader
562half4 ColorFilterShader_1(half4 inColor, half4 destColor, float2 coords)
563{
564 return sk_color_space_transform(sk_conical_grad_8_shader(coords, fsUniformData[shadingSsboIndexVar].colors_2, fsUniformData[shadingSsboIndexVar].offsets_2, fsUniformData[shadingSsboIndexVar].point0_2, fsUniformData[shadingSsboIndexVar].point1_2, fsUniformData[shadingSsboIndexVar].radius0_2, fsUniformData[shadingSsboIndexVar].radius1_2, fsUniformData[shadingSsboIndexVar].tilemode_2, fsUniformData[shadingSsboIndexVar].colorSpace_2, fsUniformData[shadingSsboIndexVar].doUnPremul_2), fsUniformData[shadingSsboIndexVar].flags_3, fsUniformData[shadingSsboIndexVar].srcKind_3, fsUniformData[shadingSsboIndexVar].gamutTransform_3, fsUniformData[shadingSsboIndexVar].dstKind_3, fsUniformData[shadingSsboIndexVar].csXformCoeffs_3);
565}
566void main()
567{
568 half4 initialColor = half4(0);
569 // [0] SolidColor
570 half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0);
571 // [1] ColorFilterShader
572 half4 outColor_1 = ColorFilterShader_1(outColor_0, half4(1), localCoordsVar);
573 // [4] DitherShader
574 half4 outColor_4 = sk_dither_shader(outColor_1, localCoordsVar, fsUniformData[shadingSsboIndexVar].range_4, sampler_4);
575 // [5] SrcOver
576 half4 outColor_5 = outColor_4;
577 half4 outputCoverage;
578 outputCoverage = analytic_rrect_coverage_fn(sk_FragCoord, jacobian, edgeDistances, xRadii, yRadii, strokeParams, perPixelControl);
579 sk_FragColor = outColor_5 * outputCoverage;
580}
581)");
582
583// This fragment shader is taken from GM_lcdtext.
584GRAPHITE_BENCH(graphite_small, R"(
585layout(location=0) in flat int shadingSsboIndexVar;
586layout(location=1) in float2 textureCoords;
587layout(location=2) in half texIndex;
588layout(location=3) in half maskFormat;
589layout (binding=1) uniform StepUniforms
590{
591 layout(offset=0) float4x4 subRunDeviceMatrix;
592 layout(offset=64) float4x4 deviceToLocal;
593 layout(offset=128) float2 atlasSizeInv;
594}
595;
596struct FSUniformData
597{
598 // 0 - SolidColor uniforms
599 float4 color_0;
600}
601;
602layout (binding=2) buffer FSUniforms
603{
604 FSUniformData fsUniformData[];
605}
606;
607layout(binding=0) sampler2D text_atlas_0;
608layout(binding=1) sampler2D text_atlas_1;
609layout(binding=2) sampler2D text_atlas_2;
610layout(binding=3) sampler2D text_atlas_3;
611void main()
612{
613 half4 initialColor = half4(0);
614 // [0] SolidColor
615 half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0);
616 // [1] SrcOver
617 half4 outColor_1 = outColor_0;
618 half4 outputCoverage;
619 outputCoverage = bitmap_text_coverage_fn(sample_indexed_atlas(textureCoords, int(texIndex), text_atlas_0, text_atlas_1, text_atlas_2, text_atlas_3), int(maskFormat));
620 sk_FragColor = outColor_1 * outputCoverage;
621}
622)");
623
624#if defined(SK_BUILD_FOR_UNIX)
625
626#include <malloc.h>
627static int64_t heap_bytes_used() {
628 return (int64_t)mallinfo().uordblks;
629}
630
631#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
632
633#include <malloc/malloc.h>
634static int64_t heap_bytes_used() {
635 malloc_statistics_t stats;
636 malloc_zone_pressure_relief(malloc_default_zone(), 0);
637 malloc_zone_statistics(malloc_default_zone(), &stats);
638 return (int64_t)stats.size_in_use;
639}
640
641#else
642
643static int64_t heap_bytes_used() {
644 return -1;
645}
646
647#endif
648
649static void bench(NanoJSONResultsWriter* log, const char* name, int bytes) {
650 SkDEBUGCODE(SkDebugf("%s: %d bytes\n", name, bytes);)
651 log->beginObject(name); // test
652 log->beginObject("meta"); // config
653 log->appendS32("bytes", bytes); // sub_result
654 log->endObject(); // config
655 log->endObject(); // test
656}
657
658// These benchmarks aren't timed, they produce memory usage statistics. They run standalone, and
659// directly add their results to the nanobench log.
660void RunSkSLModuleBenchmarks(NanoJSONResultsWriter* log) {
661 // Heap used by a default compiler (with no modules loaded)
662 int64_t before = heap_bytes_used();
663 SkSL::Compiler compiler;
664 int baselineBytes = heap_bytes_used();
665 if (baselineBytes >= 0) {
666 baselineBytes = (baselineBytes - before);
667 bench(log, "sksl_compiler_baseline", baselineBytes);
668 }
669
670 // Heap used by a compiler with the two main GPU modules (fragment + vertex) and runtime effects
671 // (shader + color filter + blender) loaded. Ganesh will load all of these in regular usage.
672 before = heap_bytes_used();
673 compiler.moduleForProgramKind(SkSL::ProgramKind::kVertex);
674 compiler.moduleForProgramKind(SkSL::ProgramKind::kFragment);
675 compiler.moduleForProgramKind(SkSL::ProgramKind::kRuntimeColorFilter);
676 compiler.moduleForProgramKind(SkSL::ProgramKind::kRuntimeShader);
677 compiler.moduleForProgramKind(SkSL::ProgramKind::kRuntimeBlender);
678 compiler.moduleForProgramKind(SkSL::ProgramKind::kPrivateRuntimeColorFilter);
679 compiler.moduleForProgramKind(SkSL::ProgramKind::kPrivateRuntimeShader);
680 compiler.moduleForProgramKind(SkSL::ProgramKind::kPrivateRuntimeBlender);
681 int64_t gpuBytes = heap_bytes_used();
682 if (gpuBytes >= 0) {
683 gpuBytes = (gpuBytes - before) + baselineBytes;
684 bench(log, "sksl_compiler_gpu", gpuBytes);
685 }
686
687#if defined(SK_GRAPHITE)
688 // Heap used by a compiler with the Graphite modules loaded.
689 before = heap_bytes_used();
690 compiler.moduleForProgramKind(SkSL::ProgramKind::kGraphiteVertex);
691 compiler.moduleForProgramKind(SkSL::ProgramKind::kGraphiteFragment);
692 int64_t graphiteBytes = heap_bytes_used();
693 if (graphiteBytes >= 0) {
694 graphiteBytes = (graphiteBytes - before) + gpuBytes;
695 bench(log, "sksl_compiler_graphite", graphiteBytes);
696 }
697
698 // Heap used by a compiler with compute-shader support loaded.
699 before = heap_bytes_used();
700 compiler.moduleForProgramKind(SkSL::ProgramKind::kCompute);
701 int64_t computeBytes = heap_bytes_used();
702 if (computeBytes >= 0) {
703 computeBytes = (computeBytes - before) + baselineBytes;
704 bench(log, "sksl_compiler_compute", computeBytes);
705 }
706#endif
707
708 // Report the minified module sizes.
709 int compilerGPUBinarySize = std::size(SKSL_MINIFIED_sksl_shared) +
710 std::size(SKSL_MINIFIED_sksl_gpu) +
711 std::size(SKSL_MINIFIED_sksl_vert) +
712 std::size(SKSL_MINIFIED_sksl_frag) +
713 std::size(SKSL_MINIFIED_sksl_public) +
714 std::size(SKSL_MINIFIED_sksl_rt_shader);
715 bench(log, "sksl_binary_size_gpu", compilerGPUBinarySize);
716
717 int compilerGraphiteBinarySize = std::size(SKSL_MINIFIED_sksl_graphite_frag) +
718 std::size(SKSL_MINIFIED_sksl_graphite_vert);
719 bench(log, "sksl_binary_size_graphite", compilerGraphiteBinarySize);
720
721 int compilerGraphiteES2BinarySize = std::size(SKSL_MINIFIED_sksl_graphite_frag_es2) +
722 std::size(SKSL_MINIFIED_sksl_graphite_vert_es2);
723 bench(log, "sksl_binary_size_graphite_es2", compilerGraphiteES2BinarySize);
724
725 int compilerComputeBinarySize = std::size(SKSL_MINIFIED_sksl_compute);
726 bench(log, "sksl_binary_size_compute", compilerComputeBinarySize);
727}
728
729class SkSLModuleLoaderBench : public Benchmark {
730public:
731 SkSLModuleLoaderBench(const char* name, std::vector<SkSL::ProgramKind> moduleList)
732 : fName(name), fModuleList(std::move(moduleList)) {}
733
734 const char* onGetName() override {
735 return fName;
736 }
737
738 bool isSuitableFor(Backend backend) override {
739 return backend == Backend::kNonRendering;
740 }
741
742 bool shouldLoop() const override {
743 return false;
744 }
745
746 void onPreDraw(SkCanvas*) override {
747 SkSL::ModuleLoader::Get().unloadModules();
748 }
749
750 void onDraw(int loops, SkCanvas*) override {
751 SkASSERT(loops == 1);
752 SkSL::Compiler compiler;
753 for (SkSL::ProgramKind kind : fModuleList) {
754 compiler.moduleForProgramKind(kind);
755 }
756 }
757
758 const char* fName;
759 std::vector<SkSL::ProgramKind> fModuleList;
760};
761
762DEF_BENCH(return new SkSLModuleLoaderBench("sksl_module_loader_ganesh",
763 {
764 SkSL::ProgramKind::kVertex,
765 SkSL::ProgramKind::kFragment,
766 SkSL::ProgramKind::kRuntimeColorFilter,
767 SkSL::ProgramKind::kRuntimeShader,
768 SkSL::ProgramKind::kRuntimeBlender,
769 SkSL::ProgramKind::kPrivateRuntimeColorFilter,
770 SkSL::ProgramKind::kPrivateRuntimeShader,
771 SkSL::ProgramKind::kPrivateRuntimeBlender,
772 SkSL::ProgramKind::kCompute,
773 });)
774
775DEF_BENCH(return new SkSLModuleLoaderBench("sksl_module_loader_graphite",
776 {
777 SkSL::ProgramKind::kVertex,
778 SkSL::ProgramKind::kFragment,
779 SkSL::ProgramKind::kRuntimeColorFilter,
780 SkSL::ProgramKind::kRuntimeShader,
781 SkSL::ProgramKind::kRuntimeBlender,
782 SkSL::ProgramKind::kPrivateRuntimeColorFilter,
783 SkSL::ProgramKind::kPrivateRuntimeShader,
784 SkSL::ProgramKind::kPrivateRuntimeBlender,
785 SkSL::ProgramKind::kCompute,
786 SkSL::ProgramKind::kGraphiteVertex,
787 SkSL::ProgramKind::kGraphiteFragment,
788 });)
SkColor4f color
static unsigned clamp(SkFixed fx, int max)
skvx::float2 float2
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct s
static const uint8_t buffer[]
uint8_t value
static float max(float r, float g, float b)
Definition hsl.cpp:49
size_t length
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
Definition main.py:1
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
Definition SkVx.h:964
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
Vec< 2, uint16_t > half2
Definition SkVx.h:1175
Vec< 4, uint16_t > half4
Definition SkVx.h:1176
SkScalar w
Point offset

◆ GRAPHITE_BENCH

#define GRAPHITE_BENCH (   name,
  text 
)
Value:
static constexpr char name##_SRC[] = text; \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGrMtl);) \
DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGrWGSL);)

Definition at line 249 of file SkSLBench.cpp.

Enumeration Type Documentation

◆ Output

enum class Output
strong
Enumerator
kNone 
kGLSL 
kMetal 
kSPIRV 
kSkRP 
kGrMtl 
kGrWGSL 

Definition at line 61 of file SkSLBench.cpp.

61 {
62 kNone,
63 kGLSL,
64 kMetal,
65 kSPIRV,
66 kSkRP,
67 kGrMtl,
68 kGrWGSL,
69};

Function Documentation

◆ bench()

static void bench ( NanoJSONResultsWriter log,
const char *  name,
int  bytes 
)
static

Definition at line 285 of file SkSLBench.cpp.

292{

◆ COMPILER_BENCH() [1/4]

COMPILER_BENCH ( large  ,
R"(uniform half4 uthresholds1_7_S1_c0_c0_c0;uniform half4 uthresholds9_13_S1_c0_c0_c0;uniform float4 uscale_S1_c0_c0_c0[4];uniform float4 ubias_S1_c0_c0_c0[4];uniform half uinvR1_S1_c0_c0_c1_c0;uniform half ufx_S1_c0_c0_c1_c0;uniform float3x3 umatrix_S1_c0_c0_c1;uniform half4 uleftBorderColor_S1_c0_c0;uniform half4 urightBorderColor_S1_c0_c0;uniform float3x3 umatrix_S1_c1;uniform half urange_S1;sampler2D uTextureSampler_0_S1;flat in half4 vcolor_S0;noperspective in float2 vTransformedCoords_6_S0;half4 UnrolledBinaryColorizer_S1_c0_c0_c0(half4 _input, float2 _coords){ half4 _tmp_0_inColor = _input; float2 _tmp_1_coords = _coords; half t = half(_tmp_1_coords.x); float4 s; float4 b; { if (t < uthresholds1_7_S1_c0_c0_c0.y) { if (t < uthresholds1_7_S1_c0_c0_c0.x) { s = uscale_S1_c0_c0_c0[0]; b = ubias_S1_c0_c0_c0[0]; } else { s = uscale_S1_c0_c0_c0[1]; b = ubias_S1_c0_c0_c0[1]; } } else { if (t < uthresholds1_7_S1_c0_c0_c0.z) { s = uscale_S1_c0_c0_c0[2]; b = ubias_S1_c0_c0_c0[2]; } else { s = uscale_S1_c0_c0_c0[3]; b = ubias_S1_c0_c0_c0[3]; } } } return half4(half4(float(t) * s + b));}half4 TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(half4 _input){ half4 _tmp_2_inColor = _input; float2 _tmp_3_coords = vTransformedCoords_6_S0; float t = -1.0; half v = 1.0; float x_t = -1.0; if (bool(int(0))) { x_t = dot(_tmp_3_coords, _tmp_3_coords) / _tmp_3_coords.x; } else if (bool(int(0))) { x_t = length(_tmp_3_coords) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } else { float temp = _tmp_3_coords.x * _tmp_3_coords.x - _tmp_3_coords.y * _tmp_3_coords.y; if (temp >= 0.0) { if (bool(int(0)) || !bool(int(1))) { x_t = -sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } else { x_t = sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0); } } } if (!bool(int(0))) { if (x_t <= 0.0) { v = -1.0; } } if (bool(int(1))) { if (bool(int(0))) { t = x_t; } else { t = x_t + float(ufx_S1_c0_c0_c1_c0); } } else { if (bool(int(0))) { t = -x_t; } else { t = -x_t + float(ufx_S1_c0_c0_c1_c0); } } if (bool(int(0))) { t = 1.0 - t; } return half4(half4(half(t), v, 0.0, 0.0));}half4 MatrixEffect_S1_c0_c0_c1(half4 _input){ return TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(_input);}half4 ClampedGradient_S1_c0_c0(half4 _input){ half4 _tmp_4_inColor = _input; half4 t = MatrixEffect_S1_c0_c0_c1(_tmp_4_inColor); half4 outColor; if (!bool(int(0)) && t.y < 0.0) { outColor = half4(0.0); } else if (t.x < 0.0) { outColor = uleftBorderColor_S1_c0_c0; } else if (t.x > 1.0) { outColor = urightBorderColor_S1_c0_c0; } else { outColor = UnrolledBinaryColorizer_S1_c0_c0_c0(_tmp_4_inColor, float2(half2(t.x, 0.0))); } return half4(outColor);}half4 DisableCoverageAsAlpha_S1_c0(half4 _input){ _input = ClampedGradient_S1_c0_c0(_input); half4 _tmp_5_inColor = _input; return half4(_input);}half4 TextureEffect_S1_c1_c0(half4 _input, float2 _coords){ return sample(uTextureSampler_0_S1, _coords).000r;}half4 MatrixEffect_S1_c1(half4 _input, float2 _coords){ return TextureEffect_S1_c1_c0(_input, float3x2(umatrix_S1_c1) * _coords.xy1);}half4 Dither_S1(half4 _input){ half4 _tmp_6_inColor = _input; half4 color = DisableCoverageAsAlpha_S1_c0(_tmp_6_inColor); half value = MatrixEffect_S1_c1(_tmp_6_inColor, sk_FragCoord.xy).w - 0.5; return half4(half4(clamp(color.xyz + value * urange_S1, 0.0, color.w), color.w));}void main(){ // Stage 0, QuadPerEdgeAAGeometryProcessor half4 outputColor_S0; outputColor_S0 = vcolor_S0; const half4 outputCoverage_S0 = half4(1); half4 output_S1; output_S1 = Dither_S1(outputColor_S0); { // Xfer Processor: Porter Duff sk_FragColor = output_S1 * outputCoverage_S0; }})"   
)

◆ COMPILER_BENCH() [2/4]

COMPILER_BENCH ( medium  ,
R"(uniform float3x3 umatrix_S1_c0;uniform float3x3 umatrix_S2_c0_c0;uniform float4 urect_S2_c0;sampler2D uTextureSampler_0_S1;sampler2D uTextureSampler_0_S2;flat in half4 vcolor_S0;noperspective in float2 vTransformedCoords_3_S0;half4 TextureEffect_S1_c0_c0(half4 _input){ return sample(uTextureSampler_0_S1, vTransformedCoords_3_S0);}half4 MatrixEffect_S1_c0(half4 _input){ return TextureEffect_S1_c0_c0(_input);}half4 DisableCoverageAsAlpha_S1(half4 _input){ _input = MatrixEffect_S1_c0(_input); half4 _tmp_0_inColor = _input; return half4(_input);}half4 TextureEffect_S2_c0_c0_c0(half4 _input, float2 _coords){ return sample(uTextureSampler_0_S2, _coords).000r;}half4 MatrixEffect_S2_c0_c0(half4 _input, float2 _coords){ return TextureEffect_S2_c0_c0_c0(_input, float3x2(umatrix_S2_c0_c0) * _coords.xy1);}half4 RectBlur_S2_c0(half4 _input, float2 _coords){ half4 _tmp_1_inColor = _input; float2 _tmp_2_coords = _coords; half xCoverage; half yCoverage; if (bool(int(1))) { half2 xy = max(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw)); xCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.x, 0.5))).w; yCoverage = MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(xy.y, 0.5))).w; } else { half4 rect = half4(half2(urect_S2_c0.xy - _tmp_2_coords), half2(_tmp_2_coords - urect_S2_c0.zw)); xCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.x, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.z, 0.5))).w; yCoverage = (1.0 - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.y, 0.5))).w) - MatrixEffect_S2_c0_c0(_tmp_1_inColor, float2(half2(rect.w, 0.5))).w; } return half4((_input * xCoverage) * yCoverage);}half4 DeviceSpace_S2(half4 _input){ return RectBlur_S2_c0(_input, sk_FragCoord.xy);}void main(){ // Stage 0, QuadPerEdgeAAGeometryProcessor half4 outputColor_S0; outputColor_S0 = vcolor_S0; const half4 outputCoverage_S0 = half4(1); half4 output_S1; output_S1 = DisableCoverageAsAlpha_S1(outputColor_S0); half4 output_S2; output_S2 = DeviceSpace_S2(outputCoverage_S0); { // Xfer Processor: Porter Duff sk_FragColor = output_S1 * output_S2; }})"   
)

◆ COMPILER_BENCH() [3/4]

COMPILER_BENCH ( small  ,
R"(sampler2D uTextureSampler_0_S0;noperspective in float2 vTextureCoords_S0;flat in float vTexIndex_S0;noperspective in half4 vinColor_S0;void main(){ // Stage 0, BitmapText half4 outputColor_S0; outputColor_S0 = vinColor_S0; half4 texColor; { texColor = sample(uTextureSampler_0_S0, vTextureCoords_S0).rrrr; } half4 outputCoverage_S0 = texColor; { // Xfer Processor: Porter Duff sk_FragColor = outputColor_S0 * outputCoverage_S0; }})"   
)

◆ COMPILER_BENCH() [4/4]

COMPILER_BENCH ( tiny  ,
"void main() { sk_FragColor = half4(1); }"   
)

◆ DEF_BENCH()

◆ GRAPHITE_BENCH() [1/2]

GRAPHITE_BENCH ( graphite_large  ,
R"(layout(location=0) in flat int shadingSsboIndexVar;layout(location=1) in float2 localCoordsVar;layout(location=2) in float4 jacobian;layout(location=3) in float4 edgeDistances;layout(location=4) in float4 xRadii;layout(location=5) in float4 yRadii;layout(location=6) in float2 strokeParams;layout(location=7) in float2 perPixelControl;struct FSUniformData{ // 0 - SolidColor uniforms float4 color_0; // 2 - ConicalGradient8 uniforms float4 colors_2[8]; float4 offsets_2[2]; float2 point0_2; float2 point1_2; float radius0_2; float radius1_2; int tilemode_2; int colorSpace_2; int doUnPremul_2; // 3 - ColorSpaceTransform uniforms int flags_3; int srcKind_3; half3x3 gamutTransform_3; int dstKind_3; half4x4 csXformCoeffs_3; // 4 - DitherShader uniforms half range_4;};layout (binding=2) buffer FSUniforms{ FSUniformData fsUniformData[];};// 4 - DitherShader samplerslayout(binding=0) sampler2D sampler_4;// [1] 1: ColorFilterShaderhalf4 ColorFilterShader_1(half4 inColor, half4 destColor, float2 coords){ return sk_color_space_transform(sk_conical_grad_8_shader(coords, fsUniformData[shadingSsboIndexVar].colors_2, fsUniformData[shadingSsboIndexVar].offsets_2, fsUniformData[shadingSsboIndexVar].point0_2, fsUniformData[shadingSsboIndexVar].point1_2, fsUniformData[shadingSsboIndexVar].radius0_2, fsUniformData[shadingSsboIndexVar].radius1_2, fsUniformData[shadingSsboIndexVar].tilemode_2, fsUniformData[shadingSsboIndexVar].colorSpace_2, fsUniformData[shadingSsboIndexVar].doUnPremul_2), fsUniformData[shadingSsboIndexVar].flags_3, fsUniformData[shadingSsboIndexVar].srcKind_3, fsUniformData[shadingSsboIndexVar].gamutTransform_3, fsUniformData[shadingSsboIndexVar].dstKind_3, fsUniformData[shadingSsboIndexVar].csXformCoeffs_3);}void main(){ half4 initialColor = half4(0); // [0] SolidColor half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0); // [1] ColorFilterShader half4 outColor_1 = ColorFilterShader_1(outColor_0, half4(1), localCoordsVar); // [4] DitherShader half4 outColor_4 = sk_dither_shader(outColor_1, localCoordsVar, fsUniformData[shadingSsboIndexVar].range_4, sampler_4); // [5] SrcOver half4 outColor_5 = outColor_4; half4 outputCoverage; outputCoverage = analytic_rrect_coverage_fn(sk_FragCoord, jacobian, edgeDistances, xRadii, yRadii, strokeParams, perPixelControl); sk_FragColor = outColor_5 * outputCoverage;})"   
)

◆ GRAPHITE_BENCH() [2/2]

GRAPHITE_BENCH ( graphite_small  ,
R"(layout(location=0) in flat int shadingSsboIndexVar;layout(location=1) in float2 textureCoords;layout(location=2) in half texIndex;layout(location=3) in half maskFormat;layout (binding=1) uniform StepUniforms{ layout(offset=0) float4x4 subRunDeviceMatrix; layout(offset=64) float4x4 deviceToLocal; layout(offset=128) float2 atlasSizeInv;};struct FSUniformData{ // 0 - SolidColor uniforms float4 color_0;};layout (binding=2) buffer FSUniforms{ FSUniformData fsUniformData[];};layout(binding=0) sampler2D text_atlas_0;layout(binding=1) sampler2D text_atlas_1;layout(binding=2) sampler2D text_atlas_2;layout(binding=3) sampler2D text_atlas_3;void main(){ half4 initialColor = half4(0); // [0] SolidColor half4 outColor_0 = sk_solid_shader(fsUniformData[shadingSsboIndexVar].color_0); // [1] SrcOver half4 outColor_1 = outColor_0; half4 outputCoverage; outputCoverage = bitmap_text_coverage_fn(sample_indexed_atlas(textureCoords, int(texIndex), text_atlas_0, text_atlas_1, text_atlas_2, text_atlas_3), int(maskFormat)); sk_FragColor = outColor_1 * outputCoverage;})"   
)

◆ heap_bytes_used()

static int64_t heap_bytes_used ( )
static

Definition at line 279 of file SkSLBench.cpp.

◆ RunSkSLModuleBenchmarks()

void RunSkSLModuleBenchmarks ( NanoJSONResultsWriter log)

Definition at line 296 of file SkSLBench.cpp.

299 {
300 x_t = dot(_tmp_3_coords, _tmp_3_coords) / _tmp_3_coords.x;
301 }
302 else if (bool(int(0)))
303 {
304 x_t = length(_tmp_3_coords) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
305 }
306 else
307 {
308 float temp = _tmp_3_coords.x * _tmp_3_coords.x - _tmp_3_coords.y * _tmp_3_coords.y;
309 if (temp >= 0.0)
310 {
311 if (bool(int(0)) || !bool(int(1)))
312 {
313 x_t = -sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
314 }
315 else
316 {
317 x_t = sqrt(temp) - _tmp_3_coords.x * float(uinvR1_S1_c0_c0_c1_c0);
318 }
319 }
320 }
321 if (!bool(int(0)))
322 {
323 if (x_t <= 0.0)
324 {
325 v = -1.0;
326 }
327 }
328 if (bool(int(1)))
329 {
330 if (bool(int(0)))
331 {
332 t = x_t;
333 }
334 else
335 {
336 t = x_t + float(ufx_S1_c0_c0_c1_c0);
337 }
338 }
339 else
340 {
341 if (bool(int(0)))
342 {
343 t = -x_t;
344 }
345 else
346 {
347 t = -x_t + float(ufx_S1_c0_c0_c1_c0);
348 }
349 }
350 if (bool(int(0)))
351 {
352 t = 1.0 - t;
353 }
354 return half4(half4(half(t), v, 0.0, 0.0));
355}
356half4 MatrixEffect_S1_c0_c0_c1(half4 _input)
357{
358 return TwoPointConicalFocalLayout_S1_c0_c0_c1_c0(_input);
359}
360half4 ClampedGradient_S1_c0_c0(half4 _input)
361{
362 half4 _tmp_4_inColor = _input;
363 half4 t = MatrixEffect_S1_c0_c0_c1(_tmp_4_inColor);