[d3d11] Refactor D3D11UserDefinedAnnotation

This commit is contained in:
Philip Rebohle 2022-08-03 17:04:33 +02:00
parent 3ead348b82
commit 4af974768a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 25 additions and 22 deletions

View File

@ -30,21 +30,18 @@ namespace dxvk {
registrationFunction(annotation);
}
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx)
: m_container(ctx),
m_eventDepth(0) {
if (m_container->IsAnnotationEnabled())
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(
D3D11DeviceContext* container,
const Rc<DxvkDevice>& dxvkDevice)
: m_container(container), m_eventDepth(0),
m_annotationsEnabled(dxvkDevice->instance()->extensions().extDebugUtils) {
if (m_annotationsEnabled)
RegisterUserDefinedAnnotation<true>(this);
}
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(const D3D11UserDefinedAnnotation&)
{
if (m_container->IsAnnotationEnabled())
RegisterUserDefinedAnnotation<true>(this);
}
D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() {
if (m_container->IsAnnotationEnabled())
if (m_annotationsEnabled)
RegisterUserDefinedAnnotation<false>(this);
}
@ -69,7 +66,7 @@ namespace dxvk {
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::BeginEvent(
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
if (!m_annotationsEnabled)
return -1;
D3D10DeviceLock lock = m_container->LockContext();
@ -89,7 +86,7 @@ namespace dxvk {
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::EndEvent() {
if (!m_container->IsAnnotationEnabled())
if (!m_annotationsEnabled)
return -1;
D3D10DeviceLock lock = m_container->LockContext();
@ -105,7 +102,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker(
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
if (!m_annotationsEnabled)
return;
D3D10DeviceLock lock = m_container->LockContext();
@ -123,7 +120,7 @@ namespace dxvk {
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation::GetStatus() {
return m_container->IsAnnotationEnabled();
return m_annotationsEnabled;
}
}

View File

@ -1,7 +1,9 @@
#pragma once
#include "d3d11_include.h"
#include "../dxvk/dxvk_annotation.h"
#include "../dxvk/dxvk_device.h"
namespace dxvk {
@ -11,10 +13,15 @@ namespace dxvk {
public:
D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx);
D3D11UserDefinedAnnotation(const D3D11UserDefinedAnnotation&);
D3D11UserDefinedAnnotation(
D3D11DeviceContext* container,
const Rc<DxvkDevice>& dxvkDevice);
~D3D11UserDefinedAnnotation();
D3D11UserDefinedAnnotation (const D3D11UserDefinedAnnotation&) = delete;
D3D11UserDefinedAnnotation& operator = (const D3D11UserDefinedAnnotation&) = delete;
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
@ -37,10 +44,9 @@ namespace dxvk {
private:
D3D11DeviceContext* m_container;
// Stack depth for non-finalized BeginEvent calls
int32_t m_eventDepth;
D3D11DeviceContext* m_container;
int32_t m_eventDepth;
bool m_annotationsEnabled;
};
}

View File

@ -19,7 +19,7 @@ namespace dxvk {
m_multithread(this, false),
m_device (Device),
m_staging (Device, StagingBufferSize),
m_annotation(this),
m_annotation(this, Device),
m_csFlags (CsFlags),
m_csChunk (AllocCsChunk()),
m_cmdData (nullptr) {
@ -2821,7 +2821,7 @@ namespace dxvk {
BOOL STDMETHODCALLTYPE D3D11DeviceContext::IsAnnotationEnabled() {
return m_device->instance()->extensions().extDebugUtils;
return m_annotation.GetStatus();
}