(
texture: BrowserGpuTexture,
width: number,
height: number,
pixels: Uint8Array
)
| 145 | } = await import(psnrModulePath) as BrowserPsnrModule; |
| 146 | |
| 147 | const uploadTexture = ( |
| 148 | texture: BrowserGpuTexture, |
| 149 | width: number, |
| 150 | height: number, |
| 151 | pixels: Uint8Array |
| 152 | ) => { |
| 153 | const bytesPerRow = Math.ceil((width * 4) / 256) * 256; |
| 154 | const upload = new Uint8Array(bytesPerRow * height); |
| 155 | for (let y = 0; y < height; y++) { |
| 156 | upload.set( |
| 157 | pixels.subarray(y * width * 4, (y + 1) * width * 4), |
| 158 | y * bytesPerRow |
| 159 | ); |
| 160 | } |
| 161 | device.queue.writeTexture( |
| 162 | { texture }, |
| 163 | upload, |
| 164 | { bytesPerRow, rowsPerImage: height }, |
| 165 | { width, height } |
| 166 | ); |
| 167 | }; |
| 168 | |
| 169 | const runCase = async ( |
| 170 | width: number, |
no test coverage detected