|
413 | 413 | } |
414 | 414 |
|
415 | 415 | MetalCommandList::~MetalCommandList() { |
416 | | - flush_pending_encoder_(); |
| 416 | + flush_pending_encoder(); |
417 | 417 | [cmdbuf_ release]; |
418 | 418 | } |
419 | 419 |
|
|
422 | 422 | // returned for commit, so a long chain of `dispatch()` calls collapses to a |
423 | 423 | // single MTLComputeCommandEncoder while incompatible ops still observe the |
424 | 424 | // right per-encoder boundary that Metal's hazard tracking relies on. |
425 | | -void MetalCommandList::flush_pending_encoder_() { |
| 425 | +void MetalCommandList::flush_pending_encoder() { |
426 | 426 | if (current_compute_encoder_ != nil) { |
427 | 427 | [current_compute_encoder_ endEncoding]; |
428 | 428 | [current_compute_encoder_ release]; |
|
487 | 487 |
|
488 | 488 | void MetalCommandList::buffer_copy(DevicePtr dst, DevicePtr src, |
489 | 489 | size_t size) noexcept { |
490 | | - flush_pending_encoder_(); |
| 490 | + flush_pending_encoder(); |
491 | 491 | const MetalMemory &src_memory = device_->get_memory(src.alloc_id); |
492 | 492 | const MetalMemory &dst_memory = device_->get_memory(dst.alloc_id); |
493 | 493 |
|
|
515 | 515 | void MetalCommandList::buffer_fill(DevicePtr ptr, size_t size, |
516 | 516 | uint32_t data) noexcept { |
517 | 517 | RHI_ASSERT(data == 0); |
518 | | - flush_pending_encoder_(); |
| 518 | + flush_pending_encoder(); |
519 | 519 |
|
520 | 520 | const MetalMemory &memory = device_->get_memory(ptr.alloc_id); |
521 | 521 |
|
|
555 | 555 | // so per-dispatch ordering inside one encoder is the same as separate |
556 | 556 | // encoders, but we save the ~700 us of encoder-end / encoder-begin gap that |
557 | 557 | // the Metal System Trace surfaces between every quadrants dispatch. The |
558 | | - // encoder is torn down by `flush_pending_encoder_` whenever an |
| 558 | + // encoder is torn down by `flush_pending_encoder` whenever an |
559 | 559 | // encoder-incompatible op (blit / render / cmdbuf finalize) needs to start. |
560 | 560 | if (current_compute_encoder_ == nullptr) { |
561 | 561 | // `[cmdbuf_ computeCommandEncoder]` returns an autoreleased encoder. |
562 | 562 | // Retain it so the encoder survives past the enclosing `@autoreleasepool` |
563 | 563 | // drain into the next `dispatch()` call; without this the autoreleased |
564 | 564 | // encoder is freed before we end it, and Metal's |
565 | 565 | // `_MTLCommandEncoder dealloc` asserts "Command encoder released without |
566 | | - // endEncoding". Released by `flush_pending_encoder_` after `endEncoding`. |
| 566 | + // endEncoding". Released by `flush_pending_encoder` after `endEncoding`. |
567 | 567 | current_compute_encoder_ = [[cmdbuf_ computeCommandEncoder] retain]; |
568 | 568 | } |
569 | 569 | MTLComputeCommandEncoder_id encoder = current_compute_encoder_; |
|
621 | 621 | std::vector<float> *clear_colors, |
622 | 622 | DeviceAllocation *depth_attachment, |
623 | 623 | bool depth_clear) { |
624 | | - flush_pending_encoder_(); |
| 624 | + flush_pending_encoder(); |
625 | 625 | current_renderpass_details_.clear_depth = depth_clear; |
626 | 626 |
|
627 | 627 | int rendertarget_height = 0; |
|
771 | 771 | void MetalCommandList::set_renderpass_active() { is_renderpass_active_ = true; } |
772 | 772 |
|
773 | 773 | MTLRenderCommandEncoder_id MetalCommandList::pre_draw_setup() { |
774 | | - flush_pending_encoder_(); |
| 774 | + flush_pending_encoder(); |
775 | 775 | const RasterParams *raster_params = current_pipeline_->raster_params(); |
776 | 776 |
|
777 | 777 | MTLRenderPassDescriptor *rpd = create_render_pass_desc( |
|
983 | 983 | buffer_image_copy_params_to_mtl(params, src_buf.offset, |
984 | 984 | dst_image.mtl_texture(), &mtl_params); |
985 | 985 |
|
986 | | - flush_pending_encoder_(); |
| 986 | + flush_pending_encoder(); |
987 | 987 | @autoreleasepool { |
988 | 988 | MTLBlitCommandEncoder_id encoder = [cmdbuf_ blitCommandEncoder]; |
989 | 989 | [encoder copyFromBuffer:src_buffer.mtl_buffer() |
|
1011 | 1011 | buffer_image_copy_params_to_mtl(params, dst_buf.offset, |
1012 | 1012 | src_image.mtl_texture(), &mtl_params); |
1013 | 1013 |
|
1014 | | - flush_pending_encoder_(); |
| 1014 | + flush_pending_encoder(); |
1015 | 1015 | @autoreleasepool { |
1016 | 1016 | MTLBlitCommandEncoder_id encoder = [cmdbuf_ blitCommandEncoder]; |
1017 | 1017 | [encoder copyFromTexture:src_image.mtl_texture() |
|
1036 | 1036 | const MetalImage &src_image = device_->get_image(src_img.alloc_id); |
1037 | 1037 | const MetalImage &dst_image = device_->get_image(dst_img.alloc_id); |
1038 | 1038 |
|
1039 | | - flush_pending_encoder_(); |
| 1039 | + flush_pending_encoder(); |
1040 | 1040 | @autoreleasepool { |
1041 | 1041 | MTLBlitCommandEncoder_id encoder = [cmdbuf_ blitCommandEncoder]; |
1042 | 1042 | [encoder |
|
1062 | 1062 | } |
1063 | 1063 |
|
1064 | 1064 | MTLCommandBuffer_id MetalCommandList::finalize() { |
1065 | | - flush_pending_encoder_(); |
| 1065 | + flush_pending_encoder(); |
1066 | 1066 | return cmdbuf_; |
1067 | 1067 | } |
1068 | 1068 |
|
|
0 commit comments