MCPcopy Index your code
hub / github.com/tensorflow/tfjs / releaseTexture

Method releaseTexture

tfjs-backend-webgpu/src/texture_manager.ts:66–96  ·  view source on GitHub ↗
(texture: GPUTexture)

Source from the content-addressed store, hash-verified

64 }
65
66 releaseTexture(texture: GPUTexture) {
67 if (this.freeTextures.size === 0) {
68 return;
69 }
70
71 const width = texture.width;
72 const height = texture.height;
73 const format = texture.format;
74 const usage = texture.usage;
75
76 const key = getTextureKey(width, height, format, usage);
77 if (!this.freeTextures.has(key)) {
78 this.freeTextures.set(key, []);
79 }
80
81 this.freeTextures.get(key).push(texture);
82 this.numFreeTextures++;
83 this.numUsedTextures--;
84
85 const textureList = this.usedTextures.get(key);
86 const textureIndex = textureList.indexOf(texture);
87 if (textureIndex < 0) {
88 throw new Error(
89 'Cannot release a texture that was never provided by this ' +
90 'texture manager');
91 }
92 textureList.splice(textureIndex, 1);
93 const bytesPerElement = getBytesPerElement(format);
94 const byteSize = width * height * bytesPerElement;
95 this.numBytesUsed -= byteSize;
96 }
97
98 getNumUsedTextures(): number {
99 return this.numUsedTextures;

Callers 1

releaseResourceMethod · 0.45

Calls 6

getTextureKeyFunction · 0.85
getBytesPerElementFunction · 0.85
hasMethod · 0.80
setMethod · 0.45
pushMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected