gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 547 forks source link

[dx12] Support for unnormalized coordinates in samplers #2883

Open kvark opened 5 years ago

kvark commented 5 years ago

Vulkan sampler descriptor has this field: unnormalizedCoordinates.

The task here is to add it to our API and do a basic investigation on where it can't be supported.

kvark commented 5 years ago

Now that #2885 has landed, we have the API in place. We need to find a way to support it on DX12, at least, and also look into DX11 and GL if possible.

kvark commented 4 years ago

I'm thinking, the possible solution could be:

  1. provide a root constant (32 bit) with each bit corresponding to a sampler. Bit = 1 if the coordinates are unnormalized.
  2. in the generated HLSL, whenever there is a sampling operation, we can insert code that checks the relevant bit. If the bit is set, the injected code would call GetDimensions on the texture, and use it to produce the normalized coordinates prior to sampling.