(nbytes: number)
| 904 | |
| 905 | // DeviceAPI |
| 906 | private deviceAllocDataSpace(nbytes: number): GPUPointer { |
| 907 | // allocate 0 bytes buffer as 1 bytes buffer. |
| 908 | if (nbytes == 0) { |
| 909 | nbytes = 1; |
| 910 | } |
| 911 | const buffer = tryCreateBuffer(this.device, { |
| 912 | size: nbytes, |
| 913 | usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST, |
| 914 | }); |
| 915 | this.currAllocatedBytes += nbytes; |
| 916 | this.allAllocatedBytes += nbytes; |
| 917 | if (this.currAllocatedBytes > this.peakAllocatedBytes) { |
| 918 | this.peakAllocatedBytes = this.currAllocatedBytes; |
| 919 | } |
| 920 | const ptr = this.attachToBufferTable(buffer); |
| 921 | return ptr; |
| 922 | } |
| 923 | |
| 924 | private deviceFreeDataSpace(ptr: GPUPointer): void { |
| 925 | const idx = ptr; |
no test coverage detected