1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-13 16:08:50 +01:00

[d3d11] Implement sequence number tracking on deferred contexts

This commit is contained in:
Philip Rebohle 2022-02-09 04:36:50 +01:00
parent 2eeb7295c8
commit bb16734a43
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 67 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include "d3d11_cmdlist.h" #include "d3d11_cmdlist.h"
#include "d3d11_device.h" #include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_texture.h"
namespace dxvk { namespace dxvk {
@ -58,6 +60,9 @@ namespace dxvk {
for (const auto& query : m_queries) for (const auto& query : m_queries)
cmdList->m_queries.push_back(query); cmdList->m_queries.push_back(query);
for (const auto& resource : m_resources)
cmdList->m_resources.push_back(resource);
MarkSubmitted(); MarkSubmitted();
} }
@ -71,11 +76,55 @@ namespace dxvk {
for (const auto& chunk : m_chunks) for (const auto& chunk : m_chunks)
seq = CsThread->dispatchChunk(DxvkCsChunkRef(chunk)); seq = CsThread->dispatchChunk(DxvkCsChunkRef(chunk));
for (const auto& resource : m_resources)
TrackResourceSequenceNumber(resource, seq);
MarkSubmitted(); MarkSubmitted();
return seq; return seq;
} }
void D3D11CommandList::TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource) {
m_resources.emplace_back(pResource, ResourceType, Subresource);
}
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;
}
}
void D3D11CommandList::MarkSubmitted() { void D3D11CommandList::MarkSubmitted() {
if (m_submitted.exchange(true) && !m_warned.exchange(true) if (m_submitted.exchange(true) && !m_warned.exchange(true)
&& m_parent->GetOptions()->dcSingleUseMode) { && m_parent->GetOptions()->dcSingleUseMode) {

View File

@ -31,17 +31,27 @@ namespace dxvk {
uint64_t EmitToCsThread( uint64_t EmitToCsThread(
DxvkCsThread* CsThread); DxvkCsThread* CsThread);
void TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource);
private: private:
UINT const m_contextFlags; UINT const m_contextFlags;
std::vector<DxvkCsChunkRef> m_chunks; std::vector<DxvkCsChunkRef> m_chunks;
std::vector<Com<D3D11Query, false>> m_queries; std::vector<Com<D3D11Query, false>> m_queries;
std::vector<D3D11ResourceRef> m_resources;
std::atomic<bool> m_submitted = { false }; std::atomic<bool> m_submitted = { false };
std::atomic<bool> m_warned = { false }; std::atomic<bool> m_warned = { false };
void TrackResourceSequenceNumber(
const D3D11ResourceRef& Resource,
uint64_t Seq);
void MarkSubmitted(); void MarkSubmitted();
}; };

View File

@ -423,13 +423,17 @@ namespace dxvk {
void D3D11DeferredContext::TrackTextureSequenceNumber( void D3D11DeferredContext::TrackTextureSequenceNumber(
D3D11CommonTexture* pResource, D3D11CommonTexture* pResource,
UINT Subresource) { UINT Subresource) {
// TODO implement m_commandList->TrackResourceUsage(
pResource->GetInterface(),
pResource->GetDimension(),
Subresource);
} }
void D3D11DeferredContext::TrackBufferSequenceNumber( void D3D11DeferredContext::TrackBufferSequenceNumber(
D3D11Buffer* pResource) { D3D11Buffer* pResource) {
// TODO implement m_commandList->TrackResourceUsage(
pResource, D3D11_RESOURCE_DIMENSION_BUFFER, 0);
} }