Attempt to fix recent D3D plugin issue. Fix bug in debugger *<:-)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@198 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-08-14 19:57:46 +00:00
parent 6d887ea18a
commit 870194db21
6 changed files with 81 additions and 49 deletions

View File

@ -83,8 +83,8 @@ namespace Jit64
if (!Core::GetStartupParameter().bUseDualCore &&
inst.OPCD == 32 &&
(inst.hex & 0xFFFF0000) == 0x800D0000 &&
Memory::ReadUnchecked_U32(js.compilerPC+4) == 0x28000000 &&
Memory::ReadUnchecked_U32(js.compilerPC+8) == 0x4182fff8)
Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 &&
Memory::ReadUnchecked_U32(js.compilerPC + 8) == 0x4182fff8)
{
gpr.Flush(FLUSH_ALL);
fpr.Flush(FLUSH_ALL);
@ -209,6 +209,8 @@ namespace Jit64
if (gpr.R(a).IsImm() && !update)
{
// If we already know the address through constant folding, we can do some
// fun tricks...
u32 addr = (u32)gpr.R(a).offset;
addr += offset;
if ((addr & 0xFFFFF000) == 0xCC008000 && jo.optimizeGatherPipe)
@ -219,6 +221,7 @@ namespace Jit64
switch (accessSize)
{
// No need to protect these, they don't touch any state
// question - should we inline them instead? Pro: Lose a CALL Con: Code bloat
case 8: CALL((void *)Asm::fifoDirectWrite8); break;
case 16: CALL((void *)Asm::fifoDirectWrite16); break;
case 32: CALL((void *)Asm::fifoDirectWrite32); break;
@ -240,7 +243,7 @@ namespace Jit64
}
// Optimized stack access?
if (accessSize == 32 && !gpr.R(a).IsImm() && a == 1 && js.st.isFirstBlockOfFunction && jo.optimizeStack) //Zelda does not like this
if (accessSize == 32 && !gpr.R(a).IsImm() && a == 1 && js.st.isFirstBlockOfFunction && jo.optimizeStack)
{
gpr.FlushLockX(ABI_PARAM1);
MOV(32, R(ABI_PARAM1), gpr.R(a));
@ -272,14 +275,7 @@ namespace Jit64
}
TEST(32, R(ABI_PARAM2), Imm32(0x0C000000));
FixupBranch unsafe_addr = J_CC(CC_NZ);
if (accessSize == 32)
BSWAP(32, ABI_PARAM1);
else if (accessSize == 16)
{
// TODO(ector): xchg ch, cl?
BSWAP(32, ABI_PARAM1);
SHR(32, R(ABI_PARAM1), Imm8(16));
}
BSWAP(accessSize, ABI_PARAM1);
#ifdef _M_X64
MOV(accessSize, MComplex(RBX, ABI_PARAM2, SCALE_1, 0), R(ABI_PARAM1));
#else

View File

@ -420,8 +420,6 @@ void CCodeWindow::Update()
UpdateButtonStates();
codeview->Center(PC);
Host_UpdateLogDisplay();
}
@ -676,7 +674,7 @@ void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
toolBar->AddTool(IDM_STEPOVER, _T("Step Over"), m_Bitmaps[Toolbar_StepOver]);
toolBar->AddTool(IDM_SKIP, _T("Skip"), m_Bitmaps[Toolbar_Skip]);
toolBar->AddSeparator();
toolBar->AddTool(IDM_GOTOPC, _T("Goto PC"), m_Bitmaps[Toolbar_GotoPC]);
toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]);
toolBar->AddSeparator();
toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T("")));

View File

@ -368,6 +368,8 @@ CFrame::InitBitmaps()
void
CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
{
if (Core::GetState() != Core::CORE_UNINITIALIZED)
return;
wxString path = wxFileSelector(
_T("Select the file to load"),
wxEmptyString, wxEmptyString, wxEmptyString,

View File

@ -206,7 +206,7 @@ namespace D3D
adapter,
D3DDEVTYPE_HAL,
wnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
// |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/,
//D3DCREATE_SOFTWARE_VERTEXPROCESSING ,
&d3dpp, &dev ) ) )
@ -220,7 +220,7 @@ namespace D3D
adapter,
D3DDEVTYPE_HAL,
wnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED,
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
// |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/,
//D3DCREATE_SOFTWARE_VERTEXPROCESSING ,
&d3dpp, &dev ) ) )

View File

