|
|
@@ -30,6 +30,48 @@
|
|
|
|
|
|
namespace dsr {
|
|
|
|
|
|
+// TODO: Reallocate the image's buffer, so that the pyramid images are placed into the same allocation.
|
|
|
+// This allow reading a texture with multiple mip levels using different 32-bit offsets in the same SIMD vector holding multiple groups of 2x2 pixels.
|
|
|
+// TODO: Adapt how far down to go in mip resolutions based on DSR_DEFAULT_ALIGNMENT, so that no mip level is padded in memory.
|
|
|
+// This is needed so that the stride can be calculated using bit shifting from the mip level.
|
|
|
+// The visual appearance may differ between SIMD lengths for low resolution textures, but not between computers running the same executable.
|
|
|
+// TODO: Store the smallest layer first in memory, so that the offset is a multiple of the smallest size following a pre-determined bit pattern.
|
|
|
+// If one s is the number of pixels in the smallest mip layer, then the size of each layer n equals s * 2^n.
|
|
|
+// The offset in s units is then the sum of all previous unpadded dimensions.
|
|
|
+// 0000000000000000 0
|
|
|
+// 0000000000000001 1
|
|
|
+// 0000000000000101 5
|
|
|
+// 0000000000010101 21
|
|
|
+// 0000000001010101 85
|
|
|
+// 0000000101010101 341
|
|
|
+// 0000010101010101 1365
|
|
|
+// 0001010101010101 5461
|
|
|
+// 0101010101010101 21845
|
|
|
+// Then one can start with the offset to the largest mip layer in pixels or bytes as the initial mask and then mask out initial ones using a mask directly from the MIP calculation.
|
|
|
+// 0000000000000000 4x2 pixels at offset 0
|
|
|
+// 0000000000001000 8x4 pixels at offset 8
|
|
|
+// 0000000000101000 16x32 pixels at offset 40
|
|
|
+// 0000000010101000 32x64 pixels at offset 168
|
|
|
+// 0000001010101000 64x128 pixels at offset 680
|
|
|
+// 0000101010101000 128x256 pixels at offset 2728 (Full unmasked offset leading to the highest mip level)
|
|
|
+// Masks for different visibility.
|
|
|
+// 0000000000000011 Very far away or seen from the side
|
|
|
+// 0000000000111111 Far away or seen from the side
|
|
|
+// 0000001111111111 Normal viewing
|
|
|
+// 0011111111111111 Close with many screen pixels per texels.
|
|
|
+// The difficult part is how to generate a good mip level offset mask from the pixel coordinate derivation from groups of 2x2 pixels.
|
|
|
+// The offset is not exactly exponential, so there will be visual tradeoffs between artifacts in this approximation.
|
|
|
+// One could take the texture coordinate offset per pixel as the initial value and
|
|
|
+// then repeat shifting and or masking at power of two offsets to only get ones after the initial one, but this would require many cycles.
|
|
|
+// Pixels per texel in full resolution times full resolution offset:
|
|
|
+// 00000000000010101000110110011001
|
|
|
+// Mip offset mask:
|
|
|
+// 00000000000011111111111111111111
|
|
|
+// Full resolution mip offset:
|
|
|
+// 00000000001010101010101010000000
|
|
|
+// Final mip offset containing half width and height:
|
|
|
+// 00000000000010101010101010000000
|
|
|
+
|
|
|
// Pointing to the parent image using raw pointers for fast rendering. May not exceed the lifetime of the parent image!
|
|
|
struct TextureRgbaLayer {
|
|
|
const uint8_t *data = 0;
|