| 25 | } |
| 26 | |
| 27 | void SceComputeQueue::dingDong(uint32_t nextStartOffsetInDw) |
| 28 | { |
| 29 | std::lock_guard<std::mutex> lock(m_mutex); |
| 30 | |
| 31 | uint32_t* nextCmd = m_ringBegin + nextStartOffsetInDw; |
| 32 | |
| 33 | if (nextCmd > m_ringCmd) |
| 34 | { |
| 35 | // Normal case, |
| 36 | // execute command in range [m_ringCmd, nextCmd] |
| 37 | SceGpuCommand cmd = {}; |
| 38 | cmd.buffer = m_ringCmd; |
| 39 | cmd.size = static_cast<uint32_t>(nextCmd - m_ringCmd) * sizeof(uint32_t); |
| 40 | m_queue->record(cmd); |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | // Ring buffer overlaps, |
| 45 | // we need to execute commands in range [m_ringCmd, m_ringEnd] and [m_ringBegin, nextCmd]. |
| 46 | |
| 47 | if (m_ringCmd != m_ringEnd) |
| 48 | { |
| 49 | SceGpuCommand cmd = {}; |
| 50 | cmd.buffer = m_ringCmd; |
| 51 | cmd.size = static_cast<uint32_t>(m_ringEnd - m_ringCmd) * sizeof(uint32_t); |
| 52 | m_queue->record(cmd); |
| 53 | } |
| 54 | |
| 55 | if (m_ringBegin != nextCmd) |
| 56 | { |
| 57 | SceGpuCommand cmd = {}; |
| 58 | cmd.buffer = m_ringBegin; |
| 59 | cmd.size = static_cast<uint32_t>(nextCmd - m_ringBegin) * sizeof(uint32_t); |
| 60 | m_queue->record(cmd); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | submitCommand(); |
| 65 | |
| 66 | m_ringCmd = nextCmd; |
| 67 | *m_offsetPtr = static_cast<uint32_t>(m_ringCmd - m_ringBegin); |
| 68 | } |
| 69 | |
| 70 | void SceComputeQueue::submitCommand() |
| 71 | { |