1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-30 08:24:05 +00:00

Modify implementation of texture coordinate bounds for non-native resolutions.

This commit is contained in:
s2s 2021-08-07 13:54:51 +02:00 committed by Sergey Lipskiy
parent 21fe9d5f92
commit 75fd353741
3 changed files with 25 additions and 10 deletions

View File

@ -72,16 +72,10 @@ public:
}
float tcbounds[4] = {};
if (useTexCoordBounds) {
f32 S = _FIXED2FLOAT(gDP.lastTexRectInfo.s, 5);
f32 T = _FIXED2FLOAT(gDP.lastTexRectInfo.t, 5);
f32 uls = S + (ceilf(gDP.lastTexRectInfo.ulx) - gDP.lastTexRectInfo.ulx) * gDP.lastTexRectInfo.dsdx;
f32 lrs = S + (ceilf(gDP.lastTexRectInfo.lrx) - gDP.lastTexRectInfo.ulx - 1.0f) * gDP.lastTexRectInfo.dsdx;
f32 ult = T + (ceilf(gDP.lastTexRectInfo.uly) - gDP.lastTexRectInfo.uly) * gDP.lastTexRectInfo.dtdy;
f32 lrt = T + (ceilf(gDP.lastTexRectInfo.lry) - gDP.lastTexRectInfo.uly - 1.0f) * gDP.lastTexRectInfo.dtdy;
tcbounds[0] = fmin(uls, lrs);
tcbounds[1] = fmin(ult, lrt);
tcbounds[2] = fmax(uls, lrs);
tcbounds[3] = fmax(ult, lrt);
tcbounds[0] = gDP.m_texCoordBounds.uls;
tcbounds[1] = gDP.m_texCoordBounds.ult;
tcbounds[2] = gDP.m_texCoordBounds.lrs;
tcbounds[3] = gDP.m_texCoordBounds.lrt;
}
uVertexOffset.set(vertexOffset, vertexOffset, _force);

View File

@ -907,6 +907,21 @@ void gDPTextureRectangle(f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, s16 s, s1
gDP.lastTexRectInfo.dsdx = !flip ? dsdx : dtdy;
gDP.lastTexRectInfo.dtdy = !flip ? dtdy : dsdx;
f32 S = _FIXED2FLOAT(!flip ? s : t, 5);
f32 T = _FIXED2FLOAT(!flip ? t : s, 5);
f32 DSDX = !flip ? dsdx : dtdy;
f32 DTDY = !flip ? dtdy : dsdx;
f32 uls = S + (ceilf(ulx) - ulx) * DSDX;
f32 lrs = S + (ceilf(lrx) - ulx - 1.0f) * DSDX;
f32 ult = T + (ceilf(uly) - uly) * DTDY;
f32 lrt = T + (ceilf(lry) - uly - 1.0f) * DTDY;
gDP.m_texCoordBounds.valid = true;
gDP.m_texCoordBounds.uls = fmin(uls, lrs);
gDP.m_texCoordBounds.ult = fmin(ult, lrt);
gDP.m_texCoordBounds.lrs = fmax(uls, lrs);
gDP.m_texCoordBounds.lrt = fmax(ult, lrt);
GraphicsDrawer & drawer = dwnd().getDrawer();
GraphicsDrawer::TexturedRectParams params(ulx, uly, lrx, lry, dsdx, dtdy, s, t,
flip, false, true, frameBufferList().getCurrent());

View File

@ -129,6 +129,11 @@ struct gDPTexrectInfo
f32 dsdx, dtdy;
};
struct texCoordBounds {
bool valid;
f32 uls, lrs, ult, lrt;
};
struct gDPInfo
{
struct OtherMode
@ -264,6 +269,7 @@ struct gDPInfo
gDPLoadTileInfo loadInfo[512];
gDPTexrectInfo lastTexRectInfo;
texCoordBounds m_texCoordBounds;
};
extern gDPInfo gDP;