summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/d3d11/d3d11_annotation.cpp
blob: 010acdd8199b3e56d37b645144913a4e180b0e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "d3d11_annotation.h"
#include "d3d11_context.h"
#include "d3d11_device.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(
          LPCWSTR                 Name) {
    if (!m_container->IsAnnotationEnabled())
      return -1;

    m_container->EmitCs([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();
      label.color[0] = 1.0f;
      label.color[1] = 1.0f;
      label.color[2] = 1.0f;
      label.color[3] = 1.0f;

      ctx->beginDebugLabel(&label);
    });

    return m_eventDepth++;
  }


  INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::EndEvent() {
    if (!m_container->IsAnnotationEnabled())
      return -1;

    m_container->EmitCs([](DxvkContext *ctx) {
      ctx->endDebugLabel();
    });

    return m_eventDepth--;
  }


  void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker(
          LPCWSTR                 Name) {
    if (!m_container->IsAnnotationEnabled())
      return;

    m_container->EmitCs([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();
      label.color[0] = 1.0f;
      label.color[1] = 1.0f;
      label.color[2] = 1.0f;
      label.color[3] = 1.0f;

      ctx->insertDebugLabel(&label);
    });
  }


  BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation::GetStatus() {
    return m_container->IsAnnotationEnabled();
  }

}