mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 05:52:11 +01:00
[d3d11] Implement D3D11UserDefinedAnnotation
Reviewed-by: Oleg Kuznetsov <okouznetsov@nvidia.com>
This commit is contained in:
parent
5ce5999232
commit
fb0b11903b
@ -1,9 +1,12 @@
|
||||
#include "d3d11_annotation.h"
|
||||
#include "d3d11_context.h"
|
||||
#include "d3d11_device.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(ID3D11DeviceContext* ctx)
|
||||
: m_container(ctx) { }
|
||||
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx)
|
||||
: m_container(ctx),
|
||||
m_eventDepth(0) { }
|
||||
|
||||
|
||||
D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() {
|
||||
@ -30,26 +33,60 @@ namespace dxvk {
|
||||
|
||||
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::BeginEvent(
|
||||
LPCWSTR Name) {
|
||||
// Currently not implemented
|
||||
return -1;
|
||||
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() {
|
||||
// Currently not implemented
|
||||
return -1;
|
||||
if (!m_container->IsAnnotationEnabled())
|
||||
return -1;
|
||||
|
||||
m_container->EmitCs([](DxvkContext *ctx) {
|
||||
ctx->endDebugLabel();
|
||||
});
|
||||
|
||||
return m_eventDepth--;
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker(
|
||||
LPCWSTR Name) {
|
||||
// Currently not implemented
|
||||
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() {
|
||||
// Currently not implemented
|
||||
return FALSE;
|
||||
return m_container->IsAnnotationEnabled();
|
||||
}
|
||||
|
||||
}
|
@ -4,11 +4,13 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11DeviceContext;
|
||||
|
||||
class D3D11UserDefinedAnnotation : ID3DUserDefinedAnnotation {
|
||||
|
||||
public:
|
||||
|
||||
D3D11UserDefinedAnnotation(ID3D11DeviceContext* ctx);
|
||||
D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx);
|
||||
~D3D11UserDefinedAnnotation();
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
@ -31,8 +33,10 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
ID3D11DeviceContext* m_container;
|
||||
D3D11DeviceContext* m_container;
|
||||
|
||||
// Stack depth for non-finalized BeginEvent calls
|
||||
int32_t m_eventDepth;
|
||||
};
|
||||
|
||||
}
|
@ -3064,8 +3064,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
BOOL STDMETHODCALLTYPE D3D11DeviceContext::IsAnnotationEnabled() {
|
||||
// Not implemented in the backend
|
||||
return FALSE;
|
||||
return m_device->instance()->extensions().extDebugUtils;
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ namespace dxvk {
|
||||
|
||||
class D3D11DeviceContext : public D3D11DeviceChild<ID3D11DeviceContext4> {
|
||||
friend class D3D11DeviceContextExt;
|
||||
// Needed in order to call EmitCs for pushing markers
|
||||
friend class D3D11UserDefinedAnnotation;
|
||||
public:
|
||||
|
||||
D3D11DeviceContext(
|
||||
|
Loading…
x
Reference in New Issue
Block a user