MCPcopy Create free account
hub / github.com/crosire/reshade / emit_loop

Function emit_loop

source/effect_codegen_spirv.cpp:2402–2435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2400 return inst;
2401 }
2402 void emit_loop(const location &loc, id, id prev_block, id header_block, id condition_block, id loop_block, id continue_block, unsigned int loop_control) override
2403 {
2404 spirv_instruction merge_label = _current_block_data->instructions.back();
2405 assert(merge_label.op == spv::OpLabel);
2406 _current_block_data->instructions.pop_back();
2407
2408 // Add previous block first
2409 _current_block_data->append(_block_data[prev_block]);
2410
2411 // Fill header block
2412 assert(_block_data[header_block].instructions.size() == 2);
2413 _current_block_data->instructions.push_back(_block_data[header_block].instructions[0]);
2414 assert(_current_block_data->instructions.back().op == spv::OpLabel);
2415
2416 // Add structured control flow instruction
2417 add_location(loc, *_current_block_data);
2418 add_instruction_without_result(spv::OpLoopMerge)
2419 .add(merge_label)
2420 .add(continue_block)
2421 .add(loop_control & 0x3); // 'LoopControl' happens to match the flags produced by the parser
2422
2423 _current_block_data->instructions.push_back(_block_data[header_block].instructions[1]);
2424 assert(_current_block_data->instructions.back().op == spv::OpBranch);
2425
2426 // Add condition block if it exists
2427 if (condition_block != 0)
2428 _current_block_data->append(_block_data[condition_block]);
2429
2430 // Append loop body block before continue block
2431 _current_block_data->append(_block_data[loop_block]);
2432 _current_block_data->append(_block_data[continue_block]);
2433
2434 _current_block_data->instructions.push_back(merge_label);
2435 }
2436 void emit_switch(const location &loc, id, id selector_block, id default_label, id default_block, const std::vector<id> &case_literal_and_labels, const std::vector<id> &case_blocks, unsigned int selection_control) override
2437 {
2438 assert(case_blocks.size() == case_literal_and_labels.size() / 2);

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected