| 667 | } |
| 668 | |
| 669 | bool TextureCache::ProcessRenderingThreadCommands(CommonRenderPasses& passes, float timeLimitMilliseconds) |
| 670 | { |
| 671 | using namespace std::chrono; |
| 672 | |
| 673 | time_point<high_resolution_clock> startTime = high_resolution_clock::now(); |
| 674 | |
| 675 | uint commandsExecuted = 0; |
| 676 | while (true) |
| 677 | { |
| 678 | std::shared_ptr<TextureData> pTexture; |
| 679 | |
| 680 | if (timeLimitMilliseconds > 0 && commandsExecuted > 0) |
| 681 | { |
| 682 | time_point<high_resolution_clock> now = high_resolution_clock::now(); |
| 683 | |
| 684 | if (float(duration_cast<microseconds>(now - startTime).count()) > timeLimitMilliseconds * 1e3f) |
| 685 | break; |
| 686 | } |
| 687 | |
| 688 | { |
| 689 | std::lock_guard<std::mutex> guard(m_TexturesToFinalizeMutex); |
| 690 | |
| 691 | if (m_TexturesToFinalize.empty()) |
| 692 | break; |
| 693 | |
| 694 | pTexture = m_TexturesToFinalize.front(); |
| 695 | m_TexturesToFinalize.pop(); |
| 696 | } |
| 697 | |
| 698 | if (pTexture->data) |
| 699 | { |
| 700 | commandsExecuted += 1; |
| 701 | |
| 702 | if (!m_CommandList) |
| 703 | { |
| 704 | m_CommandList = m_Device->createCommandList(); |
| 705 | } |
| 706 | |
| 707 | m_CommandList->open(); |
| 708 | |
| 709 | FinalizeTexture(pTexture, &passes, m_CommandList); |
| 710 | |
| 711 | m_CommandList->close(); |
| 712 | m_Device->executeCommandList(m_CommandList); |
| 713 | m_Device->runGarbageCollection(); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | return (commandsExecuted > 0); |
| 718 | } |
| 719 | |
| 720 | void TextureCache::LoadingFinished() |
| 721 | { |
no test coverage detected