Texture Fetch Survey

This document surveys how texture fetch instructions are modeled in modern GPU APIs and how they are executed in practice on mainstream desktop and mobile GPUs.

Scope:

1) Are texture instructions sync, async, queued, mailboxed?

Short answer:

Practical model:

  1. A wave/warp executes ALU until it reaches a texture op.
  2. The texture op issues one or more requests (after address/filter setup).
  3. The wave may stall on dependent use of that result.
  4. The scheduler runs other ready waves to hide the latency.
  5. When data returns, the original wave becomes runnable again.

So texture fetches are best described as:

2) Texture instruction families and parameters

2.1 Common semantic families

Family Typical API forms Coordinate domain Filtering LOD source
Implicit sample GLSL texture, HLSL Sample, SPIR-V OpImageSampleImplicitLod Normalized (except rect/buffer forms) Sampler-controlled Hardware derivatives (mostly fragment)
Explicit LOD GLSL textureLod, HLSL SampleLevel, SPIR-V OpImageSampleExplicitLod Normalized Sampler-controlled Shader-provided
Explicit gradients GLSL textureGrad, HLSL SampleGrad, SPIR-V explicit grad image sample Normalized Sampler-controlled Shader-provided ddx/ddy
Texel fetch (unfiltered) GLSL texelFetch, HLSL Load, SPIR-V OpImageFetch Integer texel space None (point fetch) Explicit mip / sample index
Gather GLSL textureGather, HLSL Gather*, SPIR-V gather ops Normalized Gather semantics (usually one channel x4 taps) Implicit or explicit forms
Depth compare sample Shadow samplers / comparison samplers Normalized Compare + filter behavior Implicit/explicit variants

2.2 Parameter types typically involved

Parameter Meaning Notes
Coordinates (x, y, z, uvw) Texture location Usually normalized for sampled textures; integer for fetch/load forms
Array layer index Selects texture array slice Typically final coordinate component or separate parameter depending on API form
LOD / mip level Chooses mip Fractional values can blend between mips
Bias Mip bias adjustment Added to implicit LOD path
Gradients (dPdx, dPdy) Explicit footprint derivatives Commonly used when implicit derivatives are invalid/undesired
Offset Constant texel offset Often must be compile-time/static immediate in many forms
Sample index (MSAA) Chooses sample in multisampled texture Used in texel-fetch/load style MSAA access
Compare value For depth comparison sampling Used with shadow/compare samplers
Sampler state Filter, address modes, anisotropy, LOD clamps, compare mode Separate object in D3D/Vulkan/Metal-style binding models

3) Coordinate systems: normalized vs pixel/texel

4) Vendor-level execution tendencies (high level)

Important: APIs are largely cross-vendor; differences are mostly in scheduling, caches, compiler lowering, and throughput/latency behavior.

NVIDIA (warp model)

AMD (wavefront model, wave32/wave64 variants)

Intel (EU/subslice model)

Apple (tile-based GPU architecture)

What differs most across vendors in practice

5) Advantages and disadvantages of differing approaches

Implicit LOD sampling

Advantages:

Disadvantages:

Explicit LOD sampling

Advantages:

Disadvantages:

Explicit gradient sampling

Advantages:

Disadvantages:

Texel fetch/load (integer, unfiltered)

Advantages:

Disadvantages:

Gather instructions

Advantages:

Disadvantages:

6) Divergent fetches inside one shader across many pixels/cores

When a wave/warp executes a texture op:

Typical consequences of high divergence:

How GPUs cope:

7) Vertex vs fragment texture fetch usage

Vertex shader texture usage

Common patterns:

Characteristics:

Fragment shader texture usage

Common patterns:

Characteristics:

Summary comparison

Aspect Vertex Fragment
Invocation volume Lower Much higher
Typical sampling mode Explicit LOD / selective sample Implicit LOD dominant
Bandwidth pressure Usually moderate Often high to extreme
Derivatives availability role Limited/less central Central for mip choice
Performance limiter tendency ALU + occasional memory Frequently texture/memory-bound

8) API-level notes you can rely on

9) Practical guidance

  1. Prefer coherent UVs and coherent control flow whenever possible.
  2. Use implicit LOD in standard fragment shading unless you have a clear reason not to.
  3. Use explicit LOD/grad in specialized passes (virtual texturing, custom filters, vertex/compute-like sampling).
  4. Keep an eye on occupancy and register pressure in texture-heavy shaders.
  5. Profile per vendor architecture; compiler and cache behavior can shift optimal choices.

10) Caveats