-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathTiledSpan.hpp
More file actions
23 lines (22 loc) · 1 KB
/
Copy pathTiledSpan.hpp
File metadata and controls
23 lines (22 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include "TileTexture.hpp"
#include <cmath>
#include <cstring>
namespace Renderer {
// For positive normal IEEE-754 floats. The exponent/mantissa seed has at most
// 12.5% relative error; three Newton steps square that error down to float
// precision. Chapel depth ratios are well inside the normal-float range.
inline float tileReciprocal(float value) {
uint32_t bits;std::memcpy(&bits,&value,4);bits=0x7f000000u-bits;
float estimate;std::memcpy(&estimate,&bits,4);
estimate*=2.f-value*estimate;
estimate*=2.f-value*estimate;
estimate*=2.f-value*estimate;
return estimate;
}
// Opaque perspective-correct indexed tile span, nearest, bilinear or three-point. Implemented
// once in IRAM on ESP32 so instruction fetches do not compete with textures.
void drawTiledSpan(const TileTexture& texture,uint16_t* out,int count,
float uq,float vq,float q,float du,float dv,float dq,
int feedbackLane,bool exact=false,TileFilter filter=TileFilter::Nearest);
}