8#ifndef SKSL_RASTERPIPELINEBUILDER
9#define SKSL_RASTERPIPELINEBUILDER
45#define SKRP_EXTENDED_OPS(M) \
51 M(invoke_color_filter) \
55 M(invoke_to_linear_srgb) \
56 M(invoke_from_linear_srgb)
62 #define M(stage) stage,
78 #define M(stage) stage,
89 push_clone_from_stack,
90 push_clone_indirect_from_stack,
93 push_immutable_indirect,
97 push_uniform_indirect,
99 copy_stack_to_slots_unmasked,
100 copy_stack_to_slots_indirect,
101 copy_uniform_to_slots_unmasked,
102 store_immutable_value,
103 swizzle_copy_stack_to_slots,
104 swizzle_copy_stack_to_slots_indirect,
112 pop_and_reenable_loop_mask,
121 branch_if_no_active_lanes_on_stack_top_equal,
126static_assert((
int)ProgramOp::label == (
int)BuilderOp::label);
157 int numImmutableSlots,
188 const SlotData& slots)
const;
190 StackDepths tempStackMaxDepths()
const;
221 float*
dst,
int numSlots)
const;
229 float*
dst,
int numSlots)
const;
284 int fNumValueSlots = 0;
285 int fNumUniformSlots = 0;
286 int fNumImmutableSlots = 0;
287 int fNumTempStackSlots = 0;
291 std::unique_ptr<SkSL::TraceHook> fTraceHook;
297 std::unique_ptr<Program>
finish(
int numValueSlots,
299 int numImmutableSlots,
316 ++fExecutionMaskWritesEnabled;
321 --fExecutionMaskWritesEnabled;
325 return fExecutionMaskWritesEnabled > 0;
330 this->appendInstruction(BuilderOp::init_lane_masks, {});
335 this->appendInstruction(BuilderOp::store_src_rg, {slots.
index});
340 this->appendInstruction(BuilderOp::store_src, {slots.
index});
345 this->appendInstruction(BuilderOp::store_dst, {slots.
index});
350 this->appendInstruction(BuilderOp::store_device_xy01, {slots.
index});
355 this->appendInstruction(BuilderOp::load_src, {slots.
index});
360 this->appendInstruction(BuilderOp::load_dst, {slots.
index});
364 fCurrentStackID = stackID;
368 void label(
int labelID);
371 void jump(
int labelID);
460 int offsetFromStackTop);
468 int offsetFromStackTop);
533 void push_clone(
int numSlots,
int offsetFromStackTop = 0);
544 int offsetFromStackTop);
548 this->appendInstruction(BuilderOp::case_op, {},
value);
553 this->appendInstruction(BuilderOp::continue_op, {}, continueMaskStackID);
569 this->appendInstruction(BuilderOp::copy_slot_masked, {
dst.index,
src.index},
dst.count);
593 void matrix_resize(
int origColumns,
int origRows,
int newColumns,
int newRows);
596 void matrix_multiply(
int leftColumns,
int leftRows,
int rightColumns,
int rightRows);
609 this->appendInstruction(BuilderOp::merge_inv_condition_mask, {});
645 this->appendInstruction(BuilderOp::mask_off_loop_mask, {});
651 this->appendInstruction(BuilderOp::reenable_loop_mask, {
src.index});
661 this->appendInstruction(BuilderOp::merge_loop_mask, {});
673 this->appendInstruction(BuilderOp::mask_off_return_mask, {});
677 this->appendInstruction(BuilderOp::invoke_shader, {}, childIdx);
681 this->appendInstruction(BuilderOp::invoke_color_filter, {}, childIdx);
685 this->appendInstruction(BuilderOp::invoke_blender, {}, childIdx);
692 this->appendInstruction(BuilderOp::invoke_to_linear_srgb, {});
700 this->appendInstruction(BuilderOp::invoke_from_linear_srgb, {});
706 this->appendInstruction(BuilderOp::trace_line, {}, traceMaskStackID,
line);
711 this->appendInstruction(BuilderOp::trace_var, {r.
index}, traceMaskStackID, r.
count);
716 int dynamicStackID,
SlotRange limitRange);
720 this->appendInstruction(BuilderOp::trace_enter, {}, traceMaskStackID, funcID);
725 this->appendInstruction(BuilderOp::trace_exit, {}, traceMaskStackID, funcID);
730 this->appendInstruction(BuilderOp::trace_scope, {}, traceMaskStackID,
delta);
739 void appendInstruction(
BuilderOp op, SlotList slots,
740 int a = 0,
int b = 0,
int c = 0,
int d = 0);
741 Instruction* lastInstruction(
int fromBack = 0);
742 Instruction* lastInstructionOnAnyStack(
int fromBack = 0);
743 void simplifyPopSlotsUnmasked(SlotRange*
dst);
744 bool simplifyImmediateUnmaskedOp();
748 int fExecutionMaskWritesEnabled = 0;
749 int fCurrentStackID = 0;
#define SK_RASTER_PIPELINE_OPS_ALL(M)
#define SKRP_EXTENDED_OPS(M)
void dot_floats(int32_t slots)
void push_constant_u(uint32_t val, int count=1)
void copy_stack_to_slots_indirect(SlotRange fixedRange, int dynamicStackID, SlotRange limitRange)
void push_duplicates(int count)
void invoke_from_linear_srgb()
void push_immutable_indirect(SlotRange fixedRange, int dynamicStack, SlotRange limitRange)
void copy_slots_unmasked(SlotRange dst, SlotRange src)
void store_dst(SlotRange slots)
void push_slots(SlotRange src)
void pad_stack(int32_t count)
void binary_op(BuilderOp op, int32_t slots)
void swizzle_copy_stack_to_slots(SlotRange dst, SkSpan< const int8_t > components, int offsetFromStackTop)
void copy_uniform_to_slots_unmasked(SlotRange dst, SlotRange src)
void copy_slots_masked(SlotRange dst, SlotRange src)
void copy_constant(Slot slot, int constantValue)
void branch_if_no_lanes_active(int labelID)
void merge_condition_mask()
void push_clone_indirect_from_stack(SlotRange fixedOffset, int dynamicStackID, int otherStackID, int offsetFromStackTop)
void push_slots_indirect(SlotRange fixedRange, int dynamicStack, SlotRange limitRange)
void store_immutable_value_i(Slot slot, int32_t val)
void discard_stack(int32_t count)
void push_clone(int numSlots, int offsetFromStackTop=0)
void swizzle_copy_stack_to_slots_indirect(SlotRange fixedRange, int dynamicStackID, SlotRange limitRange, SkSpan< const int8_t > components, int offsetFromStackTop)
void zero_slots_unmasked(SlotRange dst)
void reenable_loop_mask(SlotRange src)
void swizzle(int consumedSlots, SkSpan< const int8_t > components)
void matrix_resize(int origColumns, int origRows, int newColumns, int newRows)
void branch_if_no_active_lanes_on_stack_top_equal(int value, int labelID)
void inverse_matrix(int32_t n)
void push_uniform(SlotRange src)
void pop_slots(SlotRange dst)
void invoke_color_filter(int childIdx)
void transpose(int columns, int rows)
void mask_off_loop_mask()
void mask_off_return_mask()
void discard_stack(int32_t count, int stackID)
void pop_and_reenable_loop_mask()
void enableExecutionMaskWrites()
void trace_line(int traceMaskStackID, int line)
void trace_enter(int traceMaskStackID, int funcID)
void load_src(SlotRange slots)
void invoke_shader(int childIdx)
void invoke_blender(int childIdx)
void trace_var_indirect(int traceMaskStackID, SlotRange fixedRange, int dynamicStackID, SlotRange limitRange)
void trace_var(int traceMaskStackID, SlotRange r)
void copy_stack_to_slots(SlotRange dst)
void disableExecutionMaskWrites()
void continue_op(int continueMaskStackID)
void load_dst(SlotRange slots)
void store_src(SlotRange slots)
void copy_immutable_unmasked(SlotRange dst, SlotRange src)
std::unique_ptr< Program > finish(int numValueSlots, int numUniformSlots, int numImmutableSlots, DebugTracePriv *debugTrace=nullptr)
void push_slots_or_immutable_indirect(SlotRange fixedRange, int dynamicStack, SlotRange limitRange, BuilderOp op)
void invoke_to_linear_srgb()
void pop_slots_indirect(SlotRange fixedRange, int dynamicStackID, SlotRange limitRange)
void push_uniform_indirect(SlotRange fixedRange, int dynamicStack, SlotRange limitRange)
void ternary_op(BuilderOp op, int32_t slots)
void push_constant_f(float val)
void diagonal_matrix(int columns, int rows)
void trace_scope(int traceMaskStackID, int delta)
void store_src_rg(SlotRange slots)
void merge_inv_condition_mask()
void push_clone_from_stack(SlotRange range, int otherStackID, int offsetFromStackTop)
void unary_op(BuilderOp op, int32_t slots)
void push_immutable(SlotRange src)
void push_constant_i(int32_t val, int count=1)
void push_slots_or_immutable(SlotRange src, BuilderOp op)
void push_condition_mask()
bool executionMaskWritesAreEnabled()
void matrix_multiply(int leftColumns, int leftRows, int rightColumns, int rightRows)
void branch_if_all_lanes_active(int labelID)
void store_device_xy01(SlotRange slots)
void trace_exit(int traceMaskStackID, int funcID)
void set_current_stack(int stackID)
void pop_slots_unmasked(SlotRange dst)
void branch_if_any_lanes_active(int labelID)
void copy_stack_to_slots_unmasked(SlotRange dst)
void push_zeros(int count)
void pop_condition_mask()
virtual void toLinearSrgb(const void *color)=0
virtual bool appendShader(int index)=0
virtual bool appendBlender(int index)=0
virtual bool appendColorFilter(int index)=0
virtual ~Callbacks()=default
virtual void fromLinearSrgb(const void *color)=0
bool appendStages(SkRasterPipeline *pipeline, SkArenaAlloc *alloc, Callbacks *callbacks, SkSpan< const float > uniforms) const
void dump(SkWStream *out, bool writeInstructionCount=false) const
Program(skia_private::TArray< Instruction > instrs, int numValueSlots, int numUniformSlots, int numImmutableSlots, int numLabels, DebugTracePriv *debugTrace)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static bool unsupported()
@ push_immutable_indirect
@ pop_and_reenable_loop_mask