Skip to content

Commit 79fbde6

Browse files
mvaligurskyMartin Valigursky
andauthored
Slightly expanded functionality of Texture.resize (#7807)
Co-authored-by: Martin Valigursky <[email protected]>
1 parent 327b0da commit 79fbde6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/platform/graphics/texture.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class Texture {
289289
this._levels = options.levels;
290290
const upload = !!options.levels;
291291
if (!this._levels) {
292-
this._levels = this._cubemap ? [[null, null, null, null, null, null]] : [null];
292+
this._clearLevels();
293293
}
294294

295295
this.recreateImpl(upload);
@@ -350,9 +350,16 @@ class Texture {
350350
}
351351
}
352352

353+
_clearLevels() {
354+
this._levels = this._cubemap ? [[null, null, null, null, null, null]] : [null];
355+
}
356+
353357
/**
354-
* Resizes the texture. Only supported for render target textures, as it does not resize the
355-
* existing content of the texture, but only the allocated buffer for rendering into.
358+
* Resizes the texture. This operation is supported for render target textures, and it resizes
359+
* the allocated buffer used for rendering, not the existing content of the texture.
360+
*
361+
* It is also supported for textures with data provided via the {@link lock} method. After
362+
* resizing, the appropriately sized data must be assigned by calling {@link lock} again.
356363
*
357364
* @param {number} width - The new width of the texture.
358365
* @param {number} height - The new height of the texture.
@@ -365,6 +372,7 @@ class Texture {
365372
const device = this.device;
366373
this.adjustVramSizeTracking(device._vram, -this._gpuSize);
367374
this.impl.destroy(device);
375+
this._clearLevels();
368376

369377
this._width = Math.floor(width);
370378
this._height = Math.floor(height);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
17131713

17141714
// missing generic texture
17151715
if (!samplerValue) {
1716-
Debug.errorOnce(`Shader ${shader.name} requires ${samplerName} texture which was not set. Rendering [${DebugGraphics.toString()}]`);
1716+
Debug.errorOnce(`Shader ${shader.name} requires ${samplerName} texture which was not set. Rendering [${DebugGraphics.toString()}]`, shader);
17171717
samplerValue = getBuiltInTexture(this, 'pink');
17181718
}
17191719
}

src/scene/materials/material.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ class Material {
751751

752752
Debug.call(() => {
753753
if (data === undefined) {
754-
Debug.warnOnce(`Material#setParameter: Attempting to set undefined data for parameter "${name}", this is likely not expected.`);
754+
Debug.warnOnce(`Material#setParameter: Attempting to set undefined data for parameter "${name}", this is likely not expected.`, this);
755755
}
756756
});
757757

0 commit comments

Comments
 (0)