I am new to graphics programming and I'm trying to create an efficient 2D tilemap renderer (using rust and wgpu (webgpu)).

My current implementation

My current implementation consists of:

  1. A Rust-Vec (contains all tiles needed for rendering in a normal buffer)
  2. A Vertex Buffer (contains 4 Vertices, describing a quad)
  3. An Index Buffer (contains Indices to define the said quad)
  4. An Instance Buffer (basically contains ALL the tile data (currently only world positions (2 u32 Integers))
  5. A Uniform Buffer (contains current camera position (x, y, zoom))

The 1. buffer (Rust-Vec) is updated and copied to the Instance Buffer every new frame (both buffers are fully replaced every frame). In order to improve performance a bit, the world is split up into chunks. Although that does not affect the rendering process after the needed tiles are loaded into the 1. buffer.

The instance data (tile coordinates) is translated to the relative normal positions in the vertex shader.

My project currently does not support textures etc.


When zooming out far enough, but not unreasonably far, the frame time starts to increase immensely. Looking at a flamegraph I have found the part of code that takes the longest is updating the 1. Vector and copying it to the instance buffer. Sadly I have not come up with a more efficient solution to rendering large amounts of 2D tiles.


What concepts and ideas can I make use of to increase the performance of my project? Is my current solution inherently flawed, or is it somewhat acceptable?

  • $\begingroup$ How exactly are you drawing the tiles: one by one, or using batched rendering, or maybe instanced rendering? How many tiles do you have rendered when performance becomes an issue? $\endgroup$
    – lisyarus
    Commented May 24, 2022 at 20:26
  • $\begingroup$ The vertex and index buffer only describe a basic quad. I only reupload the whole instance buffer and render it that way (draw_instanced in wgpu). Performance becomes an issue at around 3604480 tiles. $\endgroup$
    – Q4LEX
    Commented May 25, 2022 at 10:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.