mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Temporary fix for NVidia shaking on Windows
This commit is contained in:
parent
be851a3b45
commit
e9d08c33bd
|
@ -64,10 +64,11 @@ RingBufferPool::RingBufferPool(size_t _poolSize) :
|
||||||
PoolBufferPointer RingBufferPool::createPoolBuffer(const char* _buffer, size_t _bufferSize)
|
PoolBufferPointer RingBufferPool::createPoolBuffer(const char* _buffer, size_t _bufferSize)
|
||||||
{
|
{
|
||||||
size_t realBufferSize = _bufferSize;
|
size_t realBufferSize = _bufferSize;
|
||||||
const size_t remainder = _bufferSize % 4;
|
const int byteAlignment = 8;
|
||||||
|
const size_t remainder = _bufferSize % byteAlignment;
|
||||||
|
|
||||||
if (remainder != 0)
|
if (remainder != 0)
|
||||||
realBufferSize = _bufferSize + 4 - remainder;
|
realBufferSize = _bufferSize + byteAlignment - remainder;
|
||||||
|
|
||||||
const size_t tempInUseStart = m_inUseStartOffset;
|
const size_t tempInUseStart = m_inUseStartOffset;
|
||||||
|
|
||||||
|
@ -116,23 +117,29 @@ PoolBufferPointer RingBufferPool::createPoolBuffer(const char* _buffer, size_t _
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
size_t poolBufferSize = m_poolBuffer.size();
|
||||||
if (m_poolBuffer.size() < realBufferSize) {
|
if (m_poolBuffer.size() < realBufferSize) {
|
||||||
std::stringstream errorString;
|
std::stringstream logString;
|
||||||
errorString << " Increasing buffer size from " << m_poolBuffer.size() << " to " << realBufferSize;
|
logString << " Increasing buffer size from " << m_poolBuffer.size() << " to " << realBufferSize;
|
||||||
LOG(LOG_VERBOSE, errorString.str().c_str());
|
LOG(LOG_VERBOSE, logString.str().c_str());
|
||||||
|
poolBufferSize = realBufferSize;
|
||||||
m_poolBuffer.resize(realBufferSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_condition.wait(lock, [this, realBufferSize] {
|
m_condition.wait(lock, [this, realBufferSize, poolBufferSize] {
|
||||||
const size_t tempInUseStartLocal = m_inUseStartOffset;
|
const size_t tempInUseStartLocal = m_inUseStartOffset;
|
||||||
const size_t remainingLocal =
|
const size_t remainingLocal =
|
||||||
tempInUseStartLocal > m_inUseEndOffset || m_full ? static_cast<size_t>(
|
tempInUseStartLocal > m_inUseEndOffset || m_full ? static_cast<size_t>(
|
||||||
tempInUseStartLocal - m_inUseEndOffset) :
|
tempInUseStartLocal - m_inUseEndOffset) :
|
||||||
m_poolBuffer.size() - m_inUseEndOffset + tempInUseStartLocal;
|
poolBufferSize - m_inUseEndOffset + tempInUseStartLocal;
|
||||||
|
|
||||||
return remainingLocal >= realBufferSize;
|
return remainingLocal >= realBufferSize;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Resize afterwards, we don't want to lose the validity of pointers
|
||||||
|
// pointing at the old data
|
||||||
|
if (m_poolBuffer.size() < realBufferSize) {
|
||||||
|
m_poolBuffer.resize(realBufferSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return createPoolBuffer(_buffer, _bufferSize);
|
return createPoolBuffer(_buffer, _bufferSize);
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
std::atomic<bool> m_full;
|
std::atomic<bool> m_full;
|
||||||
std::condition_variable_any m_condition;
|
std::condition_variable_any m_condition;
|
||||||
size_t m_maxBufferPoolSize;
|
size_t m_maxBufferPoolSize;
|
||||||
static const size_t m_startBufferPoolSize = 1024 * 100;
|
static const size_t m_startBufferPoolSize = 1024 * 1024 * 10;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user