Commit c42b2200 by Ben Clayton

SpirvShader: Use an atomic instead of a volatile int for serialCounter

Using 'volatile' does not make anything thread safe. Shuts up a bunch of TSAN errors. Bug: b/133127573 Change-Id: I90b708ac53824de91c316f61f137ecca34087047 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31830 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent bc0cbb97
...@@ -367,7 +367,7 @@ namespace sw ...@@ -367,7 +367,7 @@ namespace sw
} // namespace SIMD } // namespace SIMD
volatile int SpirvShader::serialCounter = 1; // Start at 1, 0 is invalid shader. std::atomic<int> SpirvShader::serialCounter(1); // Start at 1, 0 is invalid shader.
SpirvShader::SpirvShader( SpirvShader::SpirvShader(
VkPipelineShaderStageCreateInfo const *createInfo, VkPipelineShaderStageCreateInfo const *createInfo,
......
...@@ -29,16 +29,17 @@ ...@@ -29,16 +29,17 @@
#include <spirv/unified1/spirv.hpp> #include <spirv/unified1/spirv.hpp>
#include <array> #include <array>
#include <atomic>
#include <cstdint>
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <type_traits>
#include <memory> #include <memory>
#include <queue> #include <queue>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace vk namespace vk
{ {
...@@ -730,7 +731,7 @@ namespace sw ...@@ -730,7 +731,7 @@ namespace sw
private: private:
const int serialID; const int serialID;
static volatile int serialCounter; static std::atomic<int> serialCounter;
Modes modes; Modes modes;
HandleMap<Type> types; HandleMap<Type> types;
HandleMap<Object> defs; HandleMap<Object> defs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment