@@ -20,7 +20,7 @@ diff --git a/gfx/vr/VRManager.cpp b/gfx/vr/VRManager.cpp
20
20
MOZ_ASSERT(mBrowserState.layerState[0].type ==
21
21
VRLayerType::LayerType_Stereo_Immersive);
22
22
VRLayer_Stereo_Immersive& layer =
23
- @@ -1426 ,6 +1429 ,16 @@ bool VRManager::SubmitFrame(const layers
23
+ @@ -1427 ,6 +1430 ,16 @@ bool VRManager::SubmitFrame(const layers
24
24
layer.textureSize.width = desc.size().width;
25
25
layer.textureSize.height = desc.size().height;
26
26
} break;
@@ -37,7 +37,7 @@ diff --git a/gfx/vr/VRManager.cpp b/gfx/vr/VRManager.cpp
37
37
# endif
38
38
default: {
39
39
MOZ_ASSERT(false);
40
- @@ -1488 ,7 +1501 ,7 @@ void VRManager::SubmitFrameInternal(cons
40
+ @@ -1489 ,7 +1502 ,7 @@ void VRManager::SubmitFrameInternal(cons
41
41
mCurrentSubmitTask = nullptr;
42
42
}
43
43
@@ -70,10 +70,46 @@ diff --git a/gfx/vr/VRShMem.cpp b/gfx/vr/VRShMem.cpp
70
70
}
71
71
}
72
72
73
+ @@ -418,11 +426,12 @@ void VRShMem::PushBrowserState(VRBrowser
74
+ status = lock.GetStatus();
75
+ # endif // defined(XP_WIN)
76
+
77
+ - if (status) {
78
+ + if (status && pthread_mutex_lock((pthread_mutex_t*)&(mExternalShmem->geckoMutex)) == 0) {
79
+ mExternalShmem->geckoGenerationA = mExternalShmem->geckoGenerationA + 1;
80
+ memcpy((void*)&(mExternalShmem->geckoState), (void*)&aBrowserState,
81
+ sizeof(VRBrowserState));
82
+ mExternalShmem->geckoGenerationB = mExternalShmem->geckoGenerationB + 1;
83
+ + pthread_mutex_unlock((pthread_mutex_t*)&(mExternalShmem->geckoMutex));
84
+ }
85
+ #endif // defined(MOZ_WIDGET_ANDROID)
86
+ }
87
+ @@ -462,17 +471,15 @@ void VRShMem::PullBrowserState(mozilla::
88
+ }
89
+ # endif // defined(XP_WIN)
90
+ if (status) {
91
+ - VRExternalShmem tmp;
92
+ if (mExternalShmem->geckoGenerationA != mBrowserGeneration) {
93
+ // TODO - (void *) cast removes volatile semantics.
94
+ // The memcpy is not likely to be optimized out, but is theoretically
95
+ // possible. Suggest refactoring to either explicitly enforce memory
96
+ // order or to use locks.
97
+ - memcpy(&tmp, (void*)mExternalShmem, sizeof(VRExternalShmem));
98
+ - if (tmp.geckoGenerationA == tmp.geckoGenerationB &&
99
+ - tmp.geckoGenerationA != 0) {
100
+ - memcpy(&aState, &tmp.geckoState, sizeof(VRBrowserState));
101
+ - mBrowserGeneration = tmp.geckoGenerationA;
102
+ + if (pthread_mutex_lock((pthread_mutex_t*)&(mExternalShmem->geckoMutex)) == 0) {
103
+ + memcpy(&aState, (void*)&(mExternalShmem->geckoState), sizeof(VRBrowserState));
104
+ + mBrowserGeneration = mExternalShmem->geckoGenerationA;
105
+ + pthread_mutex_unlock((pthread_mutex_t*)&(mExternalShmem->geckoMutex));
106
+ }
107
+ }
108
+ }
73
109
diff --git a/gfx/vr/external_api/moz_external_vr.h b/gfx/vr/external_api/moz_external_vr.h
74
110
--- a/gfx/vr/external_api/moz_external_vr.h
75
111
+++ b/gfx/vr/external_api/moz_external_vr.h
76
- @@ -451 ,7 +451 ,8 @@ enum class VRLayerTextureType : uint16_t
112
+ @@ -452 ,7 +452 ,8 @@ enum class VRLayerTextureType : uint16_t
77
113
LayerTextureType_None = 0,
78
114
LayerTextureType_D3D10SurfaceDescriptor = 1,
79
115
LayerTextureType_MacIOSurface = 2,
@@ -83,6 +119,14 @@ diff --git a/gfx/vr/external_api/moz_external_vr.h b/gfx/vr/external_api/moz_ext
83
119
};
84
120
85
121
struct VRLayer_2D_Content {
122
+ @@ -619,6 +620,7 @@ struct VRExternalShmem {
123
+ pthread_cond_t servoCond;
124
+ #else
125
+ int64_t generationA;
126
+ + pthread_mutex_t geckoMutex;
127
+ #endif // defined(__ANDROID__)
128
+ VRSystemState state;
129
+ #if !defined(__ANDROID__)
86
130
diff --git a/gfx/vr/ipc/VRLayerChild.cpp b/gfx/vr/ipc/VRLayerChild.cpp
87
131
--- a/gfx/vr/ipc/VRLayerChild.cpp
88
132
+++ b/gfx/vr/ipc/VRLayerChild.cpp
@@ -111,7 +155,7 @@ diff --git a/gfx/vr/moz.build b/gfx/vr/moz.build
111
155
diff --git a/gfx/vr/service/OSVRSession.cpp b/gfx/vr/service/OSVRSession.cpp
112
156
--- a/gfx/vr/service/OSVRSession.cpp
113
157
+++ b/gfx/vr/service/OSVRSession.cpp
114
- @@ -497 ,7 +497 ,7 @@ bool OSVRSession::SubmitFrame(
158
+ @@ -496 ,7 +496 ,7 @@ bool OSVRSession::SubmitFrame(
115
159
return false;
116
160
// TODO Implement
117
161
}
@@ -135,7 +179,7 @@ diff --git a/gfx/vr/service/OSVRSession.h b/gfx/vr/service/OSVRSession.h
135
179
diff --git a/gfx/vr/service/OpenVRSession.cpp b/gfx/vr/service/OpenVRSession.cpp
136
180
--- a/gfx/vr/service/OpenVRSession.cpp
137
181
+++ b/gfx/vr/service/OpenVRSession.cpp
138
- @@ -1284 ,6 +1284 ,13 @@ bool OpenVRSession::SubmitFrame(
182
+ @@ -1273 ,6 +1273 ,13 @@ bool OpenVRSession::SubmitFrame(
139
183
return SubmitFrame(aTexture, ::vr::ETextureType::TextureType_IOSurface,
140
184
aLayer.leftEyeRect, aLayer.rightEyeRect);
141
185
}
@@ -149,7 +193,7 @@ diff --git a/gfx/vr/service/OpenVRSession.cpp b/gfx/vr/service/OpenVRSession.cpp
149
193
#endif
150
194
151
195
bool OpenVRSession::SubmitFrame(const VRLayerTextureHandle& aTextureHandle,
152
- @@ -1303 ,32 +1310 ,32 @@ bool OpenVRSession::SubmitFrame(const VR
196
+ @@ -1292 ,32 +1299 ,32 @@ bool OpenVRSession::SubmitFrame(const VR
153
197
154
198
CFTypeRefPtr<IOSurfaceRef> ioSurface = surf->GetIOSurfaceRef();
155
199
tex.handle = (void*)ioSurface.get();
@@ -232,7 +276,7 @@ diff --git a/gfx/vr/service/PuppetSession.h b/gfx/vr/service/PuppetSession.h
232
276
diff --git a/gfx/vr/service/VRSession.cpp b/gfx/vr/service/VRSession.cpp
233
277
--- a/gfx/vr/service/VRSession.cpp
234
278
+++ b/gfx/vr/service/VRSession.cpp
235
- @@ -12 ,6 +12 ,10 @@
279
+ @@ -14 ,6 +14 ,10 @@
236
280
# include <d3d11.h>
237
281
#endif // defined(XP_WIN)
238
282
@@ -243,7 +287,7 @@ diff --git a/gfx/vr/service/VRSession.cpp b/gfx/vr/service/VRSession.cpp
243
287
#if defined(MOZILLA_INTERNAL_API)
244
288
# if defined(XP_WIN)
245
289
# include "mozilla/gfx/Logging.h"
246
- @@ -148 ,6 +152 ,30 @@ bool VRSession::SubmitFrame(
290
+ @@ -152 ,6 +156 ,30 @@ bool VRSession::SubmitFrame(
247
291
return SubmitFrame(aLayer, aLayer.textureHandle);
248
292
}
249
293
@@ -305,7 +349,7 @@ diff --git a/gfx/vr/service/VRSession.h b/gfx/vr/service/VRSession.h
305
349
diff --git a/gfx/vr/service/moz.build b/gfx/vr/service/moz.build
306
350
--- a/gfx/vr/service/moz.build
307
351
+++ b/gfx/vr/service/moz.build
308
- @@ -32 ,6 +32 ,8 @@ if CONFIG["OS_TARGET "] in ("WINNT", "Lin
352
+ @@ -35 ,6 +35 ,8 @@ if CONFIG["TARGET_OS "] in ("WINNT", "OSX
309
353
"openvr",
310
354
]
311
355
LOCAL_INCLUDES += ["/dom/base", "/gfx/layers/d3d11"]
@@ -314,7 +358,7 @@ diff --git a/gfx/vr/service/moz.build b/gfx/vr/service/moz.build
314
358
315
359
# OpenVRSession includes MacIOSurface.h which includes Mac headers
316
360
# which define Size and Points types in the root namespace that
317
- @@ -45 ,4 +47 ,8 @@ if CONFIG["OS_TARGET "] in ("WINNT", "Lin
361
+ @@ -48 ,4 +50 ,8 @@ if CONFIG["TARGET_OS "] in ("WINNT", "OSX
318
362
"OpenVRViveMapper.cpp",
319
363
]
320
364
0 commit comments