-
Notifications
You must be signed in to change notification settings - Fork 279
Texture Uploads
Dzmitry Malyshau edited this page Sep 17, 2021
·
1 revision
Researching different ways to upload texture data for WebRender.
Implemented in WR as UploadMethod::PixelBuffer.
Method:
glBufferData(GL_PIXEL_UNPACK_BUFFER, ..)
glTexSubImage2D(..)
Angle has a fast path and a slow path. The fast path:
- uploads the data into
ID3D11Resource
of type buffer - creates an SRV from it
- 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.
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
Implemented in WR for GPU cache updates only as GpuCacheBus::Scatter
Method:
- put texture data into a vertex buffer, a texel per vertex
- issue a draw call with "point" topology, each point goes to the texel that needs to be written
Implemented in Chromium Investigation by @jrmuizel
Method:
-
glTexImage2D
=ID3D11DeviceContext::Map
+memcpy
+ID3D11DeviceContext::Unmap
into a staging texture.- tiles are fixed-size, staging is pooled
-
glCopySubTextureChromium
copies to real storage =ID3D11DeviceContext::CopySubresourceRegion
Problem:
- can't easily be used for many small uploads of arbitrary sizes
Method:
- upload data (from multiple smaller uploads) in a Texture Buffer or a Shader Storage Buffer object.
- 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)