• Builds, runs then checks the output of a flow control shader test.

    build_wgsl is a function that's called to build the WGSL shader. This function takes a FlowControlTestBuilder as the single argument, and returns either a string which is embedded into the WGSL entrypoint function, or an object of the signature { entrypoint: string; extra: string } which contains the entrypoint code, along with additional module-scope code.

    The FlowControlTestBuilder should be used to insert expectations into WGSL to validate control flow. FlowControlTestBuilder also can be used to add values to the shader which cannot be optimized away.

    Example, testing that an if-statement behaves as expected:

      runFlowControlTest(t, f =>
    `
    ${f.expect_order(0)}
    if (${f.value(true)}) {
    ${f.expect_order(1)}
    } else {
    ${f.expect_not_reached()}
    }
    ${f.expect_order(2)}
    `);

    Parameters

    • t: FlowControlTest

      The test object

    • build_wgsl: ((builder) => string | {
          entrypoint: string;
          extra: string;
      })
        • (builder): string | {
              entrypoint: string;
              extra: string;
          }
        • Parameters

          • builder: FlowControlTestBuilder

          Returns string | {
              entrypoint: string;
              extra: string;
          }

    Returns void

Generated using TypeDoc