1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Do not set sampler states for multisampled textures:

"GL_INVALID_ENUM is generated if the effective target is either GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states."
Fixed HWFBE when MSAA enabled.

Correct code formatting.
This commit is contained in:
Sergey Lipskiy 2017-02-18 21:40:41 +07:00
parent c33d8555b2
commit 5b3b2920bc
2 changed files with 76 additions and 83 deletions

View File

@ -1062,8 +1062,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
cmbInfo.update();
_updateTextures();
cmbInfo.updateParameters();
}
else {
} else {
if (_params.texrectCmd && (gSP.changed | gDP.changed) != 0)
_updateStates(DrawingState::TexRect);
gfxContext.enable(enable::CULL_FACE, false);
@ -1108,8 +1107,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
if (bUseTexrectDrawer) {
uly = (float)_params.uly * (2.0f * scaleY) - 1.0f;
lry = (float)_params.lry * (2.0f * scaleY) - 1.0f;
}
else {
} else {
uly = (float)_params.uly * (-2.0f * scaleY) + 1.0f;
lry = (float)(_params.lry) * (-2.0f * scaleY) + 1.0f;
// Flush text drawer
@ -1146,16 +1144,14 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
if (_params.uls > _params.lrs) {
texST[t].s0 = (_params.uls + _params.dsdx) * shiftScaleS - gSP.textureTile[t]->fuls;
texST[t].s1 = _params.lrs * shiftScaleS - gSP.textureTile[t]->fuls;
}
else {
} else {
texST[t].s0 = _params.uls * shiftScaleS - gSP.textureTile[t]->fuls;
texST[t].s1 = (_params.lrs + _params.dsdx) * shiftScaleS - gSP.textureTile[t]->fuls;
}
if (_params.ult > _params.lrt) {
texST[t].t0 = (_params.ult + _params.dtdy) * shiftScaleT - gSP.textureTile[t]->fult;
texST[t].t1 = _params.lrt * shiftScaleT - gSP.textureTile[t]->fult;
}
else {
} else {
texST[t].t0 = _params.ult * shiftScaleT - gSP.textureTile[t]->fult;
texST[t].t1 = (_params.lrt + _params.dtdy) * shiftScaleT - gSP.textureTile[t]->fult;
}
@ -1167,27 +1163,28 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
texST[t].t1 = cache.current[t]->offsetT - texST[t].t1;
}
Context::TexParameters texParams;
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.0 && texST[t].s1 <= (float)cache.current[t]->width :
texST[t].s1 >= 0.0 && texST[t].s0 <= (float)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]->mirrorS == 0 && cache.current[t]->maskS == 0 &&
(texST[t].s0 < texST[t].s1 ?
texST[t].s0 >= 0.0 && texST[t].s1 <= (float)cache.current[t]->width :
texST[t].s1 >= 0.0 && texST[t].s0 <= (float)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 <= (float)cache.current[t]->height :
texST[t].t1 >= 0.0f && texST[t].t0 <= (float)cache.current[t]->height))
texParams.wrapT = 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 <= (float)cache.current[t]->height :
texST[t].t1 >= 0.0f && texST[t].t0 <= (float)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 = cache.current[t]->frameBufferTexture == CachedTexture::fbMultiSample ?
textureTarget::TEXTURE_2D_MULTISAMPLE : textureTarget::TEXTURE_2D;
texParams.textureUnitIndex = textureIndices::Tex[t];
gfxContext.setTextureParameters(texParams);
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);
}
}
texST[t].s0 *= cache.current[t]->scaleS;
@ -1197,11 +1194,10 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
}
}
if (gDP.otherMode.cycleType == G_CYC_COPY) {
if (gDP.otherMode.cycleType == G_CYC_COPY && cache.current[0]->frameBufferTexture != CachedTexture::fbMultiSample) {
Context::TexParameters texParams;
texParams.handle = cache.current[0]->name;
texParams.target = cache.current[0]->frameBufferTexture == CachedTexture::fbMultiSample ?
textureTarget::TEXTURE_2D_MULTISAMPLE : textureTarget::TEXTURE_2D;
texParams.target = textureTarget::TEXTURE_2D;
texParams.textureUnitIndex = textureIndices::Tex[0];
texParams.minFilter = textureParameters::FILTER_NEAREST;
texParams.magFilter = textureParameters::FILTER_NEAREST;
@ -1228,8 +1224,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
m_rect[2].t0 = texST[0].t0;
m_rect[2].s1 = texST[1].s1;
m_rect[2].t1 = texST[1].t0;
}
else {
} else {
m_rect[1].s0 = texST[0].s1;
m_rect[1].t0 = texST[0].t0;
m_rect[1].s1 = texST[1].s1;
@ -1453,12 +1448,15 @@ void GraphicsDrawer::copyTexturedRect(const CopyRectParams & _params)
Context::TexParameters texParams;
texParams.handle = tex->name;
texParams.textureUnitIndex = textureIndices::Tex[i];
texParams.target = tex->frameBufferTexture == CachedTexture::fbMultiSample ?
textureTarget::TEXTURE_2D_MULTISAMPLE : textureTarget::TEXTURE_2D;
texParams.minFilter = _params.filter;
texParams.magFilter = _params.filter;
texParams.wrapS = textureParameters::WRAP_CLAMP_TO_EDGE;
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
if (tex->frameBufferTexture == CachedTexture::fbMultiSample)
texParams.target = textureTarget::TEXTURE_2D_MULTISAMPLE;
else {
texParams.target = textureTarget::TEXTURE_2D;
texParams.minFilter = _params.filter;
texParams.magFilter = _params.filter;
texParams.wrapS = textureParameters::WRAP_CLAMP_TO_EDGE;
texParams.wrapT = textureParameters::WRAP_CLAMP_TO_EDGE;
}
gfxContext.setTextureParameters(texParams);
}

View File

@ -1419,62 +1419,57 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
} else {
params.target = textureTarget::TEXTURE_2D;
params.textureUnitIndex = textureIndices::Tex[_t];
}
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
const bool bUseLOD = currentCombiner()->usesLOD();
const s32 texLevel = bUseLOD ? _pTexture->max_level : 0;
params.maxMipmapLevel = Parameter(texLevel);
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
const bool bUseLOD = currentCombiner()->usesLOD();
const s32 texLevel = bUseLOD ? _pTexture->max_level : 0;
params.maxMipmapLevel = Parameter(texLevel);
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
if (bUseBilinear) {
if (texLevel > 0)
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
else
params.minFilter = textureParameters::FILTER_LINEAR;
params.magFilter = textureParameters::FILTER_LINEAR;
}
else {
if (texLevel > 0)
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
else
params.minFilter = textureParameters::FILTER_NEAREST;
params.magFilter = textureParameters::FILTER_NEAREST;
}
}
else { // 3 point filter
if (texLevel > 0) { // Apply standard bilinear to mipmap textures
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
if (bUseBilinear) {
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
if (texLevel > 0)
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
else
params.minFilter = textureParameters::FILTER_LINEAR;
params.magFilter = textureParameters::FILTER_LINEAR;
} else {
if (texLevel > 0)
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
else
params.minFilter = textureParameters::FILTER_NEAREST;
params.magFilter = textureParameters::FILTER_NEAREST;
}
else {
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
} else { // 3 point filter
if (texLevel > 0) { // Apply standard bilinear to mipmap textures
if (bUseBilinear) {
params.minFilter = textureParameters::FILTER_LINEAR_MIPMAP_NEAREST;
params.magFilter = textureParameters::FILTER_LINEAR;
} else {
params.minFilter = textureParameters::FILTER_NEAREST_MIPMAP_NEAREST;
params.magFilter = textureParameters::FILTER_NEAREST;
}
} else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && bUseLOD) { // Apply standard bilinear to first tile of mipmap texture
params.minFilter = textureParameters::FILTER_LINEAR;
params.magFilter = textureParameters::FILTER_LINEAR;
} else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
params.minFilter = textureParameters::FILTER_NEAREST;
params.magFilter = textureParameters::FILTER_NEAREST;
}
}
else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && bUseLOD) { // Apply standard bilinear to first tile of mipmap texture
params.minFilter = textureParameters::FILTER_LINEAR;
params.magFilter = textureParameters::FILTER_LINEAR;
}
else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
params.minFilter = textureParameters::FILTER_NEAREST;
params.magFilter = textureParameters::FILTER_NEAREST;
}
// Set clamping modes
params.wrapS = _pTexture->clampS ? textureParameters::WRAP_CLAMP_TO_EDGE :
_pTexture->mirrorS ? textureParameters::WRAP_MIRRORED_REPEAT
: textureParameters::WRAP_REPEAT;
params.wrapT = _pTexture->clampT ? textureParameters::WRAP_CLAMP_TO_EDGE :
_pTexture->mirrorT ? textureParameters::WRAP_MIRRORED_REPEAT
: textureParameters::WRAP_REPEAT;
if (dwnd().getDrawer().getDrawingState() == DrawingState::Triangle && config.texture.maxAnisotropyF > 0.0f)
params.maxAnisotropy = Parameter(config.texture.maxAnisotropyF);
}
// Set clamping modes
params.wrapS = _pTexture->clampS ? textureParameters::WRAP_CLAMP_TO_EDGE :
_pTexture->mirrorS ? textureParameters::WRAP_MIRRORED_REPEAT
: textureParameters::WRAP_REPEAT;
params.wrapT = _pTexture->clampT ? textureParameters::WRAP_CLAMP_TO_EDGE :
_pTexture->mirrorT ? textureParameters::WRAP_MIRRORED_REPEAT
: textureParameters::WRAP_REPEAT;
if (dwnd().getDrawer().getDrawingState() == DrawingState::Triangle && config.texture.maxAnisotropyF > 0.0f)
params.maxAnisotropy = Parameter(config.texture.maxAnisotropyF);
gfxContext.setTextureParameters(params);
current[_t] = _pTexture;