mirror of
https://github.com/rt64/rt64.git
synced 2024-12-26 21:18:31 +00:00
Change streaming queue to streaming stack to prioritize later draw calls.
This commit is contained in:
parent
fa373f0b8a
commit
04c7d45920
@ -387,7 +387,7 @@ namespace RT64 {
|
|||||||
|
|
||||||
TextureCache::StreamThread::~StreamThread() {
|
TextureCache::StreamThread::~StreamThread() {
|
||||||
threadRunning = false;
|
threadRunning = false;
|
||||||
textureCache->streamDescQueueChanged.notify_all();
|
textureCache->streamDescStackChanged.notify_all();
|
||||||
thread->join();
|
thread->join();
|
||||||
thread.reset(nullptr);
|
thread.reset(nullptr);
|
||||||
}
|
}
|
||||||
@ -406,17 +406,17 @@ namespace RT64 {
|
|||||||
|
|
||||||
// Check the top of the queue or wait if it's empty.
|
// Check the top of the queue or wait if it's empty.
|
||||||
{
|
{
|
||||||
std::unique_lock queueLock(textureCache->streamDescQueueMutex);
|
std::unique_lock queueLock(textureCache->streamDescStackMutex);
|
||||||
textureCache->streamDescQueueActiveCount--;
|
textureCache->streamDescStackActiveCount--;
|
||||||
textureCache->streamDescQueueChanged.wait(queueLock, [this]() {
|
textureCache->streamDescStackChanged.wait(queueLock, [this]() {
|
||||||
return !threadRunning || !textureCache->streamDescQueue.empty();
|
return !threadRunning || !textureCache->streamDescStack.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
textureCache->streamDescQueueActiveCount++;
|
textureCache->streamDescStackActiveCount++;
|
||||||
|
|
||||||
if (!textureCache->streamDescQueue.empty()) {
|
if (!textureCache->streamDescStack.empty()) {
|
||||||
streamDesc = textureCache->streamDescQueue.front();
|
streamDesc = textureCache->streamDescStack.top();
|
||||||
textureCache->streamDescQueue.pop();
|
textureCache->streamDescStack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ namespace RT64 {
|
|||||||
uploadThread = new std::thread(&TextureCache::uploadThreadLoop, this);
|
uploadThread = new std::thread(&TextureCache::uploadThreadLoop, this);
|
||||||
|
|
||||||
// Create streaming threads.
|
// Create streaming threads.
|
||||||
streamDescQueueActiveCount = threadCount;
|
streamDescStackActiveCount = threadCount;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < threadCount; i++) {
|
for (uint32_t i = 0; i < threadCount; i++) {
|
||||||
streamThreads.push_back(std::make_unique<StreamThread>(this));
|
streamThreads.push_back(std::make_unique<StreamThread>(this));
|
||||||
@ -1141,10 +1141,10 @@ namespace RT64 {
|
|||||||
textureMap.replacementMap.streamRelativePathSet.insert(resolvedPath.relativePath);
|
textureMap.replacementMap.streamRelativePathSet.insert(resolvedPath.relativePath);
|
||||||
|
|
||||||
// Push to the streaming queue.
|
// Push to the streaming queue.
|
||||||
streamDescQueueMutex.lock();
|
streamDescStackMutex.lock();
|
||||||
streamDescQueue.push(StreamDescription(resolvedPath.relativePath, false));
|
streamDescStack.push(StreamDescription(resolvedPath.relativePath, false));
|
||||||
streamDescQueueMutex.unlock();
|
streamDescStackMutex.unlock();
|
||||||
streamDescQueueChanged.notify_all();
|
streamDescStackChanged.notify_all();
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -1491,18 +1491,18 @@ namespace RT64 {
|
|||||||
if (preloadTexturesWithThreads) {
|
if (preloadTexturesWithThreads) {
|
||||||
// Queue all textures that must be preloaded to the stream queues.
|
// Queue all textures that must be preloaded to the stream queues.
|
||||||
{
|
{
|
||||||
std::unique_lock queueLock(streamDescQueueMutex);
|
std::unique_lock queueLock(streamDescStackMutex);
|
||||||
for (uint64_t hash : hashesToPreload) {
|
for (uint64_t hash : hashesToPreload) {
|
||||||
auto it = textureMap.replacementMap.resolvedPathMap.find(hash);
|
auto it = textureMap.replacementMap.resolvedPathMap.find(hash);
|
||||||
const std::string &relativePath = it->second.relativePath;
|
const std::string &relativePath = it->second.relativePath;
|
||||||
if (textureMap.replacementMap.streamRelativePathSet.find(relativePath) == textureMap.replacementMap.streamRelativePathSet.end()) {
|
if (textureMap.replacementMap.streamRelativePathSet.find(relativePath) == textureMap.replacementMap.streamRelativePathSet.end()) {
|
||||||
streamDescQueue.push(StreamDescription(relativePath, true));
|
streamDescStack.push(StreamDescription(relativePath, true));
|
||||||
textureMap.replacementMap.streamRelativePathSet.insert(relativePath);
|
textureMap.replacementMap.streamRelativePathSet.insert(relativePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamDescQueueChanged.notify_all();
|
streamDescStackChanged.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preloadTexturesWithThreads) {
|
if (preloadTexturesWithThreads) {
|
||||||
@ -1609,15 +1609,15 @@ namespace RT64 {
|
|||||||
|
|
||||||
void TextureCache::waitForAllStreamThreads(bool clearQueueImmediately) {
|
void TextureCache::waitForAllStreamThreads(bool clearQueueImmediately) {
|
||||||
if (clearQueueImmediately) {
|
if (clearQueueImmediately) {
|
||||||
std::unique_lock<std::mutex> queueLock(streamDescQueueMutex);
|
std::unique_lock<std::mutex> queueLock(streamDescStackMutex);
|
||||||
streamDescQueue = std::queue<StreamDescription>();
|
streamDescStack = std::stack<StreamDescription>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool keepWaiting = false;
|
bool keepWaiting = false;
|
||||||
do {
|
do {
|
||||||
streamDescQueueMutex.lock();
|
streamDescStackMutex.lock();
|
||||||
keepWaiting = (streamDescQueueActiveCount > 0);
|
keepWaiting = (streamDescStackActiveCount > 0);
|
||||||
streamDescQueueMutex.unlock();
|
streamDescStackMutex.unlock();
|
||||||
|
|
||||||
if (keepWaiting) {
|
if (keepWaiting) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <stack>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@ -205,10 +205,10 @@ namespace RT64 {
|
|||||||
std::condition_variable uploadQueueFinished;
|
std::condition_variable uploadQueueFinished;
|
||||||
std::thread *uploadThread;
|
std::thread *uploadThread;
|
||||||
std::atomic<bool> uploadThreadRunning;
|
std::atomic<bool> uploadThreadRunning;
|
||||||
std::queue<StreamDescription> streamDescQueue;
|
std::stack<StreamDescription> streamDescStack;
|
||||||
std::mutex streamDescQueueMutex;
|
std::mutex streamDescStackMutex;
|
||||||
std::condition_variable streamDescQueueChanged;
|
std::condition_variable streamDescStackChanged;
|
||||||
int32_t streamDescQueueActiveCount = 0;
|
int32_t streamDescStackActiveCount = 0;
|
||||||
std::list<std::unique_ptr<StreamThread>> streamThreads;
|
std::list<std::unique_ptr<StreamThread>> streamThreads;
|
||||||
std::unordered_multimap<std::string, ReplacementCheck> streamPendingReplacementChecks;
|
std::unordered_multimap<std::string, ReplacementCheck> streamPendingReplacementChecks;
|
||||||
std::mutex streamPerformanceMutex;
|
std::mutex streamPerformanceMutex;
|
||||||
|
Loading…
Reference in New Issue
Block a user