Defer bind of shader blend copy until after verts.

This commit is contained in:
Unknown W. Brackets 2015-03-17 22:07:09 -07:00
parent 71afaffc20
commit 5360422310
6 changed files with 39 additions and 12 deletions

View File

@ -150,11 +150,7 @@ bool TransformDrawEngineDX9::ApplyShaderBlending() {
return false;
}
framebufferManager_->BindFramebufferColor(1, nullptr, false);
// If we are rendering at a higher resolution, linear is probably best for the dest color.
pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pD3Ddevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
fboTexBound_ = true;
fboTexNeedBind_ = true;
shaderManager_->DirtyUniform(DIRTY_SHADERBLEND);
return true;
@ -810,4 +806,21 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
}
}
void TransformDrawEngineDX9::ApplyDrawStateLate() {
// At this point, we know if the vertices are full alpha or not.
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
if (!gstate.isModeClear()) {
// TODO: Test texture?
if (fboTexNeedBind_) {
framebufferManager_->BindFramebufferColor(1, nullptr, false);
// If we are rendering at a higher resolution, linear is probably best for the dest color.
pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pD3Ddevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
fboTexBound_ = true;
fboTexNeedBind_ = false;
}
}
}
}

View File

@ -90,6 +90,7 @@ TransformDrawEngineDX9::TransformDrawEngineDX9()
decodeCounter_(0),
dcid_(0),
uvScale(0),
fboTexNeedBind_(false),
fboTexBound_(false) {
memset(&decOptions_, 0, sizeof(decOptions_));
@ -777,6 +778,8 @@ rotateVBO:
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255);
}
ApplyDrawStateLate();
vshader = shaderManager_->ApplyShader(prim, lastVType_);
IDirect3DVertexDeclaration9 *pHardwareVertexDecl = SetupDecFmtForDraw(vshader, dec_->GetDecVtxFmt(), dec_->VertexType());
if (pHardwareVertexDecl) {
@ -808,6 +811,9 @@ rotateVBO:
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255);
}
ApplyDrawStateLate();
vshader = shaderManager_->ApplyShader(prim, lastVType_);
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
prim = indexGen.Prim();
// Undo the strip optimization, not supported by the SW code yet.

View File

@ -247,6 +247,7 @@ private:
UVScale *uvScale;
bool fboTexNeedBind_;
bool fboTexBound_;
};

View File

@ -190,13 +190,7 @@ bool TransformDrawEngine::ApplyShaderBlending() {
return false;
}
framebufferManager_->BindFramebufferColor(GL_TEXTURE1, gstate.getFrameBufRawAddress(), nullptr);
glActiveTexture(GL_TEXTURE1);
// If we are rendering at a higher resolution, linear is probably best for the dest color.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glActiveTexture(GL_TEXTURE0);
fboTexBound_ = true;
fboTexNeedBind_ = true;
shaderManager_->DirtyUniform(DIRTY_SHADERBLEND);
return true;
@ -906,5 +900,16 @@ void TransformDrawEngine::ApplyDrawStateLate() {
if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) {
fragmentTestCache_->BindTestTexture(GL_TEXTURE2);
}
if (fboTexNeedBind_) {
framebufferManager_->BindFramebufferColor(GL_TEXTURE1, gstate.getFrameBufRawAddress(), nullptr);
glActiveTexture(GL_TEXTURE1);
// If we are rendering at a higher resolution, linear is probably best for the dest color.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glActiveTexture(GL_TEXTURE0);
fboTexBound_ = true;
fboTexNeedBind_ = false;
}
}
}

View File

@ -126,6 +126,7 @@ TransformDrawEngine::TransformDrawEngine()
decodeCounter_(0),
dcid_(0),
uvScale(0),
fboTexNeedBind_(false),
fboTexBound_(false) {
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
memset(&decOptions_, 0, sizeof(decOptions_));

View File

@ -250,5 +250,6 @@ private:
UVScale *uvScale;
bool fboTexNeedBind_;
bool fboTexBound_;
};