MCPcopy Create free account
hub / github.com/baldurk/renderdoc / MipCoordFromBase

Function MipCoordFromBase

qrenderdoc/Windows/TextureViewer.cpp:61–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59// once
60
61static inline uint32_t MipCoordFromBase(const uint32_t coord, const uint32_t mip, const uint32_t dim)
62{
63 const uint32_t mipDim = (dim >> mip) > 0 ? (dim >> mip) : 1;
64
65 // for mip levels where we more than half (e.g. 15x15 to 7x7) the coord can't be shifted by the
66 // mip.
67 // e.g. if the top level is 960x540 an x coordinate of 950 would be shifted by 7 down to 7, but
68 // mip 7 is 7x4 so the max x co-ordinate is 6. Instead we need to get the float value on the top
69 // mip, multiply by the mip dimension, and floor it
70
71 const float coordf = float(coord) / float(dim);
72
73 // we add 1e-6 to account for float errors, where we might not get back coord after rounding down
74 // in the coordf calculation even when mipDim == dim. This will not affect the rounding for any
75 // realistic texture sizes - even for a dim of 16383 and coord of 16382
76 return uint32_t(mipDim * (coordf + 1e-6f));
77}
78
79static inline uint32_t BaseCoordFromMip(uint32_t coord, const uint32_t mip, const uint32_t dim)
80{

Callers 9

RT_FetchCurrentPixelMethod · 0.85
UI_UpdateStatusTextMethod · 0.85
render_keyPressMethod · 0.85
GetPickedLocationMethod · 0.85
ShowGotoPopupMethod · 0.85
ShowPixelHistoryMethod · 0.85
MipCoordFromBaseMethod · 0.85
TextureViewer.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected