diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 6b618b7c..ab3c7c6a 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -45,6 +45,7 @@ namespace dxvk { m_uavCounters = CreateUAVCounterBuffer(); m_xfbCounters = CreateXFBCounterBuffer(); + m_predicates = CreatePredicateBuffer(); } @@ -986,7 +987,7 @@ namespace dxvk { return S_FALSE; try { - *ppPredicate = ref(new D3D11Query(this, *pPredicateDesc)); + *ppPredicate = ref(new D3D11Query(this, *pPredicateDesc, AllocPredicateSlice())); return S_OK; } catch (const DxvkError& e) { Logger::err(e.message()); @@ -1475,6 +1476,21 @@ 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 4085ad5a..a8e2df40 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -326,9 +326,11 @@ namespace dxvk { DxvkBufferSlice AllocUavCounterSlice() { return m_uavCounters->AllocSlice(); } DxvkBufferSlice AllocXfbCounterSlice() { return m_xfbCounters->AllocSlice(); } + DxvkBufferSlice AllocPredicateSlice () { return m_predicates ->AllocSlice(); } void FreeUavCounterSlice(const DxvkBufferSlice& Slice) { m_uavCounters->FreeSlice(Slice); } void FreeXfbCounterSlice(const DxvkBufferSlice& Slice) { m_xfbCounters->FreeSlice(Slice); } + void FreePredicateSlice (const DxvkBufferSlice& Slice) { m_predicates ->FreeSlice(Slice); } static bool CheckFeatureLevelSupport( const Rc& adapter, @@ -360,6 +362,7 @@ namespace dxvk { Rc m_uavCounters; Rc m_xfbCounters; + Rc m_predicates; D3D11StateObjectSet m_bsStateObjects; D3D11StateObjectSet m_dsStateObjects; @@ -369,6 +372,7 @@ namespace dxvk { Rc CreateUAVCounterBuffer(); Rc CreateXFBCounterBuffer(); + Rc CreatePredicateBuffer(); HRESULT CreateShaderModule( D3D11CommonShader* pShaderModule, diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index e174d823..5e561432 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -6,7 +6,16 @@ namespace dxvk { D3D11Query::D3D11Query( D3D11Device* device, const D3D11_QUERY_DESC& desc) - : m_device(device), m_desc(desc), + : D3D11Query(device, desc, DxvkBufferSlice()) { + + } + + + D3D11Query::D3D11Query( + D3D11Device* device, + const D3D11_QUERY_DESC& desc, + const DxvkBufferSlice& predicate) + : m_device(device), m_desc(desc), m_predicate(predicate), m_d3d10(this, device->GetD3D10Interface()) { Rc dxvkDevice = m_device->GetDXVKDevice(); @@ -75,7 +84,8 @@ namespace dxvk { D3D11Query::~D3D11Query() { - + if (m_predicate.defined()) + m_device->FreePredicateSlice(m_predicate); } @@ -198,6 +208,9 @@ namespace dxvk { default: ctx->endQuery(m_query); } + + if (m_predicate.defined()) + ctx->writePredicate(m_predicate, m_query); } diff --git a/src/d3d11/d3d11_query.h b/src/d3d11/d3d11_query.h index 229c1aa5..7a6b9907 100644 --- a/src/d3d11/d3d11_query.h +++ b/src/d3d11/d3d11_query.h @@ -17,6 +17,11 @@ namespace dxvk { D3D11Device* device, const D3D11_QUERY_DESC& desc); + D3D11Query( + D3D11Device* device, + const D3D11_QUERY_DESC& desc, + const DxvkBufferSlice& predicate); + ~D3D11Query(); HRESULT STDMETHODCALLTYPE QueryInterface( @@ -51,6 +56,8 @@ namespace dxvk { Rc m_query = nullptr; Rc m_event = nullptr; + DxvkBufferSlice m_predicate; + D3D10Query m_d3d10; UINT64 GetTimestampQueryFrequency() const;