DX11.2 Packed mipmaps don't get updated with UpdateSubresource for a tiled resource

Started by
1 comment, last by kudovickij 4 years ago

I ran into an issue while working with packed mips for a tiled resource.

Normally, you would update a tile using the UpdateTiles command. However, when a resource mip is less than the dimension of a tile (64 kb), it goes to a special tile together with all other mips that are too small. According to the documentation you should use UpdateSubresource routine to update packed mips.

My problem is that I cannot make this work at all for any mip level greater than 0. UpdateSubresource works on the 0 level well, I can immediately see the change from the provided data. However, trying to change subresource 1 or 2 has no effect (black texture).

Here is my workflow:

  • Create a tile pool buffer of size 64k * 1 (one tile only)
  • Create a Texture2D of 4x4 dimensions with 3 mips (4x4, 2x2, 1x1) marked as tiled resource.
  • Create a SRV, lowest mip = 0, 3 mips.
  • Call GetResourceTiling on the tiled resource. The results are:
    • D3D11_PACKED_MIP_DESC: 0 regular mips, 3 packed mips, 1 tile, 0 offset for packed tile.
    • D3D11_TILE_SHAPE: all resource is packed - meaningless
    • D3D11_SUBRESOURCE_TILING: ditto - meaningless
  • Call UpdateTileMappings on the tiled resource.
    • Provide a D3D11_TILED_RESOURCE_COORDINATE with zeroed X Y and Z, and the subresource pointing to the first packed mip, in our case 0. Hence, the D3D11_TILED_RESOURCE_COORDINATE is { 0, 0, 0, 0 }
    • D3D11_TILE_REGION_SIZE has 1 tile, all other parameters are meaningless for a packed mip, hence { 1, 0, 0, 0, 0 }
    • I set no flags (0)
    • The offset is the first tile (0)
    • Range spans 1 tile, (1)
    • All in all, we call UpdateTileMappings to update 1 tile.

This is where the fun begins. At this point, the tiled resource is fully initialized, and has virtual offsets mapped to a physical pool tile. At this point, we would have to update the actual raw data in the pool. As mentioned above, we have to use UpdateSubresource on packed tiles, which is what we try to do.

We call UpdateSubresource:

  • Resource is our tiled texture resource
  • Subresource is 0
  • no box (nullptr)
  • the raw data buffer has values (50, 10, 50, 10, 20, 60, 20, 60, 10, 80, 10, 80, 50, 50, 50, 50)
  • the row pitch is 4 * elements size (R16 unorm in my case, so 2)
  • Depth pitch is 0

This succeeds, and data is propagated to the texture. However, if we attempt to do the same but for subresource 1, the texture remains black.

At this point I don't really know what to do. Everything works with regular mips, yet I cannot make the packed mips to work. I am critically blocked by this, and would really appreciate some help.

Thanks

Advertisement

(facepalm) I am an idiot. I forgot to change the maxLod on the sampler, to support lods past 0. As soon as I did, everything started working.

This topic is closed to new replies.

Advertisement