File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 142142 function ret ( ) {
143143 if ( opt . floatTextures === true && ! GPUUtils . OES_texture_float ) {
144144 throw "Float textures are not supported on this browser" ;
145+ } else if ( opt . floatOutput === true && opt . floatOutputForce !== true && ! GPUUtils . test_floatReadPixels ( gpu ) ) {
146+ throw "Float texture outputs are not supported on this browser" ;
145147 } else if ( opt . floatTextures === undefined && GPUUtils . OES_texture_float ) {
146148 opt . floatTextures = true ;
149+ opt . floatOutput = GPUUtils . test_floatReadPixels ( gpu ) ;
147150 }
148151
149152 if ( ! opt . dimensions || opt . dimensions . length === 0 ) {
Original file line number Diff line number Diff line change @@ -416,5 +416,36 @@ var GPUUtils = (function() {
416416 }
417417 GPUUtils . init_webgl = init_webgl ;
418418
419+ // test_readPixels closure based memoizer
420+ var test_floatReadPixels_memoizer = null ;
421+ ///
422+ /// Function: test_floatReadPixels_memoizer
423+ ///
424+ /// Checks if the browser supports readPixels with float type
425+ ///
426+ /// Parameters:
427+ /// gpu - {gpu.js object} the gpu object
428+ ///
429+ /// Returns:
430+ /// {Boolean} true if browser supports
431+ ///
432+ function test_floatReadPixels ( gpu ) {
433+ if ( test_floatReadPixels_memoizer !== null ) {
434+ return test_floatReadPixels_memoizer
435+ }
436+
437+ var x = gpu . createKernel ( function ( ) {
438+ return 1 ;
439+ } , {
440+ 'dimensions' : [ 2 ] ,
441+ 'floatTextures' : true ,
442+ 'floatOutput' : true ,
443+ 'floatOutputForce' : true
444+ } ) . dimensions ( [ 2 ] ) ( ) ;
445+
446+ return x [ 0 ] == 1 ;
447+ }
448+ GPUUtils . test_floatReadPixels = test_floatReadPixels ;
449+
419450 return GPUUtils ;
420451} ) ( ) ;
You can’t perform that action at this time.
0 commit comments