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

GraphicsDrawer::drawTexturedRect fixes:

* remove old hack for clamp/wrap tex coords. It seems that the hack is not necessary anymore.
necessary anymore.
* minor optimization for accurate texture path.
This commit is contained in:
Sergey Lipskiy 2021-12-05 15:18:00 +07:00
parent 4e0a4f700c
commit 21fe9d5f92
2 changed files with 10 additions and 41 deletions

View File

@ -90,7 +90,6 @@ public:
m_part =
"IN highp vec4 aRectPosition; \n"
"IN highp vec2 aTexCoord0; \n"
"IN highp vec2 aTexCoord1; \n"
"IN highp vec2 aBaryCoords; \n"
" \n"
"OUT highp vec2 vTexCoord; \n"

View File

@ -1275,10 +1275,16 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
offsetY = (_params.lry - _params.uly) * _params.dtdy;
}
for (u32 t = 0; t < 2; ++t) {
if (pCurrentCombiner->usesTile(t) && cache.current[t] && gSP.textureTile[t]) {
if (config.generalEmulation.enableInaccurateTextureCoordinates) {
if (config.generalEmulation.enableInaccurateTextureCoordinates == 0u) {
// Accurate texture path
texST[0].s0 = _FIXED2FLOAT(_params.s, 5);
texST[0].s1 = texST[0].s0 + offsetX;
texST[0].t0 = _FIXED2FLOAT(_params.t, 5);
texST[0].t1 = texST[0].t0 + offsetY;
} else {
// Fast texture path
for (u32 t = 0; t < 2; ++t) {
if (pCurrentCombiner->usesTile(t) && cache.current[t] && gSP.textureTile[t]) {
f32 shiftScaleS = 1.0f;
f32 shiftScaleT = 1.0f;
@ -1303,43 +1309,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
texST[t].s1 = cache.current[t]->offsetS + texST[t].s1;
texST[t].t1 = cache.current[t]->offsetT + texST[t].t1;
}
} else {
const f32 uls = _FIXED2FLOAT(_params.s, 5);
const f32 lrs = uls + offsetX;
const f32 ult = _FIXED2FLOAT(_params.t, 5);
const f32 lrt = ult + offsetY;
texST[t].s0 = uls;
texST[t].s1 = lrs;
texST[t].t0 = ult;
texST[t].t1 = lrt;
}
if (cache.current[t]->frameBufferTexture != CachedTexture::fbMultiSample) {
Context::TexParameters texParams;
if ((cache.current[t]->mirrorS == 0 && cache.current[t]->maskS == 0 &&
(texST[t].s0 < texST[t].s1 ?
texST[t].s0 >= 0.0f && texST[t].s1 <= static_cast<f32>(cache.current[t]->width) :
texST[t].s1 >= 0.0f && texST[t].s0 <= static_cast<f32>(cache.current[t]->width)))
|| (cache.current[t]->maskS == 0 && (texST[t].s0 < -1024.0f || texST[t].s1 > 1023.99f)))
texParams.wrapS = textureParameters::WRAP_CLAMP_TO_EDGE;
if (cache.current[t]->mirrorT == 0 &&
(texST[t].t0 < texST[t].t1 ?
texST[t].t0 >= 0.0f && texST[t].t1 <= static_cast<f32>(cache.current[t]->height) :
texST[t].t1 >= 0.0f && texST[t].t0 <= static_cast<f32>(cache.current[t]->height)))
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
if (texParams.wrapS.isValid() || texParams.wrapT.isValid()) {
texParams.handle = cache.current[t]->name;
texParams.target = textureTarget::TEXTURE_2D;
texParams.textureUnitIndex = textureIndices::Tex[t];
gfxContext.setTextureParameters(texParams);
}
}
if (config.generalEmulation.enableInaccurateTextureCoordinates) {
texST[t].s0 *= cache.current[t]->scaleS;
texST[t].t0 *= cache.current[t]->scaleT;
texST[t].s1 *= cache.current[t]->scaleS;