3 ms·
Probably easiest to just calculate the inverse? You're rendering the pixel that the original one would be transformed to, so you just have to find the original
by moffkalast 4y ago
Probably easiest to just calculate the inverse? You're rendering the pixel that the original one would be transformed to, so you just have to find the original one in the sampled texture. Maybe just doing the same sin/cos vector but with negative angle.
- amelius 4y agoYes, you can scan e.g. horizontally (x axis first) through the target image, but for the source image you will have to do a memory lookup with bad locality.
- moffkalast 4y agoWell you don't need to scan, each SIMD processes a pixel in paralel and they spit out the whole thing simultaneously in the end, at least according to my understanding. You'd also presumably need to cache the entire texture that's being rendered anyway, so cache misses due to locality problems likely aren't huge.
- flohofwoe 4y agoTextures usually reside entirely in fast GPU accessible memory, but cache misses during sampling can still be a problem (so entirely random access across the whole texture is still worse then accessing nearby pixels). The texture data is 'scrambled' in memory for better 2D spatial locality though, so once in cache, access of pixel groups which are close together both horizontally or vertically is fast. (disclaimer: I'm not a hardware guy, and I also don't know if this applies to all pixel formats and different GPU architectures - texture cache details are also notoriously bad documented by GPU vendors).
- amelius 4y agoOk, I'm guessing from this that it only works for relatively small images (?)
- WithinReason 4y agoImage lookups with bad locality is exactly what a GPU's texture pipeline is for
- amelius 4y agoHow does this pipeline deal with the locality issue, assuming the texture doesn't fit in the cache?
- WithinReason 4y agoThe texture cache tries to guarantee that every pixel is only read from DRAM once, and the texture sampler does bilinear sampling "for free". So a sequential copy and a "rotation copy" should take about the same time.