Warning fixes/suppressions(aui), assorted code cleanup, d3d vertex shader cache expiration interval increased.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4165 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-02 18:55:36 +00:00
parent dd7eba0bb9
commit e97bc516e6
15 changed files with 68 additions and 82 deletions

View File

@ -127,30 +127,24 @@ void SetScissor(const BPCmd &bp)
{
Renderer::SetScissorRect();
}
void SetLineWidth(const BPCmd &bp)
{
// We can't change line width in D3D unless we use ID3DXLine
float psize = float(bpmem.lineptwidth.pointsize) * 6.0f;
Renderer::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
}
void SetDepthMode(const BPCmd &bp)
{
if (bpmem.zmode.testenable)
{
// dev->SetRenderState(D3DRS_ZENABLE, TRUE);
// dev->SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
// dev->SetRenderState(D3DRS_ZFUNC,d3dCmpFuncs[bpmem.zmode.func]);
Renderer::SetRenderState(D3DRS_ZENABLE, TRUE);
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
Renderer::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[bpmem.zmode.func]);
}
else
{
// if the test is disabled write is disabled too
// dev->SetRenderState(D3DRS_ZENABLE, FALSE);
// dev->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
Renderer::SetRenderState(D3DRS_ZENABLE, FALSE);
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
}
@ -193,7 +187,8 @@ void SetBlendMode(const BPCmd &bp)
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
}
Renderer::SetRenderState(D3DRS_BLENDOP, bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
Renderer::SetRenderState(D3DRS_BLENDOP,
bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
}
}
void SetDitherMode(const BPCmd &bp)
@ -218,9 +213,8 @@ void SetColorMask(const BPCmd &bp)
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const bool &scaleByHalf)
{
// TODO: Scale EFBRectangle correctly
RECT rec = { rc.left, rc.top, rc.right, rc.bottom };
TextureCache::CopyEFBToRenderTarget(bpmem.copyTexDest<<5, &rec);
TextureCache::CopyEFBToRenderTarget(bpmem.copyTexDest << 5, &rec);
}
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight)
@ -229,6 +223,7 @@ void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, const float &yScale, c
PRIM_LOG("Renderer::SwapBuffers()");
g_VideoInitialize.pCopiedToXFB(false);
}
void ClearScreen(const BPCmd &bp, const EFBRectangle &rc)
{
// TODO: Scale EFBRectangle correctly
@ -248,7 +243,7 @@ void ClearScreen(const BPCmd &bp, const EFBRectangle &rc)
{
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
col = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
// clearflags |= D3DCLEAR_TARGET; set to break animal crossing :p
clearflags |= D3DCLEAR_TARGET; // set to break animal crossing :p ??
}
// clear z-buffer
@ -283,10 +278,12 @@ bool GetConfig(const int &type)
return false;
}
}
u8 *GetPointer(const u32 &address)
{
return g_VideoInitialize.pGetMemoryPointer(address);
}
void SetSamplerState(const BPCmd &bp)
{
FourTexUnits &tex = bpmem.tex[(bp.address & 0xE0) == 0xA0];

View File

@ -197,7 +197,8 @@ namespace D3D
void SaveRenderStates()
{
for (int i = 0; i < 6; i++) {
for (int i = 0; i < 6; i++)
{
dev->GetRenderState((_D3DRENDERSTATETYPE)RS[i][0], &(RS_old[i]));
dev->GetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), &(TS_old[i]));
}
@ -215,10 +216,8 @@ namespace D3D
dev->SetPixelShader(0);
dev->SetVertexShader(0);
dev->SetVertexDeclaration(0);
// dev->SetFVF(D3DFVF_FONT2DVERTEX);
Renderer::SetFVF(D3DFVF_FONT2DVERTEX);
dev->SetFVF(D3DFVF_FONT2DVERTEX);
for (int i = 0; i < 6; i++) {
// dev->SetRenderState((_D3DRENDERSTATETYPE)RS[i][0],RS[i][1]);
@ -236,10 +235,8 @@ namespace D3D
dev->SetPixelShader(ps_old);
dev->SetVertexShader(vs_old);
dev->SetVertexDeclaration(decl_old);
// dev->SetFVF(FVF_old);
Renderer::SetFVF(FVF_old);
dev->SetFVF(FVF_old);
for (int i = 0; i < 6; i++)
{
@ -384,7 +381,7 @@ namespace D3D
dev->SetVertexShader(0);
dev->SetVertexDeclaration(0);
Renderer::SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
dev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex));
RestoreRenderStates();

View File

@ -98,7 +98,6 @@ void PixelShaderCache::SetShader(bool dstAlpha)
PixelShaders[uid] = newentry;
last_entry = &PixelShaders[uid];
Renderer::SetFVF(NULL);
D3D::dev->SetPixelShader(shader);
last_shader = shader;
@ -119,7 +118,7 @@ void PixelShaderCache::Cleanup()
while (iter != PixelShaders.end())
{
PSCacheEntry &entry = iter->second;
if (entry.frameCount < frameCount - 400)
if (entry.frameCount < frameCount - 1400)
{
entry.Destroy();
iter = PixelShaders.erase(iter);

View File

@ -56,7 +56,6 @@ std::vector<LPDIRECT3DBASETEXTURE9> Renderer::m_Textures;
DWORD Renderer::m_RenderStates[MaxRenderStates+46];
DWORD Renderer::m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
DWORD Renderer::m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
DWORD Renderer::m_FVF;
bool Renderer::m_LastFrameDumped;
bool Renderer::m_AVIDumping;
@ -116,7 +115,6 @@ void Renderer::Shutdown()
void Renderer::Initialize()
{
m_FVF = 0;
m_Textures.reserve(MaxTextureStages);
for (int i = 0; i < MaxTextureStages; i++)
m_Textures.push_back(NULL);
@ -360,12 +358,17 @@ void Renderer::SwapBuffers()
D3D::dev->SetScissorRect(&rc);
D3D::dev->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x101010, 0, 0);
// We probably shouldn't clear here.
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 0, 0);
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
// clearColor |= 0x003F003F;
// D3D::BeginFrame(true,clearColor,1.0f);
D3D::BeginFrame(false, clearColor, 1.0f);
D3D::EnableAlphaToCoverage();
// This probably causes problems, and the visual difference is tiny anyway.
// So let's keep it commented out.
// D3D::EnableAlphaToCoverage();
Postprocess::BeginFrame();
VertexManager::BeginFrame();
@ -502,15 +505,6 @@ void Renderer::SetTexture(DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture)
}
}
void Renderer::SetFVF(DWORD FVF)
{
if (m_FVF != FVF)
{
m_FVF = FVF;
D3D::dev->SetFVF(FVF);
}
}
void Renderer::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
{
if (m_RenderStates[State] != Value)

View File

@ -51,7 +51,6 @@ class Renderer
static DWORD m_RenderStates[MaxRenderStates+46];
static DWORD m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
static DWORD m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
static DWORD m_FVF;
public:
static void Init(SVideoInitialize &_VideoInitialize);
@ -79,7 +78,6 @@ public:
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
static void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
static void SetFVF(DWORD FVF);
static void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
static void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
static void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);

