Skip to content

texture builtins: For most texture builtins, Vulkan only allows compile-time-constant offset, and with with bounded range #1235

@dneto0

Description

@dneto0

The WGSL texture functions have an offset parameter of signed integral type (with same number of components as the coordinate). So far these are not otherwise constrained.

But Vulkan requires these to be compile-time constants.

Also, implementations have defined limits minTexelOffset (no higher than -8) and maxTexelOffset (no lower than 7)
See the Required Limits table.
Metal/MSL also limit the range from -8 through 7+.

Background: The offset operand in texture functions for Vulkan/SPIR-V has a few limitations that we need to account for:

  • There are 3 relevant image operands in SPIR-V
    • Offset: allows non-constant integer coordinate offset.
      - Vulkan limits this to only the OpImageGather and OpImageDrefGather instructions. See Vulkan spir-v environment: "Image operand Offset must only be used with OpImage*Gather instructions."
    • ConstOffsets: allows array of compile-time-constant offsets for Gather and DrefGather.
    • ConstOffset : usable by many image instructions. This only allows a compile-time-constant offset.

@ben-clayton

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions