Flutter Engine
The Flutter Engine
Classes | Typedefs | Enumerations | Functions | Variables
SkSL::RP Namespace Reference

Classes

class  AutoContinueMask
 
class  AutoLoopTarget
 
class  AutoStack
 
class  Builder
 
class  Callbacks
 
class  DynamicIndexLValue
 
class  Generator
 
class  ImmutableLValue
 
struct  Instruction
 
class  LValue
 
class  LValueSlice
 
class  Program
 
class  ScratchLValue
 
class  SlotManager
 
struct  SlotRange
 
class  SwizzleLValue
 
class  UnownedLValueSlice
 
class  VariableLValue
 

Typedefs

using Slot = int
 

Enumerations

enum class  ProgramOp { M }
 
enum class  BuilderOp {
  M , push_clone , push_clone_from_stack , push_clone_indirect_from_stack ,
  push_constant , push_immutable , push_immutable_indirect , push_slots ,
  push_slots_indirect , push_uniform , push_uniform_indirect , copy_stack_to_slots ,
  copy_stack_to_slots_unmasked , copy_stack_to_slots_indirect , copy_uniform_to_slots_unmasked , store_immutable_value ,
  swizzle_copy_stack_to_slots , swizzle_copy_stack_to_slots_indirect , discard_stack , pad_stack ,
  select , push_condition_mask , pop_condition_mask , push_loop_mask ,
  pop_loop_mask , pop_and_reenable_loop_mask , push_return_mask , pop_return_mask ,
  push_src_rgba , push_dst_rgba , push_device_xy01 , pop_src_rgba ,
  pop_dst_rgba , trace_var_indirect , branch_if_no_active_lanes_on_stack_top_equal , unsupported
}
 

Functions

static bool is_immediate_op (BuilderOp op)
 
static bool is_multi_slot_immediate_op (BuilderOp op)
 
static BuilderOp convert_n_way_op_to_immediate (BuilderOp op, int slots, int32_t *constantValue)
 
static bool slot_ranges_overlap (SlotRange x, SlotRange y)
 
static int pack_nybbles (SkSpan< const int8_t > components)
 
template<typename T >
static void unpack_nybbles_to_offsets (uint32_t components, SkSpan< T > offsets)
 
static int max_packed_nybble (uint32_t components, size_t numComponents)
 
static int stack_usage (const Instruction &inst)
 
static bool immutable_data_is_splattable (int32_t *immutablePtr, int numSlots)
 
static void * context_bit_pun (intptr_t val)
 
static bool unsupported ()
 
static bool is_sliceable_swizzle (SkSpan< const int8_t > components)
 

Variables

constexpr Slot NA = -1
 

Typedef Documentation

◆ Slot

using SkSL::RP::Slot = typedef int

Definition at line 36 of file SkSLRasterPipelineBuilder.h.

Enumeration Type Documentation

◆ BuilderOp

enum class SkSL::RP::BuilderOp
strong
Enumerator
push_clone 
push_clone_from_stack 
push_clone_indirect_from_stack 
push_constant 
push_immutable 
push_immutable_indirect 
push_slots 
push_slots_indirect 
push_uniform 
push_uniform_indirect 
copy_stack_to_slots 
copy_stack_to_slots_unmasked 
copy_stack_to_slots_indirect 
copy_uniform_to_slots_unmasked 
store_immutable_value 
swizzle_copy_stack_to_slots 
swizzle_copy_stack_to_slots_indirect 
discard_stack 
pad_stack 
select 
push_condition_mask 
pop_condition_mask 
push_loop_mask 
pop_loop_mask 
pop_and_reenable_loop_mask 
push_return_mask 
pop_return_mask 
push_src_rgba 
push_dst_rgba 
push_device_xy01 
pop_src_rgba 
pop_dst_rgba 
trace_var_indirect 
branch_if_no_active_lanes_on_stack_top_equal 
unsupported 

Definition at line 77 of file SkSLRasterPipelineBuilder.h.

77 {
78 #define M(stage) stage,
79 // An in-flight program can contain all the native Raster Pipeline ops...
81
82 // ... and our extended ops...
84 #undef M
85
86 // ... and also has Builder-specific ops. These ops generally interface with the stack, and are
87 // converted into ProgramOps during `makeStages`.
106 pad_stack,
107 select,
123};
#define SK_RASTER_PIPELINE_OPS_ALL(M)
#define M(stage)
#define SKRP_EXTENDED_OPS(M)
@ swizzle_copy_stack_to_slots_indirect
@ branch_if_no_active_lanes_on_stack_top_equal

◆ ProgramOp

enum class SkSL::RP::ProgramOp
strong
Enumerator

Definition at line 61 of file SkSLRasterPipelineBuilder.h.

61 {
62 #define M(stage) stage,
63 // A finished program can contain any native Raster Pipeline op...
65
66 // ... as well as our extended ops.
68 #undef M
69};

Function Documentation

◆ context_bit_pun()

static void * SkSL::RP::context_bit_pun ( intptr_t  val)
static

Definition at line 1630 of file SkSLRasterPipelineBuilder.cpp.

1630 {
1631 return sk_bit_cast<void*>(val);
1632}

◆ convert_n_way_op_to_immediate()

static BuilderOp SkSL::RP::convert_n_way_op_to_immediate ( BuilderOp  op,
int  slots,
int32_t *  constantValue 
)
static

Definition at line 146 of file SkSLRasterPipelineBuilder.cpp.

146 {
147 // We rely on the exact ordering of SkRP ops here; the immediate-mode op must always come
148 // directly before the n-way op. (If we have more than one, the increasing-slot variations
149 // continue backwards from there.)
150 BuilderOp immOp = (BuilderOp)((int)op - 1);
151
152 // Some immediate ops support multiple slots.
153 if (is_multi_slot_immediate_op(immOp)) {
154 return immOp;
155 }
156
157 // Most immediate ops only directly support a single slot. However, it's still faster to execute
158 // `add_imm_int, add_imm_int` instead of `splat_2_ints, add_2_ints`, so we allow those
159 // conversions as well.
160 if (slots <= 2) {
161 if (is_immediate_op(immOp)) {
162 return immOp;
163 }
164
165 // We also allow for immediate-mode subtraction, by adding a negative value.
166 switch (op) {
167 case BuilderOp::sub_n_ints:
168 *constantValue *= -1;
169 return BuilderOp::add_imm_int;
170
171 case BuilderOp::sub_n_floats: {
172 // This negates the floating-point value by inverting its sign bit.
173 *constantValue ^= 0x80000000;
174 return BuilderOp::add_imm_float;
175 }
176 default:
177 break;
178 }
179 }
180
181 // We don't have an immediate-mode version of this op.
182 return op;
183}
static bool is_immediate_op(BuilderOp op)
static bool is_multi_slot_immediate_op(BuilderOp op)

◆ immutable_data_is_splattable()

static bool SkSL::RP::immutable_data_is_splattable ( int32_t *  immutablePtr,
int  numSlots 
)
static

Definition at line 1418 of file SkSLRasterPipelineBuilder.cpp.

1418 {
1419 // If every value between `immutablePtr[0]` and `immutablePtr[numSlots]` is bit-identical, we
1420 // can use a splat.
1421 for (int index = 1; index < numSlots; ++index) {
1422 if (immutablePtr[0] != immutablePtr[index]) {
1423 return false;
1424 }
1425 }
1426 return true;
1427}

◆ is_immediate_op()

static bool SkSL::RP::is_immediate_op ( BuilderOp  op)
static

Definition at line 132 of file SkSLRasterPipelineBuilder.cpp.

132 {
133 switch (op) {
134 case ALL_IMMEDIATE_BINARY_OP_CASES: return true;
135 default: return false;
136 }
137}
#define ALL_IMMEDIATE_BINARY_OP_CASES

◆ is_multi_slot_immediate_op()

static bool SkSL::RP::is_multi_slot_immediate_op ( BuilderOp  op)
static

Definition at line 139 of file SkSLRasterPipelineBuilder.cpp.

139 {
140 switch (op) {
142 default: return false;
143 }
144}
#define ALL_IMMEDIATE_MULTI_SLOT_BINARY_OP_CASES

◆ is_sliceable_swizzle()

static bool SkSL::RP::is_sliceable_swizzle ( SkSpan< const int8_t >  components)
static

Definition at line 1233 of file SkSLRasterPipelineCodeGenerator.cpp.

1233 {
1234 // Determine if the swizzle rearranges its elements, or if it's a simple subset of its elements.
1235 // (A simple subset would be a sequential non-repeating range of components, like `.xyz` or
1236 // `.yzw` or `.z`, but not `.xx` or `.xz`, which can be accessed as a slice of the variable.)
1237 for (size_t index = 1; index < components.size(); ++index) {
1238 if (components[index] != int8_t(components[0] + index)) {
1239 return false;
1240 }
1241 }
1242 return true;
1243}
constexpr size_t size() const
Definition: SkSpan_impl.h:95

◆ max_packed_nybble()

static int SkSL::RP::max_packed_nybble ( uint32_t  components,
size_t  numComponents 
)
static

Definition at line 1089 of file SkSLRasterPipelineBuilder.cpp.

1089 {
1090 int largest = 0;
1091 for (size_t index = 0; index < numComponents; ++index) {
1092 largest = std::max<int>(largest, components & 0xF);
1093 components >>= 4;
1094 }
1095 return largest;
1096}

◆ pack_nybbles()

static int SkSL::RP::pack_nybbles ( SkSpan< const int8_t >  components)
static

Definition at line 1069 of file SkSLRasterPipelineBuilder.cpp.

1069 {
1070 // Pack up to 8 elements into nybbles, in reverse order.
1071 int packed = 0;
1072 for (auto iter = components.rbegin(); iter != components.rend(); ++iter) {
1073 SkASSERT(*iter >= 0 && *iter <= 0xF);
1074 packed <<= 4;
1075 packed |= *iter;
1076 }
1077 return packed;
1078}
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr auto rbegin() const
Definition: SkSpan_impl.h:92
constexpr auto rend() const
Definition: SkSpan_impl.h:93

◆ slot_ranges_overlap()

static bool SkSL::RP::slot_ranges_overlap ( SlotRange  x,
SlotRange  y 
)
static

Definition at line 899 of file SkSLRasterPipelineBuilder.cpp.

899 {
900 return x.index < y.index + y.count &&
901 y.index < x.index + x.count;
902}
double y
double x

◆ stack_usage()

static int SkSL::RP::stack_usage ( const Instruction inst)
static

Definition at line 1278 of file SkSLRasterPipelineBuilder.cpp.

