4
4
*
5
5
* GPU Accelerated JavaScript
6
6
*
7
- * @version 2.0.0-rc.4
8
- * @date Sun Mar 17 2019 22:11:56 GMT-0400 (Eastern Daylight Time)
7
+ * @version 2.0.0-rc.5
8
+ * @date Tue Mar 19 2019 08:40:39 GMT-0400 (Eastern Daylight Time)
9
9
*
10
10
* @license MIT
11
11
* The MIT License
@@ -2698,6 +2698,7 @@ class HeadlessGLKernel extends WebGLKernel {
2698
2698
OES_texture_float : testContext . getExtension ( 'OES_texture_float' ) ,
2699
2699
OES_texture_float_linear : testContext . getExtension ( 'OES_texture_float_linear' ) ,
2700
2700
OES_element_index_uint : testContext . getExtension ( 'OES_element_index_uint' ) ,
2701
+ WEBGL_draw_buffers : testContext . getExtension ( 'WEBGL_draw_buffers' ) ,
2701
2702
} ;
2702
2703
features = this . getFeatures ( ) ;
2703
2704
}
@@ -2715,12 +2716,16 @@ class HeadlessGLKernel extends WebGLKernel {
2715
2716
return Object . freeze ( {
2716
2717
isFloatRead : this . getIsFloatRead ( ) ,
2717
2718
isIntegerDivisionAccurate : this . getIsIntegerDivisionAccurate ( ) ,
2718
- getIsTextureFloat : true ,
2719
+ isTextureFloat : this . getIsTextureFloat ( ) ,
2719
2720
isDrawBuffers,
2720
2721
kernelMap : isDrawBuffers
2721
2722
} ) ;
2722
2723
}
2723
2724
2725
+ static getIsTextureFloat ( ) {
2726
+ return Boolean ( testExtensions . OES_texture_float ) ;
2727
+ }
2728
+
2724
2729
static getIsDrawBuffers ( ) {
2725
2730
return Boolean ( testExtensions . WEBGL_draw_buffers ) ;
2726
2731
}
@@ -2755,6 +2760,7 @@ class HeadlessGLKernel extends WebGLKernel {
2755
2760
OES_texture_float : this . context . getExtension ( 'OES_texture_float' ) ,
2756
2761
OES_texture_float_linear : this . context . getExtension ( 'OES_texture_float_linear' ) ,
2757
2762
OES_element_index_uint : this . context . getExtension ( 'OES_element_index_uint' ) ,
2763
+ WEBGL_draw_buffers : this . context . getExtension ( 'WEBGL_draw_buffers' ) ,
2758
2764
} ;
2759
2765
}
2760
2766
@@ -2764,6 +2770,7 @@ class HeadlessGLKernel extends WebGLKernel {
2764
2770
this . extensions . OES_texture_float = null ;
2765
2771
this . extensions . OES_texture_float_linear = null ;
2766
2772
this . extensions . OES_element_index_uint = null ;
2773
+ this . extensions . WEBGL_draw_buffers = null ;
2767
2774
}
2768
2775
2769
2776
static destroyContext ( context ) {
@@ -4309,7 +4316,7 @@ function webGLKernelString(gpuKernel, name) {
4309
4316
${ removeFnNoise ( gpuKernel . build . toString ( ) ) }
4310
4317
${ removeFnNoise ( gpuKernel . run . toString ( ) ) }
4311
4318
${ removeFnNoise ( gpuKernel . _addArgument . toString ( ) ) }
4312
- ${ removeFnNoise ( gpuKernel . _formatArrayTransfer . toString ( ) ) }
4319
+ ${ removeFnNoise ( gpuKernel . formatArrayTransfer . toString ( ) ) }
4313
4320
${ removeFnNoise ( gpuKernel . checkOutput . toString ( ) ) }
4314
4321
${ removeFnNoise ( gpuKernel . getArgumentTexture . toString ( ) ) }
4315
4322
${ removeFnNoise ( gpuKernel . getTextureCache . toString ( ) ) }
@@ -5079,7 +5086,7 @@ class WebGLKernel extends GLKernel {
5079
5086
const {
5080
5087
valuesFlat,
5081
5088
bitRatio
5082
- } = this . _formatArrayTransfer ( value , length ) ;
5089
+ } = this . formatArrayTransfer ( value , length ) ;
5083
5090
5084
5091
let buffer ;
5085
5092
if ( this . floatTextures ) {
@@ -5124,7 +5131,7 @@ class WebGLKernel extends GLKernel {
5124
5131
const {
5125
5132
valuesFlat,
5126
5133
bitRatio
5127
- } = this . _formatArrayTransfer ( value . value , length ) ;
5134
+ } = this . formatArrayTransfer ( value . value , length ) ;
5128
5135
5129
5136
if ( this . floatTextures ) {
5130
5137
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , input ) ;
@@ -5216,11 +5223,15 @@ class WebGLKernel extends GLKernel {
5216
5223
gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , gl . NEAREST ) ;
5217
5224
5218
5225
let length = size [ 0 ] * size [ 1 ] ;
5226
+ if ( this . floatTextures ) {
5227
+ length *= 4 ;
5228
+ length *= 4 ;
5229
+ }
5219
5230
5220
5231
const {
5221
5232
valuesFlat,
5222
5233
bitRatio
5223
- } = this . _formatArrayTransfer ( value , length ) ;
5234
+ } = this . formatArrayTransfer ( value , length ) ;
5224
5235
5225
5236
let buffer ;
5226
5237
if ( this . floatTextures ) {
@@ -5257,10 +5268,10 @@ class WebGLKernel extends GLKernel {
5257
5268
const {
5258
5269
valuesFlat,
5259
5270
bitRatio
5260
- } = this . _formatArrayTransfer ( value . value , length ) ;
5271
+ } = this . formatArrayTransfer ( value . value , length ) ;
5261
5272
5262
5273
if ( this . floatTextures ) {
5263
- gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , inputArray ) ;
5274
+ gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , valuesFlat ) ;
5264
5275
} else {
5265
5276
const buffer = new Uint8Array ( valuesFlat . buffer ) ;
5266
5277
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] / bitRatio , size [ 1 ] , 0 , gl . RGBA , gl . UNSIGNED_BYTE , buffer ) ;
@@ -5328,9 +5339,12 @@ class WebGLKernel extends GLKernel {
5328
5339
this . constantsLength ++ ;
5329
5340
}
5330
5341
5331
- _formatArrayTransfer ( value , length ) {
5342
+ formatArrayTransfer ( value , length ) {
5332
5343
let bitRatio = 1 ;
5333
5344
let valuesFlat = value ;
5345
+ if ( this . floatTextures ) {
5346
+ length *= 4 ;
5347
+ }
5334
5348
if ( utils . isArray ( value [ 0 ] ) || this . floatTextures ) {
5335
5349
valuesFlat = new Float32Array ( length ) ;
5336
5350
utils . flattenTo ( value , valuesFlat ) ;
@@ -5710,6 +5724,7 @@ class WebGLKernel extends GLKernel {
5710
5724
this . extensions . OES_texture_float = null ;
5711
5725
this . extensions . OES_texture_float_linear = null ;
5712
5726
this . extensions . OES_element_index_uint = null ;
5727
+ this . extensions . WEBGL_draw_buffers = null ;
5713
5728
}
5714
5729
5715
5730
static destroyContext ( context ) {
@@ -5729,6 +5744,7 @@ class WebGLKernel extends GLKernel {
5729
5744
module . exports = {
5730
5745
WebGLKernel
5731
5746
} ;
5747
+
5732
5748
} , { "../../plugins/triangle-noise" :26 , "../../texture" :27 , "../../utils" :28 , "../function-builder" :7 , "../gl-kernel" :9 , "./fragment-shader" :12 , "./function-node" :13 , "./kernel-string" :14 , "./vertex-shader" :16 } ] , 16 :[ function ( require , module , exports ) {
5733
5749
const vertexShader = `precision highp float;
5734
5750
precision highp int;
@@ -6291,7 +6307,7 @@ class WebGL2Kernel extends WebGLKernel {
6291
6307
const {
6292
6308
valuesFlat,
6293
6309
bitRatio
6294
- } = this . _formatArrayTransfer ( value , length ) ;
6310
+ } = this . formatArrayTransfer ( value , length ) ;
6295
6311
6296
6312
let buffer ;
6297
6313
if ( this . floatTextures ) {
@@ -6335,10 +6351,10 @@ class WebGL2Kernel extends WebGLKernel {
6335
6351
const {
6336
6352
valuesFlat,
6337
6353
bitRatio
6338
- } = this . _formatArrayTransfer ( value . value , length ) ;
6354
+ } = this . formatArrayTransfer ( value . value , length ) ;
6339
6355
6340
6356
if ( this . floatTextures ) {
6341
- gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA32F , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , inputArray ) ;
6357
+ gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA32F , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , valuesFlat ) ;
6342
6358
} else {
6343
6359
const buffer = new Uint8Array ( valuesFlat . buffer ) ;
6344
6360
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] / bitRatio , size [ 1 ] , 0 , gl . RGBA , gl . UNSIGNED_BYTE , buffer ) ;
@@ -6528,7 +6544,7 @@ class WebGL2Kernel extends WebGLKernel {
6528
6544
const {
6529
6545
valuesFlat,
6530
6546
bitRatio
6531
- } = this . _formatArrayTransfer ( value , length ) ;
6547
+ } = this . formatArrayTransfer ( value , length ) ;
6532
6548
6533
6549
let buffer ;
6534
6550
if ( this . floatTextures ) {
@@ -6565,10 +6581,10 @@ class WebGL2Kernel extends WebGLKernel {
6565
6581
const {
6566
6582
valuesFlat,
6567
6583
bitRatio
6568
- } = this . _formatArrayTransfer ( value . value , length ) ;
6584
+ } = this . formatArrayTransfer ( value . value , length ) ;
6569
6585
6570
6586
if ( this . floatTextures ) {
6571
- gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA32F , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , inputArray ) ;
6587
+ gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA32F , size [ 0 ] , size [ 1 ] , 0 , gl . RGBA , gl . FLOAT , valuesFlat ) ;
6572
6588
} else {
6573
6589
const buffer = new Uint8Array ( valuesFlat . buffer ) ;
6574
6590
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , size [ 0 ] / bitRatio , size [ 1 ] , 0 , gl . RGBA , gl . UNSIGNED_BYTE , buffer ) ;
@@ -6869,6 +6885,7 @@ class WebGL2Kernel extends WebGLKernel {
6869
6885
module . exports = {
6870
6886
WebGL2Kernel
6871
6887
} ;
6888
+
6872
6889
} , { "../../texture" :27 , "../../utils" :28 , "../function-builder" :7 , "../web-gl/kernel" :15 , "./fragment-shader" :17 , "./function-node" :18 , "./vertex-shader" :20 } ] , 20 :[ function ( require , module , exports ) {
6873
6890
const vertexShader = `#version 300 es
6874
6891
precision highp float;
@@ -7467,7 +7484,6 @@ class Texture {
7467
7484
module . exports = {
7468
7485
Texture
7469
7486
} ;
7470
-
7471
7487
} , { } ] , 28 :[ function ( require , module , exports ) {
7472
7488
const {
7473
7489
Input
@@ -7576,8 +7592,9 @@ const utils = {
7576
7592
}
7577
7593
7578
7594
if ( opt . floatTextures && ( ! output || opt . floatOutput ) ) {
7579
- w = numTexels = Math . ceil ( numTexels / 4 ) ;
7595
+ w = numTexels * 4 ;
7580
7596
}
7597
+
7581
7598
if ( h > 1 && w * h === numTexels ) {
7582
7599
return [ w , h ] ;
7583
7600
}
0 commit comments