mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[d3d11] Implement Acquire/ReleaseWrappedResource
This commit is contained in:
parent
5595844f75
commit
3d5becaf6a
@ -753,6 +753,74 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void D3D11ImmediateContext::Acquire11on12Resource(
|
||||
ID3D11Resource* pResource,
|
||||
VkImageLayout SrcLayout) {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
auto texture = GetCommonTexture(pResource);
|
||||
auto buffer = GetCommonBuffer(pResource);
|
||||
|
||||
if (buffer) {
|
||||
EmitCs([
|
||||
cBuffer = buffer->GetBuffer()
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->emitBufferBarrier(cBuffer,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT,
|
||||
cBuffer->info().stages,
|
||||
cBuffer->info().access);
|
||||
});
|
||||
} else if (texture) {
|
||||
EmitCs([
|
||||
cImage = texture->GetImage(),
|
||||
cLayout = SrcLayout
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->emitImageBarrier(cImage, cLayout,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT,
|
||||
cImage->info().layout,
|
||||
cImage->info().stages,
|
||||
cImage->info().access);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void D3D11ImmediateContext::Release11on12Resource(
|
||||
ID3D11Resource* pResource,
|
||||
VkImageLayout DstLayout) {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
auto texture = GetCommonTexture(pResource);
|
||||
auto buffer = GetCommonBuffer(pResource);
|
||||
|
||||
if (buffer) {
|
||||
EmitCs([
|
||||
cBuffer = buffer->GetBuffer()
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->emitBufferBarrier(cBuffer,
|
||||
cBuffer->info().stages,
|
||||
cBuffer->info().access,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT);
|
||||
});
|
||||
} else if (texture) {
|
||||
EmitCs([
|
||||
cImage = texture->GetImage(),
|
||||
cLayout = DstLayout
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->emitImageBarrier(cImage,
|
||||
cImage->info().layout,
|
||||
cImage->info().stages,
|
||||
cImage->info().access,
|
||||
cLayout, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void D3D11ImmediateContext::SynchronizeCsThread(uint64_t SequenceNumber) {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
|
@ -77,6 +77,14 @@ namespace dxvk {
|
||||
ID3DDeviceContextState* pState,
|
||||
ID3DDeviceContextState** ppPreviousState);
|
||||
|
||||
void Acquire11on12Resource(
|
||||
ID3D11Resource* pResource,
|
||||
VkImageLayout SrcLayout);
|
||||
|
||||
void Release11on12Resource(
|
||||
ID3D11Resource* pResource,
|
||||
VkImageLayout DstLayout);
|
||||
|
||||
void SynchronizeCsThread(
|
||||
uint64_t SequenceNumber);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "d3d11_context_imm.h"
|
||||
#include "d3d11_device.h"
|
||||
#include "d3d11_on_12.h"
|
||||
|
||||
@ -108,14 +109,48 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE D3D11on12Device::ReleaseWrappedResources(
|
||||
ID3D11Resource* const* ppResources,
|
||||
UINT ResourceCount) {
|
||||
Logger::err("D3D11on12Device::ReleaseWrappedResources: Stub");
|
||||
Com<ID3D12DXVKInteropDevice> interopDevice;
|
||||
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
|
||||
|
||||
Com<ID3D11DeviceContext> context;
|
||||
m_device->GetImmediateContext(&context);
|
||||
|
||||
for (uint32_t i = 0; i < ResourceCount; i++) {
|
||||
D3D11_ON_12_RESOURCE_INFO info;
|
||||
|
||||
if (FAILED(GetResource11on12Info(ppResources[i], &info)) || !info.IsWrappedResource) {
|
||||
Logger::warn("D3D11on12Device::ReleaseWrappedResources: Resource not a wrapped resource, skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.OutputState, &layout);
|
||||
static_cast<D3D11ImmediateContext*>(context.ptr())->Release11on12Resource(ppResources[i], layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11on12Device::AcquireWrappedResources(
|
||||
ID3D11Resource* const* ppResources,
|
||||
UINT ResourceCount) {
|
||||
Logger::err("D3D11on12Device::AcquireWrappedResources: Stub");
|
||||
Com<ID3D12DXVKInteropDevice> interopDevice;
|
||||
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
|
||||
|
||||
Com<ID3D11DeviceContext> context;
|
||||
m_device->GetImmediateContext(&context);
|
||||
|
||||
for (uint32_t i = 0; i < ResourceCount; i++) {
|
||||
D3D11_ON_12_RESOURCE_INFO info;
|
||||
|
||||
if (FAILED(GetResource11on12Info(ppResources[i], &info)) || !info.IsWrappedResource) {
|
||||
Logger::warn("D3D11on12Device::AcquireWrappedResources: Resource not a wrapped resource, skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.InputState, &layout);
|
||||
static_cast<D3D11ImmediateContext*>(context.ptr())->Acquire11on12Resource(ppResources[i], layout);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -172,6 +172,26 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
HRESULT GetResource11on12Info(
|
||||
ID3D11Resource* pResource,
|
||||
D3D11_ON_12_RESOURCE_INFO* p11on12Info) {
|
||||
auto buffer = GetCommonBuffer (pResource);
|
||||
auto texture = GetCommonTexture(pResource);
|
||||
|
||||
if (buffer != nullptr)
|
||||
*p11on12Info = buffer->Get11on12Info();
|
||||
else if (texture != nullptr)
|
||||
*p11on12Info = texture->Get11on12Info();
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (p11on12Info->Resource == nullptr)
|
||||
return E_INVALIDARG;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT GetCommonResourceDesc(
|
||||
ID3D11Resource* pResource,
|
||||
D3D11_COMMON_RESOURCE_DESC* pDesc) {
|
||||
|
@ -93,6 +93,17 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Queries D3D11on12 resource info
|
||||
*
|
||||
* \param [in] pResource The resource to query
|
||||
* \param [out] p11on12Info 11on12 info
|
||||
* \returns \c S_OK on success, or \c E_INVALIDARG
|
||||
*/
|
||||
HRESULT GetResource11on12Info(
|
||||
ID3D11Resource* pResource,
|
||||
D3D11_ON_12_RESOURCE_INFO* p11on12Info);
|
||||
|
||||
/**
|
||||
* \brief Queries common resource description
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user