2013-04-17 21:09:55 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-12-05 07:15:36 -07:00
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
#include <string>
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2010-12-05 07:15:36 -07:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/Debugger.h"
|
|
|
|
#include "VideoCommon/NativeVertexFormat.h"
|
|
|
|
#include "VideoCommon/PixelShaderGen.h"
|
2014-02-18 18:27:20 -07:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/VertexShaderGen.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2010-12-05 07:15:36 -07:00
|
|
|
|
2014-03-09 14:14:26 -06:00
|
|
|
GFXDebuggerBase *g_pdebugger = nullptr;
|
2011-07-01 14:59:57 -06: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 05:09:39 -07:00
|
|
|
|
2010-12-05 07:15:36 -07:00
|
|
|
void GFXDebuggerUpdateScreen()
|
|
|
|
{
|
2011-02-13 19:18:03 -07:00
|
|
|
// TODO: Implement this in a backend-independent way
|
2010-12-05 07:15:36 -07:00
|
|
|
/* // update screen
|
|
|
|
if (D3D::bFrameInProgress)
|
|
|
|
{
|
|
|
|
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
2014-03-09 14:14:26 -06:00
|
|
|
D3D::dev->SetDepthStencilSurface(nullptr);
|
2010-12-05 07:15:36 -07:00
|
|
|
|
2014-03-09 14:14:26 -06:00
|
|
|
D3D::dev->StretchRect(FramebufferManager::GetEFBColorRTSurface(), nullptr,
|
|
|
|
D3D::GetBackBufferSurface(), nullptr,
|
2010-12-05 07:15:36 -07:00
|
|
|
D3DTEXF_LINEAR);
|
|
|
|
|
|
|
|
D3D::dev->EndScene();
|
2014-03-09 14:14:26 -06:00
|
|
|
D3D::dev->Present(nullptr, nullptr, nullptr, nullptr);
|
2010-12-05 07:15:36 -07:00
|
|
|
|
|
|
|
D3D::dev->SetRenderTarget(0, FramebufferManager::GetEFBColorRTSurface());
|
|
|
|
D3D::dev->SetDepthStencilSurface(FramebufferManager::GetEFBDepthRTSurface());
|
|
|
|
D3D::dev->BeginScene();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3D::dev->EndScene();
|
2014-03-09 14:14:26 -06:00
|
|
|
D3D::dev->Present(nullptr, nullptr, nullptr, nullptr);
|
2010-12-05 07:15:36 -07:00
|
|
|
D3D::dev->BeginScene();
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
2011-07-01 14:59:57 -06:00
|
|
|
// GFX thread
|
2010-12-05 07:15:36 -07:00
|
|
|
void GFXDebuggerCheckAndPause(bool update)
|
|
|
|
{
|
|
|
|
if (GFXDebuggerPauseFlag)
|
|
|
|
{
|
|
|
|
g_pdebugger->OnPause();
|
2014-03-10 05:30:55 -06:00
|
|
|
while ( GFXDebuggerPauseFlag )
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
2014-02-16 21:51:41 -07:00
|
|
|
if (update) GFXDebuggerUpdateScreen();
|
2010-12-05 08:28:31 -07:00
|
|
|
SLEEP(5);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
g_pdebugger->OnContinue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 14:59:57 -06:00
|
|
|
// GFX thread
|
2010-12-05 07:15:36 -07:00
|
|
|
void GFXDebuggerToPause(bool update)
|
|
|
|
{
|
|
|
|
GFXDebuggerToPauseAtNext = NOT_PAUSE;
|
|
|
|
GFXDebuggerPauseFlag = true;
|
|
|
|
GFXDebuggerCheckAndPause(update);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContinueGFXDebugger()
|
|
|
|
{
|
|
|
|
GFXDebuggerPauseFlag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpPixelShader(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
const std::string filename = StringFromFormat("%sdump_ps.txt", path.c_str());
|
2010-12-05 07:15:36 -07:00
|
|
|
|
|
|
|
std::string output;
|
2014-03-23 14:44:23 -06:00
|
|
|
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
2010-12-05 07:15:36 -07:00
|
|
|
if (!useDstAlpha)
|
|
|
|
{
|
|
|
|
output = "Destination alpha disabled:\n";
|
2012-08-06 17:02:04 -06:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-10 05:30:55 -06:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsDualSourceBlend)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
output = "Using dual source blending for destination alpha:\n";
|
2012-08-06 17:02:04 -06:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_DUAL_SOURCE_BLEND, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output = "Using two passes for emulating destination alpha:\n";
|
2012-08-06 17:02:04 -06:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_NONE, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 07:15:36 -07:00
|
|
|
output += "\n\nDestination alpha pass shader:\n";
|
2012-08-06 17:02:04 -06:00
|
|
|
/// output += GeneratePixelShaderCode(DSTALPHA_ALPHA_PASS, g_ActiveConfig.backend_info.APIType, g_nativeVertexFmt->m_components);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
File::CreateEmptyFile(filename);
|
2013-11-04 04:33:41 -07:00
|
|
|
File::WriteStringToFile(output, filename);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpVertexShader(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
const std::string filename = StringFromFormat("%sdump_vs.txt", path.c_str());
|
2010-12-05 07:15:36 -07:00
|
|
|
|
|
|
|
File::CreateEmptyFile(filename);
|
2013-11-04 04:33:41 -07:00
|
|
|
/// File::WriteStringToFile(GenerateVertexShaderCode(g_nativeVertexFmt->m_components, g_ActiveConfig.backend_info.APIType), filename);
|
2010-12-05 07:15:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpPixelShaderConstants(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpVertexShaderConstants(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpTextures(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpFrameBuffer(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpGeometry(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpVertexDecl(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpMatrices(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void GFXDebuggerBase::DumpStats(const std::string& path)
|
2010-12-05 07:15:36 -07:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|