Skip to content
Dzmitry Malyshau edited this page Sep 17, 2021 · 1 revision

Researching different ways to upload texture data for WebRender.

PBO path

Implemented in WR as UploadMethod::PixelBuffer.

Method:

  1. glBufferData(GL_PIXEL_UNPACK_BUFFER, ..)
  2. glTexSubImage2D(..)

Angle has a fast path and a slow path. The fast path:

  1. uploads the data into ID3D11Resource of type buffer
  2. creates an SRV from it
  3. launches a draw call that reads from the SRV and writes into the target texture

Problem:

  • a draw call per upload request has driver overhead, not batched
  • there is a slow path (needs clarification)

Investigation by @nical

On intel PBOs are faster. On AMD with large blob tiles and optim to skip a copy, PBOs are faster in the worst case and slower in the simpler case.

Immediate path

Implemented in WR as UploadMethod::Immediate.

Method:

  • glTexSubImage2D = ID3D11DeviceContext::UpdateSubresource

Problems:

  • on Intel, UpdateSubresource blocks CPU upon reaching of certain amount of data in flight

Vertex data

Implemented in WR for GPU cache updates only as GpuCacheBus::Scatter

Method:

  1. put texture data into a vertex buffer, a texel per vertex
  2. issue a draw call with "point" topology, each point goes to the texel that needs to be written

Whole tile uploads

Implemented in Chromium Investigation by @jrmuizel

Method:

  1. glTexImage2D = ID3D11DeviceContext::Map+memcpy+ID3D11DeviceContext::Unmap into a staging texture.
    • tiles are fixed-size, staging is pooled
  2. glCopySubTextureChromium copies to real storage = ID3D11DeviceContext::CopySubresourceRegion

Problem:

  • can't easily be used for many small uploads of arbitrary sizes

Improved scatter

Method:

  1. upload data (from multiple smaller uploads) in a Texture Buffer or a Shader Storage Buffer object.
  2. issue an instanced draw call, which copies multipel sub-rectanges by reading the data from TBO or SSBO and writing it into the texture.

Problems:

  • neither TBO or SSBO are a part of GLES 3.1
  • TBO could be exposed by Angle (for D3D11 backend) but it's not currently (it's exposed for GL and Vulkan backends though)