back to limit vps instead of fps as this fix fps limit and now it works correctly as now the sync between the plug in and the core is almost correct.
fixed fps display in the top bar, now it shows the real fps of the game. some code clean up and some corrections to make everything work right in the reference renderer. multiples xfb now is broken even in single core as is was not an error caused by dual core, i really dono where the error is,everything looks correct but if you test a game with multiples xfb or the ipl you will see the error. ector if you can take a look at he code and throw me some ideas i'll thank you. please test. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5272 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
962fef0626
commit
a4736f7f6b
|
@ -595,14 +595,14 @@ void ScreenShot()
|
|||
// This should only be called from VI
|
||||
void VideoThrottle()
|
||||
{
|
||||
u32 TargetFPS = (SConfig::GetInstance().m_Framelimit > 1) ?
|
||||
u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 1) ?
|
||||
SConfig::GetInstance().m_Framelimit * 10 : VideoInterface::TargetRefreshRate;
|
||||
|
||||
// When frame limit is NOT off
|
||||
if (SConfig::GetInstance().m_Framelimit)
|
||||
{
|
||||
// Make the limiter a bit loose
|
||||
u32 frametime = DrawnFrame * 1000 / ++TargetFPS;
|
||||
u32 frametime = DrawnVideo * 1000 / ++TargetVPS;
|
||||
while ((u32)Timer.GetTimeDifference() < frametime)
|
||||
Common::YieldCPU();
|
||||
//Common::SleepCurrentThread(1);
|
||||
|
@ -616,7 +616,7 @@ void VideoThrottle()
|
|||
|
||||
u32 FPS = Common::AtomicLoad(DrawnFrame) * 1000 / ElapseTime;
|
||||
u32 VPS = --DrawnVideo * 1000 / ElapseTime;
|
||||
u32 Speed = FPS * 100 / VideoInterface::TargetRefreshRate;
|
||||
u32 Speed = VPS * 100 / VideoInterface::TargetRefreshRate;
|
||||
|
||||
// Settings are shown the same for both extended and summary info
|
||||
std::string SSettings = StringFromFormat("%s %s",
|
||||
|
@ -699,7 +699,8 @@ void Callback_VideoLog(const TCHAR *_szMessage, int _bDoBreak)
|
|||
// Should be called from GPU thread when a frame is drawn
|
||||
void Callback_VideoCopiedToXFB(bool video_update)
|
||||
{
|
||||
Common::AtomicIncrement(DrawnFrame);
|
||||
if(video_update)
|
||||
Common::AtomicIncrement(DrawnFrame);
|
||||
Frame::FrameUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ static const char *tevIndAlphaSel[] = {"", "x", "y", "z"};
|
|||
static const char *tevIndAlphaScale[] = {"*(248.0f/255.0f)", "*(224.0f/255.0f)","*(240.0f/255.0f)","*(248.0f/255.0f)"};
|
||||
static const char *tevIndBiasField[] = {"", "x", "y", "xy", "z", "xz", "yz", "xyz"}; // indexed by bias
|
||||
static const char *tevIndBiasAdd[] = {"-128.0f", "1.0f", "1.0f", "1.0f" }; // indexed by fmt
|
||||
static const char *tevIndWrapStart[] = {"0", "256", "128", "64", "32", "16", "0.001" };
|
||||
static const char *tevIndWrapStart[] = {"0.0f", "256.0f", "128.0f", "64.0f", "32.0f", "16.0f", "0.001f" };
|
||||
static const char *tevIndFmtScale[] = {"255.0f", "31.0f", "15.0f", "7.0f" };
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
|
|
|
@ -88,43 +88,6 @@ int TexDecoder_GetTextureSizeInBytes(int width, int height, int format)
|
|||
return (width * height * TexDecoder_GetTexelSizeInNibbles(format)) / 2;
|
||||
}
|
||||
|
||||
u32 TexDecoder_GetHash32(const u8 *src, int len, u32 samples)
|
||||
{
|
||||
const u32 m = 0x5bd1e995;
|
||||
const int r = 24;
|
||||
u32 h = len;
|
||||
const u32 * data = (const u32 *)src;
|
||||
u32 Step = (len/4);
|
||||
const u32 * End = data + Step;
|
||||
const u8 * uEnd = (const u8 *)End;
|
||||
if(samples == 0) samples = Step;
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
while(data < End)
|
||||
{
|
||||
u32 k = data[0];
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
h *= m;
|
||||
h ^= k;
|
||||
data+=Step;
|
||||
}
|
||||
|
||||
switch(len & 3)
|
||||
{
|
||||
case 3: h ^= u32(uEnd[2]) << 16;
|
||||
case 2: h ^= u32(uEnd[1]) << 8;
|
||||
case 1: h ^= u32(uEnd[0]);
|
||||
h *= m;
|
||||
};
|
||||
|
||||
h ^= h >> 13;
|
||||
h *= m;
|
||||
h ^= h >> 15;
|
||||
return h;
|
||||
}
|
||||
|
||||
#ifdef _M_X64
|
||||
u64 TexDecoder_GetHash64(const u8 *src, int len, u32 samples)
|
||||
{
|
||||
|
|
|
@ -88,9 +88,7 @@ void TexDecoder_DirectDecode(u8 *dst, const u8 *src, int width, int height,int P
|
|||
PC_TexFormat GetPC_TexFormat(int texformat, int tlutfmt);
|
||||
void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth, int texformat, int tlutaddr, int tlutfmt);
|
||||
|
||||
|
||||
u64 TexDecoder_GetHash64(const u8 *src, int len, u32 samples = 0);
|
||||
u32 TexDecoder_GetHash32(const u8 *src, int len, u32 samples = 0);
|
||||
|
||||
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
||||
|
||||
|
|
|
@ -311,6 +311,8 @@ void FramebufferManager::copyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, c
|
|||
void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 xfbTexture;
|
||||
HRESULT hr = 0;
|
||||
|
||||
|
||||
VirtualXFBListType::iterator it = findVirtualXFB(xfbAddr, fbWidth, fbHeight);
|
||||
|
||||
|
@ -361,12 +363,14 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
|||
it->xfbSource.srcWidth = fbWidth;
|
||||
it->xfbSource.srcHeight = fbHeight;
|
||||
|
||||
if(it->xfbSource.texWidth != target_width || it->xfbSource.texHeight != target_height || !it->xfbSource.texture)
|
||||
if(it->xfbSource.texWidth != target_width || it->xfbSource.texHeight != target_height || !(it->xfbSource.texture))
|
||||
{
|
||||
if(it->xfbSource.texture)
|
||||
it->xfbSource.texture->Release();
|
||||
D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
|
||||
D3DPOOL_DEFAULT, &it->xfbSource.texture, NULL);
|
||||
it->xfbSource.texture = NULL;
|
||||
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
|
||||
D3DPOOL_DEFAULT, &(it->xfbSource.texture), NULL);
|
||||
|
||||
}
|
||||
|
||||
xfbTexture = it->xfbSource.texture;
|
||||
|
@ -412,10 +416,8 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
|||
|
||||
if(!xfbTexture)
|
||||
return;
|
||||
// Make sure to resolve anything we need to read from.
|
||||
LPDIRECT3DTEXTURE9 read_texture = GetEFBColorTexture(sourceRc);
|
||||
|
||||
// We have to run a pixel shader, for color conversion.
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
|
||||
|
@ -425,7 +427,6 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
|||
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
vp.X = 0;
|
||||
vp.Y = 0;
|
||||
vp.Width = target_width;
|
||||
|
|
|
@ -61,9 +61,15 @@ inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
|||
|
||||
struct XFBSource
|
||||
{
|
||||
XFBSource() :
|
||||
texture(0)
|
||||
{}
|
||||
XFBSource()
|
||||
{
|
||||
this->srcAddr = 0;
|
||||
this->srcWidth = 0;
|
||||
this->srcHeight = 0;
|
||||
this->texture = 0;
|
||||
this->texWidth = 0;
|
||||
this->texHeight = 0;
|
||||
}
|
||||
|
||||
u32 srcAddr;
|
||||
u32 srcWidth;
|
||||
|
|
|
@ -340,7 +340,7 @@ bool Renderer::Init()
|
|||
s_LastFrameDumped = false;
|
||||
s_AVIDumping = false;
|
||||
|
||||
// We're not using fixed function, except for some 2D.
|
||||
// We're not using fixed function.
|
||||
// Let's just set the matrices to identity to be sure.
|
||||
D3DXMATRIX mtx;
|
||||
D3DXMatrixIdentity(&mtx);
|
||||
|
@ -572,19 +572,13 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
|
|||
{
|
||||
if(!fbWidth || !fbHeight)
|
||||
return;
|
||||
//VideoFifo_CheckEFBAccess();
|
||||
// If we're about to write to a requested XFB, make sure the previous
|
||||
// contents make it to the screen first.
|
||||
if (g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
|
||||
}
|
||||
VideoFifo_CheckEFBAccess();
|
||||
FBManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
|
||||
XFBWrited = true;
|
||||
// XXX: Without the VI, how would we know what kind of field this is? So
|
||||
// just use progressive.
|
||||
if (!g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
// XXX: Without the VI, how would we know what kind of field this is? So
|
||||
// just use progressive.
|
||||
Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight);
|
||||
Common::AtomicStoreRelease(s_swapRequested, FALSE);
|
||||
}
|
||||
|
@ -1019,9 +1013,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
}
|
||||
// this function is called after the XFB field is changed, not after
|
||||
// EFB is copied to XFB. In this way, flickering is reduced in games
|
||||
// and seems to also give more FPS in ZTP
|
||||
if (field == FIELD_LOWER)
|
||||
xfbAddr -= fbWidth * 2;
|
||||
// and seems to also give more FPS in ZTP
|
||||
|
||||
u32 xfbCount = 0;
|
||||
const XFBSource** xfbSourceList = FBManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
|
@ -1029,9 +1021,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
{
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Renderer::ResetAPIState();
|
||||
// Set the backbuffer as the rendering target
|
||||
|
@ -1319,7 +1309,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
UpdateViewport();
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
g_VideoInitialize.pCopiedToXFB(true);
|
||||
XFBWrited = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,14 +165,12 @@ void VertexShaderCache::Init()
|
|||
sprintf(vProg,"struct VSOUTPUT\n"
|
||||
"{\n"
|
||||
"float4 vPosition : POSITION;\n"
|
||||
"float4 vColor0 : COLOR0;\n"
|
||||
"float2 vTexCoord : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"VSOUTPUT main(float4 inPosition : POSITION,float2 inTEX0 : TEXCOORD0,float4 inColor0: COLOR0)\n"
|
||||
"VSOUTPUT main(float4 inPosition : POSITION,float2 inTEX0 : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
"VSOUTPUT OUT;\n"
|
||||
"OUT.vPosition = inPosition;\n"
|
||||
"OUT.vColor0 = inColor0;\n"
|
||||
"OUT.vTexCoord = inTEX0;\n"
|
||||
"return OUT;\n"
|
||||
"}\n");
|
||||
|
|
|
@ -358,7 +358,6 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
{
|
||||
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
// Make sure previous swap request has made it to the screen
|
||||
s_beginFieldArgs.xfbAddr = xfbAddr;
|
||||
s_beginFieldArgs.field = field;
|
||||
s_beginFieldArgs.fbWidth = fbWidth;
|
||||
|
@ -372,8 +371,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
Common::YieldCPU();
|
||||
}
|
||||
else
|
||||
VideoFifo_CheckSwapRequest();
|
||||
|
||||
VideoFifo_CheckSwapRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -805,9 +805,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
{
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
return;
|
||||
}
|
||||
if (field == FIELD_LOWER)
|
||||
xfbAddr -= fbWidth * 2;
|
||||
}
|
||||
|
||||
u32 xfbCount = 0;
|
||||
const XFBSource** xfbSourceList = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
|
@ -1143,7 +1141,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
// Renderer::SetZBufferRender();
|
||||
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
|
||||
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
g_VideoInitialize.pCopiedToXFB(true);
|
||||
XFBWrited = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -521,12 +521,6 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
{
|
||||
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
s_beginFieldArgs.xfbAddr = xfbAddr;
|
||||
s_beginFieldArgs.field = field;
|
||||
s_beginFieldArgs.fbWidth = fbWidth;
|
||||
s_beginFieldArgs.fbHeight = fbHeight;
|
||||
|
||||
Common::AtomicStoreRelease(s_swapRequested, TRUE);
|
||||
if (g_VideoInitialize.bOnThread)
|
||||
{
|
||||
while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown)
|
||||
|
@ -535,6 +529,12 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
}
|
||||
else
|
||||
VideoFifo_CheckSwapRequest();
|
||||
s_beginFieldArgs.xfbAddr = xfbAddr;
|
||||
s_beginFieldArgs.field = field;
|
||||
s_beginFieldArgs.fbWidth = fbWidth;
|
||||
s_beginFieldArgs.fbHeight = fbHeight;
|
||||
|
||||
Common::AtomicStoreRelease(s_swapRequested, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue