1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-05 11:52:10 +01:00
dxvk/src/d3d11/d3d11_annotation.cpp

93 lines
2.3 KiB
C++
Raw Normal View History

#include "d3d11_annotation.h"
#include "d3d11_context.h"
#include "d3d11_device.h"
2021-04-30 09:04:30 +01:00
#include "../util/util_misc.h"
namespace dxvk {
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx)
: m_container(ctx),
m_eventDepth(0) { }
D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() {
}
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::BeginEvent(
2021-04-30 09:04:30 +01:00
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
return -1;
2021-04-30 09:04:30 +01:00
m_container->EmitCs([color = Color, labelName = dxvk::str::fromws(Name)](DxvkContext *ctx) {
VkDebugUtilsLabelEXT label;
label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
label.pNext = nullptr;
label.pLabelName = labelName.c_str();
2021-04-30 09:04:30 +01:00
DecodeD3DCOLOR(color, label.color);
ctx->beginDebugLabel(&label);
});
return m_eventDepth++;
}
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::EndEvent() {
if (!m_container->IsAnnotationEnabled())
return -1;
D3D10DeviceLock lock = m_container->LockContext();
m_container->EmitCs([](DxvkContext *ctx) {
ctx->endDebugLabel();
});
return m_eventDepth--;
}
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker(
2021-04-30 09:04:30 +01:00
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
return;
2021-04-30 09:04:30 +01:00
m_container->EmitCs([color = Color, labelName = dxvk::str::fromws(Name)](DxvkContext *ctx) {
VkDebugUtilsLabelEXT label;
label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
label.pNext = nullptr;
label.pLabelName = labelName.c_str();
2021-04-30 09:04:30 +01:00
DecodeD3DCOLOR(color, label.color);
ctx->insertDebugLabel(&label);
});
}
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation::GetStatus() {
return m_container->IsAnnotationEnabled();
}
}