MCPcopy Create free account
hub / github.com/InoriRus/Kyty / ThreadRun

Method ThreadRun

source/emulator/src/Graphics/GraphicsRun.cpp:826–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826void ComputeRing::ThreadRun(void* data)
827{
828 EXIT_IF(data == nullptr);
829
830 auto* ring = static_cast<ComputeRing*>(data);
831 auto* cp = ring->m_cp;
832
833 EXIT_IF(ring == nullptr);
834 EXIT_IF(cp == nullptr);
835
836 uint32_t* buffer = nullptr;
837
838 KYTY_PROFILER_THREAD("Thread_Compute");
839
840 ring->m_mutex.Lock();
841
842 for (;;)
843 {
844 while (!(ring->m_active && ring->m_run_offset_dw > 0))
845 {
846 ring->m_idle = true;
847 ring->m_idle_cond_var.Signal();
848 ring->m_cond_var.Wait(&ring->m_mutex);
849 }
850
851 ring->m_idle = false;
852
853 auto pos = *ring->m_read_ptr_addr;
854 auto num_dw = ring->m_run_offset_dw;
855 auto next_pos = pos + num_dw;
856 auto ring_size = ring->m_ring_size_dw;
857 auto* ring_addr = ring->m_ring_addr;
858
859 if (next_pos <= ring_size)
860 {
861 buffer = ring_addr + pos;
862 } else
863 {
864 auto d1 = next_pos - ring_size;
865 auto d2 = num_dw - d1;
866 buffer = ring->m_internal_buffer;
867 memcpy(buffer, ring_addr + pos, d2);
868 memcpy(buffer + d2, ring_addr, d1);
869 }
870
871 ring->m_mutex.Unlock();
872
873 cp->RunLock();
874 {
875 cp->BufferInit();
876 cp->ResetDeCe();
877
878 GraphicsDbgDumpDcb("cc", num_dw, buffer);
879
880 cp->Run(buffer, num_dw);
881
882 cp->BufferFlush();
883 }

Callers

nothing calls this directly

Calls 12

memcpyFunction · 0.85
GraphicsDbgDumpDcbFunction · 0.85
RunLockMethod · 0.80
BufferInitMethod · 0.80
ResetDeCeMethod · 0.80
BufferFlushMethod · 0.80
RunUnlockMethod · 0.80
LockMethod · 0.45
SignalMethod · 0.45
WaitMethod · 0.45
UnlockMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected