Advance Blender 5.2 web parity through M12-03D
This commit is contained in:
@@ -22,6 +22,20 @@ export interface TextureUploadStatus {
|
||||
budget: PBRTextureBudgetReport;
|
||||
}
|
||||
|
||||
export interface GPUTextureStoreStatsIR {
|
||||
entries: number;
|
||||
payloadBytes: number;
|
||||
decodedGPUBytes: number;
|
||||
keys: string[];
|
||||
}
|
||||
|
||||
export interface GPUTextureStoreReleaseIR {
|
||||
releasedTextures: number;
|
||||
releasedPayloadBytes: number;
|
||||
releasedGPUBytes: number;
|
||||
resourcesAfter: 0;
|
||||
}
|
||||
|
||||
function key(imageId: string, usage: GPUTextureUsage): string {
|
||||
return `${imageId}:${usage}`;
|
||||
}
|
||||
@@ -67,6 +81,16 @@ export class GPUTextureStore {
|
||||
return this.assets.get(key(imageId, usage));
|
||||
}
|
||||
|
||||
stats(): GPUTextureStoreStatsIR {
|
||||
const assets = [...this.assets.values()];
|
||||
return {
|
||||
entries: this.textures.size,
|
||||
payloadBytes: assets.reduce((total, asset) => total + asset.byteLength, 0),
|
||||
decodedGPUBytes: assets.reduce((total, asset) => total + asset.width * asset.height * 4, 0),
|
||||
keys: [...this.textures.keys()].sort(),
|
||||
};
|
||||
}
|
||||
|
||||
async upload(assets: readonly GPUTextureAsset[]): Promise<TextureUploadStatus> {
|
||||
const candidate = new Map(this.assets);
|
||||
for (const asset of assets) {
|
||||
@@ -161,10 +185,17 @@ export class GPUTextureStore {
|
||||
return true;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
dispose(): GPUTextureStoreReleaseIR {
|
||||
const before = this.stats();
|
||||
for (const texture of this.textures.values()) texture.dispose();
|
||||
this.textures.clear();
|
||||
this.assets.clear();
|
||||
this.udimTileCounts.clear();
|
||||
return {
|
||||
releasedTextures: before.entries,
|
||||
releasedPayloadBytes: before.payloadBytes,
|
||||
releasedGPUBytes: before.decodedGPUBytes,
|
||||
resourcesAfter: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user