@@ -305,6 +305,10 @@ class GLKernel extends Kernel {
305
305
super ( source , settings ) ;
306
306
this . transferValues = null ;
307
307
this . formatValues = null ;
308
+ /**
309
+ *
310
+ * @type {Texture }
311
+ */
308
312
this . TextureConstructor = null ;
309
313
this . renderOutput = null ;
310
314
this . renderRawOutput = null ;
@@ -314,6 +318,8 @@ class GLKernel extends Kernel {
314
318
this . compiledFragmentShader = null ;
315
319
this . compiledVertexShader = null ;
316
320
this . switchingKernels = null ;
321
+ this . prevInput = null ;
322
+ this . prevMappedInputs = null ;
317
323
}
318
324
319
325
checkTextureSize ( ) {
@@ -483,7 +489,7 @@ class GLKernel extends Kernel {
483
489
case 'LiteralInteger' :
484
490
case 'Float' :
485
491
case 'Number' :
486
- case 'Integer' :
492
+ case 'Integer' : {
487
493
if ( this . output [ 2 ] > 0 ) {
488
494
this . TextureConstructor = GLTextureMemoryOptimized3D ;
489
495
this . renderStrategy = renderStrategy . MemoryOptimizedFloatPixelToMemoryOptimized3DFloat ;
@@ -500,64 +506,68 @@ class GLKernel extends Kernel {
500
506
this . formatValues = utils . erectMemoryOptimizedFloat ;
501
507
return null ;
502
508
}
503
- case 'Array(2)' :
504
- if ( this . output [ 2 ] > 0 ) {
505
- this . TextureConstructor = GLTextureArray2Float3D ;
506
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray2 ;
507
- this . formatValues = utils . erect3DArray2 ;
508
- return null ;
509
- } else if ( this . output [ 1 ] > 0 ) {
510
- this . TextureConstructor = GLTextureArray2Float2D ;
511
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray2 ;
512
- this . formatValues = utils . erect2DArray2 ;
513
- return null ;
514
- } else {
515
- this . TextureConstructor = GLTextureArray2Float ;
516
- this . renderStrategy = renderStrategy . FloatPixelToArray2 ;
517
- this . formatValues = utils . erectArray2 ;
518
- return null ;
519
- }
520
- case 'Array(3)' :
521
- if ( this . output [ 2 ] > 0 ) {
522
- this . TextureConstructor = GLTextureArray3Float3D ;
523
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray3 ;
524
- this . formatValues = utils . erect3DArray3 ;
525
- return null ;
526
- } else if ( this . output [ 1 ] > 0 ) {
527
- this . TextureConstructor = GLTextureArray3Float2D ;
528
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray3 ;
529
- this . formatValues = utils . erect2DArray3 ;
530
- return null ;
531
- } else {
532
- this . TextureConstructor = GLTextureArray3Float ;
533
- this . renderStrategy = renderStrategy . FloatPixelToArray3 ;
534
- this . formatValues = utils . erectArray3 ;
535
- return null ;
536
- }
537
- case 'Array(4)' :
538
- if ( this . output [ 2 ] > 0 ) {
539
- this . TextureConstructor = GLTextureArray4Float3D ;
540
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray4 ;
541
- this . formatValues = utils . erect3DArray4 ;
542
- return null ;
543
- } else if ( this . output [ 1 ] > 0 ) {
544
- this . TextureConstructor = GLTextureArray4Float2D ;
545
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray4 ;
546
- this . formatValues = utils . erect2DArray4 ;
547
- return null ;
548
- } else {
549
- this . TextureConstructor = GLTextureArray4Float ;
550
- this . renderStrategy = renderStrategy . FloatPixelToArray4 ;
551
- this . formatValues = utils . erectArray4 ;
552
- return null ;
553
- }
509
+ }
510
+ case 'Array(2)' : {
511
+ if ( this . output [ 2 ] > 0 ) {
512
+ this . TextureConstructor = GLTextureArray2Float3D ;
513
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray2 ;
514
+ this . formatValues = utils . erect3DArray2 ;
515
+ return null ;
516
+ } else if ( this . output [ 1 ] > 0 ) {
517
+ this . TextureConstructor = GLTextureArray2Float2D ;
518
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray2 ;
519
+ this . formatValues = utils . erect2DArray2 ;
520
+ return null ;
521
+ } else {
522
+ this . TextureConstructor = GLTextureArray2Float ;
523
+ this . renderStrategy = renderStrategy . FloatPixelToArray2 ;
524
+ this . formatValues = utils . erectArray2 ;
525
+ return null ;
526
+ }
527
+ }
528
+ case 'Array(3)' : {
529
+ if ( this . output [ 2 ] > 0 ) {
530
+ this . TextureConstructor = GLTextureArray3Float3D ;
531
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray3 ;
532
+ this . formatValues = utils . erect3DArray3 ;
533
+ return null ;
534
+ } else if ( this . output [ 1 ] > 0 ) {
535
+ this . TextureConstructor = GLTextureArray3Float2D ;
536
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray3 ;
537
+ this . formatValues = utils . erect2DArray3 ;
538
+ return null ;
539
+ } else {
540
+ this . TextureConstructor = GLTextureArray3Float ;
541
+ this . renderStrategy = renderStrategy . FloatPixelToArray3 ;
542
+ this . formatValues = utils . erectArray3 ;
543
+ return null ;
544
+ }
545
+ }
546
+ case 'Array(4)' : {
547
+ if ( this . output [ 2 ] > 0 ) {
548
+ this . TextureConstructor = GLTextureArray4Float3D ;
549
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray4 ;
550
+ this . formatValues = utils . erect3DArray4 ;
551
+ return null ;
552
+ } else if ( this . output [ 1 ] > 0 ) {
553
+ this . TextureConstructor = GLTextureArray4Float2D ;
554
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray4 ;
555
+ this . formatValues = utils . erect2DArray4 ;
556
+ return null ;
557
+ } else {
558
+ this . TextureConstructor = GLTextureArray4Float ;
559
+ this . renderStrategy = renderStrategy . FloatPixelToArray4 ;
560
+ this . formatValues = utils . erectArray4 ;
561
+ return null ;
562
+ }
563
+ }
554
564
}
555
565
} else {
556
566
switch ( this . returnType ) {
557
567
case 'LiteralInteger' :
558
568
case 'Float' :
559
569
case 'Number' :
560
- case 'Integer' :
570
+ case 'Integer' : {
561
571
if ( this . output [ 2 ] > 0 ) {
562
572
this . TextureConstructor = GLTextureFloat3D ;
563
573
this . renderStrategy = renderStrategy . FloatPixelTo3DFloat ;
@@ -574,57 +584,61 @@ class GLKernel extends Kernel {
574
584
this . formatValues = utils . erectFloat ;
575
585
return null ;
576
586
}
577
- case 'Array(2)' :
578
- if ( this . output [ 2 ] > 0 ) {
579
- this . TextureConstructor = GLTextureArray2Float3D ;
580
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray2 ;
581
- this . formatValues = utils . erect3DArray2 ;
582
- return null ;
583
- } else if ( this . output [ 1 ] > 0 ) {
584
- this . TextureConstructor = GLTextureArray2Float2D ;
585
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray2 ;
586
- this . formatValues = utils . erect2DArray2 ;
587
- return null ;
588
- } else {
589
- this . TextureConstructor = GLTextureArray2Float ;
590
- this . renderStrategy = renderStrategy . FloatPixelToArray2 ;
591
- this . formatValues = utils . erectArray2 ;
592
- return null ;
593
- }
594
- case 'Array(3)' :
595
- if ( this . output [ 2 ] > 0 ) {
596
- this . TextureConstructor = GLTextureArray3Float3D ;
597
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray3 ;
598
- this . formatValues = utils . erect3DArray3 ;
599
- return null ;
600
- } else if ( this . output [ 1 ] > 0 ) {
601
- this . TextureConstructor = GLTextureArray3Float2D ;
602
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray3 ;
603
- this . formatValues = utils . erect2DArray3 ;
604
- return null ;
605
- } else {
606
- this . TextureConstructor = GLTextureArray3Float ;
607
- this . renderStrategy = renderStrategy . FloatPixelToArray3 ;
608
- this . formatValues = utils . erectArray3 ;
609
- return null ;
610
- }
611
- case 'Array(4)' :
612
- if ( this . output [ 2 ] > 0 ) {
613
- this . TextureConstructor = GLTextureArray4Float3D ;
614
- this . renderStrategy = renderStrategy . FloatPixelTo3DArray4 ;
615
- this . formatValues = utils . erect3DArray4 ;
616
- return null ;
617
- } else if ( this . output [ 1 ] > 0 ) {
618
- this . TextureConstructor = GLTextureArray4Float2D ;
619
- this . renderStrategy = renderStrategy . FloatPixelTo2DArray4 ;
620
- this . formatValues = utils . erect2DArray4 ;
621
- return null ;
622
- } else {
623
- this . TextureConstructor = GLTextureArray4Float ;
624
- this . renderStrategy = renderStrategy . FloatPixelToArray4 ;
625
- this . formatValues = utils . erectArray4 ;
626
- return null ;
627
- }
587
+ }
588
+ case 'Array(2)' : {
589
+ if ( this . output [ 2 ] > 0 ) {
590
+ this . TextureConstructor = GLTextureArray2Float3D ;
591
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray2 ;
592
+ this . formatValues = utils . erect3DArray2 ;
593
+ return null ;
594
+ } else if ( this . output [ 1 ] > 0 ) {
595
+ this . TextureConstructor = GLTextureArray2Float2D ;
596
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray2 ;
597
+ this . formatValues = utils . erect2DArray2 ;
598
+ return null ;
599
+ } else {
600
+ this . TextureConstructor = GLTextureArray2Float ;
601
+ this . renderStrategy = renderStrategy . FloatPixelToArray2 ;
602
+ this . formatValues = utils . erectArray2 ;
603
+ return null ;
604
+ }
605
+ }
606
+ case 'Array(3)' : {
607
+ if ( this . output [ 2 ] > 0 ) {
608
+ this . TextureConstructor = GLTextureArray3Float3D ;
609
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray3 ;
610
+ this . formatValues = utils . erect3DArray3 ;
611
+ return null ;
612
+ } else if ( this . output [ 1 ] > 0 ) {
613
+ this . TextureConstructor = GLTextureArray3Float2D ;
614
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray3 ;
615
+ this . formatValues = utils . erect2DArray3 ;
616
+ return null ;
617
+ } else {
618
+ this . TextureConstructor = GLTextureArray3Float ;
619
+ this . renderStrategy = renderStrategy . FloatPixelToArray3 ;
620
+ this . formatValues = utils . erectArray3 ;
621
+ return null ;
622
+ }
623
+ }
624
+ case 'Array(4)' : {
625
+ if ( this . output [ 2 ] > 0 ) {
626
+ this . TextureConstructor = GLTextureArray4Float3D ;
627
+ this . renderStrategy = renderStrategy . FloatPixelTo3DArray4 ;
628
+ this . formatValues = utils . erect3DArray4 ;
629
+ return null ;
630
+ } else if ( this . output [ 1 ] > 0 ) {
631
+ this . TextureConstructor = GLTextureArray4Float2D ;
632
+ this . renderStrategy = renderStrategy . FloatPixelTo2DArray4 ;
633
+ this . formatValues = utils . erect2DArray4 ;
634
+ return null ;
635
+ } else {
636
+ this . TextureConstructor = GLTextureArray4Float ;
637
+ this . renderStrategy = renderStrategy . FloatPixelToArray4 ;
638
+ this . formatValues = utils . erectArray4 ;
639
+ return null ;
640
+ }
641
+ }
628
642
}
629
643
}
630
644
} else {
@@ -801,16 +815,7 @@ class GLKernel extends Kernel {
801
815
}
802
816
803
817
renderTexture ( ) {
804
- return new this . TextureConstructor ( {
805
- texture : this . outputTexture ,
806
- size : this . texSize ,
807
- dimensions : this . threadDim ,
808
- output : this . output ,
809
- context : this . context ,
810
- kernel : this ,
811
- internalFormat : this . getInternalFormat ( ) ,
812
- textureFormat : this . getTextureFormat ( ) ,
813
- } ) ;
818
+ return this . texture . clone ( ) ;
814
819
}
815
820
readPackedPixelsToUint8Array ( ) {
816
821
if ( this . precision !== 'unsigned' ) throw new Error ( 'Requires this.precision to be "unsigned"' ) ;
@@ -862,15 +867,7 @@ class GLKernel extends Kernel {
862
867
result : this . renderOutput ( ) ,
863
868
} ;
864
869
for ( let i = 0 ; i < this . subKernels . length ; i ++ ) {
865
- result [ this . subKernels [ i ] . property ] = new this . TextureConstructor ( {
866
- texture : this . subKernelOutputTextures [ i ] ,
867
- size : this . texSize ,
868
- dimensions : this . threadDim ,
869
- output : this . output ,
870
- context : this . context ,
871
- internalFormat : this . getInternalFormat ( ) ,
872
- textureFormat : this . getTextureFormat ( ) ,
873
- } ) . toArray ( ) ;
870
+ result [ this . subKernels [ i ] . property ] = this . mappedTextures [ i ] . toArray ( ) ;
874
871
}
875
872
return result ;
876
873
}
@@ -880,15 +877,7 @@ class GLKernel extends Kernel {
880
877
result : this . renderOutput ( ) ,
881
878
} ;
882
879
for ( let i = 0 ; i < this . subKernels . length ; i ++ ) {
883
- result [ this . subKernels [ i ] . property ] = new this . TextureConstructor ( {
884
- texture : this . subKernelOutputTextures [ i ] ,
885
- size : this . texSize ,
886
- dimensions : this . threadDim ,
887
- output : this . output ,
888
- context : this . context ,
889
- internalFormat : this . getInternalFormat ( ) ,
890
- textureFormat : this . getTextureFormat ( ) ,
891
- } ) ;
880
+ result [ this . subKernels [ i ] . property ] = this . mappedTextures [ i ] . clone ( ) ;
892
881
}
893
882
return result ;
894
883
}
0 commit comments