2840 {
2842
2843
2844
2845
2847 fSlots = fProgram.allocateSlotData(&alloc);
2848 float* uniformPtr = alloc.makeArray<float>(fProgram.fNumUniformSlots);
2849 fUniforms =
SkSpan(uniformPtr, fProgram.fNumUniformSlots);
2850
2851
2852 fProgram.makeStages(&fStages, &alloc, fUniforms, fSlots);
2853
2854
2857
2858
2859 if (writeInstructionCount) {
2860 int invocationCount = 0, instructionCount = 0;
2861 for (
const Stage& stage : fStages) {
2862 switch (stage.op) {
2863 case POp::label:
2864
2865 break;
2866
2867 case POp::invoke_shader:
2868 case POp::invoke_color_filter:
2869 case POp::invoke_blender:
2870 case POp::invoke_to_linear_srgb:
2871 case POp::invoke_from_linear_srgb:
2872 ++invocationCount;
2873 break;
2874
2875 default:
2876 ++instructionCount;
2877 break;
2878 }
2879 }
2880
2882 out->writeText(
" instructions");
2883 if (invocationCount > 0) {
2884 out->writeText(
", ");
2886 out->writeText(
" invocations");
2887 }
2888 out->writeText(
"\n\n");
2889 }
2890
2891
2892 const char*
header =
"[immutable slots]\n";
2893 const char* footer = "";
2894 for (
const Instruction&
inst : fProgram.fInstructions) {
2897 out->writeText(
"i");
2899 out->writeText(
" = ");
2900 out->writeText(this->
imm(sk_bit_cast<float>(
inst.fImmA)).c_str());
2901 out->writeText(
"\n");
2902
2904 footer = "\n";
2905 }
2906 }
2907 out->writeText(footer);
2908
2909
2910 for (int index = 0; index < fStages.size(); ++index) {
2911 const Stage& stage = fStages[index];
2912
2913 std::string opArg1, opArg2, opArg3, opSwizzle;
2914 switch (stage.op) {
2915 case POp::label:
2916 case POp::invoke_shader:
2917 case POp::invoke_color_filter:
2918 case POp::invoke_blender:
2919 opArg1 = this->
immCtx(stage.ctx,
false);
2920 break;
2921
2922 case POp::case_op: {
2924 opArg1 = this->
offsetCtx(ctx.offset, 1);
2925 opArg2 = this->
offsetCtx(ctx.offset +
sizeof(int32_t) * N, 1);
2926 opArg3 = this->
imm(sk_bit_cast<float>(ctx.expectedValue),
false);
2927 break;
2928 }
2929 case POp::swizzle_1:
2930 case POp::swizzle_2:
2931 case POp::swizzle_3:
2932 case POp::swizzle_4:
2933 std::tie(opArg1, opArg2) = this->
swizzleCtx(stage.op, stage.ctx);
2934 break;
2935
2936 case POp::swizzle_copy_slot_masked:
2937 case POp::swizzle_copy_2_slots_masked:
2938 case POp::swizzle_copy_3_slots_masked:
2939 case POp::swizzle_copy_4_slots_masked:
2940 std::tie(opArg1, opArg2) = this->
swizzleCopyCtx(stage.op, stage.ctx);
2941 break;
2942
2943 case POp::refract_4_floats:
2945 opArg3 = this->
ptrCtx((
const float*)(stage.ctx) + (8 * N), 1);
2946 break;
2947
2948 case POp::dot_2_floats:
2949 opArg1 = this->
ptrCtx(stage.ctx, 1);
2951 break;
2952
2953 case POp::dot_3_floats:
2954 opArg1 = this->
ptrCtx(stage.ctx, 1);
2956 break;
2957
2958 case POp::dot_4_floats:
2959 opArg1 = this->
ptrCtx(stage.ctx, 1);
2961 break;
2962
2964 std::tie(opArg1, opArg2) = this->
shuffleCtx(stage.ctx);
2965 break;
2966
2967 case POp::matrix_multiply_2:
2968 case POp::matrix_multiply_3:
2969 case POp::matrix_multiply_4:
2970 std::tie(opArg1, opArg2, opArg3) = this->
matrixMultiply(stage.ctx);
2971 break;
2972
2973 case POp::load_condition_mask:
2974 case POp::store_condition_mask:
2975 case POp::load_loop_mask:
2976 case POp::store_loop_mask:
2977 case POp::merge_loop_mask:
2978 case POp::reenable_loop_mask:
2979 case POp::load_return_mask:
2980 case POp::store_return_mask:
2981 case POp::continue_op:
2982 case POp::cast_to_float_from_int: case POp::cast_to_float_from_uint:
2983 case POp::cast_to_int_from_float: case POp::cast_to_uint_from_float:
2984 case POp::abs_int:
2985 case POp::acos_float:
2986 case POp::asin_float:
2987 case POp::atan_float:
2988 case POp::ceil_float:
2989 case POp::cos_float:
2990 case POp::exp_float:
2991 case POp::exp2_float:
2992 case POp::log_float:
2993 case POp::log2_float:
2994 case POp::floor_float:
2995 case POp::invsqrt_float:
2996 case POp::sin_float:
2997 case POp::sqrt_float:
2998 case POp::tan_float:
2999 opArg1 = this->
ptrCtx(stage.ctx, 1);
3000 break;
3001
3002 case POp::store_src_rg:
3003 case POp::cast_to_float_from_2_ints: case POp::cast_to_float_from_2_uints:
3004 case POp::cast_to_int_from_2_floats: case POp::cast_to_uint_from_2_floats:
3005 case POp::abs_2_ints:
3006 case POp::ceil_2_floats:
3007 case POp::floor_2_floats:
3008 case POp::invsqrt_2_floats:
3009 opArg1 = this->
ptrCtx(stage.ctx, 2);
3010 break;
3011
3012 case POp::cast_to_float_from_3_ints: case POp::cast_to_float_from_3_uints:
3013 case POp::cast_to_int_from_3_floats: case POp::cast_to_uint_from_3_floats:
3014 case POp::abs_3_ints:
3015 case POp::ceil_3_floats:
3016 case POp::floor_3_floats:
3017 case POp::invsqrt_3_floats:
3018 opArg1 = this->
ptrCtx(stage.ctx, 3);
3019 break;
3020
3021 case POp::load_src:
3022 case POp::load_dst:
3023 case POp::exchange_src:
3024 case POp::store_src:
3025 case POp::store_dst:
3026 case POp::store_device_xy01:
3027 case POp::invoke_to_linear_srgb:
3028 case POp::invoke_from_linear_srgb:
3029 case POp::cast_to_float_from_4_ints: case POp::cast_to_float_from_4_uints:
3030 case POp::cast_to_int_from_4_floats: case POp::cast_to_uint_from_4_floats:
3031 case POp::abs_4_ints:
3032 case POp::ceil_4_floats:
3033 case POp::floor_4_floats:
3034 case POp::invsqrt_4_floats:
3035 case POp::inverse_mat2:
3036 opArg1 = this->
ptrCtx(stage.ctx, 4);
3037 break;
3038
3039 case POp::inverse_mat3:
3040 opArg1 = this->
ptrCtx(stage.ctx, 9);
3041 break;
3042
3043 case POp::inverse_mat4:
3044 opArg1 = this->
ptrCtx(stage.ctx, 16);
3045 break;
3046
3047 case POp::copy_constant:
3048 case POp::add_imm_float:
3049 case POp::mul_imm_float:
3050 case POp::cmple_imm_float:
3051 case POp::cmplt_imm_float:
3052 case POp::cmpeq_imm_float:
3053 case POp::cmpne_imm_float:
3054 case POp::min_imm_float:
3055 case POp::max_imm_float:
3056 std::tie(opArg1, opArg2) = this->
constantCtx(stage.ctx, 1);
3057 break;
3058
3059 case POp::add_imm_int:
3060 case POp::mul_imm_int:
3061 case POp::bitwise_and_imm_int:
3062 case POp::bitwise_xor_imm_int:
3063 case POp::cmple_imm_int:
3064 case POp::cmple_imm_uint:
3065 case POp::cmplt_imm_int:
3066 case POp::cmplt_imm_uint:
3067 case POp::cmpeq_imm_int:
3068 case POp::cmpne_imm_int:
3069 std::tie(opArg1, opArg2) = this->
constantCtx(stage.ctx, 1,
false);
3070 break;
3071
3072 case POp::splat_2_constants:
3073 case POp::bitwise_and_imm_2_ints:
3074 std::tie(opArg1, opArg2) = this->
constantCtx(stage.ctx, 2);
3075 break;
3076
3077 case POp::splat_3_constants:
3078 case POp::bitwise_and_imm_3_ints:
3079 std::tie(opArg1, opArg2) = this->
constantCtx(stage.ctx, 3);
3080 break;
3081
3082 case POp::splat_4_constants:
3083 case POp::bitwise_and_imm_4_ints:
3084 std::tie(opArg1, opArg2) = this->
constantCtx(stage.ctx, 4);
3085 break;
3086
3087 case POp::copy_uniform:
3089 break;
3090
3091 case POp::copy_2_uniforms:
3093 break;
3094
3095 case POp::copy_3_uniforms:
3097 break;
3098
3099 case POp::copy_4_uniforms:
3101 break;
3102
3103 case POp::copy_slot_masked:
3104 case POp::copy_slot_unmasked:
3105 case POp::copy_immutable_unmasked:
3106 std::tie(opArg1, opArg2) = this->
binaryOpCtx(stage.ctx, 1);
3107 break;
3108
3109 case POp::copy_2_slots_masked:
3110 case POp::copy_2_slots_unmasked:
3111 case POp::copy_2_immutables_unmasked:
3112 std::tie(opArg1, opArg2) = this->
binaryOpCtx(stage.ctx, 2);
3113 break;
3114
3115 case POp::copy_3_slots_masked:
3116 case POp::copy_3_slots_unmasked:
3117 case POp::copy_3_immutables_unmasked:
3118 std::tie(opArg1, opArg2) = this->
binaryOpCtx(stage.ctx, 3);
3119 break;
3120
3121 case POp::copy_4_slots_masked:
3122 case POp::copy_4_slots_unmasked:
3123 case POp::copy_4_immutables_unmasked:
3124 std::tie(opArg1, opArg2) = this->
binaryOpCtx(stage.ctx, 4);
3125 break;
3126
3127 case POp::copy_from_indirect_uniform_unmasked:
3128 case POp::copy_from_indirect_unmasked:
3129 case POp::copy_to_indirect_masked: {
3131
3132 opArg1 = this->
ptrCtx(ctx->dst, ctx->slots);
3133 opArg2 = this->
ptrCtx(ctx->src, ctx->slots);
3134 opArg3 = this->
ptrCtx(ctx->indirectOffset, 1);
3135 break;
3136 }
3137 case POp::swizzle_copy_to_indirect_masked: {
3139 opArg1 = this->
ptrCtx(ctx->dst, this->swizzleWidth(
SkSpan(ctx->offsets,
3140 ctx->slots)));
3141 opArg2 = this->
ptrCtx(ctx->src, ctx->slots);
3142 opArg3 = this->
ptrCtx(ctx->indirectOffset, 1);
3144 break;
3145 }
3146 case POp::merge_condition_mask:
3147 case POp::merge_inv_condition_mask:
3148 case POp::add_float: case POp::add_int:
3149 case POp::sub_float: case POp::sub_int:
3150 case POp::mul_float: case POp::mul_int:
3151 case POp::div_float: case POp::div_int: case POp::div_uint:
3152 case POp::bitwise_and_int:
3153 case POp::bitwise_or_int:
3154 case POp::bitwise_xor_int:
3155 case POp::mod_float:
3156 case POp::min_float: case POp::min_int: case POp::min_uint:
3157 case POp::max_float: case POp::max_int: case POp::max_uint:
3158 case POp::cmplt_float: case POp::cmplt_int: case POp::cmplt_uint:
3159 case POp::cmple_float: case POp::cmple_int: case POp::cmple_uint:
3160 case POp::cmpeq_float: case POp::cmpeq_int:
3161 case POp::cmpne_float: case POp::cmpne_int:
3163 break;
3164
3165 case POp::mix_float: case POp::mix_int:
3166 std::tie(opArg1, opArg2, opArg3) = this->
adjacent3PtrCtx(stage.ctx, 1);
3167 break;
3168
3169 case POp::add_2_floats: case POp::add_2_ints:
3170 case POp::sub_2_floats: case POp::sub_2_ints:
3171 case POp::mul_2_floats: case POp::mul_2_ints:
3172 case POp::div_2_floats: case POp::div_2_ints: case POp::div_2_uints:
3173 case POp::bitwise_and_2_ints:
3174 case POp::bitwise_or_2_ints:
3175 case POp::bitwise_xor_2_ints:
3176 case POp::mod_2_floats:
3177 case POp::min_2_floats: case POp::min_2_ints: case POp::min_2_uints:
3178 case POp::max_2_floats: case POp::max_2_ints: case POp::max_2_uints:
3179 case POp::cmplt_2_floats: case POp::cmplt_2_ints: case POp::cmplt_2_uints:
3180 case POp::cmple_2_floats: case POp::cmple_2_ints: case POp::cmple_2_uints:
3181 case POp::cmpeq_2_floats: case POp::cmpeq_2_ints:
3182 case POp::cmpne_2_floats: case POp::cmpne_2_ints:
3184 break;
3185
3186 case POp::mix_2_floats: case POp::mix_2_ints:
3187 std::tie(opArg1, opArg2, opArg3) = this->
adjacent3PtrCtx(stage.ctx, 2);
3188 break;
3189
3190 case POp::add_3_floats: case POp::add_3_ints:
3191 case POp::sub_3_floats: case POp::sub_3_ints:
3192 case POp::mul_3_floats: case POp::mul_3_ints:
3193 case POp::div_3_floats: case POp::div_3_ints: case POp::div_3_uints:
3194 case POp::bitwise_and_3_ints:
3195 case POp::bitwise_or_3_ints:
3196 case POp::bitwise_xor_3_ints:
3197 case POp::mod_3_floats:
3198 case POp::min_3_floats: case POp::min_3_ints: case POp::min_3_uints:
3199 case POp::max_3_floats: case POp::max_3_ints: case POp::max_3_uints:
3200 case POp::cmplt_3_floats: case POp::cmplt_3_ints: case POp::cmplt_3_uints:
3201 case POp::cmple_3_floats: case POp::cmple_3_ints: case POp::cmple_3_uints:
3202 case POp::cmpeq_3_floats: case POp::cmpeq_3_ints:
3203 case POp::cmpne_3_floats: case POp::cmpne_3_ints:
3205 break;
3206
3207 case POp::mix_3_floats: case POp::mix_3_ints:
3208 std::tie(opArg1, opArg2, opArg3) = this->
adjacent3PtrCtx(stage.ctx, 3);
3209 break;
3210
3211 case POp::add_4_floats: case POp::add_4_ints:
3212 case POp::sub_4_floats: case POp::sub_4_ints:
3213 case POp::mul_4_floats: case POp::mul_4_ints:
3214 case POp::div_4_floats: case POp::div_4_ints: case POp::div_4_uints:
3215 case POp::bitwise_and_4_ints:
3216 case POp::bitwise_or_4_ints:
3217 case POp::bitwise_xor_4_ints:
3218 case POp::mod_4_floats:
3219 case POp::min_4_floats: case POp::min_4_ints: case POp::min_4_uints:
3220 case POp::max_4_floats: case POp::max_4_ints: case POp::max_4_uints:
3221 case POp::cmplt_4_floats: case POp::cmplt_4_ints: case POp::cmplt_4_uints:
3222 case POp::cmple_4_floats: case POp::cmple_4_ints: case POp::cmple_4_uints:
3223 case POp::cmpeq_4_floats: case POp::cmpeq_4_ints:
3224 case POp::cmpne_4_floats: case POp::cmpne_4_ints:
3226 break;
3227
3228 case POp::mix_4_floats: case POp::mix_4_ints:
3229 std::tie(opArg1, opArg2, opArg3) = this->
adjacent3PtrCtx(stage.ctx, 4);
3230 break;
3231
3232 case POp::add_n_floats: case POp::add_n_ints:
3233 case POp::sub_n_floats: case POp::sub_n_ints:
3234 case POp::mul_n_floats: case POp::mul_n_ints:
3235 case POp::div_n_floats: case POp::div_n_ints: case POp::div_n_uints:
3236 case POp::bitwise_and_n_ints:
3237 case POp::bitwise_or_n_ints:
3238 case POp::bitwise_xor_n_ints:
3239 case POp::mod_n_floats:
3240 case POp::min_n_floats: case POp::min_n_ints: case POp::min_n_uints:
3241 case POp::max_n_floats: case POp::max_n_ints: case POp::max_n_uints:
3242 case POp::cmplt_n_floats: case POp::cmplt_n_ints: case POp::cmplt_n_uints:
3243 case POp::cmple_n_floats: case POp::cmple_n_ints: case POp::cmple_n_uints:
3244 case POp::cmpeq_n_floats: case POp::cmpeq_n_ints:
3245 case POp::cmpne_n_floats: case POp::cmpne_n_ints:
3246 case POp::atan2_n_floats:
3247 case POp::pow_n_floats:
3249 break;
3250
3251 case POp::mix_n_floats: case POp::mix_n_ints:
3252 case POp::smoothstep_n_floats:
3254 break;
3255
3256 case POp::jump:
3257 case POp::branch_if_all_lanes_active:
3258 case POp::branch_if_any_lanes_active:
3259 case POp::branch_if_no_lanes_active:
3261 index);
3262 break;
3263
3264 case POp::branch_if_no_active_lanes_eq: {
3267 opArg2 = this->
ptrCtx(ctx->ptr, 1);
3268 opArg3 = this->
imm(sk_bit_cast<float>(ctx->value));
3269 break;
3270 }
3271 case POp::trace_var: {
3273 opArg1 = this->
ptrCtx(ctx->traceMask, 1);
3274 opArg2 = this->
ptrCtx(ctx->data, ctx->numSlots);
3275 if (ctx->indirectOffset != nullptr) {
3276 opArg3 =
" + " + this->
ptrCtx(ctx->indirectOffset, 1);
3277 }
3278 break;
3279 }
3280 case POp::trace_line: {
3282 opArg1 = this->
ptrCtx(ctx->traceMask, 1);
3284 break;
3285 }
3286 case POp::trace_enter:
3287 case POp::trace_exit: {
3289 opArg1 = this->
ptrCtx(ctx->traceMask, 1);
3290 opArg2 = (fProgram.fDebugTrace &&
3291 ctx->funcIdx >= 0 &&
3292 ctx->funcIdx < (
int)fProgram.fDebugTrace->
fFuncInfo.size())
3293 ? fProgram.fDebugTrace->
fFuncInfo[ctx->funcIdx].name
3294 : "???";
3295 break;
3296 }
3297 case POp::trace_scope: {
3299 opArg1 = this->
ptrCtx(ctx->traceMask, 1);
3301 break;
3302 }
3303 default:
3304 break;
3305 }
3306
3307 std::string_view opName;
3308 switch (stage.op) {
3309 #define M(x) case POp::x: opName = #x; break;
3312 #undef M
3313 }
3314
3315 std::string opText;
3316 switch (stage.op) {
3317 case POp::trace_var:
3318 opText = "TraceVar(" + opArg2 + opArg3 + ") when " + opArg1 + " is true";
3319 break;
3320
3321 case POp::trace_line:
3322 opText = "TraceLine(" + opArg2 + ") when " + opArg1 + " is true";
3323 break;
3324
3325 case POp::trace_enter:
3326 opText = "TraceEnter(" + opArg2 + ") when " + opArg1 + " is true";
3327 break;
3328
3329 case POp::trace_exit:
3330 opText = "TraceExit(" + opArg2 + ") when " + opArg1 + " is true";
3331 break;
3332
3333 case POp::trace_scope:
3334 opText = "TraceScope(" + opArg2 + ") when " + opArg1 + " is true";
3335 break;
3336
3337 case POp::init_lane_masks:
3338 opText = "CondMask = LoopMask = RetMask = true";
3339 break;
3340
3341 case POp::load_condition_mask:
3342 opText = "CondMask = " + opArg1;
3343 break;
3344
3345 case POp::store_condition_mask:
3346 opText = opArg1 + " = CondMask";
3347 break;
3348
3349 case POp::merge_condition_mask:
3350 opText = "CondMask = " + opArg1 + " & " + opArg2;
3351 break;
3352
3353 case POp::merge_inv_condition_mask:
3354 opText = "CondMask = " + opArg1 + " & ~" + opArg2;
3355 break;
3356
3357 case POp::load_loop_mask:
3358 opText = "LoopMask = " + opArg1;
3359 break;
3360
3361 case POp::store_loop_mask:
3362 opText = opArg1 + " = LoopMask";
3363 break;
3364
3365 case POp::mask_off_loop_mask:
3366 opText = "LoopMask &= ~(CondMask & LoopMask & RetMask)";
3367 break;
3368
3369 case POp::reenable_loop_mask:
3370 opText = "LoopMask |= " + opArg1;
3371 break;
3372
3373 case POp::merge_loop_mask:
3374 opText = "LoopMask &= " + opArg1;
3375 break;
3376
3377 case POp::load_return_mask:
3378 opText = "RetMask = " + opArg1;
3379 break;
3380
3381 case POp::store_return_mask:
3382 opText = opArg1 + " = RetMask";
3383 break;
3384
3385 case POp::mask_off_return_mask:
3386 opText = "RetMask &= ~(CondMask & LoopMask & RetMask)";
3387 break;
3388
3389 case POp::store_src_rg:
3390 opText = opArg1 + " = src.rg";
3391 break;
3392
3393 case POp::exchange_src:
3394 opText = "swap(src.rgba, " + opArg1 + ")";
3395 break;
3396
3397 case POp::store_src:
3398 opText = opArg1 + " = src.rgba";
3399 break;
3400
3401 case POp::store_dst:
3402 opText = opArg1 + " = dst.rgba";
3403 break;
3404
3405 case POp::store_device_xy01:
3406 opText = opArg1 + " = DeviceCoords.xy01";
3407 break;
3408
3409 case POp::load_src:
3410 opText = "src.rgba = " + opArg1;
3411 break;
3412
3413 case POp::load_dst:
3414 opText = "dst.rgba = " + opArg1;
3415 break;
3416
3417 case POp::bitwise_and_int:
3418 case POp::bitwise_and_2_ints:
3419 case POp::bitwise_and_3_ints:
3420 case POp::bitwise_and_4_ints:
3421 case POp::bitwise_and_n_ints:
3422 case POp::bitwise_and_imm_int:
3423 case POp::bitwise_and_imm_2_ints:
3424 case POp::bitwise_and_imm_3_ints:
3425 case POp::bitwise_and_imm_4_ints:
3426 opText = opArg1 + " &= " + opArg2;
3427 break;
3428
3429 case POp::bitwise_or_int:
3430 case POp::bitwise_or_2_ints:
3431 case POp::bitwise_or_3_ints:
3432 case POp::bitwise_or_4_ints:
3433 case POp::bitwise_or_n_ints:
3434 opText = opArg1 + " |= " + opArg2;
3435 break;
3436
3437 case POp::bitwise_xor_int:
3438 case POp::bitwise_xor_2_ints:
3439 case POp::bitwise_xor_3_ints:
3440 case POp::bitwise_xor_4_ints:
3441 case POp::bitwise_xor_n_ints:
3442 case POp::bitwise_xor_imm_int:
3443 opText = opArg1 + " ^= " + opArg2;
3444 break;
3445
3446 case POp::cast_to_float_from_int:
3447 case POp::cast_to_float_from_2_ints:
3448 case POp::cast_to_float_from_3_ints:
3449 case POp::cast_to_float_from_4_ints:
3450 opText = opArg1 + " = IntToFloat(" + opArg1 + ")";
3451 break;
3452
3453 case POp::cast_to_float_from_uint:
3454 case POp::cast_to_float_from_2_uints:
3455 case POp::cast_to_float_from_3_uints:
3456 case POp::cast_to_float_from_4_uints:
3457 opText = opArg1 + " = UintToFloat(" + opArg1 + ")";
3458 break;
3459
3460 case POp::cast_to_int_from_float:
3461 case POp::cast_to_int_from_2_floats:
3462 case POp::cast_to_int_from_3_floats:
3463 case POp::cast_to_int_from_4_floats:
3464 opText = opArg1 + " = FloatToInt(" + opArg1 + ")";
3465 break;
3466
3467 case POp::cast_to_uint_from_float:
3468 case POp::cast_to_uint_from_2_floats:
3469 case POp::cast_to_uint_from_3_floats:
3470 case POp::cast_to_uint_from_4_floats:
3471 opText = opArg1 + " = FloatToUint(" + opArg1 + ")";
3472 break;
3473
3474 case POp::copy_slot_masked: case POp::copy_2_slots_masked:
3475 case POp::copy_3_slots_masked: case POp::copy_4_slots_masked:
3476 case POp::swizzle_copy_slot_masked: case POp::swizzle_copy_2_slots_masked:
3477 case POp::swizzle_copy_3_slots_masked: case POp::swizzle_copy_4_slots_masked:
3478 opText = opArg1 + " = Mask(" + opArg2 + ")";
3479 break;
3480
3481 case POp::copy_uniform: case POp::copy_2_uniforms:
3482 case POp::copy_3_uniforms: case POp::copy_4_uniforms:
3483 case POp::copy_slot_unmasked: case POp::copy_2_slots_unmasked:
3484 case POp::copy_3_slots_unmasked: case POp::copy_4_slots_unmasked:
3485 case POp::copy_immutable_unmasked: case POp::copy_2_immutables_unmasked:
3486 case POp::copy_3_immutables_unmasked: case POp::copy_4_immutables_unmasked:
3487 case POp::copy_constant: case POp::splat_2_constants:
3488 case POp::splat_3_constants: case POp::splat_4_constants:
3489 case POp::swizzle_1: case POp::swizzle_2:
3490 case POp::swizzle_3: case POp::swizzle_4:
3492 opText = opArg1 + " = " + opArg2;
3493 break;
3494
3495 case POp::copy_from_indirect_unmasked:
3496 case POp::copy_from_indirect_uniform_unmasked:
3497 opText = opArg1 + " = Indirect(" + opArg2 + " + " + opArg3 + ")";
3498 break;
3499
3500 case POp::copy_to_indirect_masked:
3501 opText = "Indirect(" + opArg1 + " + " + opArg3 + ") = Mask(" + opArg2 + ")";
3502 break;
3503
3504 case POp::swizzle_copy_to_indirect_masked:
3505 opText = "Indirect(" + opArg1 + " + " + opArg3 + ")." + opSwizzle + " = Mask(" +
3506 opArg2 + ")";
3507 break;
3508
3509 case POp::abs_int:
3510 case POp::abs_2_ints:
3511 case POp::abs_3_ints:
3512 case POp::abs_4_ints:
3513 opText = opArg1 + " = abs(" + opArg1 + ")";
3514 break;
3515
3516 case POp::acos_float:
3517 opText = opArg1 + " = acos(" + opArg1 + ")";
3518 break;
3519
3520 case POp::asin_float:
3521 opText = opArg1 + " = asin(" + opArg1 + ")";
3522 break;
3523
3524 case POp::atan_float:
3525 opText = opArg1 + " = atan(" + opArg1 + ")";
3526 break;
3527
3528 case POp::atan2_n_floats:
3529 opText = opArg1 + " = atan2(" + opArg1 + ", " + opArg2 + ")";
3530 break;
3531
3532 case POp::ceil_float:
3533 case POp::ceil_2_floats:
3534 case POp::ceil_3_floats:
3535 case POp::ceil_4_floats:
3536 opText = opArg1 + " = ceil(" + opArg1 + ")";
3537 break;
3538
3539 case POp::cos_float:
3540 opText = opArg1 + " = cos(" + opArg1 + ")";
3541 break;
3542
3543 case POp::refract_4_floats:
3544 opText = opArg1 + " = refract(" + opArg1 + ", " + opArg2 + ", " + opArg3 + ")";
3545 break;
3546
3547 case POp::dot_2_floats:
3548 case POp::dot_3_floats:
3549 case POp::dot_4_floats:
3550 opText = opArg1 + " = dot(" + opArg2 + ", " + opArg3 + ")";
3551 break;
3552
3553 case POp::exp_float:
3554 opText = opArg1 + " = exp(" + opArg1 + ")";
3555 break;
3556
3557 case POp::exp2_float:
3558 opText = opArg1 + " = exp2(" + opArg1 + ")";
3559 break;
3560
3561 case POp::log_float:
3562 opText = opArg1 + " = log(" + opArg1 + ")";
3563 break;
3564
3565 case POp::log2_float:
3566 opText = opArg1 + " = log2(" + opArg1 + ")";
3567 break;
3568
3569 case POp::pow_n_floats:
3570 opText = opArg1 + " = pow(" + opArg1 + ", " + opArg2 + ")";
3571 break;
3572
3573 case POp::sin_float:
3574 opText = opArg1 + " = sin(" + opArg1 + ")";
3575 break;
3576
3577 case POp::sqrt_float:
3578 opText = opArg1 + " = sqrt(" + opArg1 + ")";
3579 break;
3580
3581 case POp::tan_float:
3582 opText = opArg1 + " = tan(" + opArg1 + ")";
3583 break;
3584
3585 case POp::floor_float:
3586 case POp::floor_2_floats:
3587 case POp::floor_3_floats:
3588 case POp::floor_4_floats:
3589 opText = opArg1 + " = floor(" + opArg1 + ")";
3590 break;
3591
3592 case POp::invsqrt_float:
3593 case POp::invsqrt_2_floats:
3594 case POp::invsqrt_3_floats:
3595 case POp::invsqrt_4_floats:
3596 opText = opArg1 + " = inversesqrt(" + opArg1 + ")";
3597 break;
3598
3599 case POp::inverse_mat2:
3600 case POp::inverse_mat3:
3601 case POp::inverse_mat4:
3602 opText = opArg1 + " = inverse(" + opArg1 + ")";
3603 break;
3604
3605 case POp::add_float: case POp::add_int:
3606 case POp::add_2_floats: case POp::add_2_ints:
3607 case POp::add_3_floats: case POp::add_3_ints:
3608 case POp::add_4_floats: case POp::add_4_ints:
3609 case POp::add_n_floats: case POp::add_n_ints:
3610 case POp::add_imm_float: case POp::add_imm_int:
3611 opText = opArg1 + " += " + opArg2;
3612 break;
3613
3614 case POp::sub_float: case POp::sub_int:
3615 case POp::sub_2_floats: case POp::sub_2_ints:
3616 case POp::sub_3_floats: case POp::sub_3_ints:
3617 case POp::sub_4_floats: case POp::sub_4_ints:
3618 case POp::sub_n_floats: case POp::sub_n_ints:
3619 opText = opArg1 + " -= " + opArg2;
3620 break;
3621
3622 case POp::mul_float: case POp::mul_int:
3623 case POp::mul_2_floats: case POp::mul_2_ints:
3624 case POp::mul_3_floats: case POp::mul_3_ints:
3625 case POp::mul_4_floats: case POp::mul_4_ints:
3626 case POp::mul_n_floats: case POp::mul_n_ints:
3627 case POp::mul_imm_float: case POp::mul_imm_int:
3628 opText = opArg1 + " *= " + opArg2;
3629 break;
3630
3631 case POp::div_float: case POp::div_int: case POp::div_uint:
3632 case POp::div_2_floats: case POp::div_2_ints: case POp::div_2_uints:
3633 case POp::div_3_floats: case POp::div_3_ints: case POp::div_3_uints:
3634 case POp::div_4_floats: case POp::div_4_ints: case POp::div_4_uints:
3635 case POp::div_n_floats: case POp::div_n_ints: case POp::div_n_uints:
3636 opText = opArg1 + " /= " + opArg2;
3637 break;
3638
3639 case POp::matrix_multiply_2:
3640 case POp::matrix_multiply_3:
3641 case POp::matrix_multiply_4:
3642 opText = opArg1 + " = " + opArg2 + " * " + opArg3;
3643 break;
3644
3645 case POp::mod_float:
3646 case POp::mod_2_floats:
3647 case POp::mod_3_floats:
3648 case POp::mod_4_floats:
3649 case POp::mod_n_floats:
3650 opText = opArg1 + " = mod(" + opArg1 + ", " + opArg2 + ")";
3651 break;
3652
3653 case POp::min_float: case POp::min_int: case POp::min_uint:
3654 case POp::min_2_floats: case POp::min_2_ints: case POp::min_2_uints:
3655 case POp::min_3_floats: case POp::min_3_ints: case POp::min_3_uints:
3656 case POp::min_4_floats: case POp::min_4_ints: case POp::min_4_uints:
3657 case POp::min_n_floats: case POp::min_n_ints: case POp::min_n_uints:
3658 case POp::min_imm_float:
3659 opText = opArg1 + " = min(" + opArg1 + ", " + opArg2 + ")";
3660 break;
3661
3662 case POp::max_float: case POp::max_int: case POp::max_uint:
3663 case POp::max_2_floats: case POp::max_2_ints: case POp::max_2_uints:
3664 case POp::max_3_floats: case POp::max_3_ints: case POp::max_3_uints:
3665 case POp::max_4_floats: case POp::max_4_ints: case POp::max_4_uints:
3666 case POp::max_n_floats: case POp::max_n_ints: case POp::max_n_uints:
3667 case POp::max_imm_float:
3668 opText = opArg1 + " = max(" + opArg1 + ", " + opArg2 + ")";
3669 break;
3670
3671 case POp::cmplt_float: case POp::cmplt_int: case POp::cmplt_uint:
3672 case POp::cmplt_2_floats: case POp::cmplt_2_ints: case POp::cmplt_2_uints:
3673 case POp::cmplt_3_floats: case POp::cmplt_3_ints: case POp::cmplt_3_uints:
3674 case POp::cmplt_4_floats: case POp::cmplt_4_ints: case POp::cmplt_4_uints:
3675 case POp::cmplt_n_floats: case POp::cmplt_n_ints: case POp::cmplt_n_uints:
3676 case POp::cmplt_imm_float: case POp::cmplt_imm_int: case POp::cmplt_imm_uint:
3677 opText = opArg1 + " = lessThan(" + opArg1 + ", " + opArg2 + ")";
3678 break;
3679
3680 case POp::cmple_float: case POp::cmple_int: case POp::cmple_uint:
3681 case POp::cmple_2_floats: case POp::cmple_2_ints: case POp::cmple_2_uints:
3682 case POp::cmple_3_floats: case POp::cmple_3_ints: case POp::cmple_3_uints:
3683 case POp::cmple_4_floats: case POp::cmple_4_ints: case POp::cmple_4_uints:
3684 case POp::cmple_n_floats: case POp::cmple_n_ints: case POp::cmple_n_uints:
3685 case POp::cmple_imm_float: case POp::cmple_imm_int: case POp::cmple_imm_uint:
3686 opText = opArg1 + " = lessThanEqual(" + opArg1 + ", " + opArg2 + ")";
3687 break;
3688
3689 case POp::cmpeq_float: case POp::cmpeq_int:
3690 case POp::cmpeq_2_floats: case POp::cmpeq_2_ints:
3691 case POp::cmpeq_3_floats: case POp::cmpeq_3_ints:
3692 case POp::cmpeq_4_floats: case POp::cmpeq_4_ints:
3693 case POp::cmpeq_n_floats: case POp::cmpeq_n_ints:
3694 case POp::cmpeq_imm_float: case POp::cmpeq_imm_int:
3695 opText = opArg1 + " = equal(" + opArg1 + ", " + opArg2 + ")";
3696 break;
3697
3698 case POp::cmpne_float: case POp::cmpne_int:
3699 case POp::cmpne_2_floats: case POp::cmpne_2_ints:
3700 case POp::cmpne_3_floats: case POp::cmpne_3_ints:
3701 case POp::cmpne_4_floats: case POp::cmpne_4_ints:
3702 case POp::cmpne_n_floats: case POp::cmpne_n_ints:
3703 case POp::cmpne_imm_float: case POp::cmpne_imm_int:
3704 opText = opArg1 + " = notEqual(" + opArg1 + ", " + opArg2 + ")";
3705 break;
3706
3707 case POp::mix_float: case POp::mix_int:
3708 case POp::mix_2_floats: case POp::mix_2_ints:
3709 case POp::mix_3_floats: case POp::mix_3_ints:
3710 case POp::mix_4_floats: case POp::mix_4_ints:
3711 case POp::mix_n_floats: case POp::mix_n_ints:
3712 opText = opArg1 + " = mix(" + opArg2 + ", " + opArg3 + ", " + opArg1 + ")";
3713 break;
3714
3715 case POp::smoothstep_n_floats:
3716 opText = opArg1 + " = smoothstep(" + opArg1 + ", " + opArg2 + ", " + opArg3 + ")";
3717 break;
3718
3719 case POp::jump:
3720 case POp::branch_if_all_lanes_active:
3721 case POp::branch_if_any_lanes_active:
3722 case POp::branch_if_no_lanes_active:
3723 case POp::invoke_shader:
3724 case POp::invoke_color_filter:
3725 case POp::invoke_blender:
3726 opText = std::string(opName) + " " + opArg1;
3727 break;
3728
3729 case POp::invoke_to_linear_srgb:
3730 opText = opArg1 + " = toLinearSrgb(" + opArg1 + ")";
3731 break;
3732
3733 case POp::invoke_from_linear_srgb:
3734 opText = opArg1 + " = fromLinearSrgb(" + opArg1 + ")";
3735 break;
3736
3737 case POp::branch_if_no_active_lanes_eq:
3738 opText = "branch " + opArg1 + " if no lanes of " + opArg2 + " == " + opArg3;
3739 break;
3740
3741 case POp::label:
3742 opText = "label " + opArg1;
3743 break;
3744
3745 case POp::case_op:
3746 opText = "if (" + opArg1 + " == " + opArg3 +
3747 ") { LoopMask = true; " + opArg2 + " = false; }";
3748 break;
3749
3750 case POp::continue_op:
3751 opText = opArg1 +
3752 " |= Mask(0xFFFFFFFF); LoopMask &= ~(CondMask & LoopMask & RetMask)";
3753 break;
3754
3755 default:
3756 break;
3757 }
3758
3759 opName = opName.substr(0, 30);
3760 if (!opText.empty()) {
3762 (int)opName.size(), opName.data(),
3763 opText.c_str()).c_str());
3764 } else {
3766 (int)opName.size(), opName.data()).c_str());
3767 }
3768 }
3769}
#define SK_RASTER_PIPELINE_OPS_ALL(M)
#define SKRP_EXTENDED_OPS(M)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
std::vector< FunctionDebugInfo > fFuncInfo
void buildUniqueSlotNameList()
std::string immCtx(const void *ctx, bool showAsFloat=true) const
std::tuple< std::string, std::string > swizzleCopyCtx(ProgramOp op, const void *v) const
void buildLabelToStageMap()
std::tuple< std::string, std::string > copyUniformCtx(const void *v, int numSlots) const
std::tuple< std::string, std::string > constantCtx(const void *v, int slots, bool showAsFloat=true) const
std::string swizzleOffsetSpan(SkSpan< T > offsets) const
std::tuple< std::string, std::string > adjacentBinaryOpCtx(const void *v) const
std::tuple< std::string, std::string, std::string > adjacentTernaryOpCtx(const void *v) const
std::tuple< std::string, std::string, std::string > matrixMultiply(const void *v) const
std::string branchOffset(const SkRasterPipeline_BranchCtx *ctx, int index) const
std::tuple< std::string, std::string > shuffleCtx(const void *v) const
std::tuple< std::string, std::string > swizzleCtx(ProgramOp op, const void *v) const
std::tuple< std::string, std::string > binaryOpCtx(const void *v, int numSlots) const
const char * c_str() const
SI Vec< sizeof...(Ix), T > shuffle(const Vec< N, T > &)
static const char header[]