@@ -1170,6 +1170,22 @@ class WebglGraphicsDevice extends GraphicsDevice {
11701170 this . gpuProfiler . request ( ) ;
11711171 }
11721172
1173+ _uploadDirtyTextures ( ) {
1174+
1175+ this . textures . forEach ( ( texture ) => {
1176+ if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1177+ if ( ! texture . impl . _glTexture ) {
1178+ texture . impl . initialize ( this , texture ) ;
1179+ }
1180+
1181+ this . bindTexture ( texture ) ;
1182+ texture . impl . upload ( this , texture ) ;
1183+ texture . _needsUpload = false ;
1184+ texture . _needsMipmapsUpload = false ;
1185+ }
1186+ } ) ;
1187+ }
1188+
11731189 /**
11741190 * Start a render pass.
11751191 *
@@ -1181,6 +1197,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
11811197 DebugGraphics . pushGpuMarker ( this , `Pass:${ renderPass . name } ` ) ;
11821198 DebugGraphics . pushGpuMarker ( this , `START-PASS` ) ;
11831199
1200+ this . _uploadDirtyTextures ( ) ;
1201+
11841202 // set up render target
11851203 const rt = renderPass . renderTarget ?? this . backBuffer ;
11861204 this . renderTarget = rt ;
@@ -1543,7 +1561,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
15431561 if ( ! impl . _glTexture )
15441562 impl . initialize ( this , texture ) ;
15451563
1546- if ( impl . dirtyParameterFlags > 0 || texture . _needsUpload || texture . _needsMipmapsUpload ) {
1564+ if ( impl . dirtyParameterFlags > 0 ) {
15471565
15481566 // Ensure the specified texture unit is active
15491567 this . activeTexture ( textureUnit ) ;
@@ -1555,12 +1573,6 @@ class WebglGraphicsDevice extends GraphicsDevice {
15551573 this . setTextureParameters ( texture ) ;
15561574 impl . dirtyParameterFlags = 0 ;
15571575 }
1558-
1559- if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1560- impl . upload ( this , texture ) ;
1561- texture . _needsUpload = false ;
1562- texture . _needsMipmapsUpload = false ;
1563- }
15641576 } else {
15651577 // Ensure the texture is currently bound to the correct target on the specified texture unit.
15661578 // If the texture is already bound to the correct target on the specified unit, there's no need
0 commit comments