pixi.js
    Preparing search index...

    Function generateGpuLayoutGroups

    • Advanced

      Generates the default WebGPU bind group layout for a shader from its extracted structs and groups. Every binding is marked visible to both the vertex and fragment stages (GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT).

      This is the same generator GpuProgram uses internally when no gpuLayout is supplied. It is exported so you can build the default layout, tweak only the entries you care about (for example narrowing a binding's visibility to a single stage), and pass the complete result back in via the gpuLayout option - rather than hand-authoring the whole layout:

      Parameters

      • root0: StructsAndGroups

        The structs and groups extracted from the shader source, typically produced by extractStructAndGroups.

        Defines the structure of the extracted WGSL structs and groups.

        • groups: {
              accessMode: WgslAccessMode;
              binding: number;
              group: number;
              name: string;
              type: string;
          }[]
        • structs: { members: Record<string, string>; name: string }[]

      Returns ProgramPipelineLayoutDescription

      The generated bind group layout description, one entry array per bind group.

      import { extractStructAndGroups, generateGpuLayoutGroups, GpuProgram } from 'pixi.js';

      const gpuLayout = generateGpuLayoutGroups(extractStructAndGroups(source));

      // only expose this texture to the fragment stage
      gpuLayout[0][1].visibility = GPUShaderStage.FRAGMENT;

      const program = new GpuProgram({ vertex, fragment, gpuLayout });