Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/platform/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Texture {
if (options.numLevels !== undefined) {
this._numLevels = options.numLevels;
}
this._updateNumLevel();
this._updateNumLevels();

this._minFilter = options.minFilter ?? FILTER_LINEAR_MIPMAP_LINEAR;
this._magFilter = options.magFilter ?? FILTER_LINEAR;
Expand Down Expand Up @@ -376,7 +376,7 @@ class Texture {
this._width = Math.floor(width);
this._height = Math.floor(height);
this._depth = Math.floor(depth);
this._updateNumLevel();
this._updateNumLevels();

// re-create the implementation
this.impl = device.createTextureImpl(this);
Expand Down Expand Up @@ -421,7 +421,7 @@ class Texture {
this.renderVersionDirty = this.device.renderVersion;
}

_updateNumLevel() {
_updateNumLevels() {

const maxLevels = this.mipmaps ? TextureUtils.calcMipLevelsCount(this.width, this.height) : 1;
const requestedLevels = this._numLevelsRequested;
Expand Down Expand Up @@ -673,12 +673,25 @@ class Texture {
} else if (isIntegerPixelFormat(this._format)) {
Debug.warn('Texture#mipmaps: mipmap property cannot be changed on an integer texture, will remain false', this);
} else {
const oldMipmaps = this._mipmaps;
const oldNumLevels = this._numLevels;

this._mipmaps = v;
}
this._updateNumLevels();

if (v) {
this._needsMipmapsUpload = true;
this.device?.texturesToUpload?.add(this);
// Changing mip count on array textures requires re-creating immutable storage.
if (this.array && this._numLevels !== oldNumLevels) {
this.recreateImpl();
} else if (this._mipmaps !== oldMipmaps) {
this.propertyChanged(TEXPROPERTY_MIN_FILTER);

if (this._mipmaps) {
this._needsMipmapsUpload = true;
this.device?.texturesToUpload?.add(this);
} else {
this._needsMipmapsUpload = false;
}
}
}
}
}
Expand Down