mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Big Commit this will break a lot, fix a lot, but i thing is a good step:
Implemented all the correct format conversions in efb to texture copy. replaced all the stretcrect calls with quad draws this must improve speed a bit. A BIGGGGGGGGGG cleanup in the code and reorganization. reimplemented zpeek using a secondary render target ( this still is buggy so many issues left) please a lot off feedback. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4520 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -208,10 +208,24 @@ void SaveRenderStates()
|
||||
|
||||
void RestoreRenderStates()
|
||||
{
|
||||
D3D::SetTexture(0, texture_old);
|
||||
|
||||
dev->SetPixelShader(ps_old);
|
||||
dev->SetVertexShader(vs_old);
|
||||
if(texture_old)
|
||||
{
|
||||
D3D::SetTexture(0, texture_old);
|
||||
texture_old->Release();
|
||||
texture_old = NULL;
|
||||
}
|
||||
if(ps_old)
|
||||
{
|
||||
dev->SetPixelShader(ps_old);
|
||||
ps_old->Release();
|
||||
ps_old = NULL;
|
||||
}
|
||||
if(vs_old)
|
||||
{
|
||||
dev->SetVertexShader(vs_old);
|
||||
vs_old->Release();
|
||||
vs_old = NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
@ -374,4 +388,37 @@ void quad2d(float x1, float y1, float x2, float y2, u32 color, float u1, float v
|
||||
RestoreRenderStates();
|
||||
}
|
||||
|
||||
void drawShadedTexQuad(IDirect3DTexture9 *texture,
|
||||
const RECT *rSource,
|
||||
int SourceWidth,
|
||||
int SourceHeight,
|
||||
const RECT *rDest,
|
||||
IDirect3DPixelShader9 *PShader,
|
||||
IDirect3DVertexShader9 *Vshader)
|
||||
{
|
||||
SaveRenderStates();
|
||||
|
||||
float span = ((rSource->right-rSource->left - 1.0f) * (rDest->right - rDest->left))/(SourceWidth*((rDest->right - rDest->left)-1.0f));
|
||||
float u1=((0.5f+rSource->left)/(float) SourceWidth)-(span*0.5f/(float)(rDest->right - rDest->left));
|
||||
float u2=u1+span;
|
||||
span = ((rSource->bottom-rSource->top - 1.0f) * (rDest->bottom - rDest->top))/(SourceHeight*((rDest->bottom - rDest->top)-1.0f));
|
||||
float v1=((0.5f+rSource->top)/(float) SourceHeight)-(span*0.5f/(float)(rDest->bottom - rDest->top));
|
||||
float v2=v1+span;
|
||||
|
||||
struct Q2DVertex { float x,y,z,rhw,u,v; } coords[4] = {
|
||||
{(float)rDest->left-1.0f, (float)rDest->top-1.0f, 0.0f, 1.0f, u1, v1},
|
||||
{(float)rDest->right, (float)rDest->top-1.0f, 0.0f,1.0f, u2, v1},
|
||||
{(float)rDest->right, (float)rDest->bottom, 0.0f,1.0f, u2, v2},
|
||||
{(float)rDest->left-1.0f, (float)rDest->bottom, 0.0f,1.0f, u1, v2}
|
||||
};
|
||||
dev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
dev->SetVertexShader(Vshader);
|
||||
dev->SetPixelShader(PShader);
|
||||
dev->SetTexture(0, texture);
|
||||
dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex));
|
||||
D3D::RefreshVertexDeclaration();
|
||||
RestoreRenderStates();
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user