@@ -158,6 +158,9 @@ function registerWebGLBackend() {
158
158
tf . registerBackend ( 'rn-webgl' , async ( ) => {
159
159
const glContext = await GLView . createContextAsync ( ) ;
160
160
161
+ // ExpoGl getBufferSubData is not implemented yet (throws an exception).
162
+ tf . ENV . set ( 'WEBGL_BUFFER_SUPPORTED' , false ) ;
163
+
161
164
//
162
165
// Mock extension support for EXT_color_buffer_float and
163
166
// EXT_color_buffer_half_float on the expo-gl context object.
@@ -175,8 +178,7 @@ function registerWebGLBackend() {
175
178
//
176
179
//@ts -ignore
177
180
const getExt = glContext . getExtension . bind ( glContext ) ;
178
- // tslint:disable-next-line:only-arrow-functions
179
- const shimGetExt = function ( name : string ) {
181
+ const shimGetExt = ( name : string ) => {
180
182
if ( name === 'EXT_color_buffer_float' ) {
181
183
if ( RNPlatform . OS === 'ios' ) {
182
184
// iOS does not support EXT_color_buffer_float
@@ -191,20 +193,29 @@ function registerWebGLBackend() {
191
193
}
192
194
return getExt ( name ) ;
193
195
} ;
194
- //@ts -ignore
196
+
197
+ //
198
+ // Manually make 'read' synchronous. glContext has a defined gl.fenceSync
199
+ // function that throws a "Not implemented yet" exception so core
200
+ // cannot properly detect that it is not supported. We mock
201
+ // implementations of gl.fenceSync and gl.clientWaitSync
202
+ // TODO remove once fenceSync and clientWaitSync is implemented upstream.
203
+ //
204
+ const shimFenceSync = ( ) => {
205
+ return { } ;
206
+ } ;
207
+ const shimClientWaitSync = ( ) => glContext . CONDITION_SATISFIED ;
208
+
209
+ // @ts -ignore
195
210
glContext . getExtension = shimGetExt . bind ( glContext ) ;
211
+ glContext . fenceSync = shimFenceSync . bind ( glContext ) ;
212
+ glContext . clientWaitSync = shimClientWaitSync . bind ( glContext ) ;
196
213
197
214
// Set the WebGLContext before flag evaluation
198
215
tf . webgl . setWebGLContext ( 2 , glContext ) ;
199
216
const context = new tf . webgl . GPGPUContext ( ) ;
200
217
const backend = new tf . webgl . MathBackendWebGL ( context ) ;
201
- // Manually make 'read' synchronous. glContext has a defined gl.fenceSync
202
- // function that throws a "Not implemented yet" exception so core
203
- // cannot properly detect that it is not supported.
204
- // TODO remove once fenceSync is implemented upstream.
205
- backend . read = async ( dataId ) => {
206
- return backend . readSync ( dataId ) ;
207
- } ;
218
+
208
219
return backend ;
209
220
} , PRIORITY ) ;
210
221
} catch ( e ) {
0 commit comments