rhodonite
    Preparing search index...

    Class WebGpuStrategyBasic

    Basic WebGPU rendering strategy implementation that handles mesh rendering, storage buffer management, and shader program setup for WebGPU-based rendering pipeline.

    This class provides a complete rendering solution using WebGPU API, including:

    • Storage buffer management for efficient GPU data transfer
    • Shader program compilation and setup
    • Morph target and blend shape handling
    • Camera and transform matrix updates
    • Render pass execution with proper primitive sorting
    const strategy = WebGpuStrategyBasic.getInstance();
    strategy.prerender();
    strategy.common_$render(primitiveUids, renderPass, tickCount);

    Implements

    • CGAPIStrategy
    Index

    Methods

    • Loads and prepares a mesh component for rendering. Sets up vertex buffer objects (VBO) and vertex array objects (VAO) if not already done.

      Parameters

      Returns boolean

      True if the mesh was successfully loaded, false if the mesh is null

    • Performs common loading operations required for the WebGPU strategy. Initializes morph target arrays and updates blend shape storage buffers when needed.

      Returns void

    • Main rendering method that draws all primitives in the specified render pass. Handles different primitive types (opaque, translucent, blend) with appropriate depth writing settings.

      Parameters

      • primitiveUids: number[]

        Array of primitive UIDs to render, sorted by rendering order

      • renderPass: RenderPass

        The render pass configuration containing rendering settings

      • _renderPassTickCount: number
      • displayIdx: number

        The index of the display to render to

      Returns boolean

      True if any primitives were successfully rendered

    • Destroys all GPU resources held by this strategy. Should be called when the engine is being destroyed.

      Returns void

    • Performs pre-rendering operations required before drawing. Updates storage buffers when components have been modified and handles morph target updates. This method should be called once per frame before any rendering operations.

      Returns void

    • Renders a single primitive with the specified material and render settings. Handles shader setup, uniform buffer updates, and the actual draw call.

      Parameters

      • primitiveUid: number

        Unique identifier of the primitive to render

      • renderPass: RenderPass

        Render pass containing rendering configuration

      • zWrite: boolean

        Whether to enable depth buffer writing

      • displayIdx: number

        The index of the display to render to

      Returns boolean

      True if the primitive was successfully rendered

    • Sets up shader programs for materials using the WebGPU rendering strategy. This method orchestrates the shader compilation process by providing the necessary method definitions and property setters.

      Parameters

      • material: Material

        The material to create shader programs for

      • primitive: Primitive

        The primitive geometry that will use this material

      • vertexShaderMethodDefinitionsForVertexShader: string

        WGSL code containing vertex shader helper methods

      • vertexShaderMethodDefinitionsForPixelShader: string

        WGSL code containing pixel shader helper methods

      • propertySetterOfGlobalDataRepository: getShaderPropertyFuncOfGlobalDataRepository
      • propertySetterOfMaterial: getShaderPropertyFuncOfMaterial
      • morphedPositionGetter: string

      Returns void

    • Generates vertex shader method definitions for storage buffer access. These methods provide standardized access to transform matrices, visibility flags, and morphing functionality in vertex shaders.

      Parameters

      Returns string

      WGSL shader code containing helper functions for storage buffer access