@ -29,27 +29,7 @@ namespace D3D
m_pTexture = NULL;
m_pVB = NULL;
}
const int RS[6][2] =
{
{ D3DRS_ALPHABLENDENABLE, TRUE },
{ D3DRS_SRCBLEND, D3DBLEND_SRCALPHA },
{ D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA },
{ D3DRS_CULLMODE, D3DCULL_NONE },
{ D3DRS_ZENABLE, FALSE },
{ D3DRS_FOGENABLE, FALSE },
};
const int TS[6][2] =
{
{D3DTSS_COLOROP, D3DTOP_MODULATE},
{D3DTSS_COLORARG1, D3DTA_TEXTURE},
{D3DTSS_COLORARG2, D3DTA_DIFFUSE },
{D3DTSS_ALPHAOP, D3DTOP_MODULATE },
{D3DTSS_ALPHAARG1, D3DTA_TEXTURE },
{D3DTSS_ALPHAARG2, D3DTA_DIFFUSE },
};
enum {m_dwTexWidth=512, m_dwTexHeight = 512};
enum {m_dwTexWidth = 512, m_dwTexHeight = 512};
int CD3DFont::Init()
{
@ -171,22 +151,77 @@ namespace D3D
return S_OK;
}
const int RS[6][2] =
{
{ D3DRS_ALPHABLENDENABLE, TRUE },
{ D3DRS_SRCBLEND, D3DBLEND_SRCALPHA },
{ D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA },
{ D3DRS_CULLMODE, D3DCULL_NONE },
{ D3DRS_ZENABLE, FALSE },
{ D3DRS_FOGENABLE, FALSE },
};
const int TS[6][2] =
{
{D3DTSS_COLOROP, D3DTOP_MODULATE},
{D3DTSS_COLORARG1, D3DTA_TEXTURE},
{D3DTSS_COLORARG2, D3DTA_DIFFUSE },
{D3DTSS_ALPHAOP, D3DTOP_MODULATE },
{D3DTSS_ALPHAARG1, D3DTA_TEXTURE },
{D3DTSS_ALPHAARG2, D3DTA_DIFFUSE },
};
static DWORD RS_old[6];
static DWORD TS_old[6];
static LPDIRECT3DBASETEXTURE9 texture_old;
static DWORD FVF_old;
static LPDIRECT3DVERTEXDECLARATION9 decl_old;
static LPDIRECT3DPIXELSHADER9 ps_old;
static LPDIRECT3DVERTEXSHADER9 vs_old;
void SaveRenderStates()
{
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]));
}
dev->GetTexture(0, &texture_old);
dev->GetPixelShader(&ps_old);
dev->GetVertexShader(&vs_old);
dev->GetVertexDeclaration(&decl_old);
dev->GetFVF(&FVF_old);
}
void CD3DFont::SetRenderStates()
{
for (int i=0; i<6; i++)
dev->SetTexture(0, m_pTexture);
dev->SetPixelShader(0);
dev->SetVertexShader(0);
dev->SetVertexDeclaration(0);
dev->SetFVF(D3DFVF_FONT2DVERTEX);
for (int i = 0; i < 6; i++) {
dev->SetRenderState((_D3DRENDERSTATETYPE)RS[i][0],RS[i][1]);
for (int i=0; i<6; i++)
dev->SetTextureStageState(0,(_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]),TS[i][1]);
dev->SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS[i][1]);
}
}
void RestoreRenderStates()
{
dev->SetTexture(0, texture_old);
dev->SetPixelShader(ps_old);
dev->SetVertexShader(vs_old);
dev->SetVertexDeclaration(decl_old);
dev->SetFVF(FVF_old);
for (int i = 0; i < 6; i++) {
dev->SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
dev->SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
}
}
int CD3DFont::DrawTextScaled( float x, float y, float fXScale, float fYScale, float spacing, int dwColor, const char* strText, bool center )
{
SaveRenderStates();
SetRenderStates();
dev->SetTexture( 0, m_pTexture );
dev->SetPixelShader(0);
dev->SetVertexShader(0);
dev->SetVertexDeclaration(0);
dev->SetFVF( D3DFVF_FONT2DVERTEX );
dev->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
float vpWidth = 1;
@ -228,7 +263,7 @@ namespace D3D
}
float offset=-maxx/2;
strText=oldstrText;
strText = oldstrText;
//Then let's draw it
if (center)
{
@ -293,13 +328,13 @@ namespace D3D
m_pVB->Unlock();
if( dwNumTriangles > 0 )
dev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
dev->SetRenderState(D3DRS_ZENABLE,TRUE);
RestoreRenderStates();
return S_OK;
}
void quad2d(float x1, float y1, float x2, float y2, DWORD color, float u1, float v1, float u2, float v2)
{
SaveRenderStates();
struct Q2DVertex { float x,y,z,rhw; int color; float u, v; } coords[4] = {
{x1-0.5f, y1-0.5f, 0, 1, color, u1, v1},
{x2-0.5f, y1-0.5f, 0, 1, color, u2, v1},
@ -311,6 +346,7 @@ namespace D3D
dev->SetVertexDeclaration(0);
dev->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,coords,sizeof(Q2DVertex));
RestoreRenderStates();
}
}

View File

@ -103,7 +103,7 @@ void Renderer::ProcessMessages()
if(time_left<0) alpha=0;
}
alpha<<=24;
alpha <<= 24;
RenderText(it->str, left+1, top+1, 0x000000|alpha);
RenderText(it->str, left, top, 0xffff30|alpha);