@@ -1303,6 +1303,22 @@ class WebglGraphicsDevice extends GraphicsDevice {
13031303 this . gpuProfiler . request ( ) ;
13041304 }
13051305
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+
13061322 /**
13071323 * Start a render pass.
13081324 *
@@ -1314,6 +1330,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
13141330 DebugGraphics . pushGpuMarker ( this , `Pass:${ renderPass . name } ` ) ;
13151331 DebugGraphics . pushGpuMarker ( this , `START-PASS` ) ;
13161332
1333+ this . _uploadDirtyTextures ( ) ;
1334+
13171335 // set up render target
13181336 const rt = renderPass . renderTarget ?? this . backBuffer ;
13191337 this . renderTarget = rt ;
@@ -1676,7 +1694,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
16761694 if ( ! impl . _glTexture )
16771695 impl . initialize ( this , texture ) ;
16781696
1679- if ( impl . dirtyParameterFlags > 0 || texture . _needsUpload || texture . _needsMipmapsUpload ) {
1697+ if ( impl . dirtyParameterFlags > 0 ) {
16801698
16811699 // Ensure the specified texture unit is active
16821700 this . activeTexture ( textureUnit ) ;
@@ -1688,12 +1706,6 @@ class WebglGraphicsDevice extends GraphicsDevice {
16881706 this . setTextureParameters ( texture ) ;
16891707 impl . dirtyParameterFlags = 0 ;
16901708 }
1691-
1692- if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1693- impl . upload ( this , texture ) ;
1694- texture . _needsUpload = false ;
1695- texture . _needsMipmapsUpload = false ;
1696- }
16971709 } else {
16981710 // Ensure the texture is currently bound to the correct target on the specified texture unit.
16991711 // If the texture is already bound to the correct target on the specified unit, there's no need
0 commit comments