samplerjit: Take texptr/bufw as arrays.

Prep for moving mip map sampling into linear.
This commit is contained in:
Unknown W. Brackets 2021-12-28 12:04:16 -08:00
parent 4864850b3b
commit a4558a5736
4 changed files with 33 additions and 20 deletions

View file

@ -521,10 +521,8 @@ template <bool mayHaveMipLevels>
static inline Vec4IntResult SOFTRAST_CALL ApplyTexturing(Sampler::Funcs sampler, Vec4IntArg prim_color, float s, float t, int texlevel, int frac_texlevel, bool bilinear, u8 *texptr[], int texbufw[], int x, int y) {
Vec4<int> texcolor0;
Vec4<int> texcolor1;
const u8 *tptr0 = texptr[mayHaveMipLevels ? texlevel : 0];
int bufw0 = texbufw[mayHaveMipLevels ? texlevel : 0];
const u8 *tptr1 = texptr[mayHaveMipLevels ? texlevel + 1 : 0];
int bufw1 = texbufw[mayHaveMipLevels ? texlevel + 1 : 0];
const u8 **tptr0 = const_cast<const u8 **>(&texptr[mayHaveMipLevels ? texlevel : 0]);
const int *bufw0 = &texbufw[mayHaveMipLevels ? texlevel : 0];
if (!bilinear) {
int u[8] = { 0 }, v[8] = { 0 }; // 1.27.4 fixed point
@ -535,14 +533,14 @@ static inline Vec4IntResult SOFTRAST_CALL ApplyTexturing(Sampler::Funcs sampler,
GetTexelCoordinates(texlevel + 1, s, t, u[1], v[1], x, y);
}
texcolor0 = Vec4<int>(sampler.nearest(u[0], v[0], tptr0, bufw0, mayHaveMipLevels ? texlevel : 0));
texcolor0 = Vec4<int>(sampler.nearest(u[0], v[0], tptr0[0], bufw0[0], mayHaveMipLevels ? texlevel : 0));
if (mayHaveMipLevels && frac_texlevel) {
texcolor1 = Vec4<int>(sampler.nearest(u[1], v[1], tptr1, bufw1, texlevel + 1));
texcolor1 = Vec4<int>(sampler.nearest(u[1], v[1], tptr0[1], bufw0[1], texlevel + 1));
}
} else {
texcolor0 = Vec4<int>(sampler.linear(s, t, x, y, prim_color, tptr0, bufw0, mayHaveMipLevels ? texlevel : 0, 0));
texcolor0 = Vec4<int>(sampler.linear(s, t, x, y, prim_color, tptr0, bufw0, mayHaveMipLevels ? texlevel : 0, mayHaveMipLevels ? frac_texlevel : 0));
if (mayHaveMipLevels && frac_texlevel) {
texcolor1 = Vec4<int>(sampler.linear(s, t, x, y, prim_color, tptr1, bufw1, texlevel + 1, frac_texlevel));
texcolor1 = Vec4<int>(sampler.linear(s, t, x, y, prim_color, tptr0 + 1, bufw0 + 1, texlevel + 1, frac_texlevel));
}
}