@@ -1303,6 +1303,22 @@ class WebglGraphicsDevice extends GraphicsDevice {
1303
1303
this . gpuProfiler . request ( ) ;
1304
1304
}
1305
1305
1306
+ _uploadDirtyTextures ( ) {
1307
+
1308
+ this . textures . forEach ( ( texture ) => {
1309
+ if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1310
+ if ( ! texture . impl . _glTexture ) {
1311
+ texture . impl . initialize ( this , texture ) ;
1312
+ }
1313
+
1314
+ this . bindTexture ( texture ) ;
1315
+ texture . impl . upload ( this , texture ) ;
1316
+ texture . _needsUpload = false ;
1317
+ texture . _needsMipmapsUpload = false ;
1318
+ }
1319
+ } ) ;
1320
+ }
1321
+
1306
1322
/**
1307
1323
* Start a render pass.
1308
1324
*
@@ -1314,6 +1330,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
1314
1330
DebugGraphics . pushGpuMarker ( this , `Pass:${ renderPass . name } ` ) ;
1315
1331
DebugGraphics . pushGpuMarker ( this , `START-PASS` ) ;
1316
1332
1333
+ this . _uploadDirtyTextures ( ) ;
1334
+
1317
1335
// set up render target
1318
1336
const rt = renderPass . renderTarget ?? this . backBuffer ;
1319
1337
this . renderTarget = rt ;
@@ -1676,7 +1694,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
1676
1694
if ( ! impl . _glTexture )
1677
1695
impl . initialize ( this , texture ) ;
1678
1696
1679
- if ( impl . dirtyParameterFlags > 0 || texture . _needsUpload || texture . _needsMipmapsUpload ) {
1697
+ if ( impl . dirtyParameterFlags > 0 ) {
1680
1698
1681
1699
// Ensure the specified texture unit is active
1682
1700
this . activeTexture ( textureUnit ) ;
@@ -1688,12 +1706,6 @@ class WebglGraphicsDevice extends GraphicsDevice {
1688
1706
this . setTextureParameters ( texture ) ;
1689
1707
impl . dirtyParameterFlags = 0 ;
1690
1708
}
1691
-
1692
- if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1693
- impl . upload ( this , texture ) ;
1694
- texture . _needsUpload = false ;
1695
- texture . _needsMipmapsUpload = false ;
1696
- }
1697
1709
} else {
1698
1710
// Ensure the texture is currently bound to the correct target on the specified texture unit.
1699
1711
// If the texture is already bound to the correct target on the specified unit, there's no need
0 commit comments