()
| 212 | }; |
| 213 | |
| 214 | const runTiledParityCase = async (): Promise<{ |
| 215 | full: BrowserPsnrMetric; |
| 216 | tiled: BrowserPsnrMetric; |
| 217 | }> => { |
| 218 | const width = 4; |
| 219 | const height = 2; |
| 220 | const renderedPixels = new Uint8Array(width * height * 4); |
| 221 | const groundTruthPixels = new Uint8Array(width * height * 4); |
| 222 | for (let pixel = 0; pixel < width * height; pixel++) { |
| 223 | renderedPixels[pixel * 4 + 3] = 255; |
| 224 | groundTruthPixels[pixel * 4 + 3] = 255; |
| 225 | } |
| 226 | groundTruthPixels[1 * 4] = 10; |
| 227 | groundTruthPixels[7 * 4 + 1] = 20; |
| 228 | |
| 229 | const renderedTexture = device.createTexture({ |
| 230 | size: { width, height }, |
| 231 | format: 'rgba8unorm', |
| 232 | usage: textureUsageCopyDst | textureUsageTextureBinding, |
| 233 | }); |
| 234 | const groundTruthTexture = device.createTexture({ |
| 235 | size: { width, height }, |
| 236 | format: 'rgba8unorm', |
| 237 | usage: textureUsageCopyDst | textureUsageTextureBinding, |
| 238 | }); |
| 239 | try { |
| 240 | uploadTexture(renderedTexture, width, height, renderedPixels); |
| 241 | uploadTexture(groundTruthTexture, width, height, groundTruthPixels); |
| 242 | const full = await computePsnrFromRgbaTexturesWebGpu({ |
| 243 | device: trackedDevice, |
| 244 | renderedTexture, |
| 245 | groundTruthTexture, |
| 246 | width, |
| 247 | height, |
| 248 | }); |
| 249 | const left = await computePsnrTextureReductionFromRgbaTexturesWebGpu({ |
| 250 | device: trackedDevice, |
| 251 | renderedTexture, |
| 252 | groundTruthTexture, |
| 253 | width: 2, |
| 254 | height, |
| 255 | }); |
| 256 | const right = await computePsnrTextureReductionFromRgbaTexturesWebGpu({ |
| 257 | device: trackedDevice, |
| 258 | renderedTexture, |
| 259 | groundTruthTexture, |
| 260 | width: 2, |
| 261 | height, |
| 262 | renderedOrigin: { x: 2, y: 0 }, |
| 263 | groundTruthOrigin: { x: 2, y: 0 }, |
| 264 | }); |
| 265 | const tiled = computePsnrFromTextureReduction( |
| 266 | accumulatePsnrTextureReductions([left, right]) |
| 267 | ); |
| 268 | return { full, tiled }; |
| 269 | } finally { |
| 270 | renderedTexture.destroy(); |
| 271 | groundTruthTexture.destroy(); |
no test coverage detected