mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Fix linux build problems
This commit is contained in:
parent
57691d5d66
commit
cb336bdeab
2 changed files with 21 additions and 8 deletions
|
@ -317,7 +317,7 @@ inline QString getTestResource(const QString& relativePath) {
|
|||
return QDir::cleanPath(dir.absoluteFilePath(relativePath));
|
||||
}
|
||||
|
||||
inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) {
|
||||
inline bool afterUsecs(quint64& startUsecs, quint64 maxIntervalUecs) {
|
||||
auto now = usecTimestampNow();
|
||||
auto interval = now - startUsecs;
|
||||
if (interval > maxIntervalUecs) {
|
||||
|
@ -327,18 +327,18 @@ inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) {
|
|||
return false;
|
||||
}
|
||||
|
||||
inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) {
|
||||
inline bool afterSecs(quint64& startUsecs, quint64 maxIntervalSecs) {
|
||||
return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) {
|
||||
void doEvery(quint64& lastReportUsecs, quint64 secs, F lamdba) {
|
||||
if (afterSecs(lastReportUsecs, secs)) {
|
||||
lamdba();
|
||||
}
|
||||
}
|
||||
|
||||
inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) {
|
||||
inline void failAfter(quint64 startUsecs, quint64 secs, const char* message) {
|
||||
if (afterSecs(startUsecs, secs)) {
|
||||
QFAIL(message);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ void TextureTest::testTextureLoading() {
|
|||
auto lastReport = usecTimestampNow();
|
||||
auto start = usecTimestampNow();
|
||||
while (expectedAllocation != allocatedMemory) {
|
||||
reportEvery(lastReport, 4, reportLambda);
|
||||
doEvery(lastReport, 4, reportLambda);
|
||||
failAfter(start, 10, "Failed to allocate texture memory after 10 seconds");
|
||||
renderFrame(renderTexturesLamdba);
|
||||
allocatedMemory = gpu::Context::getTextureResourceGPUMemSize();
|
||||
|
@ -218,7 +218,7 @@ void TextureTest::testTextureLoading() {
|
|||
start = usecTimestampNow();
|
||||
// Cycle frames we're fully populated
|
||||
while (allocatedMemory != populatedMemory || 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) {
|
||||
reportEvery(lastReport, 4, reportLambda);
|
||||
doEvery(lastReport, 4, reportLambda);
|
||||
failAfter(start, 10, "Failed to populate texture memory after 10 seconds");
|
||||
renderFrame();
|
||||
allocatedMemory = gpu::Context::getTextureResourceGPUMemSize();
|
||||
|
@ -240,7 +240,7 @@ void TextureTest::testTextureLoading() {
|
|||
start = usecTimestampNow();
|
||||
// Cycle frames until the allocated memory is below the max memory
|
||||
while (allocatedMemory > maxMemory || allocatedMemory != populatedMemory) {
|
||||
reportEvery(lastReport, 4, reportLambda);
|
||||
doEvery(lastReport, 4, reportLambda);
|
||||
failAfter(start, 10, "Failed to deallocate texture memory after 10 seconds");
|
||||
renderFrame(renderTexturesLamdba);
|
||||
allocatedMemory = gpu::Context::getTextureResourceGPUMemSize();
|
||||
|
@ -259,7 +259,7 @@ void TextureTest::testTextureLoading() {
|
|||
gpu::Texture::setAllowedGPUMemoryUsage(0);
|
||||
// Cycle frames we're fully populated
|
||||
while (allocatedMemory != expectedAllocation || allocatedMemory != populatedMemory) {
|
||||
reportEvery(lastReport, 4, reportLambda);
|
||||
doEvery(lastReport, 4, reportLambda);
|
||||
failAfter(start, 10, "Failed to populate texture memory after 10 seconds");
|
||||
renderFrame();
|
||||
allocatedMemory = gpu::Context::getTextureResourceGPUMemSize();
|
||||
|
@ -268,4 +268,17 @@ void TextureTest::testTextureLoading() {
|
|||
reportLambda();
|
||||
QCOMPARE(allocatedMemory, expectedAllocation);
|
||||
QCOMPARE(populatedMemory, allocatedMemory);
|
||||
|
||||
_textures.clear();
|
||||
// Cycle frames we're fully populated
|
||||
while (allocatedMemory != 0) {
|
||||
failAfter(start, 10, "Failed to clear texture memory after 10 seconds");
|
||||
renderFrame();
|
||||
allocatedMemory = gpu::Context::getTextureResourceGPUMemSize();
|
||||
populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize();
|
||||
}
|
||||
QCOMPARE(allocatedMemory, 0);
|
||||
QCOMPARE(populatedMemory, 0);
|
||||
qDebug() << "Done";
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue