2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-12-05 14:15:36 +00:00
|
|
|
|
|
|
|
#include "IniFile.h"
|
|
|
|
#include "Debugger.h"
|
|
|
|
#include "FileUtil.h"
|
|
|
|
|
|
|
|
#include "VideoConfig.h"
|
|
|
|
#include "TextureCacheBase.h"
|
|
|
|
#include "PixelShaderGen.h"
|
|
|
|
#include "VertexShaderGen.h"
|
|
|
|
#include "NativeVertexFormat.h"
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
//void UpdateFPSDisplay(const char *text);
|
2010-12-05 14:15:36 +00:00
|
|
|
extern NativeVertexFormat *g_nativeVertexFmt;
|
|
|
|
|
2011-02-16 12:09:39 +00:00
|
|
|
GFXDebuggerBase *g_pdebugger = NULL;
|
2011-07-01 20:59:57 +00:00
|
|
|
volatile bool GFXDebuggerPauseFlag = false; // if true, the GFX thread will be spin locked until it's false again
|
|
|
|
volatile PauseEvent GFXDebuggerToPauseAtNext = NOT_PAUSE; // Event which will trigger spin locking the GFX thread
|
|
|
|
volatile int GFXDebuggerEventToPauseCount = 0; // Number of events to wait for until GFX thread will be paused
|
2011-02-16 12:09:39 +00:00
|
|
|
|
2010-12-05 14:15:36 +00:00
|
|
|
void GFXDebuggerUpdateScreen()
|
|
|
|
{
|
2011-02-14 02:18:03 +00:00
|
|
|
// TODO: Implement this in a backend-independent way
|
2010-12-05 14:15:36 +00:00
|
|
|
/* // 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();
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
2011-07-01 20:59:57 +00:00
|
|
|
// GFX thread
|
2010-12-05 14:15:36 +00:00
|
|
|
void GFXDebuggerCheckAndPause(bool update)
|
|
|
|
{
|
|
|
|
if (GFXDebuggerPauseFlag)
|
|
|
|
{
|
|
|
|
g_pdebugger->OnPause();
|
|
|
|
while( GFXDebuggerPauseFlag )
|
|
|
|
{
|
2011-01-31 01:28:32 +00:00
|
|
|
g_video_backend->UpdateFPSDisplay("Paused by Video Debugger");
|
2010-12-05 14:15:36 +00:00
|
|
|
|
|
|
|
if (update) GFXDebuggerUpdateScreen();
|
2010-12-05 15:28:31 +00:00
|
|
|
SLEEP(5);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
g_pdebugger->OnContinue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 20:59:57 +00:00
|
|
|
// GFX thread
|
2010-12-05 14:15:36 +00:00
|
|
|
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];
|
2010-12-14 23:19:34 +00:00
|
|
|
sprintf(filename, "%sdump_ps.txt", path);
|
2010-12-05 14:15:36 +00:00
|
|
|
|
|
|
|
std::string output;
|
2011-07-01 20:59:57 +00:00
|
|
|
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
2010-12-05 14:15:36 +00:00
|
|
|
if (!useDstAlpha)
|
|
|
|
{
|
|
|
|
output = "Destination alpha disabled:\n";
|
2012-08-06 23:02:04 +00:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(g_ActiveConfig.backend_info.bSupportsDualSourceBlend)
|
|
|
|
{
|
|
|
|
output = "Using dual source blending for destination alpha:\n";
|
2012-08-06 23:02:04 +00:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_DUAL_SOURCE_BLEND, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output = "Using two passes for emulating destination alpha:\n";
|
2012-08-06 23:02:04 +00:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 14:15:36 +00:00
|
|
|
output += "\n\nDestination alpha pass shader:\n";
|
2012-08-06 23:02:04 +00:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_ALPHA_PASS, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
File::CreateEmptyFile(filename);
|
2011-03-01 03:06:14 +00:00
|
|
|
File::WriteStringToFile(true, output, filename);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerBase::DumpVertexShader(const char* path)
|
|
|
|
{
|
|
|
|
char filename[MAX_PATH];
|
2010-12-15 14:47:13 +00:00
|
|
|
sprintf(filename, "%sdump_vs.txt", path);
|
2010-12-05 14:15:36 +00:00
|
|
|
|
|
|
|
File::CreateEmptyFile(filename);
|
2012-08-06 20:41:30 +00:00
|
|
|
/// File::WriteStringToFile(true, GenerateVertexShaderCode(g_nativeVertexFmt->m_components, g_ActiveConfig.backend_info.APIType), filename);
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|