Skip to content

Commit

Permalink
fix texture vram tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims committed Nov 16, 2016
1 parent 9f81c61 commit e2bb125
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/graphics/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pc.extend(pc, function () {
var mips = 1;
if (tex._pot && (tex._mipmaps || tex._minFilter === gl.NEAREST_MIPMAP_NEAREST ||
tex._minFilter === gl.NEAREST_MIPMAP_LINEAR || tex._minFilter === gl.LINEAR_MIPMAP_NEAREST ||
tex._minFilter === gl.LINEAR_MIPMAP_LINEAR)) {
tex._minFilter === gl.LINEAR_MIPMAP_LINEAR) && ! (tex._compressed && tex._levels.length === 1)) {

mips = Math.round(Math.log2(Math.max(tex._width, tex._height)) + 1);
}
Expand Down Expand Up @@ -1229,7 +1229,18 @@ pc.extend(pc, function () {
texture._mipmapsUploaded = true;
}

if (texture._gpuSize) this._vram.tex -= texture._gpuSize;
if (texture._gpuSize) {
this._vram.tex -= texture._gpuSize;
// #ifdef PROFILER
if (texture.profilerHint === pc.TEXHINT_SHADOWMAP) {
this._vram.texShadow -= texture._gpuSize;
} else if (texture.profilerHint === pc.TEXHINT_ASSET) {
this._vram.texAsset -= texture._gpuSize;
} else if (texture.profilerHint === pc.TEXHINT_LIGHTMAP) {
this._vram.texLightmap -= texture._gpuSize;
}
// #endif
}

texture._gpuSize = gpuTexSize(gl, texture);
this._vram.tex += texture._gpuSize;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pc.extend(pc, function () {
this.device._vram.texShadow -= this._gpuSize;
} else if (this.profilerHint === pc.TEXHINT_ASSET) {
this.device._vram.texAsset -= this._gpuSize;
} else if (this.profilerHint === +pc.TEXHINT_LIGHTMAP) {
} else if (this.profilerHint === pc.TEXHINT_LIGHTMAP) {
this.device._vram.texLightmap -= this._gpuSize;
}
// #endif
Expand Down

0 comments on commit e2bb125

Please sign in to comment.