Skip to content

Commit ff111e5

Browse files
committed
WebGL _uploadDirtyTextures
1 parent 59708a4 commit ff111e5

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/platform/graphics/webgl/webgl-graphics-device.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/platform/graphics/webgl/webgl-render-target.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class WebglRenderTarget {
134134
colorBuffer._width = Math.min(colorBuffer.width, device.maxRenderBufferSize);
135135
colorBuffer._height = Math.min(colorBuffer.height, device.maxRenderBufferSize);
136136
device.setTexture(colorBuffer, 0);
137+
colorBuffer.upload(true);
137138
}
138139
// Attach the color buffer
139140
gl.framebufferTexture2D(
@@ -158,6 +159,7 @@ class WebglRenderTarget {
158159
depthBuffer._width = Math.min(depthBuffer.width, device.maxRenderBufferSize);
159160
depthBuffer._height = Math.min(depthBuffer.height, device.maxRenderBufferSize);
160161
device.setTexture(depthBuffer, 0);
162+
depthBuffer.upload(true);
161163
}
162164
// Attach
163165
if (target._stencil) {

src/platform/graphics/webgpu/webgpu-graphics-device.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
602602
_uploadDirtyTextures() {
603603

604604
this.textures.forEach((texture) => {
605-
if (texture._needsUpload || texture._needsMipmaps) {
605+
if (texture._needsUpload || texture._needsMipmapsUpload) {
606606
texture.upload();
607607
}
608608
});

0 commit comments

Comments
 (0)