mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 19:24:12 +01:00
[d3d11] Lazily allocate predicate on SetPredication
Many games use CreatePredicate to create occlusion queries without actually using predication, and we don't want to pay any runtime cost for this when predicates aren't actually being used.
This commit is contained in:
parent
87dc472a8d
commit
295d583c1d
@ -283,12 +283,15 @@ namespace dxvk {
|
||||
return;
|
||||
|
||||
EmitCs([
|
||||
cPredicate = predicate
|
||||
? predicate->GetPredicate()
|
||||
: DxvkBufferSlice(),
|
||||
cPredicate = Com<D3D11Query>(predicate),
|
||||
cValue = PredicateValue
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->setPredicate(cPredicate,
|
||||
DxvkBufferSlice predSlice;
|
||||
|
||||
if (cPredicate != nullptr)
|
||||
predSlice = cPredicate->GetPredicate(ctx);
|
||||
|
||||
ctx->setPredicate(predSlice,
|
||||
cValue ? VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT : 0);
|
||||
});
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ namespace dxvk {
|
||||
return S_FALSE;
|
||||
|
||||
try {
|
||||
*ppPredicate = ref(new D3D11Query(this, *pPredicateDesc, AllocPredicateSlice()));
|
||||
*ppPredicate = ref(new D3D11Query(this, *pPredicateDesc));
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
|
@ -6,16 +6,7 @@ namespace dxvk {
|
||||
D3D11Query::D3D11Query(
|
||||
D3D11Device* device,
|
||||
const D3D11_QUERY_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_device(device), m_desc(desc),
|
||||
m_d3d10(this, device->GetD3D10Interface()) {
|
||||
Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice();
|
||||
|
||||
@ -308,6 +299,18 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxvkBufferSlice D3D11Query::GetPredicate(DxvkContext* ctx) {
|
||||
std::lock_guard<sync::Spinlock> lock(m_predicateLock);
|
||||
|
||||
if (unlikely(!m_predicate.defined())) {
|
||||
m_predicate = m_device->AllocPredicateSlice();
|
||||
ctx->writePredicate(m_predicate, m_query);
|
||||
}
|
||||
|
||||
return m_predicate;
|
||||
}
|
||||
|
||||
|
||||
UINT64 D3D11Query::GetTimestampQueryFrequency() const {
|
||||
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
|
||||
Rc<DxvkAdapter> adapter = device->adapter();
|
||||
|
@ -17,11 +17,6 @@ namespace dxvk {
|
||||
D3D11Device* device,
|
||||
const D3D11_QUERY_DESC& desc);
|
||||
|
||||
D3D11Query(
|
||||
D3D11Device* device,
|
||||
const D3D11_QUERY_DESC& desc,
|
||||
const DxvkBufferSlice& predicate);
|
||||
|
||||
~D3D11Query();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
@ -44,9 +39,7 @@ namespace dxvk {
|
||||
void* pData,
|
||||
UINT GetDataFlags);
|
||||
|
||||
DxvkBufferSlice GetPredicate() const {
|
||||
return m_predicate;
|
||||
}
|
||||
DxvkBufferSlice GetPredicate(DxvkContext* ctx);
|
||||
|
||||
D3D10Query* GetD3D10Iface() {
|
||||
return &m_d3d10;
|
||||
@ -60,6 +53,7 @@ namespace dxvk {
|
||||
Rc<DxvkGpuQuery> m_query = nullptr;
|
||||
Rc<DxvkGpuEvent> m_event = nullptr;
|
||||
|
||||
sync::Spinlock m_predicateLock;
|
||||
DxvkBufferSlice m_predicate;
|
||||
|
||||
D3D10Query m_d3d10;
|
||||
|
Loading…
Reference in New Issue
Block a user