2018-01-23 09:23:31 +01:00
|
|
|
#include "d3d11_cmdlist.h"
|
|
|
|
#include "d3d11_device.h"
|
2022-02-09 04:36:50 +01:00
|
|
|
#include "d3d11_buffer.h"
|
|
|
|
#include "d3d11_texture.h"
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
D3D11CommandList::D3D11CommandList(
|
2019-10-27 11:00:59 +01:00
|
|
|
D3D11Device* pDevice,
|
|
|
|
UINT ContextFlags)
|
2021-01-07 20:08:55 +00:00
|
|
|
: D3D11DeviceChild<ID3D11CommandList>(pDevice),
|
2019-10-27 11:00:59 +01:00
|
|
|
m_contextFlags(ContextFlags) { }
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
D3D11CommandList::~D3D11CommandList() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE D3D11CommandList::QueryInterface(REFIID riid, void** ppvObject) {
|
2019-02-10 07:01:01 +00:00
|
|
|
if (ppvObject == nullptr)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2018-04-02 12:52:02 +02:00
|
|
|
*ppvObject = nullptr;
|
|
|
|
|
|
|
|
if (riid == __uuidof(IUnknown)
|
|
|
|
|| riid == __uuidof(ID3D11DeviceChild)
|
|
|
|
|| riid == __uuidof(ID3D11CommandList)) {
|
|
|
|
*ppvObject = ref(this);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
Logger::warn("D3D11CommandList::QueryInterface: Unknown interface query");
|
2018-03-12 14:05:43 +03:00
|
|
|
Logger::warn(str::format(riid));
|
2018-01-23 09:23:31 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-23 12:16:28 +01:00
|
|
|
UINT STDMETHODCALLTYPE D3D11CommandList::GetContextFlags() {
|
2018-01-23 09:23:31 +01:00
|
|
|
return m_contextFlags;
|
|
|
|
}
|
|
|
|
|
2018-01-23 12:03:26 +01:00
|
|
|
|
2018-08-27 16:07:38 +02:00
|
|
|
void D3D11CommandList::AddChunk(DxvkCsChunkRef&& Chunk) {
|
2018-01-23 12:03:26 +01:00
|
|
|
m_chunks.push_back(std::move(Chunk));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-02 13:06:44 +01:00
|
|
|
void D3D11CommandList::AddQuery(D3D11Query* pQuery) {
|
|
|
|
m_queries.emplace_back(pQuery);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-23 12:03:26 +01:00
|
|
|
void D3D11CommandList::EmitToCommandList(ID3D11CommandList* pCommandList) {
|
|
|
|
auto cmdList = static_cast<D3D11CommandList*>(pCommandList);
|
|
|
|
|
2018-04-28 02:14:57 +03:00
|
|
|
for (const auto& chunk : m_chunks)
|
2018-01-23 12:03:26 +01:00
|
|
|
cmdList->m_chunks.push_back(chunk);
|
2019-11-02 13:06:44 +01:00
|
|
|
|
|
|
|
for (const auto& query : m_queries)
|
|
|
|
cmdList->m_queries.push_back(query);
|
|
|
|
|
2022-02-09 04:36:50 +01:00
|
|
|
for (const auto& resource : m_resources)
|
|
|
|
cmdList->m_resources.push_back(resource);
|
|
|
|
|
2018-06-29 12:44:52 +02:00
|
|
|
MarkSubmitted();
|
2018-01-23 12:03:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-09 03:21:58 +01:00
|
|
|
uint64_t D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) {
|
|
|
|
uint64_t seq = 0;
|
|
|
|
|
2019-11-02 13:24:36 +01:00
|
|
|
for (const auto& query : m_queries)
|
|
|
|
query->DoDeferredEnd();
|
|
|
|
|
2018-04-28 02:14:57 +03:00
|
|
|
for (const auto& chunk : m_chunks)
|
2022-02-09 03:21:58 +01:00
|
|
|
seq = CsThread->dispatchChunk(DxvkCsChunkRef(chunk));
|
2018-06-29 12:44:52 +02:00
|
|
|
|
2022-02-09 04:36:50 +01:00
|
|
|
for (const auto& resource : m_resources)
|
|
|
|
TrackResourceSequenceNumber(resource, seq);
|
|
|
|
|
2018-06-29 12:44:52 +02:00
|
|
|
MarkSubmitted();
|
2022-02-09 03:21:58 +01:00
|
|
|
return seq;
|
2018-06-29 12:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-09 04:36:50 +01:00
|
|
|
void D3D11CommandList::TrackResourceUsage(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
D3D11_RESOURCE_DIMENSION ResourceType,
|
|
|
|
UINT Subresource) {
|
2022-02-10 14:23:24 +01:00
|
|
|
m_resources.emplace_back(pResource, Subresource, ResourceType);
|
2022-02-09 04:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void D3D11CommandList::TrackResourceSequenceNumber(
|
|
|
|
const D3D11ResourceRef& Resource,
|
|
|
|
uint64_t Seq) {
|
|
|
|
ID3D11Resource* iface = Resource.Get();
|
|
|
|
UINT subresource = Resource.GetSubresource();
|
|
|
|
|
|
|
|
switch (Resource.GetType()) {
|
|
|
|
case D3D11_RESOURCE_DIMENSION_UNKNOWN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_RESOURCE_DIMENSION_BUFFER: {
|
|
|
|
auto impl = static_cast<D3D11Buffer*>(iface);
|
|
|
|
impl->TrackSequenceNumber(Seq);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D: {
|
|
|
|
auto impl = static_cast<D3D11Texture1D*>(iface)->GetCommonTexture();
|
|
|
|
impl->TrackSequenceNumber(subresource, Seq);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: {
|
|
|
|
auto impl = static_cast<D3D11Texture2D*>(iface)->GetCommonTexture();
|
|
|
|
impl->TrackSequenceNumber(subresource, Seq);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: {
|
|
|
|
auto impl = static_cast<D3D11Texture3D*>(iface)->GetCommonTexture();
|
|
|
|
impl->TrackSequenceNumber(subresource, Seq);
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-29 12:44:52 +02:00
|
|
|
void D3D11CommandList::MarkSubmitted() {
|
2018-10-09 16:29:50 +02:00
|
|
|
if (m_submitted.exchange(true) && !m_warned.exchange(true)
|
2021-01-07 20:08:55 +00:00
|
|
|
&& m_parent->GetOptions()->dcSingleUseMode) {
|
2018-06-29 12:44:52 +02:00
|
|
|
Logger::warn(
|
2018-10-09 16:29:50 +02:00
|
|
|
"D3D11: Command list submitted multiple times,\n"
|
2018-11-20 10:51:09 +01:00
|
|
|
" but d3d11.dcSingleUseMode is enabled");
|
2018-06-29 12:44:52 +02:00
|
|
|
}
|
2018-01-23 12:03:26 +01:00
|
|
|
}
|
|
|
|
|
2021-01-07 20:08:55 +00:00
|
|
|
}
|