Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call adjustVramSizeTracking for WebGPU textures #5915

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platform/graphics/texture.js
Expand Up @@ -34,7 +34,7 @@ class Texture {
*/
name;

/** @protected */
/** @ignore */
_gpuSize = 0;
mvaligursky marked this conversation as resolved.
Show resolved Hide resolved

/** @protected */
Expand Down
4 changes: 4 additions & 0 deletions src/platform/graphics/webgl/webgl-texture.js
Expand Up @@ -287,6 +287,10 @@ class WebglTexture {
this._glCreated = false;
}

/**
* @param {import('./webgl-graphics-device.js').WebglGraphicsDevice} device - The device.
* @param {import('../texture.js').Texture} texture - The texture to update.
*/
upload(device, texture) {

Debug.assert(texture.device, "Attempting to use a texture that has been destroyed.", texture);
Expand Down
8 changes: 8 additions & 0 deletions src/platform/graphics/webgpu/webgpu-texture.js
Expand Up @@ -384,6 +384,14 @@ class WebgpuTexture {
if (anyUploads && anyLevelMissing && texture.mipmaps && !isCompressedPixelFormat(texture.format)) {
device.mipmapRenderer.generate(this);
}

// update vram stats
if (texture._gpuSize) {
texture.adjustVramSizeTracking(device._vram, -texture._gpuSize);
}

texture._gpuSize = texture.gpuSize;
texture.adjustVramSizeTracking(device._vram, texture._gpuSize);
mvaligursky marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down