View File

@ -105,8 +105,8 @@ void TextureCache::Cleanup()
TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt)
{
if (address == 0) return NULL;
if (address == 0)
return NULL;
TexCache::iterator iter = textures.find(address);
@ -185,7 +185,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
d3d_fmt = D3DFMT_R5G6B5;
break;
case PC_TEX_FMT_IA4_AS_IA8:
d3d_fmt = D3DFMT_A8L8; //D3DFMT_A4L4;
d3d_fmt = D3DFMT_A8L8;
break;
case PC_TEX_FMT_I8:
case PC_TEX_FMT_I4_AS_I8:
@ -262,24 +262,25 @@ void TextureCache::CopyEFBToRenderTarget(u32 address, RECT *source)
{
if (!iter->second.isRenderTarget)
{
g_VideoInitialize.pLog("Using non-rendertarget texture as render target!!! WTF?", FALSE);
ERROR_LOG(VIDEO, "Using non-rendertarget texture as render target!!! WTF?", FALSE);
//TODO: remove it and recreate it as a render target
}
tex = iter->second.texture;
iter->second.frameCount=frameCount;
iter->second.frameCount = frameCount;
}
else
{
TCacheEntry entry;
entry.isRenderTarget=true;
entry.isRenderTarget = true;
entry.hash = 0;
entry.hashoffset = 0;
entry.frameCount = frameCount;
// TODO(ector): infer this size in some sensible way
D3D::dev->CreateTexture(512,512,1,D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0);
D3D::dev->CreateTexture(512, 512, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0);
textures[address] = entry;
tex = entry.texture;
}
LPDIRECT3DSURFACE9 srcSurface,destSurface;
tex->GetSurfaceLevel(0,&destSurface);
srcSurface = D3D::GetBackBufferSurface();

View File

@ -110,8 +110,7 @@ void VertexShaderCache::SetShader(u32 components)
PanicAlert("Failed to compile Vertex Shader:\n\n%s", code);
}
Renderer::SetFVF(NULL);
//D3D::dev->SetVertexShader(shader);
D3D::dev->SetFVF(NULL);
}
void VertexShaderCache::Cleanup()
@ -119,7 +118,7 @@ void VertexShaderCache::Cleanup()
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end();)
{
VSCacheEntry &entry = iter->second;
if (entry.frameCount < frameCount - 30)
if (entry.frameCount < frameCount - 1400)
{
entry.Destroy();
iter = vshaders.erase(iter);