1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d11] Move D3D11UserDefinedAnnotation member to D3D11CommonContext

This needs to be temlpated because we'll be moving EmitCs to the
common implementation as well, and make EmitCsChunk non-virtual.
This commit is contained in:
Philip Rebohle 2022-08-03 17:13:32 +02:00
parent 10345d0063
commit 3f5f731c42
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 51 additions and 31 deletions

View File

@ -1,5 +1,6 @@
#include "d3d11_annotation.h" #include "d3d11_annotation.h"
#include "d3d11_context.h" #include "d3d11_context_def.h"
#include "d3d11_context_imm.h"
#include "d3d11_device.h" #include "d3d11_device.h"
#include "../util/util_misc.h" #include "../util/util_misc.h"
@ -30,40 +31,47 @@ namespace dxvk {
registrationFunction(annotation); registrationFunction(annotation);
} }
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(
D3D11DeviceContext* container, template<typename ContextType>
D3D11UserDefinedAnnotation<ContextType>::D3D11UserDefinedAnnotation(
ContextType* container,
const Rc<DxvkDevice>& dxvkDevice) const Rc<DxvkDevice>& dxvkDevice)
: m_container(container), m_eventDepth(0), : m_container(container), m_eventDepth(0),
m_annotationsEnabled(dxvkDevice->instance()->extensions().extDebugUtils) { m_annotationsEnabled(dxvkDevice->instance()->extensions().extDebugUtils) {
if (m_annotationsEnabled) if (!IsDeferred && m_annotationsEnabled)
RegisterUserDefinedAnnotation<true>(this); RegisterUserDefinedAnnotation<true>(this);
} }
D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() { template<typename ContextType>
if (m_annotationsEnabled) D3D11UserDefinedAnnotation<ContextType>::~D3D11UserDefinedAnnotation() {
if (!IsDeferred && m_annotationsEnabled)
RegisterUserDefinedAnnotation<false>(this); RegisterUserDefinedAnnotation<false>(this);
} }
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::AddRef() { template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::AddRef() {
return m_container->AddRef(); return m_container->AddRef();
} }
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::Release() { template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::Release() {
return m_container->Release(); return m_container->Release();
} }
HRESULT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::QueryInterface( template<typename ContextType>
HRESULT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::QueryInterface(
REFIID riid, REFIID riid,
void** ppvObject) { void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject); return m_container->QueryInterface(riid, ppvObject);
} }
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::BeginEvent( template<typename ContextType>
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::BeginEvent(
D3DCOLOR Color, D3DCOLOR Color,
LPCWSTR Name) { LPCWSTR Name) {
if (!m_annotationsEnabled) if (!m_annotationsEnabled)
@ -85,7 +93,8 @@ namespace dxvk {
} }
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::EndEvent() { template<typename ContextType>
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::EndEvent() {
if (!m_annotationsEnabled) if (!m_annotationsEnabled)
return -1; return -1;
@ -99,7 +108,8 @@ namespace dxvk {
} }
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker( template<typename ContextType>
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::SetMarker(
D3DCOLOR Color, D3DCOLOR Color,
LPCWSTR Name) { LPCWSTR Name) {
if (!m_annotationsEnabled) if (!m_annotationsEnabled)
@ -119,8 +129,13 @@ namespace dxvk {
} }
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation::GetStatus() { template<typename ContextType>
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::GetStatus() {
return m_annotationsEnabled; return m_annotationsEnabled;
} }
template class D3D11UserDefinedAnnotation<D3D11DeferredContext>;
template class D3D11UserDefinedAnnotation<D3D11ImmediateContext>;
} }

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <type_traits>
#include "d3d11_include.h" #include "d3d11_include.h"
#include "../dxvk/dxvk_annotation.h" #include "../dxvk/dxvk_annotation.h"
@ -7,14 +9,16 @@
namespace dxvk { namespace dxvk {
class D3D11DeviceContext; class D3D11DeferredContext;
class D3D11ImmediateContext;
template<typename ContextType>
class D3D11UserDefinedAnnotation final : public IDXVKUserDefinedAnnotation { class D3D11UserDefinedAnnotation final : public IDXVKUserDefinedAnnotation {
constexpr static bool IsDeferred = std::is_same_v<ContextType, D3D11DeferredContext>;
public: public:
D3D11UserDefinedAnnotation( D3D11UserDefinedAnnotation(
D3D11DeviceContext* container, ContextType* container,
const Rc<DxvkDevice>& dxvkDevice); const Rc<DxvkDevice>& dxvkDevice);
~D3D11UserDefinedAnnotation(); ~D3D11UserDefinedAnnotation();
@ -44,9 +48,9 @@ namespace dxvk {
private: private:
D3D11DeviceContext* m_container; ContextType* m_container;
int32_t m_eventDepth; int32_t m_eventDepth;
bool m_annotationsEnabled; bool m_annotationsEnabled;
}; };
} }

View File

@ -19,7 +19,6 @@ namespace dxvk {
m_multithread(this, false), m_multithread(this, false),
m_device (Device), m_device (Device),
m_staging (Device, StagingBufferSize), m_staging (Device, StagingBufferSize),
m_annotation(this, Device),
m_csFlags (CsFlags), m_csFlags (CsFlags),
m_csChunk (AllocCsChunk()), m_csChunk (AllocCsChunk()),
m_cmdData (nullptr) { m_cmdData (nullptr) {
@ -2780,11 +2779,6 @@ namespace dxvk {
} }
BOOL STDMETHODCALLTYPE D3D11DeviceContext::IsAnnotationEnabled() {
return m_annotation.GetStatus();
}
void STDMETHODCALLTYPE D3D11DeviceContext::SetMarkerInt( void STDMETHODCALLTYPE D3D11DeviceContext::SetMarkerInt(
LPCWSTR pLabel, LPCWSTR pLabel,
INT Data) { INT Data) {

View File

@ -21,6 +21,7 @@ namespace dxvk {
class D3D11DeviceContext : public D3D11DeviceChild<ID3D11DeviceContext4> { class D3D11DeviceContext : public D3D11DeviceChild<ID3D11DeviceContext4> {
friend class D3D11DeviceContextExt; friend class D3D11DeviceContextExt;
// Needed in order to call EmitCs for pushing markers // Needed in order to call EmitCs for pushing markers
template<typename T>
friend class D3D11UserDefinedAnnotation; friend class D3D11UserDefinedAnnotation;
constexpr static VkDeviceSize StagingBufferSize = 4ull << 20; constexpr static VkDeviceSize StagingBufferSize = 4ull << 20;
@ -658,8 +659,6 @@ namespace dxvk {
ID3D11Buffer** ppSOTargets, ID3D11Buffer** ppSOTargets,
UINT* pOffsets); UINT* pOffsets);
BOOL STDMETHODCALLTYPE IsAnnotationEnabled();
void STDMETHODCALLTYPE SetMarkerInt( void STDMETHODCALLTYPE SetMarkerInt(
LPCWSTR pLabel, LPCWSTR pLabel,
INT Data); INT Data);
@ -695,9 +694,6 @@ namespace dxvk {
Rc<DxvkDataBuffer> m_updateBuffer; Rc<DxvkDataBuffer> m_updateBuffer;
DxvkStagingBuffer m_staging; DxvkStagingBuffer m_staging;
//has to be declared after m_device, as compiler initialize in order of declaration in the class
D3D11UserDefinedAnnotation m_annotation;
DxvkCsChunkFlags m_csFlags; DxvkCsChunkFlags m_csFlags;
DxvkCsChunkRef m_csChunk; DxvkCsChunkRef m_csChunk;

View File

@ -9,7 +9,8 @@ namespace dxvk {
D3D11Device* pParent, D3D11Device* pParent,
const Rc<DxvkDevice>& Device, const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags) DxvkCsChunkFlags CsFlags)
: D3D11DeviceContext(pParent, Device, CsFlags) { : D3D11DeviceContext(pParent, Device, CsFlags),
m_annotation(static_cast<ContextType*>(this), Device) {
} }
@ -88,6 +89,12 @@ namespace dxvk {
} }
template<typename ContextType>
BOOL STDMETHODCALLTYPE D3D11CommonContext<ContextType>::IsAnnotationEnabled() {
return m_annotation.GetStatus();
}
template<typename ContextType> template<typename ContextType>
void D3D11CommonContext<ContextType>::UpdateResource( void D3D11CommonContext<ContextType>::UpdateResource(
ID3D11Resource* pDstResource, ID3D11Resource* pDstResource,

View File

@ -85,8 +85,12 @@ namespace dxvk {
UINT SrcDepthPitch, UINT SrcDepthPitch,
UINT CopyFlags); UINT CopyFlags);
BOOL STDMETHODCALLTYPE IsAnnotationEnabled();
protected: protected:
D3D11UserDefinedAnnotation<ContextType> m_annotation;
void UpdateResource( void UpdateResource(
ID3D11Resource* pDstResource, ID3D11Resource* pDstResource,
UINT DstSubresource, UINT DstSubresource,