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

[d3d11] Fix device child refs properly

This commit is contained in:
Joshua Ashton 2021-01-07 20:08:55 +00:00 committed by Philip Rebohle
parent 499f15011f
commit 742b52bbb5
38 changed files with 156 additions and 337 deletions

View File

@ -6,7 +6,8 @@ namespace dxvk {
D3D11BlendState::D3D11BlendState(
D3D11Device* device,
const D3D11_BLEND_DESC1& desc)
: m_device(device), m_desc(desc), m_d3d10(this) {
: D3D11StateObject<ID3D11BlendState1>(device),
m_desc(desc), m_d3d10(this) {
// If Independent Blend is disabled, we must ignore the
// blend modes for render target 1 to 7. In Vulkan, all
// blend modes need to be identical in that case.
@ -34,22 +35,6 @@ namespace dxvk {
D3D11BlendState::~D3D11BlendState() {
}
ULONG STDMETHODCALLTYPE D3D11BlendState::AddRef() {
ULONG refCount = m_refCount++;
if (!refCount)
m_device->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11BlendState::Release() {
ULONG refCount = --m_refCount;
if (!refCount)
m_device->Release();
return refCount;
}
HRESULT STDMETHODCALLTYPE D3D11BlendState::QueryInterface(REFIID riid, void** ppvObject) {
@ -79,11 +64,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11BlendState::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = ref(m_device);
}
void STDMETHODCALLTYPE D3D11BlendState::GetDesc(D3D11_BLEND_DESC* pDesc) {
pDesc->AlphaToCoverageEnable = m_desc.AlphaToCoverageEnable;
pDesc->IndependentBlendEnable = m_desc.IndependentBlendEnable;

View File

@ -11,7 +11,7 @@ namespace dxvk {
class D3D11Device;
class D3D11BlendState : public D3D11DeviceChild<ID3D11BlendState1, NoWrapper> {
class D3D11BlendState : public D3D11StateObject<ID3D11BlendState1> {
public:
@ -21,18 +21,11 @@ namespace dxvk {
D3D11Device* device,
const D3D11_BLEND_DESC1& desc);
~D3D11BlendState();
ULONG STDMETHODCALLTYPE AddRef() final;
ULONG STDMETHODCALLTYPE Release() final;
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetDesc(
D3D11_BLEND_DESC* pDesc) final;
@ -55,7 +48,6 @@ namespace dxvk {
private:
D3D11Device* const m_device;
D3D11_BLEND_DESC1 m_desc;
std::array<DxvkBlendMode, 8> m_blendModes;
@ -63,8 +55,6 @@ namespace dxvk {
DxvkLogicOpState m_loState;
D3D10BlendState m_d3d10;
std::atomic<uint32_t> m_refCount = { 0u };
static DxvkBlendMode DecodeBlendMode(
const D3D11_RENDER_TARGET_BLEND_DESC1& BlendDesc);

View File

@ -9,7 +9,7 @@ namespace dxvk {
D3D11Buffer::D3D11Buffer(
D3D11Device* pDevice,
const D3D11_BUFFER_DESC* pDesc)
: m_device (pDevice),
: D3D11DeviceChild<ID3D11Buffer>(pDevice),
m_desc (*pDesc),
m_resource (this),
m_d3d10 (this) {
@ -35,17 +35,17 @@ namespace dxvk {
if (pDesc->BindFlags & D3D11_BIND_CONSTANT_BUFFER) {
info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
info.stages |= m_device->GetEnabledShaderStages();
info.stages |= m_parent->GetEnabledShaderStages();
info.access |= VK_ACCESS_UNIFORM_READ_BIT;
if (m_device->GetOptions()->constantBufferRangeCheck)
if (m_parent->GetOptions()->constantBufferRangeCheck)
info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
}
if (pDesc->BindFlags & D3D11_BIND_SHADER_RESOURCE) {
info.usage |= VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
| VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
info.stages |= m_device->GetEnabledShaderStages();
info.stages |= m_parent->GetEnabledShaderStages();
info.access |= VK_ACCESS_SHADER_READ_BIT;
}
@ -58,7 +58,7 @@ namespace dxvk {
if (pDesc->BindFlags & D3D11_BIND_UNORDERED_ACCESS) {
info.usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
| VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
info.stages |= m_device->GetEnabledShaderStages();
info.stages |= m_parent->GetEnabledShaderStages();
info.access |= VK_ACCESS_SHADER_READ_BIT
| VK_ACCESS_SHADER_WRITE_BIT;
}
@ -71,7 +71,7 @@ namespace dxvk {
// Create the buffer and set the entire buffer slice as mapped,
// so that we only have to update it when invalidating th buffer
m_buffer = m_device->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();
// For Stream Output buffers we need a counter
@ -120,11 +120,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11Buffer::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
UINT STDMETHODCALLTYPE D3D11Buffer::GetEvictionPriority() {
return DXGI_RESOURCE_PRIORITY_NORMAL;
}
@ -161,7 +156,7 @@ namespace dxvk {
// Check whether the given combination of buffer view
// type and view format is supported by the device
DXGI_VK_FORMAT_INFO viewFormat = m_device->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY);
DXGI_VK_FORMAT_INFO viewFormat = m_parent->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY);
VkFormatFeatureFlags features = GetBufferFormatFeatures(BindFlags);
return CheckFormatFeatureSupport(viewFormat.Format, features);
@ -208,7 +203,7 @@ namespace dxvk {
BOOL D3D11Buffer::CheckFormatFeatureSupport(
VkFormat Format,
VkFormatFeatureFlags Features) const {
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format);
VkFormatProperties properties = m_parent->GetDXVKDevice()->adapter()->formatProperties(Format);
return (properties.bufferFeatures & Features) == Features;
}
@ -250,7 +245,7 @@ namespace dxvk {
break;
}
if (memoryFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT && m_device->GetOptions()->apitraceMode) {
if (memoryFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT && m_parent->GetOptions()->apitraceMode) {
memoryFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
}
@ -260,7 +255,7 @@ namespace dxvk {
Rc<DxvkBuffer> D3D11Buffer::CreateSoCounterBuffer() {
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
Rc<DxvkDevice> device = m_parent->GetDXVKDevice();
DxvkBufferCreateInfo info;
info.size = sizeof(D3D11SOCounter);

View File

@ -48,9 +48,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetType(
D3D11_RESOURCE_DIMENSION *pResourceDimension) final;
@ -125,7 +122,6 @@ namespace dxvk {
private:
const Com<D3D11Device> m_device;
const D3D11_BUFFER_DESC m_desc;
Rc<DxvkBuffer> m_buffer;

View File

@ -5,7 +5,7 @@ namespace dxvk {
D3D11ClassLinkage::D3D11ClassLinkage(
D3D11Device* pDevice)
: m_device(pDevice) {
: D3D11DeviceChild<ID3D11ClassLinkage>(pDevice) {
}
@ -34,11 +34,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11ClassLinkage::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
HRESULT STDMETHODCALLTYPE D3D11ClassLinkage::CreateClassInstance(
LPCSTR pClassTypeName,
UINT ConstantBufferOffset,

View File

@ -20,9 +20,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
HRESULT STDMETHODCALLTYPE CreateClassInstance(
LPCSTR pClassTypeName,
UINT ConstantBufferOffset,
@ -36,10 +33,6 @@ namespace dxvk {
UINT InstanceIndex,
ID3D11ClassInstance **ppInstance);
private:
Com<D3D11Device> m_device;
};
}

View File

@ -6,7 +6,7 @@ namespace dxvk {
D3D11CommandList::D3D11CommandList(
D3D11Device* pDevice,
UINT ContextFlags)
: m_device (pDevice),
: D3D11DeviceChild<ID3D11CommandList>(pDevice),
m_contextFlags(ContextFlags) { }
@ -34,11 +34,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11CommandList::GetDevice(ID3D11Device **ppDevice) {
*ppDevice = ref(m_device);
}
UINT STDMETHODCALLTYPE D3D11CommandList::GetContextFlags() {
return m_contextFlags;
}
@ -80,11 +75,11 @@ namespace dxvk {
void D3D11CommandList::MarkSubmitted() {
if (m_submitted.exchange(true) && !m_warned.exchange(true)
&& m_device->GetOptions()->dcSingleUseMode) {
&& m_parent->GetOptions()->dcSingleUseMode) {
Logger::warn(
"D3D11: Command list submitted multiple times,\n"
" but d3d11.dcSingleUseMode is enabled");
}
}
}
}

View File

@ -18,9 +18,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
UINT STDMETHODCALLTYPE GetContextFlags() final;
void AddChunk(
@ -37,7 +34,6 @@ namespace dxvk {
private:
D3D11Device* const m_device;
UINT const m_contextFlags;
std::vector<DxvkCsChunkRef> m_chunks;
@ -50,4 +46,4 @@ namespace dxvk {
};
}
}

View File

@ -13,7 +13,7 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags)
: m_parent (pParent),
: D3D11DeviceChild<ID3D11DeviceContext4>(pParent),
m_contextExt(this),
m_annotation(this),
m_multithread(this, false),
@ -134,11 +134,6 @@ namespace dxvk {
}
}
}
void STDMETHODCALLTYPE D3D11DeviceContext::GetDevice(ID3D11Device **ppDevice) {
*ppDevice = ref(m_parent);
}
void STDMETHODCALLTYPE D3D11DeviceContext::ClearState() {

View File

@ -39,8 +39,6 @@ namespace dxvk {
ID3D11View* pResourceView,
const D3D11_RECT* pRects,
UINT NumRects);
void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice);
void STDMETHODCALLTYPE ClearState();
@ -706,7 +704,6 @@ namespace dxvk {
protected:
D3D11Device* const m_parent;
D3D11DeviceContextExt m_contextExt;
D3D11UserDefinedAnnotation m_annotation;
D3D10Multithread m_multithread;

View File

@ -35,22 +35,6 @@ namespace dxvk {
}
ULONG STDMETHODCALLTYPE D3D11ImmediateContext::AddRef() {
ULONG refCount = m_refCount++;
if (!refCount)
m_parent->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11ImmediateContext::Release() {
ULONG refCount = --m_refCount;
if (!refCount)
m_parent->Release();
return refCount;
}
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE D3D11ImmediateContext::GetType() {
return D3D11_DEVICE_CONTEXT_IMMEDIATE;
}

View File

@ -21,10 +21,6 @@ namespace dxvk {
const Rc<DxvkDevice>& Device);
~D3D11ImmediateContext();
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType();
UINT STDMETHODCALLTYPE GetContextFlags();
@ -116,8 +112,6 @@ namespace dxvk {
DxvkCsThread m_csThread;
bool m_csIsBusy = false;
std::atomic<uint32_t> m_refCount = { 0 };
Rc<sync::Win32Fence> m_eventSignal;
uint64_t m_eventCount = 0;

View File

@ -6,7 +6,8 @@ namespace dxvk {
D3D11DepthStencilState::D3D11DepthStencilState(
D3D11Device* device,
const D3D11_DEPTH_STENCIL_DESC& desc)
: m_device(device), m_desc(desc), m_d3d10(this) {
: D3D11StateObject<ID3D11DepthStencilState>(device),
m_desc(desc), m_d3d10(this) {
m_state.enableDepthTest = desc.DepthEnable;
m_state.enableDepthWrite = desc.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ALL;
m_state.enableStencilTest = desc.StencilEnable;
@ -19,22 +20,6 @@ namespace dxvk {
D3D11DepthStencilState::~D3D11DepthStencilState() {
}
ULONG STDMETHODCALLTYPE D3D11DepthStencilState::AddRef() {
ULONG refCount = m_refCount++;
if (!refCount)
m_device->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11DepthStencilState::Release() {
ULONG refCount = --m_refCount;
if (!refCount)
m_device->Release();
return refCount;
}
HRESULT STDMETHODCALLTYPE D3D11DepthStencilState::QueryInterface(REFIID riid, void** ppvObject) {
@ -62,11 +47,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DepthStencilState::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = ref(m_device);
}
void STDMETHODCALLTYPE D3D11DepthStencilState::GetDesc(D3D11_DEPTH_STENCIL_DESC* pDesc) {
*pDesc = m_desc;
}

View File

@ -11,7 +11,7 @@ namespace dxvk {
class D3D11Device;
class D3D11DepthStencilState : public D3D11DeviceChild<ID3D11DepthStencilState, NoWrapper> {
class D3D11DepthStencilState : public D3D11StateObject<ID3D11DepthStencilState> {
public:
@ -21,18 +21,11 @@ namespace dxvk {
D3D11Device* device,
const D3D11_DEPTH_STENCIL_DESC& desc);
~D3D11DepthStencilState();
ULONG STDMETHODCALLTYPE AddRef() final;
ULONG STDMETHODCALLTYPE Release() final;
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetDesc(
D3D11_DEPTH_STENCIL_DESC* pDesc) final;
@ -48,12 +41,9 @@ namespace dxvk {
private:
D3D11Device* const m_device;
D3D11_DEPTH_STENCIL_DESC m_desc;
DxvkDepthStencilState m_state;
D3D10DepthStencilState m_d3d10;
std::atomic<uint32_t> m_refCount = { 0u };
VkStencilOpState DecodeStencilOpState(
const D3D11_DEPTH_STENCILOP_DESC& StencilDesc,

View File

@ -42,13 +42,13 @@ namespace dxvk {
m_dxbcOptions (m_dxvkDevice, m_d3d11Options) {
m_initializer = new D3D11Initializer(this);
m_context = new D3D11ImmediateContext(this, m_dxvkDevice);
m_d3d10Device = new D3D10Device(this, m_context);
m_d3d10Device = new D3D10Device(this, m_context.ptr());
}
D3D11Device::~D3D11Device() {
delete m_d3d10Device;
delete m_context;
m_context = nullptr;
delete m_initializer;
}
@ -1757,22 +1757,22 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11Device::GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) {
*ppImmediateContext = ref(m_context);
*ppImmediateContext = m_context.ref();
}
void STDMETHODCALLTYPE D3D11Device::GetImmediateContext1(ID3D11DeviceContext1** ppImmediateContext) {
*ppImmediateContext = ref(m_context);
*ppImmediateContext = m_context.ref();
}
void STDMETHODCALLTYPE D3D11Device::GetImmediateContext2(ID3D11DeviceContext2** ppImmediateContext) {
*ppImmediateContext = ref(m_context);
*ppImmediateContext = m_context.ref();
}
void STDMETHODCALLTYPE D3D11Device::GetImmediateContext3(ID3D11DeviceContext3** ppImmediateContext) {
*ppImmediateContext = ref(m_context);
*ppImmediateContext = m_context.ref();
}

View File

@ -446,8 +446,8 @@ namespace dxvk {
DxvkCsChunkPool m_csChunkPool;
D3D11Initializer* m_initializer = nullptr;
D3D11ImmediateContext* m_context = nullptr;
D3D10Device* m_d3d10Device = nullptr;
Com<D3D11ImmediateContext, false> m_context;
D3D11StateObjectSet<D3D11BlendState> m_bsStateObjects;
D3D11StateObjectSet<D3D11DepthStencilState> m_dsStateObjects;

View File

@ -5,11 +5,18 @@
#include "../util/com/com_private_data.h"
namespace dxvk {
template<typename Base, template<class> class Wrapper = ComObject>
class D3D11DeviceChild : public Wrapper<Base> {
class D3D11Device;
template<typename Base>
class D3D11DeviceObject : public Base {
public:
D3D11DeviceObject(D3D11Device* pDevice)
: m_parent(pDevice) {
}
HRESULT STDMETHODCALLTYPE GetPrivateData(
REFGUID guid,
@ -33,11 +40,91 @@ namespace dxvk {
return m_privateData.setInterface(
guid, pUnknown);
}
void STDMETHODCALLTYPE GetDevice(
ID3D11Device** ppDevice) final {
*ppDevice = ref(GetParentInterface());
}
protected:
ID3D11Device* GetParentInterface() const {
// We don't know the definition of ID3D11Device
// here, because D3D11Device includes this file.
return reinterpret_cast<ID3D11Device*>(m_parent);
}
D3D11Device* const m_parent;
private:
ComPrivateData m_privateData;
};
template<typename Base>
class D3D11DeviceChild : public D3D11DeviceObject<ComObject<Base>> {
public:
D3D11DeviceChild(D3D11Device* pDevice)
: D3D11DeviceObject<ComObject<Base>>(pDevice) {
}
ULONG STDMETHODCALLTYPE AddRef() {
uint32_t refCount = this->m_refCount++;
if (unlikely(!refCount)) {
this->AddRefPrivate();
this->GetParentInterface()->AddRef();
}
return refCount + 1;
}
ULONG STDMETHODCALLTYPE Release() {
uint32_t refCount = --this->m_refCount;
if (unlikely(!refCount)) {
auto* parent = this->GetParentInterface();
this->ReleasePrivate();
parent->Release();
}
return refCount;
}
};
template<typename Base>
class D3D11StateObject : public D3D11DeviceObject<Base> {
public:
D3D11StateObject(D3D11Device* pDevice)
: D3D11DeviceObject<Base>(pDevice) {
}
ULONG STDMETHODCALLTYPE AddRef() {
uint32_t refCount = this->m_refCount++;
if (unlikely(!refCount))
this->GetParentInterface()->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE Release() {
uint32_t refCount = --this->m_refCount;
if (unlikely(!refCount))
this->GetParentInterface()->Release();
return refCount;
}
private:
std::atomic<uint32_t> m_refCount = { 0u };
};
}

View File

@ -9,7 +9,8 @@ namespace dxvk {
const DxvkVertexAttribute* pAttributes,
uint32_t numBindings,
const DxvkVertexBinding* pBindings)
: m_device(pDevice), m_d3d10(this) {
: D3D11DeviceChild<ID3D11InputLayout>(pDevice),
m_d3d10(this) {
m_attributes.resize(numAttributes);
m_bindings.resize(numBindings);
@ -51,11 +52,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11InputLayout::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
void D3D11InputLayout::BindToContext(const Rc<DxvkContext>& ctx) {
ctx->setInputLayout(
m_attributes.size(),

View File

@ -25,9 +25,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device** ppDevice) final;
void BindToContext(
const Rc<DxvkContext>& ctx);
@ -40,8 +37,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
std::vector<DxvkVertexAttribute> m_attributes;
std::vector<DxvkVertexBinding> m_bindings;

View File

@ -6,10 +6,11 @@ namespace dxvk {
D3D11Query::D3D11Query(
D3D11Device* device,
const D3D11_QUERY_DESC1& desc)
: m_device(device), m_desc(desc),
: D3D11DeviceChild<ID3D11Query1>(device),
m_desc(desc),
m_state(D3D11_VK_QUERY_INITIAL),
m_d3d10(this) {
Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice();
Rc<DxvkDevice> dxvkDevice = m_parent->GetDXVKDevice();
switch (m_desc.Query) {
case D3D11_QUERY_EVENT:
@ -125,11 +126,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11Query::GetDevice(ID3D11Device **ppDevice) {
*ppDevice = m_device.ref();
}
UINT STDMETHODCALLTYPE D3D11Query::GetDataSize() {
switch (m_desc.Query) {
case D3D11_QUERY_EVENT:
@ -337,7 +333,7 @@ namespace dxvk {
UINT64 D3D11Query::GetTimestampQueryFrequency() const {
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
Rc<DxvkDevice> device = m_parent->GetDXVKDevice();
Rc<DxvkAdapter> adapter = device->adapter();
VkPhysicalDeviceLimits limits = adapter->deviceProperties().limits;

View File

@ -30,9 +30,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device** ppDevice) final;
UINT STDMETHODCALLTYPE GetDataSize();
void STDMETHODCALLTYPE GetDesc(D3D11_QUERY_DESC* pDesc) final;
@ -96,7 +93,6 @@ namespace dxvk {
private:
const Com<D3D11Device> m_device;
D3D11_QUERY_DESC1 m_desc;
D3D11_VK_QUERY_STATE m_state;

View File

@ -6,7 +6,8 @@ namespace dxvk {
D3D11RasterizerState::D3D11RasterizerState(
D3D11Device* device,
const D3D11_RASTERIZER_DESC2& desc)
: m_device(device), m_desc(desc), m_d3d10(this) {
: D3D11StateObject<ID3D11RasterizerState2>(device),
m_desc(desc), m_d3d10(this) {
// Polygon mode. Determines whether the rasterizer fills
// a polygon or renders lines connecting the vertices.
switch (desc.FillMode) {
@ -48,22 +49,6 @@ namespace dxvk {
D3D11RasterizerState::~D3D11RasterizerState() {
}
ULONG STDMETHODCALLTYPE D3D11RasterizerState::AddRef() {
ULONG refCount = m_refCount++;
if (!refCount)
m_device->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11RasterizerState::Release() {
ULONG refCount = --m_refCount;
if (!refCount)
m_device->Release();
return refCount;
}
HRESULT STDMETHODCALLTYPE D3D11RasterizerState::QueryInterface(REFIID riid, void** ppvObject) {
@ -93,11 +78,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11RasterizerState::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = ref(m_device);
}
void STDMETHODCALLTYPE D3D11RasterizerState::GetDesc(D3D11_RASTERIZER_DESC* pDesc) {
pDesc->FillMode = m_desc.FillMode;
pDesc->CullMode = m_desc.CullMode;
@ -215,4 +195,4 @@ namespace dxvk {
return S_OK;
}
}
}

View File

@ -10,7 +10,7 @@ namespace dxvk {
class D3D11Device;
class D3D11RasterizerState : public D3D11DeviceChild<ID3D11RasterizerState2, NoWrapper> {
class D3D11RasterizerState : public D3D11StateObject<ID3D11RasterizerState2> {
public:
@ -21,17 +21,10 @@ namespace dxvk {
const D3D11_RASTERIZER_DESC2& desc);
~D3D11RasterizerState();
ULONG STDMETHODCALLTYPE AddRef() final;
ULONG STDMETHODCALLTYPE Release() final;
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetDesc(
D3D11_RASTERIZER_DESC* pDesc) final;
@ -63,13 +56,10 @@ namespace dxvk {
private:
D3D11Device* const m_device;
D3D11_RASTERIZER_DESC2 m_desc;
DxvkRasterizerState m_state;
DxvkDepthBias m_depthBias;
D3D10RasterizerState m_d3d10;
std::atomic<uint32_t> m_refCount = { 0u };
};

View File

@ -7,7 +7,8 @@ namespace dxvk {
D3D11SamplerState::D3D11SamplerState(
D3D11Device* device,
const D3D11_SAMPLER_DESC& desc)
: m_device(device), m_desc(desc), m_d3d10(this) {
: D3D11StateObject<ID3D11SamplerState>(device),
m_desc(desc), m_d3d10(this) {
DxvkSamplerCreateInfo info;
// While D3D11_FILTER is technically an enum, its value bits
@ -57,22 +58,6 @@ namespace dxvk {
D3D11SamplerState::~D3D11SamplerState() {
}
ULONG STDMETHODCALLTYPE D3D11SamplerState::AddRef() {
ULONG refCount = m_refCount++;
if (!refCount)
m_device->AddRef();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11SamplerState::Release() {
ULONG refCount = --m_refCount;
if (!refCount)
m_device->Release();
return refCount;
}
HRESULT STDMETHODCALLTYPE D3D11SamplerState::QueryInterface(REFIID riid, void** ppvObject) {
@ -100,11 +85,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11SamplerState::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = ref(m_device);
}
void STDMETHODCALLTYPE D3D11SamplerState::GetDesc(D3D11_SAMPLER_DESC* pDesc) {
*pDesc = m_desc;
}

View File

@ -10,7 +10,7 @@ namespace dxvk {
class D3D11Device;
class D3D11SamplerState : public D3D11DeviceChild<ID3D11SamplerState, NoWrapper> {
class D3D11SamplerState : public D3D11StateObject<ID3D11SamplerState> {
public:
@ -20,18 +20,11 @@ namespace dxvk {
D3D11Device* device,
const D3D11_SAMPLER_DESC& desc);
~D3D11SamplerState();
ULONG STDMETHODCALLTYPE AddRef() final;
ULONG STDMETHODCALLTYPE Release() final;
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetDesc(
D3D11_SAMPLER_DESC* pDesc) final;
@ -48,7 +41,6 @@ namespace dxvk {
private:
D3D11Device* const m_device;
D3D11_SAMPLER_DESC m_desc;
Rc<DxvkSampler> m_sampler;
D3D10SamplerState m_d3d10;

View File

@ -72,7 +72,8 @@ namespace dxvk {
public:
D3D11Shader(D3D11Device* device, const D3D11CommonShader& shader)
: m_device(device), m_shader(shader), m_d3d10(this) { }
: D3D11DeviceChild<D3D11Interface>(device),
m_shader(shader), m_d3d10(this) { }
~D3D11Shader() { }
@ -97,10 +98,6 @@ namespace dxvk {
return E_NOINTERFACE;
}
void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice) final {
*ppDevice = m_device.ref();
}
const D3D11CommonShader* GetCommonShader() const {
return &m_shader;
}
@ -111,7 +108,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
D3D11CommonShader m_shader;
D3D10ShaderClass m_d3d10;

View File

@ -3,8 +3,8 @@
namespace dxvk {
D3D11DeviceContextState::D3D11DeviceContextState(
ID3D11Device* pDevice)
: m_device(pDevice) {
D3D11Device* pDevice)
: D3D11DeviceChild<ID3DDeviceContextState>(pDevice) {
}
@ -34,10 +34,4 @@ namespace dxvk {
return E_NOINTERFACE;
}
void STDMETHODCALLTYPE D3D11DeviceContextState::GetDevice(
ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
}
}

View File

@ -19,7 +19,7 @@ namespace dxvk {
public:
D3D11DeviceContextState(
ID3D11Device* pDevice);
D3D11Device* pDevice);
~D3D11DeviceContextState();
@ -27,9 +27,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject);
void STDMETHODCALLTYPE GetDevice(
ID3D11Device** ppDevice);
void SetState(const D3D11ContextState& State) {
m_state = State;
}
@ -40,7 +37,6 @@ namespace dxvk {
private:
Com<ID3D11Device> m_device;
D3D11ContextState m_state;
};

View File

@ -214,11 +214,6 @@ namespace dxvk {
}
void D3D11CommonTexture::GetDevice(ID3D11Device** ppDevice) const {
*ppDevice = m_device.ref();
}
bool D3D11CommonTexture::CheckViewCompatibility(UINT BindFlags, DXGI_FORMAT Format) const {
const DxvkImageCreateInfo& imageInfo = m_image->info();
@ -779,7 +774,8 @@ namespace dxvk {
D3D11Texture1D::D3D11Texture1D(
D3D11Device* pDevice,
const D3D11_COMMON_TEXTURE_DESC* pDesc)
: m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE1D, VK_NULL_HANDLE),
: D3D11DeviceChild<ID3D11Texture1D>(pDevice),
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE1D, VK_NULL_HANDLE),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource(this),
@ -840,11 +836,6 @@ namespace dxvk {
return E_NOINTERFACE;
}
void STDMETHODCALLTYPE D3D11Texture1D::GetDevice(ID3D11Device** ppDevice) {
m_texture.GetDevice(ppDevice);
}
void STDMETHODCALLTYPE D3D11Texture1D::GetType(D3D11_RESOURCE_DIMENSION *pResourceDimension) {
*pResourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D;
@ -881,7 +872,8 @@ namespace dxvk {
D3D11Texture2D::D3D11Texture2D(
D3D11Device* pDevice,
const D3D11_COMMON_TEXTURE_DESC* pDesc)
: m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, VK_NULL_HANDLE),
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, VK_NULL_HANDLE),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource(this),
@ -894,7 +886,8 @@ namespace dxvk {
D3D11Device* pDevice,
const D3D11_COMMON_TEXTURE_DESC* pDesc,
VkImage vkImage)
: m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, vkImage),
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, vkImage),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource(this),
@ -956,11 +949,6 @@ namespace dxvk {
return E_NOINTERFACE;
}
void STDMETHODCALLTYPE D3D11Texture2D::GetDevice(ID3D11Device** ppDevice) {
m_texture.GetDevice(ppDevice);
}
void STDMETHODCALLTYPE D3D11Texture2D::GetType(D3D11_RESOURCE_DIMENSION *pResourceDimension) {
*pResourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
@ -1014,7 +1002,8 @@ namespace dxvk {
D3D11Texture3D::D3D11Texture3D(
D3D11Device* pDevice,
const D3D11_COMMON_TEXTURE_DESC* pDesc)
: m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE3D, VK_NULL_HANDLE),
: D3D11DeviceChild<ID3D11Texture3D1>(pDevice),
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE3D, VK_NULL_HANDLE),
m_interop (this, &m_texture),
m_resource(this),
m_d3d10 (this) {
@ -1067,11 +1056,6 @@ namespace dxvk {
return E_NOINTERFACE;
}
void STDMETHODCALLTYPE D3D11Texture3D::GetDevice(ID3D11Device** ppDevice) {
m_texture.GetDevice(ppDevice);
}
void STDMETHODCALLTYPE D3D11Texture3D::GetType(D3D11_RESOURCE_DIMENSION *pResourceDimension) {
*pResourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE3D;

View File

@ -173,12 +173,6 @@ namespace dxvk {
*/
DXGI_VK_FORMAT_MODE GetFormatMode() const;
/**
* \brief Retrieves parent D3D11 device
* \param [out] ppDevice The device
*/
void GetDevice(ID3D11Device** ppDevice) const;
/**
* \brief Checks whether a view can be created for this textue
*
@ -208,7 +202,7 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
D3D11Device* const m_device;
D3D11_COMMON_TEXTURE_DESC m_desc;
D3D11_COMMON_TEXTURE_MAP_MODE m_mapMode;
@ -381,9 +375,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetType(
D3D11_RESOURCE_DIMENSION *pResourceDimension) final;
@ -434,9 +425,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetType(
D3D11_RESOURCE_DIMENSION *pResourceDimension) final;
@ -485,9 +473,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
void STDMETHODCALLTYPE GetType(
D3D11_RESOURCE_DIMENSION *pResourceDimension) final;

View File

@ -10,7 +10,8 @@ namespace dxvk {
D3D11Device* pDevice,
ID3D11Resource* pResource,
const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
: D3D11DeviceChild<ID3D11DepthStencilView>(pDevice),
m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
ResourceAddRefPrivate(m_resource);
D3D11_COMMON_RESOURCE_DESC resourceDesc;
@ -135,11 +136,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DepthStencilView::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
void STDMETHODCALLTYPE D3D11DepthStencilView::GetResource(ID3D11Resource** ppResource) {
*ppResource = ref(m_resource);
}

View File

@ -31,8 +31,6 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final;
void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final;
void STDMETHODCALLTYPE GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) final;
@ -89,7 +87,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
ID3D11Resource* m_resource;
D3D11_DEPTH_STENCIL_VIEW_DESC m_desc;
D3D11_VK_VIEW_INFO m_info;

View File

@ -10,7 +10,8 @@ namespace dxvk {
D3D11Device* pDevice,
ID3D11Resource* pResource,
const D3D11_RENDER_TARGET_VIEW_DESC1* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
: D3D11DeviceChild<ID3D11RenderTargetView1>(pDevice),
m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
ResourceAddRefPrivate(m_resource);
D3D11_COMMON_RESOURCE_DESC resourceDesc;
@ -142,11 +143,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11RenderTargetView::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
void STDMETHODCALLTYPE D3D11RenderTargetView::GetResource(ID3D11Resource** ppResource) {
*ppResource = ref(m_resource);
}

View File

@ -27,8 +27,6 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final;
void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final;
void STDMETHODCALLTYPE GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final;
@ -76,7 +74,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
ID3D11Resource* m_resource;
D3D11_RENDER_TARGET_VIEW_DESC1 m_desc;
D3D11_VK_VIEW_INFO m_info;

View File

@ -10,7 +10,8 @@ namespace dxvk {
D3D11Device* pDevice,
ID3D11Resource* pResource,
const D3D11_SHADER_RESOURCE_VIEW_DESC1* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
: D3D11DeviceChild<ID3D11ShaderResourceView1>(pDevice),
m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
ResourceAddRefPrivate(m_resource);
D3D11_COMMON_RESOURCE_DESC resourceDesc;
@ -211,11 +212,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11ShaderResourceView::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
void STDMETHODCALLTYPE D3D11ShaderResourceView::GetResource(ID3D11Resource** ppResource) {
*ppResource = ref(m_resource);
}

View File

@ -27,8 +27,6 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final;
void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final;
void STDMETHODCALLTYPE GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) final;
@ -80,7 +78,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
ID3D11Resource* m_resource;
D3D11_SHADER_RESOURCE_VIEW_DESC1 m_desc;
D3D11_VK_VIEW_INFO m_info;

View File

@ -10,7 +10,8 @@ namespace dxvk {
D3D11Device* pDevice,
ID3D11Resource* pResource,
const D3D11_UNORDERED_ACCESS_VIEW_DESC1* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
: D3D11DeviceChild<ID3D11UnorderedAccessView1>(pDevice),
m_resource(pResource), m_desc(*pDesc) {
ResourceAddRefPrivate(m_resource);
D3D11_COMMON_RESOURCE_DESC resourceDesc;
@ -147,11 +148,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11UnorderedAccessView::GetDevice(ID3D11Device** ppDevice) {
*ppDevice = m_device.ref();
}
void STDMETHODCALLTYPE D3D11UnorderedAccessView::GetResource(ID3D11Resource** ppResource) {
*ppResource = ref(m_resource);
}
@ -420,7 +416,7 @@ namespace dxvk {
Rc<DxvkBuffer> D3D11UnorderedAccessView::CreateCounterBuffer() {
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
Rc<DxvkDevice> device = m_parent->GetDXVKDevice();
DxvkBufferCreateInfo info;
info.size = sizeof(uint32_t);

View File

@ -29,8 +29,6 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final;
void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final;
void STDMETHODCALLTYPE GetDesc(D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) final;
@ -78,7 +76,6 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
ID3D11Resource* m_resource;
D3D11_UNORDERED_ACCESS_VIEW_DESC1 m_desc;
D3D11_VK_VIEW_INFO m_info;