| <script> |
| async function makeDataUrl(width, height, color) { |
| let offscreenCanvas = new OffscreenCanvas(width, height); |
| let ctx = offscreenCanvas.getContext('2d'); |
| ctx.fillStyle = color; |
| ctx.fillRect(0, 0, width, height); |
| let blob = await offscreenCanvas.convertToBlob(); |
| let fileReader = new FileReader(); |
| fileReader.readAsDataURL(blob); |
| return new Promise(resolve => { |
| fileReader.onload = () => { |
| resolve(fileReader.result); |
| }; |
| }); |
| } |
| |
| async function imageWithData(width, height, color) { |
| let dataUrl = await makeDataUrl(width, height, color); |
| let img = document.createElement('img'); |
| img.src = dataUrl; |
| await img.decode(); |
| return img; |
| } |
| |
| if (window.testRunner) { testRunner.waitUntilDone(); testRunner.dumpAsText() } |
| onload = async () => { |
| let adapter0 = await navigator.gpu.requestAdapter( |
| { |
| } |
| ); |
| |
| let device0 = await adapter0.requestDevice( |
| { |
| requiredFeatures: [ |
| 'depth-clip-control', |
| 'depth32float-stencil8', |
| 'shader-f16', |
| 'rg11b10ufloat-renderable', |
| 'bgra8unorm-storage' |
| ], |
| } |
| ); |
| |
| let img0 = await imageWithData(2, 245, '#b84778'); |
| |
| let texture3 = device0.createTexture( |
| { |
| size: { |
| width: 5209, |
| height: 5392, |
| depthOrArrayLayers: 1, |
| }, |
| mipLevelCount: 7, |
| sampleCount: 1, |
| dimension: '3d', |
| format: 'rgba16float', |
| usage: GPUTextureUsage.COPY_SRC, |
| viewFormats: [ |
| 'rgb9e5ufloat' |
| ], |
| } |
| ); |
| |
| device0.queue.copyExternalImageToTexture( |
| { |
| source: img0, |
| origin: [ |
| |
| ], |
| }, |
| { |
| texture: texture3, |
| mipLevel: 6208, |
| origin: [ |
| 2518, |
| 3374 |
| ], |
| aspect: 'depth-only', |
| colorSpace: 'srgb', |
| premultipliedAlpha: true, |
| }, |
| [ |
| |
| ] |
| ); |
| if (window.testRunner) { testRunner.notifyDone() } |
| }; |
| </script> |
| This test passes if it does not crash. |