| 165 | } |
| 166 | |
| 167 | uint32_t |
| 168 | CommandQueue::WaitForFinishThread() { |
| 169 | env::setThreadName("dxmt-finish-thread"); |
| 170 | SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); |
| 171 | uint64_t internal_seq = 1; |
| 172 | while (!stopped.load()) { |
| 173 | ready_for_commit.wait(internal_seq, std::memory_order_acquire); |
| 174 | if (stopped.load()) |
| 175 | break; |
| 176 | auto &chunk = chunks[internal_seq % kCommandChunkCount]; |
| 177 | if (chunk.attached_cmdbuf.status() <= WMTCommandBufferStatusScheduled) { |
| 178 | chunk.attached_cmdbuf.waitUntilCompleted(); |
| 179 | } |
| 180 | if (chunk.attached_cmdbuf.status() == WMTCommandBufferStatusError) { |
| 181 | ERR("Device error at frame ", chunk.frame_, ": ", chunk.attached_cmdbuf.error().description().getUTF8String()); |
| 182 | } |
| 183 | if (auto logs = chunk.attached_cmdbuf.logs()) { |
| 184 | for (auto &log : logs.elements()) { |
| 185 | ERR("Frame ", chunk.frame_, ": ", log.description().getUTF8String()); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if (chunk.signal_frame_latency_fence_ != ~0ull) |
| 190 | frame_latency_fence_.signal(chunk.signal_frame_latency_fence_); |
| 191 | |
| 192 | chunk.reset(); |
| 193 | cpu_coherent.signal(internal_seq); |
| 194 | chunk_ongoing.fetch_sub(1, std::memory_order_release); |
| 195 | chunk_ongoing.notify_one(); |
| 196 | |
| 197 | staging_allocator.free_blocks(internal_seq); |
| 198 | copy_temp_allocator.free_blocks(internal_seq); |
| 199 | argbuf_allocator.free_blocks(internal_seq); |
| 200 | |
| 201 | internal_seq++; |
| 202 | } |
| 203 | TRACE("finishing thread gracefully terminates"); |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | void CommandQueue::Retain(uint64_t seq, Allocation* allocation) { |
| 208 | auto &chunk = chunks[seq % kCommandChunkCount]; |
no test coverage detected