some minor changes preparing for future commits, and a correction to texture alignment that must solve the efb misalignments in various games
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4556 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
654800458f
commit
e56ca08b4f
|
@ -120,7 +120,7 @@ void PixelShaderManager::SetConstants()
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// 24 bits
|
// 24 bits
|
||||||
ftemp[0] = ffrac/65536.0f; ftemp[1] = ffrac/256.0f; ftemp[2] = ffrac; ftemp[3] = ffrac/16777216.0f;
|
ftemp[0] = ffrac/65536.0f; ftemp[1] = ffrac/256.0f; ftemp[2] = ffrac; ftemp[3] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetPSConstant4fv(C_ZBIAS, ftemp);
|
SetPSConstant4fv(C_ZBIAS, ftemp);
|
||||||
|
|
|
@ -60,6 +60,25 @@ int TexDecoder_GetTexelSizeInNibbles(int format)
|
||||||
case GX_TF_C8: return 2;
|
case GX_TF_C8: return 2;
|
||||||
case GX_TF_C14X2: return 4;
|
case GX_TF_C14X2: return 4;
|
||||||
case GX_TF_CMPR: return 1;
|
case GX_TF_CMPR: return 1;
|
||||||
|
case GX_CTF_R4: return 1;
|
||||||
|
case GX_CTF_RA4: return 2;
|
||||||
|
case GX_CTF_RA8: return 4;
|
||||||
|
case GX_CTF_YUVA8: return 8;
|
||||||
|
case GX_CTF_A8: return 2;
|
||||||
|
case GX_CTF_R8: return 2;
|
||||||
|
case GX_CTF_G8: return 2;
|
||||||
|
case GX_CTF_B8: return 2;
|
||||||
|
case GX_CTF_RG8: return 4;
|
||||||
|
case GX_CTF_GB8: return 4;
|
||||||
|
|
||||||
|
case GX_TF_Z8: return 2;
|
||||||
|
case GX_TF_Z16: return 4;
|
||||||
|
case GX_TF_Z24X8: return 8;
|
||||||
|
|
||||||
|
case GX_CTF_Z4: return 1;
|
||||||
|
case GX_CTF_Z8M: return 2;
|
||||||
|
case GX_CTF_Z8L: return 2;
|
||||||
|
case GX_CTF_Z16L: return 4;
|
||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,18 +398,18 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture,
|
||||||
{
|
{
|
||||||
SaveRenderStates();
|
SaveRenderStates();
|
||||||
|
|
||||||
float span = ((rSource->right-rSource->left - 1.0f) * (rDest->right - rDest->left))/(SourceWidth*((rDest->right - rDest->left)-1.0f));
|
//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 u1=((float)rSource->left+1.0f)/(float) SourceWidth;//*/((0.5f+rSource->left)/(float) SourceWidth)-(span*0.5f/(float)(rDest->right - rDest->left));
|
||||||
float u2=u1+span;
|
float u2=((float)rSource->right-1.0f)/(float) SourceWidth;;//*/u1+span;
|
||||||
span = ((rSource->bottom-rSource->top - 1.0f) * (rDest->bottom - rDest->top))/(SourceHeight*((rDest->bottom - rDest->top)-1.0f));
|
//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 v1=((float)rSource->top+1.0f)/(float) SourceHeight;//*/((0.5f+rSource->top)/(float) SourceHeight)-(span*0.5f/(float)(rDest->bottom - rDest->top));
|
||||||
float v2=v1+span;
|
float v2=((float)rSource->bottom-1.0f)/(float) SourceHeight;//*/v1+span;
|
||||||
|
|
||||||
struct Q2DVertex { float x,y,z,rhw,u,v; } coords[4] = {
|
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->left-0.5f, (float)rDest->top-0.5f, 0.0f, 1.0f, u1, v1},
|
||||||
{(float)rDest->right, (float)rDest->top-1.0f, 0.0f,1.0f, u2, v1},
|
{(float)rDest->right-0.5f, (float)rDest->top-0.5f, 0.0f,1.0f, u2, v1},
|
||||||
{(float)rDest->right, (float)rDest->bottom, 0.0f,1.0f, u2, v2},
|
{(float)rDest->right-0.5f, (float)rDest->bottom-0.5f, 0.0f,1.0f, u2, v2},
|
||||||
{(float)rDest->left-1.0f, (float)rDest->bottom, 0.0f,1.0f, u1, v2}
|
{(float)rDest->left-0.5f, (float)rDest->bottom-0.5f, 0.0f,1.0f, u1, v2}
|
||||||
};
|
};
|
||||||
dev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
dev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||||
dev->SetVertexShader(Vshader);
|
dev->SetVertexShader(Vshader);
|
||||||
|
|
|
@ -359,6 +359,9 @@ static void DX9DebuggerUpdateScreen()
|
||||||
D3D::dev->Present(NULL, NULL, NULL, NULL);
|
D3D::dev->Present(NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
||||||
|
|
||||||
|
if(D3D::GetCaps().NumSimultaneousRTs > 1)
|
||||||
|
D3D::dev->SetRenderTarget(1,FBManager::GetEFBDepthEncodedSurface());
|
||||||
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
||||||
D3D::dev->BeginScene();
|
D3D::dev->BeginScene();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,31 @@ void TextureCache::Invalidate(bool shutdown)
|
||||||
textures.clear();
|
textures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCache::InvalidateRange(u32 start_address, u32 size)
|
||||||
|
{
|
||||||
|
TexCache::iterator iter = textures.begin();
|
||||||
|
while (iter != textures.end())
|
||||||
|
{
|
||||||
|
if (iter->second.IntersectsMemoryRange(start_address, size))
|
||||||
|
{
|
||||||
|
iter->second.Destroy(false);
|
||||||
|
ERASE_THROUGH_ITERATOR(textures, iter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextureCache::TCacheEntry::IntersectsMemoryRange(u32 range_address, u32 range_size)
|
||||||
|
{
|
||||||
|
if (addr + size_in_bytes < range_address)
|
||||||
|
return false;
|
||||||
|
if (addr >= range_address + range_size)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void TextureCache::Shutdown()
|
void TextureCache::Shutdown()
|
||||||
{
|
{
|
||||||
Invalidate(true);
|
Invalidate(true);
|
||||||
|
@ -183,6 +208,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
D3DFORMAT d3d_fmt;
|
D3DFORMAT d3d_fmt;
|
||||||
switch (pcfmt) {
|
switch (pcfmt) {
|
||||||
case PC_TEX_FMT_BGRA32:
|
case PC_TEX_FMT_BGRA32:
|
||||||
|
case PC_TEX_FMT_RGBA32:
|
||||||
d3d_fmt = D3DFMT_A8R8G8B8;
|
d3d_fmt = D3DFMT_A8R8G8B8;
|
||||||
break;
|
break;
|
||||||
case PC_TEX_FMT_RGB565:
|
case PC_TEX_FMT_RGB565:
|
||||||
|
@ -204,7 +230,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
d3d_fmt = D3DFMT_DXT1;
|
d3d_fmt = D3DFMT_DXT1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make an entry in the table
|
//Make an entry in the table
|
||||||
TCacheEntry& entry = textures[texID];
|
TCacheEntry& entry = textures[texID];
|
||||||
|
|
||||||
|
@ -310,25 +336,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||||
tex = entry.texture;
|
tex = entry.texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
have_texture:
|
have_texture:
|
||||||
/*TargetRectangle targetSource = Renderer::ConvertEFBRectangle(source_rect);
|
|
||||||
RECT source_rc;
|
|
||||||
source_rc.left = targetSource.left;
|
|
||||||
source_rc.top = targetSource.top;
|
|
||||||
source_rc.right = targetSource.right;
|
|
||||||
source_rc.bottom = targetSource.bottom;
|
|
||||||
RECT dest_rc;
|
|
||||||
dest_rc.left = 0;
|
|
||||||
dest_rc.top = 0;
|
|
||||||
dest_rc.right = tex_w;
|
|
||||||
dest_rc.bottom = tex_h;
|
|
||||||
|
|
||||||
LPDIRECT3DSURFACE9 srcSurface, destSurface;
|
|
||||||
tex->GetSurfaceLevel(0, &destSurface);
|
|
||||||
srcSurface = FBManager::GetEFBColorRTSurface();
|
|
||||||
D3D::dev->StretchRect(srcSurface, &source_rc, destSurface, &dest_rc, D3DTEXF_LINEAR);
|
|
||||||
destSurface->Release();
|
|
||||||
return;*/
|
|
||||||
float colmat[16]= {0.0f};
|
float colmat[16]= {0.0f};
|
||||||
float fConstAdd[4] = {0.0f};
|
float fConstAdd[4] = {0.0f};
|
||||||
|
|
||||||
|
@ -446,7 +454,8 @@ have_texture:
|
||||||
hr = tex->GetSurfaceLevel(0,&Rendersurf);
|
hr = tex->GetSurfaceLevel(0,&Rendersurf);
|
||||||
CHECK(hr);
|
CHECK(hr);
|
||||||
D3D::dev->SetDepthStencilSurface(NULL);
|
D3D::dev->SetDepthStencilSurface(NULL);
|
||||||
D3D::dev->SetRenderTarget(1, NULL);
|
if(D3D::GetCaps().NumSimultaneousRTs > 1)
|
||||||
|
D3D::dev->SetRenderTarget(1, NULL);
|
||||||
D3D::dev->SetRenderTarget(0, Rendersurf);
|
D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||||
|
|
||||||
D3DVIEWPORT9 vp;
|
D3DVIEWPORT9 vp;
|
||||||
|
@ -468,17 +477,18 @@ have_texture:
|
||||||
|
|
||||||
|
|
||||||
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
|
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
|
||||||
//TargetRectangle targetSource = Renderer::ConvertEFBRectangle(source_rect);
|
TargetRectangle targetSource = Renderer::ConvertEFBRectangle(source_rect);
|
||||||
RECT sourcerect;
|
RECT sourcerect;
|
||||||
sourcerect.bottom = source_rect.bottom;
|
sourcerect.bottom = targetSource.bottom;
|
||||||
sourcerect.left = source_rect.left;
|
sourcerect.left = targetSource.left;
|
||||||
sourcerect.right = source_rect.right;
|
sourcerect.right = targetSource.right;
|
||||||
sourcerect.top = source_rect.top;
|
sourcerect.top = targetSource.top;
|
||||||
|
|
||||||
D3D::drawShadedTexQuad(read_texture,&sourcerect, EFB_WIDTH , EFB_HEIGHT,&destrect,(FBManager::GetEFBDepthRTSurfaceFormat() == D3DFMT_R32F && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(): PixelShaderCache::GetColorMatrixProgram(),NULL);
|
D3D::drawShadedTexQuad(read_texture,&sourcerect, Renderer::GetTargetWidth() , Renderer::GetTargetHeight(),&destrect,(FBManager::GetEFBDepthRTSurfaceFormat() == D3DFMT_R32F && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(): PixelShaderCache::GetColorMatrixProgram(),VertexShaderCache::GetSimpleVertexSahder());
|
||||||
|
|
||||||
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
||||||
D3D::dev->SetRenderTarget(1, FBManager::GetEFBDepthEncodedSurface());
|
if(D3D::GetCaps().NumSimultaneousRTs > 1)
|
||||||
|
D3D::dev->SetRenderTarget(1, FBManager::GetEFBDepthEncodedSurface());
|
||||||
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
||||||
VertexShaderManager::SetViewportChanged();
|
VertexShaderManager::SetViewportChanged();
|
||||||
Renderer::RestoreAPIState();
|
Renderer::RestoreAPIState();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
oldpixel = 0;
|
oldpixel = 0;
|
||||||
}
|
}
|
||||||
void Destroy(bool shutdown);
|
void Destroy(bool shutdown);
|
||||||
|
bool IntersectsMemoryRange(u32 range_address, u32 range_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -67,6 +68,7 @@ public:
|
||||||
static void Cleanup();
|
static void Cleanup();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static void Invalidate(bool shutdown);
|
static void Invalidate(bool shutdown);
|
||||||
|
static void InvalidateRange(u32 start_address, u32 size);
|
||||||
static TCacheEntry *Load(int stage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
|
static TCacheEntry *Load(int stage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
|
||||||
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect);
|
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue