@@ -1141,6 +1141,22 @@ class WebglGraphicsDevice extends GraphicsDevice {
1141
1141
this . gpuProfiler . request ( ) ;
1142
1142
}
1143
1143
1144
+ _uploadDirtyTextures ( ) {
1145
+
1146
+ this . textures . forEach ( ( texture ) => {
1147
+ if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1148
+ if ( ! texture . impl . _glTexture ) {
1149
+ texture . impl . initialize ( this , texture ) ;
1150
+ }
1151
+
1152
+ this . bindTexture ( texture ) ;
1153
+ texture . impl . upload ( this , texture ) ;
1154
+ texture . _needsUpload = false ;
1155
+ texture . _needsMipmapsUpload = false ;
1156
+ }
1157
+ } ) ;
1158
+ }
1159
+
1144
1160
/**
1145
1161
* Start a render pass.
1146
1162
*
@@ -1152,6 +1168,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
1152
1168
DebugGraphics . pushGpuMarker ( this , `Pass:${ renderPass . name } ` ) ;
1153
1169
DebugGraphics . pushGpuMarker ( this , 'START-PASS' ) ;
1154
1170
1171
+ this . _uploadDirtyTextures ( ) ;
1172
+
1155
1173
// set up render target
1156
1174
const rt = renderPass . renderTarget ?? this . backBuffer ;
1157
1175
this . renderTarget = rt ;
@@ -1515,7 +1533,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
1515
1533
impl . initialize ( this , texture ) ;
1516
1534
}
1517
1535
1518
- if ( impl . dirtyParameterFlags > 0 || texture . _needsUpload || texture . _needsMipmapsUpload ) {
1536
+ if ( impl . dirtyParameterFlags > 0 ) {
1519
1537
1520
1538
// Ensure the specified texture unit is active
1521
1539
this . activeTexture ( textureUnit ) ;
@@ -1527,12 +1545,6 @@ class WebglGraphicsDevice extends GraphicsDevice {
1527
1545
this . setTextureParameters ( texture ) ;
1528
1546
impl . dirtyParameterFlags = 0 ;
1529
1547
}
1530
-
1531
- if ( texture . _needsUpload || texture . _needsMipmapsUpload ) {
1532
- impl . upload ( this , texture ) ;
1533
- texture . _needsUpload = false ;
1534
- texture . _needsMipmapsUpload = false ;
1535
- }
1536
1548
} else {
1537
1549
// Ensure the texture is currently bound to the correct target on the specified texture unit.
1538
1550
// If the texture is already bound to the correct target on the specified unit, there's no need
0 commit comments