Merge pull request #247 from dneto0/no-mutex
Remove use of std::mutex in gtest code.
This commit is contained in:
commit
d6abcee1fc
@ -35,8 +35,6 @@
|
|||||||
#ifndef GLSLANG_GTESTS_INITIALIZER_H
|
#ifndef GLSLANG_GTESTS_INITIALIZER_H
|
||||||
#define GLSLANG_GTESTS_INITIALIZER_H
|
#define GLSLANG_GTESTS_INITIALIZER_H
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "glslang/Public/ShaderLang.h"
|
#include "glslang/Public/ShaderLang.h"
|
||||||
|
|
||||||
namespace glslangtest {
|
namespace glslangtest {
|
||||||
@ -63,55 +61,25 @@ public:
|
|||||||
// A token indicates that the glslang is reinitialized (if necessary) to the
|
// A token indicates that the glslang is reinitialized (if necessary) to the
|
||||||
// required semantics. And that won't change until the token is destroyed.
|
// required semantics. And that won't change until the token is destroyed.
|
||||||
class InitializationToken {
|
class InitializationToken {
|
||||||
public:
|
|
||||||
InitializationToken() : initializer(nullptr) {}
|
|
||||||
~InitializationToken()
|
|
||||||
{
|
|
||||||
if (initializer) {
|
|
||||||
initializer->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializationToken(InitializationToken&& other)
|
|
||||||
: initializer(other.initializer)
|
|
||||||
{
|
|
||||||
other.initializer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializationToken(const InitializationToken&) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InitializationToken(GlslangInitializer* initializer)
|
|
||||||
: initializer(initializer) {}
|
|
||||||
|
|
||||||
friend class GlslangInitializer;
|
|
||||||
GlslangInitializer* initializer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Obtains exclusive access to the glslang state. The state remains
|
|
||||||
// exclusive until the Initialization Token has been destroyed.
|
|
||||||
// Re-initializes glsl state iff the previous messages and the current
|
// Re-initializes glsl state iff the previous messages and the current
|
||||||
// messages are incompatible.
|
// messages are incompatible. We assume external synchronization, i.e.
|
||||||
|
// there is at most one acquired token at any one time.
|
||||||
InitializationToken acquire(EShMessages new_messages)
|
InitializationToken acquire(EShMessages new_messages)
|
||||||
{
|
{
|
||||||
stateLock.lock();
|
|
||||||
|
|
||||||
if ((lastMessages ^ new_messages) &
|
if ((lastMessages ^ new_messages) &
|
||||||
(EShMsgVulkanRules | EShMsgSpvRules)) {
|
(EShMsgVulkanRules | EShMsgSpvRules)) {
|
||||||
glslang::FinalizeProcess();
|
glslang::FinalizeProcess();
|
||||||
glslang::InitializeProcess();
|
glslang::InitializeProcess();
|
||||||
}
|
}
|
||||||
lastMessages = new_messages;
|
lastMessages = new_messages;
|
||||||
return InitializationToken(this);
|
return InitializationToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void release() { stateLock.unlock(); }
|
|
||||||
|
|
||||||
friend class InitializationToken;
|
|
||||||
|
|
||||||
EShMessages lastMessages;
|
EShMessages lastMessages;
|
||||||
std::mutex stateLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace glslangtest
|
} // namespace glslangtest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user