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

107 lines
3.3 KiB
C
Raw Normal View History

2022-08-03 16:33:54 +02:00
#pragma once
#include <type_traits>
#include <vector>
#include "d3d11_buffer.h"
#include "d3d11_context.h"
#include "d3d11_texture.h"
namespace dxvk {
class D3D11DeferredContext;
class D3D11ImmediateContext;
template<bool IsDeferred>
struct D3D11ContextObjectForwarder;
/**
* \brief Object forwarder for immediate contexts
*
* Binding methods can use this to efficiently bind objects
* to the DXVK context without redundant reference counting.
*/
template<>
struct D3D11ContextObjectForwarder<false> {
template<typename T>
static T&& move(T& object) {
return std::move(object);
}
};
/**
* \brief Object forwarder for deferred contexts
*
* This forwarder will create a copy of the object passed
* into it, so that CS chunks can be reused if necessary.
*/
template<>
struct D3D11ContextObjectForwarder<true> {
template<typename T>
static T move(const T& object) {
return object;
}
};
/**
* \brief Common D3D11 device context implementation
*
* Implements all common device context methods, but since this is
* templates with the actual context type (deferred or immediate),
* all methods can call back into context-specific methods without
* having to use virtual methods.
*/
template<typename ContextType>
class D3D11CommonContext : public D3D11DeviceContext {
constexpr static bool IsDeferred = std::is_same_v<ContextType, D3D11DeferredContext>;
using Forwarder = D3D11ContextObjectForwarder<IsDeferred>;
public:
D3D11CommonContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags);
~D3D11CommonContext();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
void STDMETHODCALLTYPE UpdateSubresource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch);
2022-08-03 16:33:54 +02:00
void STDMETHODCALLTYPE UpdateSubresource1(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags);
BOOL STDMETHODCALLTYPE IsAnnotationEnabled();
protected:
D3D11DeviceContextExt<ContextType> m_contextExt;
D3D11UserDefinedAnnotation<ContextType> m_annotation;
void UpdateResource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags);
2022-08-03 16:33:54 +02:00
};
}