| 97 | } |
| 98 | |
| 99 | void CommandBuffer::Enqueue(std::shared_ptr<XCommand> xcmd) |
| 100 | { |
| 101 | auto ready_time = std::chrono::system_clock::now(); |
| 102 | XASSERT(xcmd != nullptr, "xcmd should not be nullptr"); |
| 103 | xcmd->SetState(kCommandStatePending); |
| 104 | |
| 105 | mtx_.lock(); |
| 106 | |
| 107 | if (xcmd->GetType() == kCommandTypeHardware && xq_state_ == kQueueStateIdle) { |
| 108 | xq_state_ = kQueueStateReady; |
| 109 | SchedAgent::SendEvent(std::make_shared<XQueueReadyEvent>(kXQueueHandle, ready_time)); |
| 110 | } |
| 111 | |
| 112 | last_enqueued_cmd_ = xcmd; |
| 113 | cmds_.emplace_back(xcmd); |
| 114 | XDEBG("xcmd (%p) type (%d) enqueued to cmd buf (%p)", xcmd.get(), xcmd->GetType(), this); |
| 115 | |
| 116 | mtx_.unlock(); |
| 117 | cv_.notify_all(); |
| 118 | } |
| 119 | |
| 120 | void CommandBuffer::DropAll() |
| 121 | { |