Render != Rasterize

Article: Tile-based Rasterization in Nvidia GPUs
By: Philip Taylor (philip.delete@this.zaynar.co.uk), August 3, 2016 3:41 am
Room: Moderated Discussions
Peter McGuinness (peter.mcguinness.delete@this.gobrach.com) on August 2, 2016 9:41 pm wrote:
> [...] It only looks like regular tiling because all the triangles are huge
> and are all directly on top of each other; scatter randomly sized triangles around the screen in random locations
> and you will soon see the apparent order break down. In fact, you only need to shift each triangle by one pixel
> to see this start to happen. The point is that the 'tiling' is relative to the triangles, not to the screen
> and the term 'tile based' is universally accepted to refer to a tiled screen.

That's not what I see. I changed the test code to say:

if (VertexID % 3 == 0)
  output.Position = float4(-1, 1, 0, 1);
else if (VertexID % 3 == 1)
  output.Position = float4(-0.9, 1, 0, 1);
else if (VertexID % 3 == 2)
  output.Position = float4(-1, 0.9, 0, 1);

output.Position.x += 0.05 * ((VertexID / 3) % 32);
output.Position.y -= 0.05 * ((VertexID / 3) / 32);

so it's drawing lots of small triangles across the screen, ordered from left to right, top to bottom. I scaled MaxNumPixels appropriately and set "number of triangles" to 1000.

On a GTX 970 (Maxwell), it first pixel-shades all the triangles in the top-left 256x512 pixel region of the screen (clipped to that region). Once those are finished, it moves right to the next 256x512 region. Then it carries on until it wraps around to the second row of regions.

That means it's rasterising in a very different order to how the triangles were submitted. And it's reordering them to keep all its framebuffer accesses within a ~0.5MB region, suggesting it wants to fit in a cache of that size.

If I increase "num floats per vertex" to 32, and also change the vertex shader to set "output.ExtraFloats[i] = VertexID * NUM_EXTRA_FLOATs + i;" (the +i is to avoid compression of identical values), the behaviour is very different - that's much closer to (though not exactly the same as) the original submission order (i.e. left-to-right for a single whole row of triangles (or sometimes ~3 rows at once), then down to the next row). That indicates the reordering only works within a smallish buffer of primitive data - exceeding that limit means it has to flush out the earlier-submitted triangles first to make space, instead of collecting enough to fill the whole 0.5MB region, so it loses some efficiency.

> In any case, OpenGL and DX rules forbid the re-ordering of triangles and it is up to the application
> to group geometry to be cache friendly.

I'm not sure how GL/DX phrase it, but Vulkan explicitly only requires the implementation to follow API order between the framebuffer operations for a given sample position. There's nothing to stop it processing two different triangles at two different sample positions in any arbitrary order, since that will have no observable effect on the rendering (at least until the pixel shaders start doing weird things with atomics to demonstrate that order).

