mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[util] Add function to cache QueryInterface errors
This commit is contained in:
parent
81440340ac
commit
aa92cf48f5
@ -1,9 +1,47 @@
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "com_guid.h"
|
||||
|
||||
#include "../../d3d11/d3d11_interfaces.h"
|
||||
|
||||
#include "../../dxgi/dxgi_interfaces.h"
|
||||
|
||||
#include "../../dxvk/dxvk_hash.h"
|
||||
|
||||
#include "../thread.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
struct GuidPair {
|
||||
GuidPair() { };
|
||||
GuidPair(IID a_, IID b_)
|
||||
: a(a_), b(b_) { }
|
||||
|
||||
IID a, b;
|
||||
|
||||
size_t hash() const {
|
||||
return size_t(a.Data1) ^ size_t(b.Data1);
|
||||
}
|
||||
|
||||
bool eq(const GuidPair& other) const {
|
||||
return a == other.a && b == other.b;
|
||||
}
|
||||
};
|
||||
|
||||
dxvk::mutex g_loggedQueryInterfaceErrorMutex;
|
||||
std::unordered_set<GuidPair, DxvkHash, DxvkEq> g_loggedQueryInterfaceErrors;
|
||||
|
||||
bool logQueryInterfaceError(REFIID objectGuid, REFIID requestedGuid) {
|
||||
if (Logger::logLevel() > LogLevel::Warn)
|
||||
return false;
|
||||
|
||||
std::lock_guard lock(g_loggedQueryInterfaceErrorMutex);
|
||||
return g_loggedQueryInterfaceErrors.emplace(objectGuid, requestedGuid).second;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& os, REFIID guid) {
|
||||
os << std::hex << std::setfill('0')
|
||||
<< std::setw(8) << guid.Data1 << '-';
|
||||
|
@ -5,4 +5,17 @@
|
||||
|
||||
#include "com_include.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Checks whether an unknown GUID should be logged
|
||||
*
|
||||
* \param [in] objectGuid GUID of the object that QueryInterface is called on
|
||||
* \param [in] requestGuid Requested unsupported GUID
|
||||
* \returns \c true if the error should be logged
|
||||
*/
|
||||
bool logQueryInterfaceError(REFIID objectGuid, REFIID requestedGuid);
|
||||
|
||||
};
|
||||
|
||||
std::ostream& operator << (std::ostream& os, REFIID guid);
|
||||
|
Loading…
Reference in New Issue
Block a user