Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/webgpu/tests/reftest/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 4 kB image not shown  

Quelle  draw-storage-compute.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/webgpu/tests/reftest/draw-storage-compute.html


<!doctype html>

<!-- Render a triangle to a storage texture using a compute shader. The
     triangle should be displayed. Regression test for
     https://bugzilla.mozilla.org/show_bug.cgi?id=1972921. -->


<html class="reftest-wait">
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
    <canvas id="canvas" width=512 height=512></canvas>
  </body>
  <script>
    (async function() {
      try {
        var code = `
        @group(0) @binding(0var output: texture_storage_2d<{PRESENTATION_FORMAT}, write>;

        @compute @workgroup_size(1616)
        fn main(
          @builtin(global_invocation_id) invocation_id: vec3u
        ) {
          let x = i32(invocation_id.x);
          let y = i32(invocation_id.y);
          if (y >= 128 && y < 384 && 2 * x >= 640 - y && 2 * x < 384 + y) {
            textureStore(output, invocation_id.xy, vec4f(1001));
          } else {
            textureStore(output, invocation_id.xy, vec4f(0001));
          }
        }
        `;

        const canvas = document.querySelector('canvas');
        const adapter = await navigator.gpu?.requestAdapter({ });

        let presentationFormat = navigator.gpu.getPreferredCanvasFormat();
        if (presentationFormat != 'rgba8unorm' && presentationFormat != 'bgra8unorm') {
          throw new Error('Unsupported presentation format: ' + presentationFormat);
        }
        const deviceDescriptor = {};
        if (presentationFormat == 'bgra8unorm') {
          if (!adapter.features.has('bgra8unorm-storage')) {
            console.warn('Using rgba8unorm because bgra8unorm-storage feature is not available');
            presentationFormat = 'rgba8unorm';
          } else {
            deviceDescriptor.requiredFeatures = ['bgra8unorm-storage'];
          }
        }

        const device = await adapter?.requestDevice(deviceDescriptor);
        const context = canvas.getContext('webgpu');
        const devicePixelRatio = window.devicePixelRatio;
        canvas.width = canvas.clientWidth * devicePixelRatio;
        canvas.height = canvas.clientHeight * devicePixelRatio;
        context.configure({
          device,
          format: presentationFormat,
          usage: GPUTextureUsage.STORAGE_BINDING,
        });

        const canvasView = context.getCurrentTexture().createView();
        const bindGroupLayout = device.createBindGroupLayout({
          entries: [
            {
              binding: 0,
              visibility: GPUShaderStage.COMPUTE,
              storageTexture: {
                access: 'write-only',
                format: presentationFormat,
                viewDimension: '2d',
              },
            },
          ],
        });
        const bindGroup = device.createBindGroup({
          layout: bindGroupLayout,
          entries: [
            {
              binding: 0,
              resource: canvasView,
            },
          ],
        });

        const pipelineLayout = device.createPipelineLayout({
          bindGroupLayouts: [bindGroupLayout],
        });
        const pipeline = device.createComputePipeline({
          layout: pipelineLayout,
          compute: {
            module: device.createShaderModule({
              codecode.replace('{PRESENTATION_FORMAT}', presentationFormat),
            }),
          },
        });

        const commandEncoder = device.createCommandEncoder();
        const passEncoder = commandEncoder.beginComputePass();
        passEncoder.setBindGroup(0, bindGroup);
        passEncoder.setPipeline(pipeline);
        passEncoder.dispatchWorkgroups(3232);
        passEncoder.end();
        device.queue.submit([commandEncoder.finish()]);
        await device.queue.onSubmittedWorkDone();
        requestAnimationFrame(() => {
          requestAnimationFrame(() => document.documentElement.className = '');
        });
      } catch (error) {
        console.error(error);
        document.getElementById('canvas').style.display = 'none';
        document.body.append(error.toString());
        document.documentElement.className = '';
      }
    })();
  </script>
</html>

Messung V0.5 in Prozent
C=78 H=98 G=88

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.