gpu-memory
v1.0.0
Published
Estimate the GPU memory used by textures.
Readme
gpu-memory
Estimate the GPU memory used by textures.

Installation
npm install gpu-memoryUsage
import { getTextureMemory } from "gpu-memory";
import createCanvasContext from "canvas-context";
const width = 1024;
const height = 1024;
const { context: gl } = createCanvasContext("webgl2", { width, height });
const texture = {
width,
height,
format: gl.RGBA,
type: gl.FLOAT,
mipmap: true,
};
console.log(getTextureMemory(texture));
// => 23068672 (23MB)API
Modules
Typedefs
gpu-memory
gpu-memory.getTextureMemory([options]) ⇒ number
Estimate the GPU memory used by a texture.
Kind: static method of gpu-memory Returns: number - Bytes
| Param | Type | Default | | --------- | ---------------------------------------------- | --------------- | | [options] | TextureOptions | {} |
TextureOptions : object
Kind: global typedef Properties
| Name | Type | Default | Description | | -------- | -------------------- | ------------------ | ------------- | | width | number | | | | height | number | | | | [depth] | number | 1 | | | format | GLenum | | WebGL2 format | | type | GLenum | | WebGL2 type | | [mipmap] | boolean | false | |
License
MIT. See license file.
