Merged the D3D9 debugger into VideoCommon/VideoUICommon:

Separated UI from debugger functionality. Generally cleaned up that stuff.
Most functionality needs to be reimplemented now, but will be available to D3D9, D3D11 as well as OpenGL then.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6523 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX
2010-12-05 14:15:36 +00:00
parent 9da4fe086b
commit 7854bd7109
36 changed files with 735 additions and 1112 deletions

View File

@ -3,6 +3,7 @@ set(SRCS Src/BPMemory.cpp
Src/BPStructs.cpp
Src/CommandProcessor.cpp
Src/CPMemory.cpp
Src/Debugger.cpp
Src/DLCache.cpp
Src/Fifo.cpp
Src/FramebufferManagerBase.cpp

View File

@ -0,0 +1,173 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "IniFile.h"
#include "Debugger.h"
#include "FileUtil.h"
#include "VideoConfig.h"
#include "TextureCacheBase.h"
#include "PixelShaderGen.h"
#include "VertexShaderGen.h"
#include "NativeVertexFormat.h"
GFXDebuggerBase *g_pdebugger = NULL;
volatile bool GFXDebuggerPauseFlag = false;
volatile PauseEvent GFXDebuggerToPauseAtNext = NOT_PAUSE;
volatile int GFXDebuggerEventToPauseCount = 0;
void UpdateFPSDisplay(const char *text);
extern NativeVertexFormat *g_nativeVertexFmt;
void GFXDebuggerUpdateScreen()
{
// TODO: Implement this in a plugin-independent way
/* // update screen
if (D3D::bFrameInProgress)
{
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(NULL);
D3D::dev->StretchRect(FramebufferManager::GetEFBColorRTSurface(), NULL,
D3D::GetBackBufferSurface(), NULL,
D3DTEXF_LINEAR);
D3D::dev->EndScene();
D3D::dev->Present(NULL, NULL, NULL, NULL);
D3D::dev->SetRenderTarget(0, FramebufferManager::GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FramebufferManager::GetEFBDepthRTSurface());
D3D::dev->BeginScene();
}
else
{
D3D::dev->EndScene();
D3D::dev->Present(NULL, NULL, NULL, NULL);
D3D::dev->BeginScene();
}*/
}
void GFXDebuggerCheckAndPause(bool update)
{
if (GFXDebuggerPauseFlag)
{
g_pdebugger->OnPause();
while( GFXDebuggerPauseFlag )
{
UpdateFPSDisplay("Paused by Video Debugger");
if (update) GFXDebuggerUpdateScreen();
Sleep(5);
}
g_pdebugger->OnContinue();
}
}
void GFXDebuggerToPause(bool update)
{
GFXDebuggerToPauseAtNext = NOT_PAUSE;
GFXDebuggerPauseFlag = true;
GFXDebuggerCheckAndPause(update);
}
void ContinueGFXDebugger()
{
GFXDebuggerPauseFlag = false;
}
void GFXDebuggerBase::DumpPixelShader(const char* path)
{
char filename[MAX_PATH];
sprintf(filename, "%s/dump_ps.txt", path);
std::string output;
bool useDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
if (!useDstAlpha)
{
output = "Destination alpha disabled:\n";
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
}
else
{
if(g_ActiveConfig.backend_info.bSupportsDualSourceBlend)
{
output = "Using dual source blending for destination alpha:\n";
output += GeneratePixelShaderCode(DSTALPHA_DUAL_SOURCE_BLEND, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
}
else
{
output = "Using two passes for emulating destination alpha:\n";
output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
output += "\n\nDestination alpha pass shader:\n";
output += GeneratePixelShaderCode(DSTALPHA_ALPHA_PASS, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
}
}
File::CreateEmptyFile(filename);
File::WriteStringToFile(true, output.c_str(), filename);
}
void GFXDebuggerBase::DumpVertexShader(const char* path)
{
char filename[MAX_PATH];
sprintf(filename, "%s/dump_vs_consts.txt", path);
File::CreateEmptyFile(filename);
File::WriteStringToFile(true, GenerateVertexShaderCode(g_nativeVertexFmt->m_components, g_ActiveConfig.backend_info.APIType), filename);
}
void GFXDebuggerBase::DumpPixelShaderConstants(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpVertexShaderConstants(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpTextures(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpFrameBuffer(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpGeometry(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpVertexDecl(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpMatrices(const char* path)
{
// TODO
}
void GFXDebuggerBase::DumpStats(const char* path)
{
// TODO
}

View File

@ -0,0 +1,90 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _GFX_DEBUGGER_H_
#define _GFX_DEBUGGER_H_
class GFXDebuggerBase
{
public:
// if paused, debugging functions can be enabled
virtual void OnPause() {};
virtual void OnContinue() {};
void DumpPixelShader(const char* path);
void DumpVertexShader(const char* path);
void DumpPixelShaderConstants(const char* path);
void DumpVertexShaderConstants(const char* path);
void DumpTextures(const char* path);
void DumpFrameBuffer(const char* path);
void DumpGeometry(const char* path);
void DumpVertexDecl(const char* path);
void DumpMatrices(const char* path);
void DumpStats(const char* path);
};
enum PauseEvent {
NOT_PAUSE = 0,
NEXT_FRAME = 1<<0,
NEXT_FLUSH = 1<<1,
NEXT_PIXEL_SHADER_CHANGE = 1<<2,
NEXT_VERTEX_SHADER_CHANGE = 1<<3,
NEXT_TEXTURE_CHANGE = 1<<4,
NEXT_NEW_TEXTURE = 1<<5,
NEXT_XFB_CMD = 1<<6, // TODO
NEXT_EFB_CMD = 1<<7, // TODO
NEXT_MATRIX_CMD = 1<<8, // TODO
NEXT_VERTEX_CMD = 1<<9, // TODO
NEXT_TEXTURE_CMD = 1<<10, // TODO
NEXT_LIGHT_CMD = 1<<11, // TODO
NEXT_FOG_CMD = 1<<12, // TODO
NEXT_SET_TLUT = 1<<13, // TODO
NEXT_ERROR = 1<<14, // TODO
};
extern GFXDebuggerBase *g_pdebugger;
extern volatile bool GFXDebuggerPauseFlag;
extern volatile PauseEvent GFXDebuggerToPauseAtNext;
extern volatile int GFXDebuggerEventToPauseCount;
void ContinueGFXDebugger();
void GFXDebuggerCheckAndPause(bool update);
void GFXDebuggerToPause(bool update);
void GFXDebuggerUpdateScreen();
#undef ENABLE_GFX_DEBUGGER
#if defined(_DEBUG) || defined(DEBUGFAST)
#define ENABLE_GFX_DEBUGGER
#endif
#ifdef ENABLE_GFX_DEBUGGER
#define GFX_DEBUGGER_PAUSE_AT(event,update) {if (((GFXDebuggerToPauseAtNext & event) && --GFXDebuggerEventToPauseCount<=0) || GFXDebuggerPauseFlag) GFXDebuggerToPause(update);}
#define GFX_DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc) {if (((GFXDebuggerToPauseAtNext & event) && --GFXDebuggerEventToPauseCount<=0) || GFXDebuggerPauseFlag) {{dumpfunc};GFXDebuggerToPause(update);}}
#define GFX_DEBUGGER_LOG_AT(event,dumpfunc) {if (( GFXDebuggerToPauseAtNext & event ) ) {{dumpfunc};}}
#else
// Disable debugging calls in Release build
#define GFX_DEBUGGER_PAUSE_AT(event,update)
#define GFX_DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc)
#define GFX_DEBUGGER_LOG_AT(event,dumpfunc)
#endif ENABLE_GFX_DEBUGGER
#endif // _GFX_DEBUGGER_H_

View File

@ -8,6 +8,7 @@ files = [
'BPStructs.cpp',
'CPMemory.cpp',
'CommandProcessor.cpp',
'DebuggerPanel.cpp',
'DLCache.cpp',
'Fifo.cpp',
'FramebufferManagerBase.cpp',

View File

@ -11,6 +11,7 @@
#include "PluginSpecs.h"
#include "TextureCacheBase.h"
#include "Debugger.h"
// ugly
extern int frameCount;
@ -261,7 +262,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
hash_value = 0;
}
// TODO: Is the mipLevels check needed?
if (((entry->isRenderTarget || entry->isDynamic) && hash_value == entry->hash && address == entry->addr)
|| ((address == entry->addr) && (hash_value == entry->hash) && full_format == entry->format && entry->mipLevels == maxlevel))
{
@ -275,7 +275,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
// Might speed up movie playback very, very slightly.
texture_is_dynamic = (entry->isRenderTarget || entry->isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
// TODO: Is the mipLevels check needed?
if (!entry->isRenderTarget &&
((!entry->isDynamic && width == entry->realW && height == entry->realH && full_format == entry->format && entry->mipLevels == maxlevel)
|| (entry->isDynamic && entry->realW == width && entry->realH == height)))
@ -331,6 +330,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
// e.g. if our texture cache entry got too many mipmap levels we can limit the number of used levels by setting the appropriate render states
// Thus, we don't update this member for every Load, but just whenever the texture gets recreated
entry->mipLevels = maxlevel;
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
}
entry->addr = address;
@ -412,6 +413,8 @@ return_entry:
entry->frameCount = frameCount;
entry->Bind(stage);
GFX_DEBUGGER_PAUSE_AT(NEXT_TEXTURE_CHANGE, true);
return entry;
}

View File

@ -158,6 +158,7 @@ struct VideoConfig
bool bSupportsRealXFB;
bool bSupports3DVision;
bool bAllowSignedBytes; // D3D9 doesn't support signed bytes (?)
bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL
} backend_info;
};

View File

@ -734,6 +734,14 @@
<Filter
Name="Base"
>
<File
RelativePath=".\Src\Debugger.cpp"
>
</File>
<File
RelativePath=".\Src\Debugger.h"
>
</File>
<File
RelativePath=".\Src\FramebufferManagerBase.cpp"
>