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();
|
|
|
|
|
2022-08-03 17:09:30 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
|
|
|
|
2022-08-03 16:41:50 +02:00
|
|
|
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
|
|
|
|
2022-08-03 16:41:50 +02:00
|
|
|
void STDMETHODCALLTYPE UpdateSubresource1(
|
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
const D3D11_BOX* pDstBox,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT SrcRowPitch,
|
|
|
|
UINT SrcDepthPitch,
|
|
|
|
UINT CopyFlags);
|
|
|
|
|
2022-08-03 17:13:32 +02:00
|
|
|
BOOL STDMETHODCALLTYPE IsAnnotationEnabled();
|
|
|
|
|
2022-08-03 16:41:50 +02:00
|
|
|
protected:
|
|
|
|
|
2022-08-03 17:24:34 +02:00
|
|
|
D3D11DeviceContextExt<ContextType> m_contextExt;
|
2022-08-03 17:13:32 +02:00
|
|
|
D3D11UserDefinedAnnotation<ContextType> m_annotation;
|
|
|
|
|
2022-08-03 16:41:50 +02:00
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|