From 8ebdc303945afff179021dce558738174e365252 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 6 Mar 2013 17:29:22 -0500 Subject: [PATCH] Add Yield function to global namespace In order to develop a threadsafe texture compression function, we will need to preempt threads in order to not kill performance while we initialzie everything... --- Core/include/TexComp.h | 4 ++++ Core/src/TexComp.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Core/include/TexComp.h b/Core/include/TexComp.h index 222fa52..5d1b2cc 100644 --- a/Core/include/TexComp.h +++ b/Core/include/TexComp.h @@ -121,4 +121,8 @@ typedef void (* CompressionFuncWithStats)( // compressed image and a raw image. extern double ComputePSNR(const CompressedImage &ci, const ImageFile &file); +// This is a multi-platform yield function that preempts the current thread +// based on the threading library that we're using. +extern void YieldThread(); + #endif //_TEX_COMP_H_ diff --git a/Core/src/TexComp.cpp b/Core/src/TexComp.cpp index 030ee81..7cd4ca9 100644 --- a/Core/src/TexComp.cpp +++ b/Core/src/TexComp.cpp @@ -49,6 +49,7 @@ #include #include "BC7Compressor.h" +#include "Thread.h" #include "WorkerQueue.h" #include "ThreadGroup.h" @@ -322,3 +323,7 @@ bool CompressImageData( return true; } + +void YieldThread() { + TCThread::Yield(); +}