mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
Add a LibraryHooks callback when capture options are changed
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "data/version.h"
|
||||
#include "crash_handler.h"
|
||||
#include "hooks/hooks.h"
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
#include "common/dds_readwrite.h"
|
||||
@@ -769,6 +770,8 @@ map<RDCDriver, string> RenderDoc::GetRemoteDrivers()
|
||||
void RenderDoc::SetCaptureOptions(const CaptureOptions &opts)
|
||||
{
|
||||
m_Options = opts;
|
||||
|
||||
LibraryHooks::GetInstance().OptionsUpdated();
|
||||
}
|
||||
|
||||
void RenderDoc::SetLogFile(const char *logFile)
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
bool UseHooks()
|
||||
{
|
||||
return (d3d11hooks.m_HasHooks && d3d11hooks.m_EnabledHooks);
|
||||
|
||||
@@ -69,6 +69,8 @@ class D3D9Hook : LibraryHook
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
private:
|
||||
static D3D9Hook d3d9hooks;
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
bool UseHooks()
|
||||
{
|
||||
return (dxgihooks.m_HasHooks && dxgihooks.m_EnabledHooks);
|
||||
|
||||
@@ -305,6 +305,8 @@ class OpenGLHook : LibraryHook
|
||||
{
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
static OpenGLHook glhooks;
|
||||
|
||||
|
||||
@@ -243,6 +243,8 @@ class OpenGLHook : LibraryHook
|
||||
{
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
static OpenGLHook glhooks;
|
||||
|
||||
|
||||
@@ -67,10 +67,13 @@ void LibraryHooks::RemoveHooks()
|
||||
void LibraryHooks::EnableHooks(bool enable)
|
||||
{
|
||||
RDCDEBUG("%s hooks!", enable ? "Enabling" : "Disabling");
|
||||
|
||||
if(!enable)
|
||||
return;
|
||||
|
||||
for(auto it=m_Hooks.begin(); it!=m_Hooks.end(); ++it)
|
||||
it->second->EnableHooks(it->first, enable);
|
||||
}
|
||||
|
||||
void LibraryHooks::OptionsUpdated()
|
||||
{
|
||||
for(auto it=m_Hooks.begin(); it!=m_Hooks.end(); ++it)
|
||||
it->second->OptionsUpdated(it->first);
|
||||
}
|
||||
@@ -98,6 +98,7 @@ struct LibraryHook
|
||||
{
|
||||
virtual bool CreateHooks(const char *libName) = 0;
|
||||
virtual void EnableHooks(const char *libName, bool enable) = 0;
|
||||
virtual void OptionsUpdated(const char *libName) = 0;
|
||||
};
|
||||
|
||||
// this singleton allows you to compile in code that defines a hook for a given library
|
||||
@@ -110,6 +111,7 @@ class LibraryHooks
|
||||
static LibraryHooks &GetInstance();
|
||||
void RegisterHook(const char *libName, LibraryHook *hook);
|
||||
void CreateHooks();
|
||||
void OptionsUpdated();
|
||||
void EnableHooks(bool enable);
|
||||
void RemoveHooks();
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ class SysHook : LibraryHook
|
||||
m_EnabledHooks = enable;
|
||||
}
|
||||
|
||||
void OptionsUpdated(const char *libName) {}
|
||||
|
||||
private:
|
||||
static SysHook syshooks;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user