(options: {
device?: GPUDevice;
renderSession?: SplatRenderSession;
createRenderSession?: WebGpuSplatPsnrSessionDeps['createRenderSession'];
computePsnrFromTextures?: WebGpuSplatPsnrSessionDeps['computePsnrFromTextures'];
computePsnrTextureReductionFromTextures?: WebGpuSplatPsnrSessionDeps['computePsnrTextureReductionFromTextures'];
createMetricFrame?: WebGpuSplatPsnrSessionDeps['createMetricFrame'];
} = {})
| 164 | } |
| 165 | |
| 166 | function createHarness(options: { |
| 167 | device?: GPUDevice; |
| 168 | renderSession?: SplatRenderSession; |
| 169 | createRenderSession?: WebGpuSplatPsnrSessionDeps['createRenderSession']; |
| 170 | computePsnrFromTextures?: WebGpuSplatPsnrSessionDeps['computePsnrFromTextures']; |
| 171 | computePsnrTextureReductionFromTextures?: WebGpuSplatPsnrSessionDeps['computePsnrTextureReductionFromTextures']; |
| 172 | createMetricFrame?: WebGpuSplatPsnrSessionDeps['createMetricFrame']; |
| 173 | } = {}) { |
| 174 | const splatFile = buildFile('scene.spz', 'spz'); |
| 175 | const loadedCloud = makeLoadedCloud(splatFile); |
| 176 | const sceneRelease = vi.fn(); |
| 177 | const sceneRef = makeSceneRef(sceneRelease); |
| 178 | const resourceManager = { |
| 179 | acquire: vi.fn(() => sceneRef), |
| 180 | dispose: vi.fn(), |
| 181 | }; |
| 182 | const renderSession = options.renderSession ?? makeRenderSession(); |
| 183 | const bitmap = makeBitmap(); |
| 184 | const groundTruthTexture = { |
| 185 | texture: makeTexture('ground-truth'), |
| 186 | width: 4, |
| 187 | height: 3, |
| 188 | dispose: vi.fn(), |
| 189 | }; |
| 190 | const metric = { |
| 191 | sumSquaredError: 492, |
| 192 | psnr: 32, |
| 193 | mse: 41, |
| 194 | validPixelCount: 12, |
| 195 | }; |
| 196 | const deps = { |
| 197 | loadGaussianCloudFromFile: vi.fn(async () => loadedCloud), |
| 198 | createSceneResourceManager: vi.fn(() => resourceManager), |
| 199 | createRenderSession: options.createRenderSession ?? vi.fn(() => renderSession), |
| 200 | createBitmap: vi.fn(async () => bitmap), |
| 201 | createGroundTruthTexture: vi.fn(() => groundTruthTexture), |
| 202 | computePsnrFromTextures: options.computePsnrFromTextures ?? vi.fn(async () => metric), |
| 203 | computePsnrTextureReductionFromTextures: options.computePsnrTextureReductionFromTextures |
| 204 | ?? vi.fn(async () => ({ sumSquaredError: 0, validPixelCount: 1 })), |
| 205 | createMetricFrame: options.createMetricFrame ?? vi.fn(() => makeFrame()), |
| 206 | } satisfies WebGpuSplatPsnrSessionDeps; |
| 207 | |
| 208 | return { |
| 209 | bitmap, |
| 210 | deps, |
| 211 | groundTruthTexture, |
| 212 | loadedCloud, |
| 213 | metric, |
| 214 | renderSession, |
| 215 | resourceManager, |
| 216 | sceneRef, |
| 217 | sceneRelease, |
| 218 | splatFile, |
| 219 | device: options.device ?? makeDevice().device, |
| 220 | }; |
| 221 | } |
| 222 | |
| 223 | describe('WebGPU splat PSNR session', () => { |
no test coverage detected