expo/expo-three

`ExpoTHREE.Renderer.extensions::has` returns false for all well-known extensions?

wilson0x4d opened this issue · 3 comments

I'm having trouble resolving extension availability with ExpoTHREE.Renderer, all checks return false which seems unlikely.

I've been using ExpoTHREE successfully for perhaps a year now, no problems, but need to check TC extension availability at this point in our lifecycle. Consider the following code:

    readonly extensions: { [key: string]: boolean } = {};
    private populateExtensions(renderer: ExpoTHREE.Renderer) {
        const extensionsToCheck = [
            // TC extensions (what we need to know)
            'WEBGL_compressed_texture_astc',
            'WEBGL_compressed_texture_etc1',
            'WEBGL_compressed_texture_etc',
            'WEBGL_compressed_texture_s3tc',
            'EXT_texture_compression_bptc',
            'WEBGL_compressed_texture_pvrtc',
            'WEBKIT_WEBGL_compressed_texture_pvrtc',
            // Khronos ratified
            'OES_texture_float',
            'OES_texture_half_float',
            'WEBGL_lose_context',
            'OES_standard_derivatives',
            'OES_vertex_array_object',
            'WEBGL_debug_renderer_info',
            'WEBGL_debug_shaders',
            'WEBGL_compressed_texture_s3tc',
            'WEBGL_depth_texture',
            'OES_element_index_uint',
            'EXT_texture_filter_anisotropic',
            'EXT_frag_depth',
            'WEBGL_draw_buffers',
            'ANGLE_instanced_arrays',
            'OES_texture_float_linear',
            'OES_texture_half_float_linear',
            'EXT_blend_minmax',
            'EXT_shader_texture_lod',
            // community approved
            'WEBGL_compressed_texture_pvrtc',
            'EXT_color_buffer_half_float',
            'WEBGL_color_buffer_float',
            'EXT_sRGB',
            'WEBGL_compressed_texture_etc1',
            'EXT_disjoint_timer_query',
            'OES_fbo_render_mipmap',
            'WEBGL_compressed_texture_etc',
            'WEBGL_compressed_texture_astc',
            'EXT_color_buffer_float',
            'WEBGL_compressed_texture_s3tc_srgb',
            'EXT_disjoint_timer_query_webgl2',
            'EXT_float_blend',
            'OVR_multiview2',
            'KHR_parallel_shader_compile',
            'EXT_texture_compression_bptc',
            'EXT_texture_compression_rgtc',
            'WEBGL_multi_draw',
            'EXT_texture_norm16',
            // draft extensions
            'WEBGL_blend_equation_advanced_coherent',
            'EXT_clip_cull_distance',
            'OES_draw_buffers_indexed',
            'WEBGL_draw_instanced_base_vertex_base_instance',
            'WEBGL_multi_draw_instanced_base_vertex_base_instance',
            // rejected
            'EXT_texture_storage',
            'OES_depth24',
            'WEBGL_compressed_texture_atc',
            'WEBGL_debug_shader_precision',
            'WEBGL_draw_elements_no_range_check',
            'WEBGL_get_buffer_sub_data_async',
            'WEBGL_security_sensitive_resources',
            'WEBGL_shared_resources',
            'WEBGL_subscribe_uniform',
            'WEBGL_texture_from_depth_video'
        ];
        for (let i = 0; i < extensionsToCheck.length; i++) {
            const extension = extensionsToCheck[i];
            this.extensions[extension] = renderer.extensions.has(extension);
        }
        console.warn(this.extensions);
    }

Is there a better mechanism for checking extension support with ExpoTHREE?

In this case I am testing on an S10 phone (phy/non-emu), SDK level 29, Three 0.121.1, rn 0.63.4, and expo-three 5.6.2,

Thanks.

here is the logging output of the same code from above:

03-17 01:43:40.811  1004 13433 W ReactNativeJS: { WEBGL_compressed_texture_astc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_etc1: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_etc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_s3tc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_texture_compression_bptc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_pvrtc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBKIT_WEBGL_compressed_texture_pvrtc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_texture_float: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_texture_half_float: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_lose_context: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_standard_derivatives: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_vertex_array_object: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_debug_renderer_info: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_debug_shaders: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_depth_texture: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_element_index_uint: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_texture_filter_anisotropic: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_frag_depth: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_draw_buffers: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   ANGLE_instanced_arrays: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_texture_float_linear: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_texture_half_float_linear: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_blend_minmax: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_shader_texture_lod: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_color_buffer_half_float: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_color_buffer_float: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_sRGB: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_disjoint_timer_query: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_fbo_render_mipmap: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_color_buffer_float: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_s3tc_srgb: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_disjoint_timer_query_webgl2: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_float_blend: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OVR_multiview2: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   KHR_parallel_shader_compile: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_texture_compression_rgtc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_multi_draw: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_texture_norm16: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_blend_equation_advanced_coherent: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_clip_cull_distance: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_draw_buffers_indexed: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_draw_instanced_base_vertex_base_instance: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_multi_draw_instanced_base_vertex_base_instance: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   EXT_texture_storage: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   OES_depth24: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_compressed_texture_atc: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_debug_shader_precision: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_draw_elements_no_range_check: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_get_buffer_sub_data_async: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_security_sensitive_resources: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_shared_resources: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_subscribe_uniform: false,
03-17 01:43:40.811  1004 13433 W ReactNativeJS:   WEBGL_texture_from_depth_video: false }

lol, okay. this does seem like a problem:

NATIVE_METHOD(getSupportedExtensions) {
  return jsi::Array(runtime, 0);
}

NATIVE_METHOD(getExtension) {
  return nullptr;
}

Excerpt is from expo-gl-cpp:

https://github.com/expo/expo/blob/fa078bd395861307e70ec0622e4e7e37e038b8e9/packages/expo-gl-cpp/cpp/EXGLNativeMethods.cpp#L1565-L1574

This may also explain why all calls to context::getSupportedExtensions() returns an empty array and and context::getExtension() always returns null.

there is code which depends on this functioning correctly, for example, from THREE:

	detectSupport( renderer ) {

		this.transcoderConfig = {
			astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
			etc1Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc1' ),
			etc2Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc' ),
			dxtSupported: renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' ),
			bptcSupported: renderer.extensions.has( 'EXT_texture_compression_bptc' ),
			pvrtcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
				|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
		};

		return this;

	}

and another excerpt from THREE:

	detectSupport: function ( renderer ) {

		var config = this.workerConfig;

		config.astcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_astc' );
		config.bptcSupported = renderer.extensions.has( 'EXT_texture_compression_bptc' );
		config.etcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_etc1' );
		config.dxtSupported = renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' );
		config.pvrtcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
			|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );

		if ( config.astcSupported ) {

			config.format = BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4;

		} else if ( config.bptcSupported ) {

I can't believe I am the first person to need compressed textures or to validate available GLSL shader extensions, what to do?