If there was a restriction that triangles must be processed completely sequentially, so you couldn't start pixel shaders for one until the previous one had been completely shaded, that'd also prevent any concurrent shading of two non-overlapping triangles, so there's no way they can realistically have that restriction.
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Article: Tile-based Rasterization in Nvidia GPUsDavid Kanter2016/08/01 12:01 AM
  Article: Tile-based Rasterization in Nvidia GPUsBenjamin2016/08/01 02:22 AM
    GM, M = Maxwell, Tile = YesJohn H2016/08/01 05:59 AM
      GM, M = Maxwell, Tile = YesDavid Kanter2016/08/01 08:33 AM
        Updated articleDavid Kanter2016/08/01 08:35 AM
    Article: Tile-based Rasterization in Nvidia GPUsDavid Kanter2017/01/17 05:56 PM
      Optimus (d*mn, it isn't blue now)blue2017/01/19 06:34 PM
    Probably not in earlier MaxwellsDavid Kanter2017/01/17 05:56 PM
  Article: Tile-based Rasterization in Nvidia GPUsDan2016/08/01 03:12 AM
    Article: Tile-based Rasterization in Nvidia GPUsGionatan Danti2016/08/01 03:20 AM
      Article: Tile-based Rasterization in Nvidia GPUsSimon Farnsworth2016/08/01 04:00 AM
      Article: Tile-based Rasterization in Nvidia GPUsGiGNiC2016/08/01 04:30 AM
      Not deferred, still immediate-modeDavid Kanter2016/08/01 07:25 AM
        Not deferred, still immediate-modeRob Clark2016/08/01 09:44 AM
          Not deferred, still immediate-modeRob Clark2016/08/01 10:12 AM
            Not deferred, still immediate-modeSeni2016/08/01 12:25 PM
              Not deferred, still immediate-modeRob Clark2016/08/01 02:38 PM
              Not deferred, still immediate-modevvid2016/08/03 12:59 AM
            Not deferred, still immediate-modePhilip Taylor2016/08/01 04:55 PM
              Not deferred, still immediate-modeRob Clark2016/08/01 05:56 PM
                Not deferred, still immediate-modePhilip Taylor2016/08/01 07:33 PM
                  Not deferred, still immediate-modePhilip Taylor2016/08/02 04:46 PM
                    Not deferred, still immediate-modePhilip Taylor2016/08/03 01:36 PM
    Article: Tile-based Rasterization in Nvidia GPUsGabriele Svelto2016/08/01 06:48 AM
      Article: Tile-based Rasterization in Nvidia GPUsExophase2016/08/01 11:35 AM
        Article: Tile-based Rasterization in Nvidia GPUsGabriele Svelto2016/08/04 01:22 AM
  Article: Tile-based Rasterization in Nvidia GPUsGionatan Danti2016/08/01 03:16 AM
    Not deferred, still immediate-modeDavid Kanter2016/08/01 07:40 AM
  Article: Tile-based Rasterization in Nvidia GPUsJohn H2016/08/01 06:13 AM
    Article: Tile-based Rasterization in Nvidia GPUsAndrei Frumusanu2016/08/01 06:21 AM
      Article: Tile-based Rasterization in Nvidia GPUsblue2016/08/01 08:58 AM
        Article: Tile-based Rasterization in Nvidia GPUsAndrei Frumusanu2016/08/01 10:38 AM
          Article: Tile-based Rasterization in Nvidia GPUsblue2016/08/01 01:02 PM
  Article: Tile-based Rasterization in Nvidia GPUsKlimax2016/08/01 07:14 AM
    Article: Tile-based Rasterization in Nvidia GPUsAaron Spink2016/08/01 07:29 AM
  Everybody using tilesvvid2016/08/01 09:45 AM
    Everybody using tilesRob Clark2016/08/01 09:49 AM
      Everybody using tileswumpus2016/08/01 11:29 AM
        Everybody using tilesSimon Farnsworth2016/08/01 01:01 PM
          Everybody using tileswumpus2016/08/02 07:57 AM
            Everybody using tilesSimon Farnsworth2016/08/02 08:12 AM
  Testing MethodologyDavid2016/08/01 01:22 PM
    Testing MethodologyJoel H2016/08/01 01:57 PM
      Testing MethodologyDavid2016/08/01 04:09 PM
  Flicker?Wanderer2016/08/01 05:08 PM
    Flicker?Philip Taylor2016/08/01 05:30 PM
      Flicker?Beastian2016/08/01 09:33 PM
    Flicker?David Kanter2016/08/01 06:19 PM
      Flicker?Wanderer2016/08/02 07:14 AM
  Article: Tile-based Rasterization in Nvidia GPUsPM2016/08/01 06:39 PM
    Article: Tile-based Rasterization in Nvidia GPUsGiGNiC2016/08/02 12:03 PM
    GCN Imagesvvid2016/08/03 12:22 AM
      GCN ImagesVertexMaster2016/08/04 10:06 AM
        GCN Imagesvvid2016/08/04 11:30 AM
          GCN ImagesVertexMaster2016/08/04 04:38 PM
            GCN Imagesvvid2016/08/05 03:30 AM
              GCN ImagesVertexMaster2016/08/05 05:16 AM
                TBDRvvid2016/08/05 09:15 AM
                GCN1.2?vvid2016/08/07 04:33 AM
  Sorry, this is not a tile based renderer.Peter McGuinness2016/08/02 08:11 AM
    Render != RasterizeDavid Kanter2016/08/02 08:30 AM
      Render != RasterizePeter McGuinness2016/08/02 08:43 AM
        Render != RasterizeDavid Kanter2016/08/02 09:45 AM
          Render != RasterizePeter McGuinness2016/08/02 10:05 AM
            Render != RasterizePhilip Taylor2016/08/02 06:53 PM
              Render != RasterizePeter McGuinness2016/08/02 09:41 PM
                Render != RasterizePhilip Taylor2016/08/03 03:41 AM
                  Render != RasterizePeter McGuinness2016/08/04 12:34 PM
                    Render != RasterizePhilip Taylor2016/08/04 04:06 PM
                      Render != RasterizeMontaray Jack2016/08/05 02:26 PM
                        Render != RasterizeJouni Osmala2016/08/05 11:49 PM
                          Render != RasterizeMegol2016/08/06 03:30 AM
                            Render != RasterizeJouni Osmala2016/08/06 09:08 AM
                              Scratching that itchMontaray Jack2016/08/06 10:42 AM
                            Render != RasterizeMontaray Jack2016/08/06 10:08 AM
  Article: Tile-based Rasterization in Nvidia GPUsDoug Patel2016/08/02 09:39 AM
  Article: Tile-based Rasterization in Nvidia GPUsMontaray Jack2016/08/02 10:35 AM
    Article: Tile-based Rasterization in Nvidia GPUsdglow2016/08/02 05:08 PM
      Article: Tile-based Rasterization in Nvidia GPUsMontaray Jack2016/08/03 04:43 AM
        Article: Tile-based Rasterization in Nvidia GPUsdglow2016/08/03 07:04 AM
          Article: Tile-based Rasterization in Nvidia GPUsmarees2016/08/03 12:46 PM
      Article: Tile-based Rasterization in Nvidia GPUsDavid Kanter2016/08/04 08:03 AM
        Article: Tile-based Rasterization in Nvidia GPUsMontaray Jack2016/08/04 11:47 AM
    Oh god, the spambots have finally found us (NT)Anon2017/01/17 05:27 AM
      Delete the messages ASAPGtoo2017/01/17 03:19 PM
  Article: Tile-based Rasterization in Nvidia GPUssteve m2017/05/10 05:16 PM
    Article: Tile-based Rasterization in Nvidia GPUsGabriele Svelto2017/05/10 07:15 PM
      Article: Tile-based Rasterization in Nvidia GPUssteve m2017/05/11 10:11 AM
        Article: Tile-based Rasterization in Nvidia GPUsGabriele Svelto2017/05/12 02:15 AM
          Article: Tile-based Rasterization in Nvidia GPUssteve m2017/05/16 11:49 AM
            Article: Tile-based Rasterization in Nvidia GPUsGabriele Svelto2017/05/17 05:43 AM
              Article: Tile-based Rasterization in Nvidia GPUssteve m2017/05/17 08:35 PM
                Article: Tile-based Rasterization in Nvidia GPUspocak2017/05/18 04:19 PM
                  Article: Tile-based Rasterization in Nvidia GPUsDavid Kanter2017/05/20 07:55 AM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell tangerine? 🍊