summarylogtreecommitdiffstats
path: root/tbb.patch
blob: 5ef25e685fff32dd377f0f4f94a4248c95e44053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
diff --git a/moonray/moonray/dso/map/Image/ImageMap.cc b/moonray/moonray/dso/map/Image/ImageMap.cc
index 82a5556..4e48964 100644
--- a/moonray/moonray/dso/map/Image/ImageMap.cc
+++ b/moonray/moonray/dso/map/Image/ImageMap.cc
@@ -84,8 +84,8 @@ ImageMap::ImageMap(const scene_rdl2::rdl2::SceneClass &sceneClass, const std::st
     // to allow for the possibility that we may someday create these maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::scoped_lock lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticImageMapData.sErrorInvalidUdimCoord =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonray/dso/map/UsdUVTexture/UsdUVTexture.cc b/moonray/moonray/dso/map/UsdUVTexture/UsdUVTexture.cc
index c652bcb..dc615f3 100644
--- a/moonray/moonray/dso/map/UsdUVTexture/UsdUVTexture.cc
+++ b/moonray/moonray/dso/map/UsdUVTexture/UsdUVTexture.cc
@@ -53,8 +53,8 @@ UsdUVTexture::UsdUVTexture(const scene_rdl2::rdl2::SceneClass &sceneClass, const
     // to allow for the possibility that we may someday create these maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::scoped_lock lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticUsdUVTextureData.sErrorInvalidUdimCoord =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonray/lib/common/mcrt_util/MutexPool2D.h b/moonray/moonray/lib/common/mcrt_util/MutexPool2D.h
index 54eac61..af3a33b 100644
--- a/moonray/moonray/lib/common/mcrt_util/MutexPool2D.h
+++ b/moonray/moonray/lib/common/mcrt_util/MutexPool2D.h
@@ -8,8 +8,6 @@
 #include <scene_rdl2/common/platform/Platform.h>
 #include <scene_rdl2/render/util/BitUtils.h>

-#include <tbb/mutex.h>
-
 namespace moonray {
     constexpr int getMutexCount(int log2MutexCount)
     {
@@ -55,7 +53,7 @@ namespace moonray {
     }
 #endif

-    template <int sLog2MutexCount, typename MutexType = tbb::mutex>
+    template <int sLog2MutexCount, typename MutexType = std::mutex>
     class MutexPool2D
     {
     public:
diff --git a/moonray/moonray/lib/common/mcrt_util/ProcessStats.h b/moonray/moonray/lib/common/mcrt_util/ProcessStats.h
index 20202f2..d3bf528 100644
--- a/moonray/moonray/lib/common/mcrt_util/ProcessStats.h
+++ b/moonray/moonray/lib/common/mcrt_util/ProcessStats.h
@@ -8,12 +8,11 @@
 #include <scene_rdl2/common/platform/Platform.h>
 #include <scene_rdl2/render/logging/logging.h>

-#include <tbb/mutex.h>
-
 #include <fstream>
 #include <iomanip>
 #include <iostream>
 #include <string>
+#include <mutex>

 namespace moonray {
 namespace util {
@@ -49,9 +48,9 @@ private:
     // ifstream mutex to prevent corrupt reads
     // when we are getting log messages from
     // threaded sections of code
-    mutable tbb::mutex mMemoryReadMutex;
-    mutable tbb::mutex mReadIOMutex;
-    mutable tbb::mutex mSystemUtilMutex;
+    mutable std::mutex mMemoryReadMutex;
+    mutable std::mutex mReadIOMutex;
+    mutable std::mutex mSystemUtilMutex;

 };

diff --git a/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.cc b/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.cc
index d86098b..a497252 100644
--- a/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.cc
+++ b/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.cc
@@ -8,7 +8,7 @@ using namespace scene_rdl2;
 namespace moonray {
 namespace shading {

-tbb::mutex AttributeKey::sRegisterMutex;
+std::mutex AttributeKey::sRegisterMutex;
 std::vector<std::string> AttributeKey::sKeyNames;
 std::vector<AttributeType> AttributeKey::sKeyTypes;
 std::vector<size_t> AttributeKey::sKeySizes;
diff --git a/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.h b/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.h
index 2cbd271..6d29a0c 100644
--- a/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.h
+++ b/moonray/moonray/lib/rendering/bvh/shading/AttributeKey.h
@@ -9,7 +9,6 @@
 #pragma once

 #include <scene_rdl2/scene/rdl2/Types.h>
-#include <tbb/mutex.h>
 #include <unordered_set>
 #include <map>

@@ -87,7 +86,7 @@ protected:
     static finline bool hasDerivatives(AttributeKey key);

 private:
-    static tbb::mutex sRegisterMutex;
+    static std::mutex sRegisterMutex;
     static std::vector<std::string> sKeyNames;
     static std::vector<AttributeType> sKeyTypes;
     static std::vector<size_t> sKeySizes;
@@ -269,7 +268,7 @@ AttributeKey::requestDerivatives() const
         return false;
     }
     {
-        tbb::mutex::scoped_lock lock(sRegisterMutex);
+        std::scoped_lock lock(sRegisterMutex);
         sHasDerivatives[mIndex] = 1;
     }
     return true;
@@ -302,7 +301,7 @@ AttributeKey::insertKey(const std::string &name, bool requestDerivatives)
     std::pair<std::string, AttributeType> lookup(name, type);
     int index = -1;
     {
-        tbb::mutex::scoped_lock lock(sRegisterMutex);
+        std::scoped_lock lock(sRegisterMutex);
         auto it = sTable.find(lookup);
         if (it == sTable.end()) {
             index = static_cast<int>(sKeyNames.size());
diff --git a/moonray/moonray/lib/rendering/bvh/shading/ShadingTLState.cc b/moonray/moonray/lib/rendering/bvh/shading/ShadingTLState.cc
index 1aaa1ad..cc51886 100644
--- a/moonray/moonray/lib/rendering/bvh/shading/ShadingTLState.cc
+++ b/moonray/moonray/lib/rendering/bvh/shading/ShadingTLState.cc
@@ -3,7 +3,6 @@

 #include "ShadingTLState.h"
 #include <moonray/common/mcrt_macros/moonray_static_check.h>
-#include <tbb/mutex.h>

 namespace ispc {
 extern "C" uint32_t ShadingTLState_hudValidation(bool);
@@ -33,7 +32,7 @@ struct Private
 };

 Private gPrivate;
-tbb::mutex gInitMutex;
+std::mutex gInitMutex;

 void
 initPrivate(const mcrt_common::TLSInitParams &initParams)
@@ -71,7 +70,7 @@ TLState::~TLState()

     {
         // Protect against races the during gPrivate clean up.
-        //tbb::mutex::scoped_lock lock(gInitMutex);
+        //std::scoped_lock lock(gInitMutex);

         MOONRAY_THREADSAFE_STATIC_WRITE(--gPrivate.mRefCount);
         if (gPrivate.mRefCount == 0) {
@@ -97,7 +96,7 @@ TLState::allocTls(mcrt_common::ThreadLocalState *tls,
 {
     {
         // Protect against races the very first time we initialize gPrivate.
-        tbb::mutex::scoped_lock lock(gInitMutex);
+        std::scoped_lock lock(gInitMutex);

         if (gPrivate.mRefCount == 0) {
             texture::TLState::initPrivate(initParams);
diff --git a/moonray/moonray/lib/rendering/geom/Procedural.cc b/moonray/moonray/lib/rendering/geom/Procedural.cc
index 1ed000e..05d1003 100644
--- a/moonray/moonray/lib/rendering/geom/Procedural.cc
+++ b/moonray/moonray/lib/rendering/geom/Procedural.cc
@@ -14,7 +14,7 @@
 #include <moonray/rendering/geom/PrimitiveGroup.h>
 #include <moonray/rendering/geom/PrimitiveVisitor.h>

-#include <tbb/atomic.h>
+#include <atomic>

 #include <numeric>

@@ -25,7 +25,7 @@ class PrimitiveMemoryAccumulator : public PrimitiveVisitor
 {
 public:
     PrimitiveMemoryAccumulator(
-            tbb::atomic<Primitive::size_type>& usage,
+            std::atomic<Primitive::size_type>& usage,
             SharedPrimitiveSet& sharedPrimitives,
             bool inPrimitiveGroup = false) :
         mUsage(usage), mSharedPrimitives(sharedPrimitives),
@@ -63,7 +63,7 @@ public:
     }

 private:
-    tbb::atomic<Primitive::size_type>& mUsage;
+    std::atomic<Primitive::size_type>& mUsage;
     SharedPrimitiveSet& mSharedPrimitives;
     bool mInPrimitiveGroup;
 };
@@ -123,7 +123,7 @@ private:
 Procedural::size_type
 Procedural::getMemory()
 {
-    tbb::atomic<Primitive::size_type> usage {0u};
+    std::atomic<Primitive::size_type> usage {0u};
     SharedPrimitiveSet sharedPrimitives;
     PrimitiveMemoryAccumulator accumulator(usage, sharedPrimitives);
     forEachPrimitive(accumulator);
@@ -138,8 +138,6 @@ Procedural::getStatistics() const
     SharedPrimitiveSet sharedPrimitives;
     StatisticsAccumulator accumulator(geometryStatistics, sharedPrimitives);
     const_cast<Procedural *>(this)->forEachPrimitive(accumulator);
-
-    return geometryStatistics;
 }


diff --git a/moonray/moonray/lib/rendering/geom/Procedural.h b/moonray/moonray/lib/rendering/geom/Procedural.h
index 54c8ec7..b57007d 100644
--- a/moonray/moonray/lib/rendering/geom/Procedural.h
+++ b/moonray/moonray/lib/rendering/geom/Procedural.h
@@ -30,11 +30,18 @@ struct GeometryStatistics {
     GeometryStatistics(): mFaceCount {0}, mMeshVertexCount {0},
         mCurvesCount {0}, mCVCount {0}, mInstanceCount {0} {}

-    tbb::atomic<Primitive::size_type> mFaceCount;
-    tbb::atomic<Primitive::size_type> mMeshVertexCount;
-    tbb::atomic<Primitive::size_type> mCurvesCount;
-    tbb::atomic<Primitive::size_type> mCVCount;
-    tbb::atomic<Primitive::size_type> mInstanceCount;
+    GeometryStatistics(const GeometryStatistics &other):
+        mFaceCount(other.mFaceCount.load()),
+        mMeshVertexCount(other.mMeshVertexCount.load()),
+        mCurvesCount(other.mCurvesCount.load()),
+        mCVCount(other.mCVCount.load()),
+        mInstanceCount(other.mInstanceCount.load()) {}
+
+    std::atomic<Primitive::size_type> mFaceCount;
+    std::atomic<Primitive::size_type> mMeshVertexCount;
+    std::atomic<Primitive::size_type> mCurvesCount;
+    std::atomic<Primitive::size_type> mCVCount;
+    std::atomic<Primitive::size_type> mInstanceCount;
 };

 //----------------------------------------------------------------------------
diff --git a/moonray/moonray/lib/rendering/mcrt_common/Bundle.h b/moonray/moonray/lib/rendering/mcrt_common/Bundle.h
index b5402a5..37761a7 100644
--- a/moonray/moonray/lib/rendering/mcrt_common/Bundle.h
+++ b/moonray/moonray/lib/rendering/mcrt_common/Bundle.h
@@ -210,7 +210,7 @@ protected:
         return unsigned(entriesToFlush);
     }

-    tbb::atomic<uint32_t>   mQueueSize;   // must not exceed mMaxEntries
+    std::atomic<uint32_t>   mQueueSize;   // must not exceed mMaxEntries
     uint32_t                mMaxEntries;
     EntryType *             mEntries;     // all data offsets are relative to this address
     Handler                 mHandler;
@@ -502,7 +502,7 @@ protected:
         return unsigned(entriesToFlush);
     }

-    tbb::atomic<uint32_t>   mQueueSize;   // must not exceed mMaxEntries
+    std::atomic<uint32_t>   mQueueSize;   // must not exceed mMaxEntries
     uint32_t                mMaxEntries;
     EntryType *             mEntries;     // all data offsets are relative to this address
     Handler                 mHandler;
@@ -788,7 +788,7 @@ protected:
         return unsigned(entriesToFlush);
     }

-    tbb::atomic<uint32_t>       mQueueSize;   // must not exceed mMaxEntries
+    std::atomic<uint32_t>       mQueueSize;   // must not exceed mMaxEntries
     uint32_t                    mMaxEntries;
     EntryType *                 mEntries;     // all data offsets are relative to this address
     Handler                     mHandler;
diff --git a/moonray/moonray/lib/rendering/mcrt_common/ThreadLocalState.cc b/moonray/moonray/lib/rendering/mcrt_common/ThreadLocalState.cc
index 941607f..5307c4e 100644
--- a/moonray/moonray/lib/rendering/mcrt_common/ThreadLocalState.cc
+++ b/moonray/moonray/lib/rendering/mcrt_common/ThreadLocalState.cc
@@ -10,7 +10,7 @@
 #include <scene_rdl2/render/logging/logging.h>
 #include <scene_rdl2/render/util/Memory.h>
 #include <tbb/enumerable_thread_specific.h>
-#include <tbb/task_scheduler_init.h>
+#include <thread>

 // There are on average 3 entries added to the profiler stack for each single
 // entry on the handler stack. This heuristic is used to compute the
@@ -42,7 +42,7 @@ namespace
 {

 // Counter to hand out unique indices to TLSProxy objects.
-tbb::atomic<unsigned> gNextFrameUpdateTLSIndex;
+std::atomic<unsigned> gNextFrameUpdateTLSIndex;

 // These are lightweight objects which we put into a tbb::enumerable_thread_specific
 // container so that we can map OS thread ids to consistent top level ThreadLocalState
@@ -50,7 +50,7 @@ tbb::atomic<unsigned> gNextFrameUpdateTLSIndex;
 struct FrameUpdateTLSProxy
 {
     FrameUpdateTLSProxy() :
-        mTLSIndex(gNextFrameUpdateTLSIndex.fetch_and_increment())
+        mTLSIndex(gNextFrameUpdateTLSIndex++)
     {
     }

@@ -288,7 +288,7 @@ initTLS(const TLSInitParams &initParams)
     gPrivate.mInitParams = initParams;

     if (gPrivate.mInitParams.mDesiredNumTBBThreads == 0) {
-        gPrivate.mInitParams.mDesiredNumTBBThreads = tbb::task_scheduler_init::default_num_threads();
+        gPrivate.mInitParams.mDesiredNumTBBThreads = std::thread::hardware_concurrency();
     }

     MNRY_ASSERT_REQUIRE(gPrivate.mInitParams.mDesiredNumTBBThreads);
diff --git a/moonray/moonray/lib/rendering/mcrt_common/Util.cc b/moonray/moonray/lib/rendering/mcrt_common/Util.cc
index 39d43fb..ac4b995 100644
--- a/moonray/moonray/lib/rendering/mcrt_common/Util.cc
+++ b/moonray/moonray/lib/rendering/mcrt_common/Util.cc
@@ -4,9 +4,8 @@
 //
 #include "Util.h"
 #include <execinfo.h>  // backtrace
-#include <tbb/mutex.h>
 #include <sys/syscall.h>
-
+#include <mutex>
 #include <cstring>

 namespace moonray {
@@ -21,7 +20,7 @@ threadSleep()
 void
 threadYield()
 {
-    __TBB_Yield();
+    sched_yield();
 }

 void
@@ -38,7 +37,7 @@ debugPrintThreadID(const char *contextString)
 void
 debugPrintCallstack(const char *contextString)
 {
-    static tbb::mutex mutex;
+    static std::mutex mutex;

     mutex.lock();

diff --git a/moonray/moonray/lib/rendering/pbr/Types.h b/moonray/moonray/lib/rendering/pbr/Types.h
index 4a1e4cf..09662cd 100644
--- a/moonray/moonray/lib/rendering/pbr/Types.h
+++ b/moonray/moonray/lib/rendering/pbr/Types.h
@@ -12,7 +12,6 @@
 #include <scene_rdl2/common/math/Vec3.h>
 #include <scene_rdl2/common/math/Vec4.h>

-#include <tbb/atomic.h>
 #include <vector>


diff --git a/moonray/moonray/lib/rendering/pbr/Types.hh b/moonray/moonray/lib/rendering/pbr/Types.hh
index 0a6c453..bd7b72f 100644
--- a/moonray/moonray/lib/rendering/pbr/Types.hh
+++ b/moonray/moonray/lib/rendering/pbr/Types.hh
@@ -155,7 +155,7 @@ enum OcclTestType


 #define DEEP_DATA_MEMBERS                                               \
-    HUD_CPP_MEMBER(tbb::atomic<int>, mRefCount, 4);                     \
+    HUD_CPP_MEMBER(std::atomic<int>, mRefCount, 4);                     \
     HUD_MEMBER(uint32_t, mHitDeep);                                     \
     HUD_MEMBER(float, mSubpixelX);                                      \
     HUD_MEMBER(float, mSubpixelY);                                      \
@@ -182,7 +182,7 @@ enum OcclTestType


 #define CRYPTOMATTE_DATA_MEMBERS                                    \
-    HUD_CPP_MEMBER(tbb::atomic<int>, mRefCount, 4);                 \
+    HUD_CPP_MEMBER(std::atomic<int>, mRefCount, 4);                 \
     HUD_CPP_PTR(pbr::CryptomatteBuffer*, mCryptomatteBuffer);       \
     HUD_MEMBER(uint32_t, mHit);                                     \
     HUD_MEMBER(uint32_t, mPrevPresence);                            \
@@ -211,7 +211,7 @@ enum OcclTestType
 // bytes in size due to them being allocated as one cache line.

 #define CRYPTOMATTE_DATA_MEMBERS_2                                  \
-    HUD_CPP_MEMBER(tbb::atomic<int>, mRefCount, 4);                 \
+    HUD_CPP_MEMBER(std::atomic<int>, mRefCount, 4);                 \
     HUD_MEMBER(HVD_NAMESPACE(scene_rdl2::math, Vec3f), mRefP);      \
     HUD_MEMBER(HVD_NAMESPACE(scene_rdl2::math, Vec3f), mRefN);      \
     HUD_MEMBER(HVD_NAMESPACE(scene_rdl2::math, Vec2f), mUV)
diff --git a/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.cc b/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.cc
index 739ec3a..9305031 100644
--- a/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.cc
+++ b/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.cc
@@ -96,7 +96,7 @@ void CryptomatteBuffer::addSampleVector(unsigned x, unsigned y, float sampleId,
                                         bool incrementSamples)
 {
     // Lock in case multiple threads want to add samples to this pixel
-    tbb::mutex::scoped_lock lock(mPixelMutexes[getMutexIdx(x, y)]);
+    std::scoped_lock lock(mPixelMutexes[getMutexIdx(x, y)]);

     PixelEntry &pixelEntry = mPixelEntries[CRYPTOMATTE_TYPE_REGULAR][y * mWidth + x];

diff --git a/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.h b/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.h
index 4cbe45c..943b9d2 100644
--- a/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.h
+++ b/moonray/moonray/lib/rendering/pbr/core/Cryptomatte.h
@@ -9,7 +9,6 @@
 #include <scene_rdl2/scene/rdl2/RenderOutput.h>

 #include <list>
-#include <tbb/mutex.h>
 #include <vector>

 namespace moonray {
@@ -202,7 +201,7 @@ private:
  */
     static const int mMutexTileSize = 15;
     // force mutex to be cache-line aligned for speed
-    struct CACHE_ALIGN AlignedMutex : public tbb::mutex {};
+    struct CACHE_ALIGN AlignedMutex : public std::mutex {};
     AlignedMutex *mPixelMutexes;
     int getMutexIdx(unsigned x, unsigned y) const {
         return (y % mMutexTileSize) * mMutexTileSize + (x % mMutexTileSize);
diff --git a/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.cc b/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.cc
index 52043d0..9ce2b85 100644
--- a/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.cc
+++ b/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.cc
@@ -351,7 +351,7 @@ DeepBuffer::addSample8x8Safe(unsigned x, unsigned y, unsigned subpixelX, unsigne
                              float scale, float weight)
 {
     // Lock in case multiple threads want to add samples to this pixel
-    tbb::mutex::scoped_lock lock(mPixelMutex[getMutexIdx(x, y)]);
+    std::scoped_lock lock(mPixelMutex[getMutexIdx(x, y)]);

     addSample8x8(x, y, subpixelX, subpixelY, layer, ids, t, rayZ, normal, alpha,
                  channels, numChannels, values, scale, weight);
diff --git a/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.h b/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.h
index b8372f8..536423f 100644
--- a/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.h
+++ b/moonray/moonray/lib/rendering/pbr/core/DeepBuffer.h
@@ -13,7 +13,6 @@
 #include <moonray/deepfile/DcxChannelSet.h>
 #include <moonray/deepfile/DcxDeepImageTile.h>
 #include <OpenEXR/ImfHeader.h>
-#include <tbb/mutex.h>

 namespace moonray {

@@ -420,7 +419,7 @@ private:
  */
     static const int mMutexTileSize = 15;
     // force mutex to be cache-line aligned for speed
-    struct CACHE_ALIGN AlignedMutex : public tbb::mutex {};
+    struct CACHE_ALIGN AlignedMutex : public std::mutex {};
     AlignedMutex *mPixelMutex;
     int getMutexIdx(unsigned x, unsigned y) const {
         return (y % mMutexTileSize) * mMutexTileSize + (x % mMutexTileSize);
diff --git a/moonray/moonray/lib/rendering/pbr/core/PbrTLState.cc b/moonray/moonray/lib/rendering/pbr/core/PbrTLState.cc
index 5281335..b828a2e 100644
--- a/moonray/moonray/lib/rendering/pbr/core/PbrTLState.cc
+++ b/moonray/moonray/lib/rendering/pbr/core/PbrTLState.cc
@@ -10,7 +10,6 @@
 #include <moonray/rendering/pbr/handlers/RayHandlers.h>
 #include <moonray/rendering/shading/Types.h>
 #include <moonray/common/mcrt_macros/moonray_static_check.h>
-#include <tbb/mutex.h>

 // These aren't free so only turn it on if you are doing memory profiling.
 // This will print out the peak number of pool items used for a particular run.
@@ -58,8 +57,8 @@ MNRY_STATIC_ASSERT(ALLOC_LIST_MAX_NUM_ITEMS <=
                   ((ALLOC_LIST_INFO_BITS >> ALLOC_LIST_INFO_BIT_SHIFT) + 1));

 // Per frame counter, gets reset each frame.
-CACHE_ALIGN tbb::atomic<unsigned> gFailedRayStateAllocs;
-CACHE_ALIGN tbb::atomic<unsigned> gFailedCL1Allocs;
+CACHE_ALIGN std::atomic<unsigned> gFailedRayStateAllocs;
+CACHE_ALIGN std::atomic<unsigned> gFailedCL1Allocs;

 // For memory profiling, see DEBUG_RECORD_PEAK_RAYSTATE_USAGE.
 unsigned MAYBE_UNUSED gPeakRayStateUsage = 0;
@@ -100,7 +99,7 @@ struct Private
 };

 Private gPrivate;
-tbb::mutex gInitMutex;
+std::mutex gInitMutex;

 void
 initPool(const unsigned poolSize, const unsigned numTBBThreads,
@@ -357,7 +356,7 @@ TLState::~TLState()

     {
         // Protect against races the during gPrivate clean up.
-        tbb::mutex::scoped_lock lock(gInitMutex);
+        std::scoped_lock lock(gInitMutex);

         MOONRAY_THREADSAFE_STATIC_WRITE(--gPrivate.mRefCount);
         if (gPrivate.mRefCount == 0) {
@@ -416,7 +415,7 @@ TLState::poolAlloc(const char * const typeName,
                    unsigned numEntries,
                    ResType **entries,
                    OverlappedAccType accumStall,
-                   tbb::atomic<unsigned> &numFailedAllocs)
+                   std::atomic<unsigned> &numFailedAllocs)
 {
     // 99.9999% case, allocation should succeed.
     bool success = pool.allocList(numEntries, entries);
@@ -883,7 +882,7 @@ TLState::allocTls(mcrt_common::ThreadLocalState *tls,
 {
     {
         // Protect against races the very first time we initialize gPrivate.
-        tbb::mutex::scoped_lock lock(gInitMutex);
+        std::scoped_lock lock(gInitMutex);

         if (gPrivate.mRefCount == 0) {
             initPrivate(initParams);
diff --git a/moonray/moonray/lib/rendering/pbr/core/PbrTLState.h b/moonray/moonray/lib/rendering/pbr/core/PbrTLState.h
index 12a8a95..4eb7354 100644
--- a/moonray/moonray/lib/rendering/pbr/core/PbrTLState.h
+++ b/moonray/moonray/lib/rendering/pbr/core/PbrTLState.h
@@ -196,7 +196,7 @@ private:
                            unsigned numEntries,
                            ResType **entries,
                            OverlappedAccType accumStall,
-                           tbb::atomic<unsigned> &numFailedAlloc);
+                           std::atomic<unsigned> &numFailedAlloc);

     DISALLOW_COPY_OR_ASSIGNMENT(TLState);
 };
diff --git a/moonray/moonray/lib/rendering/rndr/Film.h b/moonray/moonray/lib/rendering/rndr/Film.h
index e4c5623..1f792d0 100644
--- a/moonray/moonray/lib/rendering/rndr/Film.h
+++ b/moonray/moonray/lib/rendering/rndr/Film.h
@@ -213,7 +213,7 @@ public:
     // updating statistics in vector mode.
     void addSampleStatisticsSafe(unsigned px, unsigned py, std::size_t idx, const float* aovs)
     {
-        tbb::mutex::scoped_lock lock(mStatsMutex.getMutex(px, py));
+        std::scoped_lock lock(mStatsMutex.getMutex(px, py));
         addSampleStatistics(px, py, idx, aovs);
     }

diff --git a/moonray/moonray/lib/rendering/rndr/RenderContext.cc b/moonray/moonray/lib/rendering/rndr/RenderContext.cc
index 42020a1..b842960 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderContext.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderContext.cc
@@ -1507,7 +1507,7 @@ RenderContext::runDisplayFiltersBatch() const
     }
     snapshotAovsForDisplayFilters(true, true);
     simpleLoop (/*parallel*/ true, 0u, (unsigned)mDriver->getTiles()->size(), [&](unsigned tileIdx) {
-        int threadId = tbb::task_arena::current_thread_index();
+        int threadId = tbb::this_task_arena::current_thread_index();
         displayFilterDriver.runDisplayFilters(tileIdx, threadId);
     });
 }
diff --git a/moonray/moonray/lib/rendering/rndr/RenderDriver.cc b/moonray/moonray/lib/rendering/rndr/RenderDriver.cc
index 81b4ec7..70885b5 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderDriver.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderDriver.cc
@@ -548,7 +548,7 @@ RenderDriver::RenderDriver(const TLSInitParams &initParams) :
     MNRY_ASSERT(tlsInitParams.mArenaBlockPool);

     if (tlsInitParams.mDesiredNumTBBThreads == 0) {
-        tlsInitParams.mDesiredNumTBBThreads = tbb::task_scheduler_init::default_num_threads();
+        tlsInitParams.mDesiredNumTBBThreads = std::thread::hardware_concurrency();
     }

 #ifdef FORCE_SINGLE_THREADED_RENDERING
@@ -565,7 +565,7 @@ RenderDriver::RenderDriver(const TLSInitParams &initParams) :
     // building phase to that specified in the TLSInitParams. The second allows
     // the render thread to take part in the rendering phase and ensures a TLS
     // is created for it.
-    mTaskScheduler = new tbb::task_scheduler_init(int(tlsInitParams.mDesiredNumTBBThreads));
+    mTaskScheduler = new tbb::global_control(tbb::global_control::max_allowed_parallelism, int(tlsInitParams.mDesiredNumTBBThreads));

     mFilms = alignedMallocArrayCtor<Film>(mNumFilmsAllocated, CACHE_LINE_SIZE);

@@ -620,7 +620,6 @@ RenderDriver::~RenderDriver()
     // when building this library, and also to make sure that no other
     // tbb::task_scheduler_init or other higher-level task scheduler objects
     // (i.e. tbb::task_group, etc.) are active in the process.
-    MNRY_VERIFY(mTaskScheduler)->terminate();
     delete mTaskScheduler;

     cleanUpTLS();
@@ -2426,7 +2425,7 @@ RenderDriver::renderThread(RenderDriver *driver,
     // task scheduler used for rendering. By creating a new task scheduler
     // instance here, we are allowing this thread to take part in rendering work
     // (tbb will spawn tasks on this thread when invoked from this thread.)
-    tbb::task_scheduler_init scheduler(int(initParams.mDesiredNumTBBThreads));
+    tbb::global_control scheduler(tbb::global_control::max_allowed_parallelism, int(initParams.mDesiredNumTBBThreads));

     // TLS initialization.
     initTLS(initParams);
@@ -2466,7 +2465,6 @@ RenderDriver::renderThread(RenderDriver *driver,
         case KILL_RENDER_THREAD:
             // This is a sub-tbb scheduler init, we still have the main one to
             // clean up later, which happens in the RenderDriver destructor.
-            scheduler.terminate();
             driver->mRenderThreadState.set(KILL_RENDER_THREAD, DEAD);
             quit = true;
             break;
diff --git a/moonray/moonray/lib/rendering/rndr/RenderDriver.h b/moonray/moonray/lib/rendering/rndr/RenderDriver.h
index be0231c..5931dd6 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderDriver.h
+++ b/moonray/moonray/lib/rendering/rndr/RenderDriver.h
@@ -27,7 +27,8 @@
 #include <scene_rdl2/common/grid_util/Parser.h>
 #include <scene_rdl2/render/util/AtomicFloat.h>

-#include <tbb/task_scheduler_init.h>
+#include <tbb/global_control.h>
+#include <tbb/spin_mutex.h>

 //#define SINGLE_THREAD_CRAWLALLPIXELS

@@ -766,7 +767,7 @@ private:
     std::unique_ptr<TileScheduler>  mTileSchedulerCheckpointInitEstimation;
     TileWorkQueue       mTileWorkQueue;

-    tbb::task_scheduler_init *mTaskScheduler;
+    tbb::global_control *mTaskScheduler;

     // The is the per film sample count, NOT the cumulative sample count over
     // all films.
diff --git a/moonray/moonray/lib/rendering/rndr/RenderFrame.cc b/moonray/moonray/lib/rendering/rndr/RenderFrame.cc
index dd42082..becf29d 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderFrame.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderFrame.cc
@@ -415,7 +415,7 @@ RenderDriver::runDisplayFiltersEndOfPass(RenderDriver *driver, const FrameState
     fs.mRenderContext->snapshotAovsForDisplayFilters(true, true);
     const DisplayFilterDriver& displayFilterDriver = driver->getDisplayFilterDriver();
     simpleLoop (true, 0u, (unsigned int)driver->getTiles()->size() - 1u, [&](unsigned tileIdx) {
-        int threadId = tbb::task_arena::current_thread_index();
+        int threadId = tbb::this_task_arena::current_thread_index();
         displayFilterDriver.runDisplayFilters(tileIdx, threadId);
     });
 }
diff --git a/moonray/moonray/lib/rendering/rndr/RenderFramePasses.cc b/moonray/moonray/lib/rendering/rndr/RenderFramePasses.cc
index f6f5e76..3210f53 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderFramePasses.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderFramePasses.cc
@@ -103,8 +103,8 @@ RenderDriver::renderPasses(RenderDriver *driver, const FrameState &fs,

     // This counter verifies that we don't leave this function until all threads
     // have started working.
-    CACHE_ALIGN tbb::atomic<unsigned> numTBBThreads;
-    CACHE_ALIGN tbb::atomic<bool> canceled;
+    CACHE_ALIGN std::atomic<unsigned> numTBBThreads;
+    CACHE_ALIGN std::atomic<bool> canceled;

     numTBBThreads = 0;
     canceled = false;
diff --git a/moonray/moonray/lib/rendering/rndr/RenderOptions.cc b/moonray/moonray/lib/rendering/rndr/RenderOptions.cc
index eb06cd0..3cf65b1 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderOptions.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderOptions.cc
@@ -13,8 +13,6 @@
 #include <scene_rdl2/render/util/StrUtil.h>
 #include <scene_rdl2/scene/rdl2/rdl2.h>

-#include <tbb/task_scheduler_init.h>
-
 #include <algorithm>
 #include <cctype>
 #include <cstddef>
@@ -648,7 +646,7 @@ RenderOptions::getThreads() const
     }

     // Last-ditch default.
-    return tbb::task_scheduler_init::default_num_threads();
+    return std::thread::hardware_concurrency();
 }

 void
diff --git a/moonray/moonray/lib/rendering/rndr/RenderStatistics.cc b/moonray/moonray/lib/rendering/rndr/RenderStatistics.cc
index 5bc7b27..2949b47 100644
--- a/moonray/moonray/lib/rendering/rndr/RenderStatistics.cc
+++ b/moonray/moonray/lib/rendering/rndr/RenderStatistics.cc
@@ -963,24 +963,24 @@ RenderStats::logGeometryUsage(const geom::GeometryStatistics& totalGeomStatistic

     for(std::size_t i = 0; i < geomStateInfo.size(); ++i) {
         geomTable.emplace_back(geomStateInfo[i].first,
-           geomStateInfo[i].second.mFaceCount,
-           geomStateInfo[i].second.mMeshVertexCount,
-           geomStateInfo[i].second.mCurvesCount,
-           geomStateInfo[i].second.mCVCount,
-           geomStateInfo[i].second.mInstanceCount);
+           geomStateInfo[i].second.mFaceCount.load(),
+           geomStateInfo[i].second.mMeshVertexCount.load(),
+           geomStateInfo[i].second.mCurvesCount.load(),
+           geomStateInfo[i].second.mCVCount.load(),
+           geomStateInfo[i].second.mInstanceCount.load());
     }

     StatsTable<2> summaryTable("Geometry Statistics Summary");
     summaryTable.emplace_back("Total Face Count",
-        totalGeomStatistics.mFaceCount);
+        totalGeomStatistics.mFaceCount.load());
     summaryTable.emplace_back("Total Mesh Vertex Count",
-        totalGeomStatistics.mMeshVertexCount);
+        totalGeomStatistics.mMeshVertexCount.load());
     summaryTable.emplace_back("Total Curves Count",
-        totalGeomStatistics.mCurvesCount);
+        totalGeomStatistics.mCurvesCount.load());
     summaryTable.emplace_back("Total Curves CV Count",
-        totalGeomStatistics.mCVCount);
+        totalGeomStatistics.mCVCount.load());
     summaryTable.emplace_back("Total Instance Count",
-        totalGeomStatistics.mInstanceCount);
+        totalGeomStatistics.mInstanceCount.load());

     auto writeCSV = [&](std::ostream& outs, bool athenaFormat) {
         outs.precision(2);
diff --git a/moonray/moonray/lib/rendering/rt/EmbreeAccelerator.cc b/moonray/moonray/lib/rendering/rt/EmbreeAccelerator.cc
index cb348a0..84a7b5c 100644
--- a/moonray/moonray/lib/rendering/rt/EmbreeAccelerator.cc
+++ b/moonray/moonray/lib/rendering/rt/EmbreeAccelerator.cc
@@ -41,7 +41,7 @@ namespace rt {


 typedef tbb::concurrent_unordered_map<std::shared_ptr<geom::SharedPrimitive>,
-        tbb::atomic<bool>, geom::SharedPtrHash> SharedSceneMap;
+        std::atomic<bool>, geom::SharedPtrHash> SharedSceneMap;


 class BVHBuilder : public geom::PrimitiveVisitor
diff --git a/moonray/moonray/lib/rendering/rt/GeometryManager.cc b/moonray/moonray/lib/rendering/rt/GeometryManager.cc
index e238a93..09bcd1c 100644
--- a/moonray/moonray/lib/rendering/rt/GeometryManager.cc
+++ b/moonray/moonray/lib/rendering/rt/GeometryManager.cc
@@ -1371,7 +1371,7 @@ GeometryManager::getEmissiveRegions(const scene_rdl2::rdl2::Layer* layer,
 }

 // Counter to provide unique thread ids
-tbb::atomic<unsigned> gThreadIdCounter;
+std::atomic<unsigned> gThreadIdCounter;

 GeometryManager::GM_RESULT
 GeometryManager::tessellate(scene_rdl2::rdl2::Layer* layer,
@@ -1406,7 +1406,7 @@ GeometryManager::tessellate(scene_rdl2::rdl2::Layer* layer,
     struct ThreadID {
         // When we create a ThreadID, the counter increments and so
         // each thread gets a unique human readable id.
-        ThreadID() : mId(gThreadIdCounter.fetch_and_increment()){}
+        ThreadID() : mId(gThreadIdCounter++){}
         unsigned mId;
     };
     typedef tbb::enumerable_thread_specific< ThreadID > EnumerableThreadID;
diff --git a/moonray/moonray/lib/rendering/rt/GeometryManager.h b/moonray/moonray/lib/rendering/rt/GeometryManager.h
index bb1e8e1..2a01398 100644
--- a/moonray/moonray/lib/rendering/rt/GeometryManager.h
+++ b/moonray/moonray/lib/rendering/rt/GeometryManager.h
@@ -38,7 +38,7 @@ namespace rt {

 enum class ChangeFlag;

-typedef tbb::concurrent_unordered_map<geom::internal::Primitive *, tbb::atomic<unsigned int>> PrimitiveReferenceCountMap;
+typedef tbb::concurrent_unordered_map<geom::internal::Primitive *, std::atomic<unsigned int>> PrimitiveReferenceCountMap;

 struct GeometryManagerStats
 {
@@ -187,7 +187,7 @@ public:

     finline void compareAndSwapFlag(ChangeFlag swapFlag, ChangeFlag compareFlag)
     {
-        mChangeStatus.compare_and_swap(swapFlag, compareFlag);
+        mChangeStatus.compare_exchange_strong(swapFlag, compareFlag);
     }

     void updateGPUAccelerator(const scene_rdl2::rdl2::Layer* layer);
@@ -255,7 +255,7 @@ private:

     GeometryManagerOptions mOptions;

-    typedef tbb::atomic<ChangeFlag> ChangeFlagAtomic;
+    typedef std::atomic<ChangeFlag> ChangeFlagAtomic;

     /// Tracks current change status
     ChangeFlagAtomic mChangeStatus;
diff --git a/moonray/moonray/lib/rendering/rt/gpu/GPUAcceleratorImpl.h b/moonray/moonray/lib/rendering/rt/gpu/GPUAcceleratorImpl.h
index a4449d6..9afd705 100644
--- a/moonray/moonray/lib/rendering/rt/gpu/GPUAcceleratorImpl.h
+++ b/moonray/moonray/lib/rendering/rt/gpu/GPUAcceleratorImpl.h
@@ -23,7 +23,7 @@ namespace rt {

 // Also in EmbreeAccelerator.cc
 typedef tbb::concurrent_unordered_map<std::shared_ptr<geom::SharedPrimitive>,
-        tbb::atomic<GPUPrimitiveGroup*>, geom::SharedPtrHash> SharedGroupMap;
+        std::atomic<GPUPrimitiveGroup*>, geom::SharedPtrHash> SharedGroupMap;


 class GPUAcceleratorImpl
diff --git a/moonray/moonray/lib/rendering/shading/BasicTexture.cc b/moonray/moonray/lib/rendering/shading/BasicTexture.cc
index 1510a57..1f75499 100644
--- a/moonray/moonray/lib/rendering/shading/BasicTexture.cc
+++ b/moonray/moonray/lib/rendering/shading/BasicTexture.cc
@@ -99,8 +99,8 @@ public:
         // to allow for the possibility that we may someday create image maps
         // on multiple threads, we'll protect the writes of the class statics
         // with a mutex.
-        static tbb::mutex errorMutex;
-        tbb::mutex::scoped_lock lock(errorMutex);
+        static std::mutex errorMutex;
+        std::scoped_lock lock(errorMutex);
         MOONRAY_START_THREADSAFE_STATIC_WRITE

         mIspc.mBasicTextureStaticDataPtr = &sBasicTextureStaticData;
diff --git a/moonray/moonray/lib/rendering/shading/Material.cc b/moonray/moonray/lib/rendering/shading/Material.cc
index f3c52b5..fec2e1c 100644
--- a/moonray/moonray/lib/rendering/shading/Material.cc
+++ b/moonray/moonray/lib/rendering/shading/Material.cc
@@ -8,17 +8,17 @@
 namespace moonray {
 namespace shading {

-tbb::mutex Material::sMaterialListMutex;
+std::mutex Material::sMaterialListMutex;
 MaterialPtrList Material::sAllMaterials;
 MaterialPtrList Material::sQueuelessMaterials;

-tbb::mutex Material::sShadeQueueMutex;
+std::mutex Material::sShadeQueueMutex;
 ShadeQueueList Material::sShadeQueues;

-tbb::atomic<size_t> Material::sFlushCycleIdx;
+std::atomic<size_t> Material::sFlushCycleIdx;

-tbb::atomic<uint32_t> Material::sDeferredEntryCalls;
-tbb::atomic<uint32_t> Material::sTotalDeferredEntries;
+std::atomic<uint32_t> Material::sDeferredEntryCalls;
+std::atomic<uint32_t> Material::sTotalDeferredEntries;

 Material::Material(const scene_rdl2::rdl2::SceneObject & owner) :
     RootShader(owner),
@@ -27,7 +27,7 @@ Material::Material(const scene_rdl2::rdl2::SceneObject & owner) :
     mMaterialLabelId(-1),   // no material label
     mLpeMaterialLabelId(-1) // no lpe material label
 {
-    tbb::mutex::scoped_lock lock(sMaterialListMutex);
+    std::scoped_lock lock(sMaterialListMutex);
     sAllMaterials.push_back(this);
     sQueuelessMaterials.push_back(this);
     mMaterialId = 0;
@@ -39,7 +39,7 @@ Material::~Material()
     if (mShadeQueue) {

         {
-            tbb::mutex::scoped_lock lock(sShadeQueueMutex);
+            std::scoped_lock lock(sShadeQueueMutex);

             // Check the shade queue size also since it may have already been destroyed
             // during global program destruction time.
@@ -59,7 +59,7 @@ Material::~Material()
     }

     {
-        tbb::mutex::scoped_lock lock(sMaterialListMutex);
+        std::scoped_lock lock(sMaterialListMutex);

         // Remove ourselves from global list of Materials.
         for (auto it = sAllMaterials.begin(); it != sAllMaterials.end(); ++it) {
@@ -99,7 +99,7 @@ Material::deferEntriesForLaterProcessing(mcrt_common::ThreadLocalState *tls,
     }

     {
-        tbb::mutex::scoped_lock lock(mDeferredEntryMutex);
+        std::scoped_lock lock(mDeferredEntryMutex);
         mDeferredEntries.insert(mDeferredEntries.end(), entries, entries + numEntries);
     }
 }
@@ -151,8 +151,8 @@ Material::retrieveDeferredEntries(mcrt_common::ThreadLocalState *tls,
 void
 Material::allocShadeQueues(unsigned shadeQueueSize, ShadeQueue::Handler handler)
 {
-    tbb::mutex::scoped_lock lockMaterialMutex(sMaterialListMutex);
-    tbb::mutex::scoped_lock lockShadeQueueMutex(sShadeQueueMutex);
+    std::scoped_lock lockMaterialMutex(sMaterialListMutex);
+    std::scoped_lock lockShadeQueueMutex(sShadeQueueMutex);

     for (auto it = sQueuelessMaterials.begin(); it != sQueuelessMaterials.end(); ++it) {
         (*it)->allocShadeQueue(shadeQueueSize, handler);
@@ -283,7 +283,7 @@ Material::resetDeferredEntryState()
 {
     for (auto it = sAllMaterials.begin(); it != sAllMaterials.end(); ++it) {
         Material *material = *it;
-        tbb::mutex::scoped_lock lock(material->mDeferredEntryMutex);
+        std::scoped_lock lock(material->mDeferredEntryMutex);
         material->mDeferredEntries.clear();
     }

diff --git a/moonray/moonray/lib/rendering/shading/Material.h b/moonray/moonray/lib/rendering/shading/Material.h
index 6d9e92e..f6bd723 100644
--- a/moonray/moonray/lib/rendering/shading/Material.h
+++ b/moonray/moonray/lib/rendering/shading/Material.h
@@ -167,24 +167,24 @@ protected:
     // We will also get warned when executing this codepath at render time via
     // the logger so if it becomes a common case, we need to revisit and remove
     // these locks and heap allocations.
-    tbb::mutex              mDeferredEntryMutex;
+    std::mutex              mDeferredEntryMutex;
     std::vector<SortedRayState> mDeferredEntries;

-    static tbb::mutex       sMaterialListMutex;
+    static std::mutex       sMaterialListMutex;
     static MaterialPtrList  sAllMaterials;
     static MaterialPtrList  sQueuelessMaterials;

-    static tbb::mutex       sShadeQueueMutex;
+    static std::mutex       sShadeQueueMutex;
     static ShadeQueueList   sShadeQueues;

     // This is used by the flushNonEmptyShadeQueue function to iterate through all queues
     // in a cyclic fashion as opposed to starting the iteration at the beginning of the
     // queue list each time.
-    static tbb::atomic<size_t> sFlushCycleIdx;
+    static std::atomic<size_t> sFlushCycleIdx;

     // Shared between all Materials.
-    static tbb::atomic<uint32_t> sDeferredEntryCalls;
-    static tbb::atomic<uint32_t> sTotalDeferredEntries;
+    static std::atomic<uint32_t> sDeferredEntryCalls;
+    static std::atomic<uint32_t> sTotalDeferredEntries;
 };

 template <typename Body>
diff --git a/moonray/moonray/lib/rendering/shading/UdimTexture.cc b/moonray/moonray/lib/rendering/shading/UdimTexture.cc
index fe4385b..35fc8f3 100644
--- a/moonray/moonray/lib/rendering/shading/UdimTexture.cc
+++ b/moonray/moonray/lib/rendering/shading/UdimTexture.cc
@@ -19,7 +19,6 @@

 #include <tbb/blocked_range.h>
 #include <tbb/parallel_for.h>
-#include <tbb/mutex.h>

 #include <dirent.h>
 #include <unordered_set>
@@ -121,8 +120,8 @@ public:
         // to allow for the possibility that we may someday create image maps
         // on multiple threads, we'll protect the writes of the class statics
         // with a mutex.
-        static tbb::mutex errorMutex;
-        tbb::mutex::scoped_lock lock(errorMutex);
+        static std::mutex errorMutex;
+        std::scoped_lock lock(errorMutex);
         MOONRAY_START_THREADSAFE_STATIC_WRITE

         mIspc.mUdimTextureStaticDataPtr = &sUdimTextureStaticData;
@@ -251,7 +250,7 @@ public:
         mIspc.mIs8bit = mIs8bit;

         mIspc.mIsValid = true;
-        tbb::mutex errorMutex;
+        std::mutex errorMutex;

         tbb::blocked_range<int> range(0, mTextureHandleIndices.size());
         tbb::parallel_for(range, [&] (const tbb::blocked_range<int> &r) {
diff --git a/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.h b/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.h
index 8b8e103..599cb8d 100644
--- a/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.h
+++ b/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.h
@@ -11,8 +11,6 @@
 #include <scene_rdl2/common/grid_util/Parser.h>
 #include <scene_rdl2/common/math/Color.h>

-#include <tbb/recursive_mutex.h>
-
 // system
 #include <string>
 #include <set>
@@ -137,7 +135,7 @@ protected:
     // For the udim case, a single ImageMap may reference multiple texture files.
     std::multimap<scene_rdl2::rdl2::Shader *, OIIO::ustring> mShaderToName;

-    tbb::recursive_mutex mMutex;
+    std::recursive_mutex mMutex;

     Parser mParser;
 };
diff --git a/moonray/moonray/lib/rendering/texturing/sampler/TextureTLState.cc b/moonray/moonray/lib/rendering/texturing/sampler/TextureTLState.cc
index 3e95ce5..2dc55ee 100644
--- a/moonray/moonray/lib/rendering/texturing/sampler/TextureTLState.cc
+++ b/moonray/moonray/lib/rendering/texturing/sampler/TextureTLState.cc
@@ -4,7 +4,6 @@
 #include "TextureSampler.h"
 #include "TextureTLState.h"
 #include <moonray/common/mcrt_macros/moonray_static_check.h>
-#include <tbb/mutex.h>

 namespace ispc {
 extern "C" uint32_t TextureTLState_hudValidation(bool);
diff --git a/moonray/moonray/tests/lib/rendering/geom/prim/main.cc b/moonray/moonray/tests/lib/rendering/geom/prim/main.cc
index 8b93592..d3c15a3 100644
--- a/moonray/moonray/tests/lib/rendering/geom/prim/main.cc
+++ b/moonray/moonray/tests/lib/rendering/geom/prim/main.cc
@@ -5,7 +5,6 @@
 #include "TestInterpolator.h"
 #include <moonray/rendering/mcrt_common/ThreadLocalState.h>
 #include <scene_rdl2/pdevunit/pdevunit.h>
-#include <tbb/task_scheduler_init.h>
 int
 main(int argc, char *argv[])
 {
@@ -15,7 +14,7 @@ main(int argc, char *argv[])

     moonray::mcrt_common::TLSInitParams initParams;
     initParams.mUnitTests = true;
-    initParams.mDesiredNumTBBThreads = tbb::task_scheduler_init::default_num_threads();
+    initParams.mDesiredNumTBBThreads = std::thread::hardware_concurrency();
     initParams.mArenaBlockPool = arenaBlockPool.get();
     moonray::mcrt_common::initTLS(initParams);

diff --git a/moonray/moonray/tests/lib/rendering/pbr/TestBsdfCommon.cc b/moonray/moonray/tests/lib/rendering/pbr/TestBsdfCommon.cc
index 2009211..9c78ed3 100755
--- a/moonray/moonray/tests/lib/rendering/pbr/TestBsdfCommon.cc
+++ b/moonray/moonray/tests/lib/rendering/pbr/TestBsdfCommon.cc
@@ -320,7 +320,7 @@ static void runTest(const TestBsdfSettings& test, int sampleCount, ProducerArgs&
 #if defined(RUN_SINGLE_THREADED)
     const unsigned sTaskCount = 1u;
 #else
-    const unsigned sTaskCount = tbb::task_scheduler_init::default_num_threads() - 1u; // Leave one for producer
+    const unsigned sTaskCount = tbb::this_task_arena::max_concurrency() - 1u; // Leave one for producer
 #endif

     TaskQueueType<Task> taskQueue;
diff --git a/moonray/moonray/tests/lib/rendering/pbr/TestLightSetSampler.cc b/moonray/moonray/tests/lib/rendering/pbr/TestLightSetSampler.cc
index 12437a1..fdda757 100644
--- a/moonray/moonray/tests/lib/rendering/pbr/TestLightSetSampler.cc
+++ b/moonray/moonray/tests/lib/rendering/pbr/TestLightSetSampler.cc
@@ -23,8 +23,6 @@
 #include <scene_rdl2/common/math/Math.h>
 #include <scene_rdl2/render/util/Arena.h>

-#include <tbb/task_scheduler_init.h>
-

 // to iterate over the [0, 1)^2 space we take (NUM_SAMPLES_PER_AXIS * NUM_SAMPLES_PER_AXIS) samples
 #define NUM_SAMPLES_PER_AXIS                1000
diff --git a/moonray/moonray/tests/lib/rendering/pbr/TestLights.cc b/moonray/moonray/tests/lib/rendering/pbr/TestLights.cc
index 409f893..8314b89 100644
--- a/moonray/moonray/tests/lib/rendering/pbr/TestLights.cc
+++ b/moonray/moonray/tests/lib/rendering/pbr/TestLights.cc
@@ -271,7 +271,7 @@ testLightPDF(const Vec3f &p, const Vec3f &n, const LightTester *lightTester,
     // compute ref pdfs (only for unit test debugging)
     //

-    tbb::atomic<unsigned> refValidSampleCount;
+    std::atomic<unsigned> refValidSampleCount;
     refValidSampleCount = 0;

     double refPdf = doReductionOverUnitSquare<double>(0.0,
@@ -326,7 +326,7 @@ testLightPDF(const Vec3f &p, const Vec3f &n, const LightTester *lightTester,
     // compute test pdf
     //

-    tbb::atomic<unsigned> testValidSampleCount;
+    std::atomic<unsigned> testValidSampleCount;
     testValidSampleCount = 0;

     double testPdf = doReductionOverUnitSquare<double>(0.0,
@@ -394,7 +394,7 @@ testLightPDF(const Vec3f &p, const Vec3f &n, const LightTester *lightTester,
     // compute test pdf of ISPC light
     //

-    tbb::atomic<unsigned> testIspcValidSampleCount;
+    std::atomic<unsigned> testIspcValidSampleCount;
     testIspcValidSampleCount = 0;

     double testIspcPdf = doReductionOverUnitSquare<double>(0.0,
@@ -525,7 +525,7 @@ testLightCanIlluminate(const Vec3f &, const Vec3f &, const LightTester *lightTes
     // Test C++ light implementation
     //

-    tbb::atomic<int32_t> seed;
+    std::atomic<int32_t> seed;
     seed = initialSeed;

     tbb::parallel_for(tbb::blocked_range<unsigned>(0, NUM_CAN_ILLUMINATE_TESTS,
@@ -651,11 +651,11 @@ testLightIntersection(const Vec3f &p, const Vec3f &n, const LightTester *lightTe
     // Test C++ implementation
     //

-    tbb::atomic<unsigned> cppIsectsEqual;
+    std::atomic<unsigned> cppIsectsEqual;
     cppIsectsEqual = 0;
-    tbb::atomic<unsigned> cppNoIntersection;
+    std::atomic<unsigned> cppNoIntersection;
     cppNoIntersection = 0;
-    tbb::atomic<unsigned> cppInvalidSamples;
+    std::atomic<unsigned> cppInvalidSamples;
     cppInvalidSamples = 0;

     tbb::parallel_for (tbb::blocked_range<unsigned>(0u, NUM_SAMPLES_PER_AXIS, GRAINSIZE_PER_AXIS),
@@ -780,11 +780,11 @@ testLightIntersection(const Vec3f &p, const Vec3f &n, const LightTester *lightTe
     // Test ISPC implementation
     //

-    tbb::atomic<unsigned> ispcIsectsEqual;
+    std::atomic<unsigned> ispcIsectsEqual;
     ispcIsectsEqual = 0;
-    tbb::atomic<unsigned> ispcNoIntersection;
+    std::atomic<unsigned> ispcNoIntersection;
     ispcNoIntersection = 0;
-    tbb::atomic<unsigned> ispcInvalidSamples;
+    std::atomic<unsigned> ispcInvalidSamples;
     ispcInvalidSamples = 0;

     tbb::parallel_for (tbb::blocked_range<unsigned>(0u, NUM_SAMPLES_PER_AXIS, GRAINSIZE_PER_AXIS),
Submodule moonray/moonray_arras/mcrt_computation contains modified content
diff --git a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeClockDeltaDriver.h b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeClockDeltaDriver.h
index efd01eb..fa7cd00 100644
--- a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeClockDeltaDriver.h
+++ b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeClockDeltaDriver.h
@@ -8,12 +8,11 @@
 #include <mcrt_dataio/share/sock/SockServer.h>
 #include <mcrt_dataio/share/sock/SockServerConnection.h>

-#include <tbb/atomic.h>
-
 #include <condition_variable>
 #include <memory>
 #include <mutex>
 #include <thread>
+#include <atomic>

 namespace mcrt_computation {

@@ -52,8 +51,8 @@ private:

     std::thread mServerThread;
     std::thread mWorkerThread;  // single worker
-    tbb::atomic<ThreadState> mServerThreadState;
-    tbb::atomic<ThreadState> mWorkerThreadState;
+    std::atomic<ThreadState> mServerThreadState;
+    std::atomic<ThreadState> mWorkerThreadState;
     bool mThreadShutdown;

     mutable std::mutex mMutex;
diff --git a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.cc b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.cc
index afb7fcc..0ae9678 100644
--- a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.cc
+++ b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.cc
@@ -107,7 +107,7 @@ ProgMcrtMergeComputation::configure(const std::string &op,
     if (aConfig[arras4::api::ConfigNames::maxThreads].isIntegral()) {
         mNumThreads = aConfig[arras4::api::ConfigNames::maxThreads].asInt();
     } else {
-        mNumThreads = tbb::task_scheduler_init::default_num_threads();
+        mNumThreads = tbb::this_task_arena::max_concurrency();
     }

     if (aConfig["packTilePrecision"].isString()) {
@@ -180,7 +180,7 @@ ProgMcrtMergeComputation::onStart()
 #       ifdef DEVELOP_VER_MESSAGE
         std::cerr << ">> ProgMcrtMergeComputation.cc set TBB numThreads:" << mNumThreads << std::endl;
 #       endif // end DEVELOP_VER_MESSAGE
-        mTaskScheduler = new tbb::task_scheduler_init(mNumThreads);
+        tbb::task_arena *mTaskScheduler = new tbb::task_arena(mNumThreads);
     }

     //------------------------------
diff --git a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.h b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.h
index e224d18..f54c694 100644
--- a/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.h
+++ b/moonray/moonray_arras/mcrt_computation/computation/progmcrt_merge/ProgMcrtMergeComputation.h
@@ -27,12 +27,11 @@
 #include <scene_rdl2/common/grid_util/Parser.h>
 #include <scene_rdl2/common/math/Viewport.h>

-#include <tbb/task_scheduler_init.h>
-
 #include <cstdint>
 #include <memory>
 #include <string>
 #include <vector>
+#include <tbb/global_control.h>

 namespace moonray {
 namespace rndr {
@@ -179,7 +178,7 @@ private:

     arras4::api::UUID mPrevRecvMsg {""}; // for debug message

-    tbb::task_scheduler_init *mTaskScheduler {nullptr};
+    tbb::global_control *mTaskScheduler {nullptr};

     std::string mSource;        // source id, correlating incoming to outgoing messages

diff --git a/moonray/moonray_gui/cmd/moonray_gui/RenderGui.h b/moonray/moonray_gui/cmd/moonray_gui/RenderGui.h
index caf5694..fcb15ce 100644
--- a/moonray/moonray_gui/cmd/moonray_gui/RenderGui.h
+++ b/moonray/moonray_gui/cmd/moonray_gui/RenderGui.h
@@ -9,8 +9,6 @@
 #include <mcrt_denoise/denoiser/Denoiser.h>
 #include <moonray/rendering/rndr/rndr.h>

-#include <tbb/atomic.h>
-
 #define NUM_TILE_FADE_STEPS  4

 namespace moonray_gui {
@@ -119,7 +117,7 @@ private:
     /// The renderering code will strive to render this frame. If it's rendering
     /// a frame with a lower timestamp then we know the frame it's currently
     /// rendering is old.
-    tbb::atomic<uint32_t>   mMasterTimestamp;
+    std::atomic<uint32_t>   mMasterTimestamp;

     /// The timestamp of the frame the renderer is currently processing.
     uint32_t                mRenderTimestamp;
Submodule moonray/moonshine contains modified content
diff --git a/moonray/moonshine/dso/map/DeformationMap/DeformationMap.cc b/moonray/moonshine/dso/map/DeformationMap/DeformationMap.cc
index 61412d6..4727cd8 100644
--- a/moonray/moonshine/dso/map/DeformationMap/DeformationMap.cc
+++ b/moonray/moonshine/dso/map/DeformationMap/DeformationMap.cc
@@ -56,8 +56,8 @@ DeformationMap::DeformationMap(const scene_rdl2::rdl2::SceneClass& sceneClass,
     // To allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);

     MOONRAY_START_THREADSAFE_STATIC_WRITE

diff --git a/moonray/moonshine/dso/map/DirectionalMap/DirectionalMap.cc b/moonray/moonshine/dso/map/DirectionalMap/DirectionalMap.cc
index efcd5db..ffda350 100644
--- a/moonray/moonshine/dso/map/DirectionalMap/DirectionalMap.cc
+++ b/moonray/moonshine/dso/map/DirectionalMap/DirectionalMap.cc
@@ -57,8 +57,8 @@ DirectionalMap::DirectionalMap(const SceneClass& sceneClass, const std::string&
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE

     sDirectionalMapData.sErrorMissingRefN = mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/map/GradientMap/GradientMap.cc b/moonray/moonshine/dso/map/GradientMap/GradientMap.cc
index 8937826..89923e8 100644
--- a/moonray/moonshine/dso/map/GradientMap/GradientMap.cc
+++ b/moonray/moonshine/dso/map/GradientMap/GradientMap.cc
@@ -114,8 +114,8 @@ GradientMap::GradientMap(const scene_rdl2::rdl2::SceneClass &sceneClass,
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticGradientMapData.sErrorMissingReferenceData =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/map/HairColumnMap/HairColumnMap.cc b/moonray/moonshine/dso/map/HairColumnMap/HairColumnMap.cc
index 71d0c9b..53728d5 100644
--- a/moonray/moonshine/dso/map/HairColumnMap/HairColumnMap.cc
+++ b/moonray/moonshine/dso/map/HairColumnMap/HairColumnMap.cc
@@ -49,8 +49,8 @@ HairColumnMap::HairColumnMap(const SceneClass &sceneClass, const std::string &na
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sErrorScatterTagMissing =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/map/NoiseMap/v2/NoiseMap_v2.cc b/moonray/moonshine/dso/map/NoiseMap/v2/NoiseMap_v2.cc
index 92f615d..800932d 100644
--- a/moonray/moonshine/dso/map/NoiseMap/v2/NoiseMap_v2.cc
+++ b/moonray/moonshine/dso/map/NoiseMap/v2/NoiseMap_v2.cc
@@ -67,8 +67,8 @@ NoiseMap_v2::NoiseMap_v2(SceneClass const &sceneClass,
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticNoiseMapData.sErrorMissingReferenceData =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/map/NoiseWorleyMap/v2/NoiseWorleyMap_v2.cc b/moonray/moonshine/dso/map/NoiseWorleyMap/v2/NoiseWorleyMap_v2.cc
index cc41dd6..5982436 100644
--- a/moonray/moonshine/dso/map/NoiseWorleyMap/v2/NoiseWorleyMap_v2.cc
+++ b/moonray/moonshine/dso/map/NoiseWorleyMap/v2/NoiseWorleyMap_v2.cc
@@ -68,8 +68,8 @@ NoiseWorleyMap_v2::NoiseWorleyMap_v2(SceneClass const &sceneClass, std::string c
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticNoiseWorleyMapData.sErrorMissingReferenceData =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/map/UVTransformMap/UVTransformMap.cc b/moonray/moonshine/dso/map/UVTransformMap/UVTransformMap.cc
index 6aa9ac6..1b1216c 100644
--- a/moonray/moonshine/dso/map/UVTransformMap/UVTransformMap.cc
+++ b/moonray/moonshine/dso/map/UVTransformMap/UVTransformMap.cc
@@ -96,8 +96,8 @@ UVTransformMap::UVTransformMap(const SceneClass& sceneClass,
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE
     sStaticUVTransformMapData.sErrorMissingReferenceData =
         mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/dso/material/HairLayer/HairLayerMaterial.cc b/moonray/moonshine/dso/material/HairLayer/HairLayerMaterial.cc
index a46d5b5..9c045c7 100644
--- a/moonray/moonshine/dso/material/HairLayer/HairLayerMaterial.cc
+++ b/moonray/moonshine/dso/material/HairLayer/HairLayerMaterial.cc
@@ -140,8 +140,8 @@ HairLayerMaterial::HairLayerMaterial(const scene_rdl2::rdl2::SceneClass& sceneCl
     // with a mutex.
     mIspc.mStaticData = (ispc::HairLayerMaterialStaticData*)&sStaticHairLayerMaterialData;

-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE

     mIspc.mStaticData->sErrorMismatchedFresnelType =
diff --git a/moonray/moonshine/lib/common/noise/Noise.cc b/moonray/moonshine/lib/common/noise/Noise.cc
index cf814dd..b806521 100644
--- a/moonray/moonshine/lib/common/noise/Noise.cc
+++ b/moonray/moonshine/lib/common/noise/Noise.cc
@@ -13,7 +13,7 @@ using namespace scene_rdl2::math;

 bool Noise::sNoiseIsDataInitialized = false;
 scene_rdl2::util::Random Noise::sNoiseRandom = scene_rdl2::util::Random(0xbeadceef);
-tbb::mutex Noise::sNoiseInitDataMutex;
+std::mutex Noise::sNoiseInitDataMutex;
 std::vector<int> Noise::sNoisePermutationTable;

 Noise::Noise(const int seed,
@@ -25,7 +25,7 @@ Noise::Noise(const int seed,
     mIspc.mTableSize = tableSize;

     if (useStaticTables) {
-        tbb::mutex::scoped_lock dataLock(sNoiseInitDataMutex); // Lock this part that initializes static data
+        std::lock_guard<std::mutex> dataLock(sNoiseInitDataMutex); // Lock this part that initializes static data
         // Only construct the static data once to share across all instances
         if (!sNoiseIsDataInitialized) {
             buildStaticTables(tableSize);
diff --git a/moonray/moonshine/lib/common/noise/Noise.h b/moonray/moonshine/lib/common/noise/Noise.h
index 422d438..3e40dcd 100644
--- a/moonray/moonshine/lib/common/noise/Noise.h
+++ b/moonray/moonshine/lib/common/noise/Noise.h
@@ -8,7 +8,7 @@
 #pragma warning disable 1711 // Warnings about assignemnt to statically allocated data

 #include "Noise_ispc_stubs.h"
-#include <tbb/mutex.h>
+#include <mutex>
 #include <scene_rdl2/common/math/Vec3.h>
 #include <scene_rdl2/common/math/Xform.h>

@@ -71,7 +71,7 @@ protected:
     // Static data
     static bool sNoiseIsDataInitialized;
     static scene_rdl2::util::Random sNoiseRandom;
-    static tbb::mutex sNoiseInitDataMutex;
+    static std::mutex sNoiseInitDataMutex;
     static std::vector<int> sNoisePermutationTable;

 private:
diff --git a/moonray/moonshine/lib/common/noise/Worley.cc b/moonray/moonshine/lib/common/noise/Worley.cc
index 248667a..7954f49 100644
--- a/moonray/moonshine/lib/common/noise/Worley.cc
+++ b/moonray/moonshine/lib/common/noise/Worley.cc
@@ -227,7 +228,7 @@ collectPoints(const Worley_PointArray::iterator tmpWorleyPointsBeg,

 // Static data
 bool Worley::sIsWorleyDataInitialized = false;
-tbb::mutex Worley::sWorleyInitDataMutex;
+std::mutex Worley::sWorleyInitDataMutex;
 std::vector<float> Worley::sWorleyPointsX;
 std::vector<float> Worley::sWorleyPointsY;
 std::vector<float> Worley::sWorleyPointsZ;
@@ -255,7 +256,7 @@ Worley::Worley(const int seed,
     initPointProbabilities();

     if (useStaticTables) {
-        tbb::mutex::scoped_lock dataLock(sWorleyInitDataMutex); // Lock this part that initializes static data
+        std::lock_guard<std::mutex> dataLock(sWorleyInitDataMutex); // Lock this part that initializes static data
         // Only construct the static data once to share across all instances
         if (!sIsWorleyDataInitialized) {
             buildStaticPointTables(addNormals, tableSize);
diff --git a/moonray/moonshine/lib/common/noise/Worley.h b/moonray/moonshine/lib/common/noise/Worley.h
index 59997bc..75d3955 100644
--- a/moonray/moonshine/lib/common/noise/Worley.h
+++ b/moonray/moonshine/lib/common/noise/Worley.h
@@ -184,7 +185,7 @@ private:

     // Static data
     static bool sIsWorleyDataInitialized;
-    static tbb::mutex sWorleyInitDataMutex;
+    static std::mutex sWorleyInitDataMutex;

     static std::vector<float> sWorleyPointsX;
     static std::vector<float> sWorleyPointsY;
diff --git a/moonray/moonshine/lib/map/projection/ProjectionUtil.cc b/moonray/moonshine/lib/map/projection/ProjectionUtil.cc
index bc0b252..7041632 100644
--- a/moonray/moonshine/lib/map/projection/ProjectionUtil.cc
+++ b/moonray/moonshine/lib/map/projection/ProjectionUtil.cc
@@ -24,8 +24,8 @@ initLogEvents(ispc::PROJECTION_StaticData& staticData,
     // to allow for the possibility that we may someday create image maps
     // on multiple threads, we'll protect the writes of the class statics
     // with a mutex.
-    static tbb::mutex errorMutex;
-    tbb::mutex::scoped_lock lock(errorMutex);
+    static std::mutex errorMutex;
+    std::lock_guard<std::mutex> lock(errorMutex);
     MOONRAY_START_THREADSAFE_STATIC_WRITE

     staticData.sErrorMissingProjector = logEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
diff --git a/moonray/moonshine/lib/material/dwabase/DwaBaseLayerable.cc b/moonray/moonshine/lib/material/dwabase/DwaBaseLayerable.cc
index 51ca1ed..6af10c5 100644
--- a/moonray/moonshine/lib/material/dwabase/DwaBaseLayerable.cc
+++ b/moonray/moonshine/lib/material/dwabase/DwaBaseLayerable.cc
@@ -53,8 +53,8 @@ DwaBaseLayerable::registerShadeTimeEventMessages()
    // To allow for the possibility that we may someday create materials
    // on multiple threads, we'll protect the writes of the class statics
    // with a mutex.
-   static tbb::mutex errorMutex;
-   tbb::mutex::scoped_lock lock(errorMutex);
+   static std::mutex errorMutex;
+   std::lock_guard<std::mutex> lock(errorMutex);
    MOONRAY_START_THREADSAFE_STATIC_WRITE

    sEventMessages.sErrorNoRefN =
diff --git a/moonray/scene_rdl2/lib/render/util/Arena.h b/moonray/scene_rdl2/lib/render/util/Arena.h
index ada0b49..bd7e327 100644
--- a/moonray/scene_rdl2/lib/render/util/Arena.h
+++ b/moonray/scene_rdl2/lib/render/util/Arena.h
@@ -115,7 +115,7 @@ public:

 protected:
     unsigned            mBlockSize;
-    tbb::atomic<unsigned> mTotalBlocks;
+    std::atomic<unsigned> mTotalBlocks;

     CACHE_ALIGN util::ConcurrentSList mFreeBlocks;
 };
diff --git a/moonray/scene_rdl2/lib/render/util/MiscUtils.h b/moonray/scene_rdl2/lib/render/util/MiscUtils.h
index 3f632e9..cfb3c00 100644
--- a/moonray/scene_rdl2/lib/render/util/MiscUtils.h
+++ b/moonray/scene_rdl2/lib/render/util/MiscUtils.h
@@ -6,13 +6,13 @@
 // Include this before any other includes!
 #include <scene_rdl2/common/platform/Platform.h>

-#include <tbb/atomic.h>
+#include <atomic>

 namespace scene_rdl2 {
 namespace util {

 template<typename T>
-struct CACHE_ALIGN CacheLineAtomic : public tbb::atomic<T>
+struct CACHE_ALIGN CacheLineAtomic : public std::atomic<T>
 {
 };

diff --git a/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.cc b/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.cc
index 811f55e..3b328b1 100644
--- a/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.cc
+++ b/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.cc
@@ -31,7 +31,6 @@
 #include <scene_rdl2/render/logging/logging.h>

 #include <tbb/concurrent_hash_map.h>
-#include <tbb/mutex.h>
 #include <tbb/parallel_for_each.h>

 #include <algorithm>
@@ -185,7 +184,7 @@ const rdl2::Camera*
 SceneContext::getPrimaryCamera() const
 {
     // Prevent possible race condition with mCameras.push_back() in createSceneObject().
-    tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+    std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);

     if (mCameras.size() == 0) {
         return nullptr;
@@ -205,7 +204,7 @@ std::vector<const rdl2::Camera*>
 SceneContext::getCameras() const
 {
     // Prevent possible race condition with mCameras.push_back() in createSceneObject().
-    tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+    std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);

     std::vector<const rdl2::Camera*> cameras;

@@ -236,7 +235,7 @@ std::vector<const rdl2::Camera*>
 SceneContext::getActiveCameras(void) const
 {
     // Prevent possible race condition with mCameras.push_back() in createSceneObject().
-    tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+    std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);

     std::vector<const rdl2::Camera*> cameras;

@@ -447,16 +446,16 @@ SceneContext::createSceneObject(const std::string& className,

         // Do any type-specific setup.
         if (obj->isA<Geometry>()) {
-            tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+            std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);
             mGeometries.push_back(obj->asA<Geometry>());
         } else if (obj->isA<GeometrySet>()) {
-            tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+            std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);
             mGeometrySets.push_back(obj->asA<GeometrySet>());
         } else if (obj->isA<Camera>()) {
-            tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+            std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);
             mCameras.push_back(obj->asA<Camera>());
         } else if (obj->isA<RenderOutput>()) {
-            tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
+            std::lock_guard<std::mutex> lock(mCreateSceneObjectMutex);
             mRenderOutputs.push_back(obj->asA<RenderOutput>());
         }

@@ -770,7 +769,7 @@ SceneContext::computeTimeRescalingCoeffs(float shutterOpen, float shutterClose,
 {
     // See declaration of TimeRescalingCoeffs in Types.h for details.

-    tbb::mutex::scoped_lock lock(mTimeRescalingCoeffsMutex);
+    std::lock_guard<std::mutex> lock(mTimeRescalingCoeffsMutex);

     MNRY_ASSERT_REQUIRE(motionSteps.size() >= 1 && motionSteps.size() <= 2);
     if (motionSteps.size() == 1  ||  motionSteps[0] == motionSteps[1]) {
diff --git a/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.h b/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.h
index 8b7c9ce..4735b13 100644
--- a/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.h
+++ b/moonray/scene_rdl2/lib/scene/rdl2/SceneContext.h
@@ -13,7 +13,6 @@
 #include <scene_rdl2/render/util/Alloc.h>
 #include <scene_rdl2/common/platform/Platform.h>
 #include <tbb/concurrent_hash_map.h>
-#include <tbb/mutex.h>

 #include <string>

@@ -382,7 +381,7 @@ private:
     // it's being updated. In other words, doing an interpolated get() against
     // ANY object while the camera's shutter interval or SceneVariables motion
     // steps are being updated is a recipe for threading errors.
-    tbb::mutex mTimeRescalingCoeffsMutex;
+    std::mutex mTimeRescalingCoeffsMutex;

     // All cameras in the rdl context (including the primary camera).
     // This is in creation order.  The primary camera can't be assumed to be
@@ -414,7 +413,7 @@ private:
     // Mutex to sync write access to thread unsafe vectors like mGeometries only in
     // conditioning time. Those vectors will remain lock free for reading and reading / writing
     // at the same time is not allowed or protected in any way
-    mutable tbb::mutex mCreateSceneObjectMutex;
+    mutable std::mutex mCreateSceneObjectMutex;

     RenderOutputVector mRenderOutputs;
     std::string mDsoPath;
diff --git a/moonray/scene_rdl2/lib/scene/rdl2/Shader.h b/moonray/scene_rdl2/lib/scene/rdl2/Shader.h
index bb21139..097f2bb 100644
--- a/moonray/scene_rdl2/lib/scene/rdl2/Shader.h
+++ b/moonray/scene_rdl2/lib/scene/rdl2/Shader.h
@@ -6,6 +6,7 @@

 #include "SceneClass.h"
 #include "SceneObject.h"
+#include <mutex>

 namespace moonray { namespace shading { class ThreadLocalObjectState; } }

@@ -86,7 +87,7 @@ public:

     // Copy existing attributes into a cache
     void cacheAttributes() const {
-        tbb::mutex::scoped_lock lock(mCachedAttributesMutex);
+        std::lock_guard<std::mutex> lock(mCachedAttributesMutex);

         mCachedRequiredAttributes.clear();
         if (!mRequiredAttributes.empty()) {
@@ -127,7 +128,7 @@ public:
     }

     void clearCachedAttributes() const {
-        tbb::mutex::scoped_lock lock(mCachedAttributesMutex);
+        std::lock_guard<std::mutex> lock(mCachedAttributesMutex);

         mCachedRequiredAttributes.clear();
         mCachedOptionalAttributes.clear();
@@ -176,7 +177,7 @@ private:
     /**
      * Mutex to protect the attribute caches.
      */
-    mutable tbb::mutex mCachedAttributesMutex;
+    mutable std::mutex mCachedAttributesMutex;
 };

 template <>
diff --git a/moonray/scene_rdl2/tests/lib/render/util/TestMemPool.cc b/moonray/scene_rdl2/tests/lib/render/util/TestMemPool.cc
index af4ff8f..9decbcf 100644
--- a/moonray/scene_rdl2/tests/lib/render/util/TestMemPool.cc
+++ b/moonray/scene_rdl2/tests/lib/render/util/TestMemPool.cc
@@ -9,7 +9,7 @@
 #include <scene_rdl2/render/util/Random.h>
 #include <tbb/enumerable_thread_specific.h>
 #include <tbb/parallel_for.h>
-#include <tbb/task_scheduler_init.h>
+#include <thread>
 #include <set>
 #include <vector>

@@ -208,14 +207,14 @@ typedef uint64_t EntryType;
 typedef MemPool<MemBlockType, EntryType> LocalMemPool;

 // Counter to hand out unique indices to TLSProxy objects.
-tbb::atomic<unsigned> gNextTLSIndex;
+std::atomic<unsigned> gNextTLSIndex;

 // This is a lightweight object which we put into a tbb::enumerable_thread_specific
 // container so that we can map OS thread ids to consistent top level ThreadLocalState
 // objects when running parallel_for loops in the update phase of the frame.
 struct TLSProxy
 {
-    TLSProxy() : mTLSIndex(gNextTLSIndex.fetch_and_increment()) {}
+    TLSProxy() : mTLSIndex(gNextTLSIndex.fetch_add(1)) {}
     unsigned mTLSIndex;
 };

@@ -249,7 +248,7 @@ testMemPoolAllocator(const char *name,
                      unsigned numLoops,
                      unsigned numOpsPerLoop)
 {
-    const unsigned numThreads = tbb::task_scheduler_init::default_num_threads();
+    const unsigned numThreads = std::thread::hardware_concurrency();
     const unsigned totalBlocks = numBlocksToReservePerThread * numThreads;

     //
diff --git a/moonray/moonray_arras/mcrt_computation/lib/engine/mcrt/RenderContextDriver.h b/moonray/moonray_arras/mcrt_computation/lib/engine/mcrt/RenderContextDriver.h
index 909775b..34a2278 100644
--- a/moonray/moonray_arras/mcrt_computation/lib/engine/mcrt/RenderContextDriver.h
+++ b/moonray/moonray_arras/mcrt_computation/lib/engine/mcrt/RenderContextDriver.h
@@ -27,8 +27,6 @@
 #include <scene_rdl2/common/grid_util/Parser.h>
 #include <scene_rdl2/common/math/Viewport.h>

-#include <tbb/atomic.h>
-
 #include <condition_variable>
 #include <mutex>
 #include <thread>
@@ -345,8 +343,8 @@ private:
     //
     int mDriverId;
     std::thread mThread;
-    tbb::atomic<ThreadState> mThreadState {ThreadState::INIT};
-    tbb::atomic<RunState> mRunState {RunState::WAIT};
+    std::atomic<ThreadState> mThreadState {ThreadState::INIT};
+    std::atomic<RunState> mRunState {RunState::WAIT};
     bool mThreadShutdown {false}; 

     mutable std::mutex mMutexBoot;

diff --git a/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.cc b/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.cc
index 14ed965..520c777 100644
--- a/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.cc
+++ b/moonray/moonray/lib/rendering/texturing/sampler/TextureSampler.cc
@@ -466,7 +466,7 @@ TextureSampler::registerMapForInvalidation(const std::string &fileName, scene_rd
 {

     // Textures could be loaded in parallel, use mutex to avoid data race.
-    tbb::recursive_mutex::scoped_lock lock(mMutex);
+    std::scoped_lock lock(mMutex);
     
     OIIO::ustring oiioFileName(fileName);

@@ -492,7 +492,7 @@ TextureSampler::registerMapForInvalidation(const std::string &fileName, scene_rd
 void
 TextureSampler::unregisterMapForInvalidation(scene_rdl2::rdl2::Shader *map)
 {
-    tbb::recursive_mutex::scoped_lock lock(mMutex);
+    std::scoped_lock lock(mMutex);
     MNRY_ASSERT(isValid());

     auto mapRange = mShaderToName.equal_range(map);