1278 {
1279 switch (inst.fOp) {
1280 case BuilderOp::push_condition_mask:
1281 case BuilderOp::push_loop_mask:
1282 case BuilderOp::push_return_mask:
1283 return 1;
1284
1285 case BuilderOp::push_src_rgba:
1286 case BuilderOp::push_dst_rgba:
1287 case BuilderOp::push_device_xy01:
1288 return 4;
1289
1290 case BuilderOp::push_immutable:
1291 case BuilderOp::push_immutable_indirect:
1292 case BuilderOp::push_constant:
1293 case BuilderOp::push_slots:
1294 case BuilderOp::push_slots_indirect:
1295 case BuilderOp::push_uniform:
1296 case BuilderOp::push_uniform_indirect:
1297 case BuilderOp::push_clone:
1298 case BuilderOp::push_clone_from_stack:
1299 case BuilderOp::push_clone_indirect_from_stack:
1300 case BuilderOp::pad_stack:
1301 return inst.fImmA;
1302
1303 case BuilderOp::pop_condition_mask:
1304 case BuilderOp::pop_loop_mask:
1305 case BuilderOp::pop_and_reenable_loop_mask:
1306 case BuilderOp::pop_return_mask:
1307 return -1;
1308
1309 case BuilderOp::pop_src_rgba:
1310 case BuilderOp::pop_dst_rgba:
1311 return -4;
1312
1315 case BuilderOp::discard_stack:
1316 case BuilderOp::select:
1317 return -inst.fImmA;
1318
1321 return 2 * -inst.fImmA;
1322
1323 case BuilderOp::swizzle_1:
1324 return 1 - inst.fImmA; // consumes immA slots and emits a scalar
1325 case BuilderOp::swizzle_2:
1326 return 2 - inst.fImmA; // consumes immA slots and emits a 2-slot vector
1327 case BuilderOp::swizzle_3:
1328 return 3 - inst.fImmA; // consumes immA slots and emits a 3-slot vector
1329 case BuilderOp::swizzle_4:
1330 return 4 - inst.fImmA; // consumes immA slots and emits a 4-slot vector
1331
1332 case BuilderOp::dot_2_floats:
1333 return -3; // consumes two 2-slot vectors and emits one scalar
1334 case BuilderOp::dot_3_floats:
1335 return -5; // consumes two 3-slot vectors and emits one scalar
1336 case BuilderOp::dot_4_floats:
1337 return -7; // consumes two 4-slot vectors and emits one scalar
1338
1339 case BuilderOp::refract_4_floats:
1340 return -5; // consumes nine slots (N + I + eta) and emits a 4-slot vector (R)
1341
1342 case BuilderOp::matrix_multiply_2:
1343 case BuilderOp::matrix_multiply_3:
1344 case BuilderOp::matrix_multiply_4:
1345 // consumes the left- and right-matrices; emits result over existing padding slots
1346 return -(inst.fImmA * inst.fImmB + inst.fImmC * inst.fImmD);
1347
1348 case BuilderOp::shuffle: {
1349 int consumed = inst.fImmA;
1350 int generated = inst.fImmB;
1351 return generated - consumed;
1352 }
1356 default:
1357 return 0;
1358 }
1359}
#define ALL_N_WAY_TERNARY_OP_CASES
#define ALL_MULTI_SLOT_TERNARY_OP_CASES
#define ALL_N_WAY_BINARY_OP_CASES
#define ALL_MULTI_SLOT_UNARY_OP_CASES
#define ALL_MULTI_SLOT_BINARY_OP_CASES
#define ALL_SINGLE_SLOT_UNARY_OP_CASES
inst
Definition: malisc.py:37
SI Vec< sizeof...(Ix), T > shuffle(const Vec< N, T > &)
Definition: SkVx.h:667

◆ unpack_nybbles_to_offsets()

template<typename T >
static void SkSL::RP::unpack_nybbles_to_offsets ( uint32_t  components,
SkSpan< T offsets 
)
static

Definition at line 1081 of file SkSLRasterPipelineBuilder.cpp.

1081 {
1082 // Unpack component nybbles into byte-offsets pointing at stack slots.
1083 for (size_t index = 0; index < offsets.size(); ++index) {
1084 offsets[index] = (components & 0xF) * SkOpts::raster_pipeline_highp_stride * sizeof(float);
1085 components >>= 4;
1086 }
1087}
size_t raster_pipeline_highp_stride
Definition: SkOpts.cpp:26
list offsets
Definition: mskp_parser.py:37

◆ unsupported()

static bool SkSL::RP::unsupported ( )
static

Definition at line 86 of file SkSLRasterPipelineCodeGenerator.cpp.

86 {
87 // If MakeRasterPipelineProgram returns false, set a breakpoint here for more information.
88 return false;
89}

Variable Documentation

◆ NA

constexpr Slot SkSL::RP::NA = -1
constexpr

Definition at line 37 of file SkSLRasterPipelineBuilder.h.