diff options
author | Joshua Ashton <joshua@froggi.es> | 2021-04-30 12:32:10 +0300 |
---|---|---|
committer | Joshua Ashton <joshua@froggi.es> | 2021-04-30 12:34:04 +0300 |
commit | 2892916f68ae111aaef0a6e7a4caf485a7431e62 (patch) | |
tree | ba080b682b46cb59e207d9989e2a59dcace6b35f | |
parent | 0bcb1ea7ff128681d583f43970f4dfd4aa1c42f9 (diff) |
[d3d11] Register annotation interfaces with D3D9global-annotations
Some apps try use the D3DPERF_ functions for debug markers/annotations.
This utilizes the DXVK_RegisterAnnotation hidden functions to share the interfaces.
-rw-r--r-- | src/d3d11/d3d11_annotation.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/d3d11/d3d11_annotation.cpp b/src/d3d11/d3d11_annotation.cpp index ddb4cfaf..24740815 100644 --- a/src/d3d11/d3d11_annotation.cpp +++ b/src/d3d11/d3d11_annotation.cpp @@ -6,13 +6,41 @@ namespace dxvk { + template <bool Register> + static void RegisterUserDefinedAnnotation(IDXVKUserDefinedAnnotation* annotation) { + using RegistrationFunctionType = void(__stdcall *)(IDXVKUserDefinedAnnotation*); + static const int16_t RegisterOrdinal = 28257; + static const int16_t UnregisterOrdinal = 28258; + + HMODULE d3d9Module = ::LoadLibraryA("d3d9.dll"); + if (!d3d9Module) { + Logger::info("Unable to find d3d9, some annotations may be missed."); + return; + } + + const int16_t ordinal = Register ? UnregisterOrdinal : RegisterOrdinal; + auto registrationFunction = reinterpret_cast<RegistrationFunctionType>(::GetProcAddress(d3d9Module, + reinterpret_cast<const char*>(static_cast<uintptr_t>(ordinal)))); + + if (!registrationFunction) { + Logger::info("Unable to find DXVK_RegisterAnnotation, some annotations may be missed."); + return; + } + + registrationFunction(annotation); + } + D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx) : m_container(ctx), - m_eventDepth(0) { } + m_eventDepth(0) { + if (m_container->IsAnnotationEnabled()) + RegisterUserDefinedAnnotation<true>(this); + } D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() { - + if (m_container->IsAnnotationEnabled()) + RegisterUserDefinedAnnotation<false>(this); } |