VideoCommon: refactor PixelShaderManager setters

The old way was to use a dirty flag per setter. Now we just update the const buffer per setter directly.
The old optimization isn't needed any more as the setters don't call the backend any more.

The follow parts are rewritten:

Alpha

ZTextureType

zbias

FogParam

FogColor

Color

TexDim

IndMatrix

MaterialColor

FogRangeAdjust

Lights
This commit is contained in:
degasus
2013-10-12 20:31:25 +02:00
parent 15ed0ea9cf
commit cc6c454898
6 changed files with 157 additions and 358 deletions
+20 -11
View File
@@ -168,12 +168,16 @@ void BPWritten(const BPCmd& bp)
case BPMEM_IND_MTXA+6:
case BPMEM_IND_MTXB+6:
case BPMEM_IND_MTXC+6:
PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3);
if(bp.changes)
PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3);
break;
case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0
PixelShaderManager::SetIndTexScaleChanged(0x03);
if(bp.changes)
PixelShaderManager::SetIndTexScaleChanged(0x03);
break;
case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1
PixelShaderManager::SetIndTexScaleChanged(0x0c);
if(bp.changes)
PixelShaderManager::SetIndTexScaleChanged(0x0c);
break;
// ----------------
// Scissor Control
@@ -220,7 +224,8 @@ void BPWritten(const BPCmd& bp)
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
{
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
if(bp.changes & 0xFF)
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
if(bp.changes & 0x100)
SetBlendMode();
break;
@@ -341,29 +346,32 @@ void BPWritten(const BPCmd& bp)
case BPMEM_FOGRANGE+3:
case BPMEM_FOGRANGE+4:
case BPMEM_FOGRANGE+5:
if (!GetConfig(CONFIG_DISABLEFOG))
if (!GetConfig(CONFIG_DISABLEFOG) && bp.changes)
PixelShaderManager::SetFogRangeAdjustChanged();
break;
case BPMEM_FOGPARAM0:
case BPMEM_FOGBMAGNITUDE:
case BPMEM_FOGBEXPONENT:
case BPMEM_FOGPARAM3:
if (!GetConfig(CONFIG_DISABLEFOG))
if (!GetConfig(CONFIG_DISABLEFOG) && bp.changes)
PixelShaderManager::SetFogParamChanged();
break;
case BPMEM_FOGCOLOR: // Fog Color
if (!GetConfig(CONFIG_DISABLEFOG))
if (!GetConfig(CONFIG_DISABLEFOG) && bp.changes)
PixelShaderManager::SetFogColorChanged();
break;
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alpha_test.ref0,
bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1, bpmem.alpha_test.logic);
PixelShaderManager::SetAlpha(bpmem.alpha_test);
g_renderer->SetColorMask();
if(bp.changes & 0xFFFF)
PixelShaderManager::SetAlpha(bpmem.alpha_test);
if(bp.changes)
g_renderer->SetColorMask();
break;
case BPMEM_BIAS: // BIAS
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias);
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
if(bp.changes)
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
break;
case BPMEM_ZTEX2: // Z Texture type
{
@@ -573,7 +581,8 @@ void BPWritten(const BPCmd& bp)
case BPMEM_SU_TSIZE+12:
case BPMEM_SU_SSIZE+14:
case BPMEM_SU_TSIZE+14:
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
if(bp.changes)
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
break;
// ------------------------
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
File diff suppressed because it is too large Load Diff
@@ -17,7 +17,6 @@ class PointerWrap;
// The non-API dependent parts.
class PixelShaderManager
{
static void SetPSTextureDims(int texid);
public:
static void Init();
static void Dirty();
@@ -41,9 +40,8 @@ public:
static void SetFogColorChanged();
static void SetFogParamChanged();
static void SetFogRangeAdjustChanged();
static void SetColorMatrix(const float* pmatrix);
static void InvalidateXFRange(int start, int end);
static void SetMaterialColorChanged(int index);
static void SetMaterialColorChanged(int index, u32 color);
static PixelShaderConstants constants;
static bool dirty;
@@ -643,7 +643,7 @@ void VertexShaderManager::SetProjectionChanged()
bProjectionChanged = true;
}
void VertexShaderManager::SetMaterialColorChanged(int index)
void VertexShaderManager::SetMaterialColorChanged(int index, u32 color)
{
nMaterialsChanged |= (1 << index);
}
@@ -31,7 +31,7 @@ public:
static void SetTexMatrixChangedB(u32 value);
static void SetViewportChanged();
static void SetProjectionChanged();
static void SetMaterialColorChanged(int index);
static void SetMaterialColorChanged(int index, u32 color);
static void TranslateView(float x, float y, float z = 0.0f);
static void RotateView(float x, float y);
+4 -4
View File
@@ -60,8 +60,8 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
if (xfregs.ambColor[chan] != newValue)
{
VertexManager::Flush();
VertexShaderManager::SetMaterialColorChanged(chan);
PixelShaderManager::SetMaterialColorChanged(chan);
VertexShaderManager::SetMaterialColorChanged(chan, newValue);
PixelShaderManager::SetMaterialColorChanged(chan, newValue);
}
break;
}
@@ -73,8 +73,8 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
if (xfregs.matColor[chan] != newValue)
{
VertexManager::Flush();
VertexShaderManager::SetMaterialColorChanged(chan + 2);
PixelShaderManager::SetMaterialColorChanged(chan + 2);
VertexShaderManager::SetMaterialColorChanged(chan + 2, newValue);
PixelShaderManager::SetMaterialColorChanged(chan + 2, newValue);
}
break;
}