diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index c02883af1..668801ea6 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -44,8 +44,6 @@ namespace dxvk { m_initializer = new D3D11Initializer(this); m_context = new D3D11ImmediateContext(this, m_dxvkDevice); m_d3d10Device = new D3D10Device(this, m_context); - - m_predicates = CreatePredicateBuffer(); } @@ -1968,21 +1966,6 @@ namespace dxvk { } - Rc D3D11Device::CreatePredicateBuffer() { - DxvkBufferCreateInfo predCounterInfo; - predCounterInfo.size = 4096 * sizeof(uint32_t); - predCounterInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT - | VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT; - predCounterInfo.stages = VK_PIPELINE_STAGE_TRANSFER_BIT - | VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT; - predCounterInfo.access = VK_ACCESS_TRANSFER_WRITE_BIT - | VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT; - - return new D3D11CounterBuffer(m_dxvkDevice, - predCounterInfo, sizeof(uint32_t)); - } - - HRESULT D3D11Device::CreateShaderModule( D3D11CommonShader* pShaderModule, DxvkShaderKey ShaderKey, diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 80808f2ea..19da337a4 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -425,10 +425,6 @@ namespace dxvk { return m_d3d10Device; } - DxvkBufferSlice AllocPredicateSlice () { return m_predicates ->AllocSlice(); } - - void FreePredicateSlice (const DxvkBufferSlice& Slice) { m_predicates ->FreeSlice(Slice); } - static bool CheckFeatureLevelSupport( const Rc& adapter, D3D_FEATURE_LEVEL featureLevel); @@ -457,8 +453,6 @@ namespace dxvk { D3D11ImmediateContext* m_context = nullptr; D3D10Device* m_d3d10Device = nullptr; - Rc m_predicates; - D3D11StateObjectSet m_bsStateObjects; D3D11StateObjectSet m_dsStateObjects; D3D11StateObjectSet m_rsStateObjects; @@ -466,8 +460,6 @@ namespace dxvk { D3D11ShaderModuleSet m_shaderModules; D3D11CommandListAllocator m_commandListAllocator; - Rc CreatePredicateBuffer(); - HRESULT CreateShaderModule( D3D11CommonShader* pShaderModule, DxvkShaderKey ShaderKey, diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index bb763fcc7..554be1445 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -80,8 +80,7 @@ namespace dxvk { D3D11Query::~D3D11Query() { - if (m_predicate.defined()) - m_device->FreePredicateSlice(m_predicate); + } @@ -221,8 +220,8 @@ namespace dxvk { ctx->endQuery(m_query[0]); } - if (unlikely(m_predicate.defined())) - ctx->writePredicate(m_predicate, m_query[0]); + if (unlikely(m_predicate != nullptr)) + ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]); m_state = D3D11_VK_QUERY_ENDED; } @@ -331,12 +330,12 @@ namespace dxvk { if (unlikely(m_state != D3D11_VK_QUERY_ENDED)) return DxvkBufferSlice(); - if (unlikely(!m_predicate.defined())) { - m_predicate = m_device->AllocPredicateSlice(); - ctx->writePredicate(m_predicate, m_query[0]); + if (unlikely(m_predicate != nullptr)) { + m_predicate = CreatePredicateBuffer(); + ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]); } - return m_predicate; + return DxvkBufferSlice(m_predicate); } @@ -356,5 +355,20 @@ namespace dxvk { return S_OK; } + + + Rc D3D11Query::CreatePredicateBuffer() { + Rc device = m_device->GetDXVKDevice(); + + DxvkBufferCreateInfo info; + info.size = sizeof(uint32_t); + info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT + | VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT; + info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT + | VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT; + info.access = VK_ACCESS_TRANSFER_WRITE_BIT + | VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT; + return device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + } } diff --git a/src/d3d11/d3d11_query.h b/src/d3d11/d3d11_query.h index ba6317ebe..1c1f7b812 100644 --- a/src/d3d11/d3d11_query.h +++ b/src/d3d11/d3d11_query.h @@ -92,8 +92,8 @@ namespace dxvk { std::array, MaxGpuQueries> m_query; std::array, MaxGpuEvents> m_event; - sync::Spinlock m_predicateLock; - DxvkBufferSlice m_predicate; + sync::Spinlock m_predicateLock; + Rc m_predicate; D3D10Query m_d3d10; @@ -101,6 +101,8 @@ namespace dxvk { bool m_stallFlag = false; UINT64 GetTimestampQueryFrequency() const; + + Rc CreatePredicateBuffer(); };