mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[d3d11] Track query state correctly
Not sure if any game actually needs this, but we should avoid sending bogus commands to the backend when the app sends bogus commands to us.
This commit is contained in:
parent
364ae7270d
commit
ca717eeb62
@ -7,6 +7,7 @@ namespace dxvk {
|
||||
D3D11Device* device,
|
||||
const D3D11_QUERY_DESC& desc)
|
||||
: m_device(device), m_desc(desc),
|
||||
m_state(D3D11_VK_QUERY_INITIAL),
|
||||
m_d3d10(this, device->GetD3D10Interface()) {
|
||||
Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice();
|
||||
|
||||
@ -171,6 +172,9 @@ namespace dxvk {
|
||||
|
||||
|
||||
void D3D11Query::Begin(DxvkContext* ctx) {
|
||||
if (unlikely(m_state == D3D11_VK_QUERY_BEGUN))
|
||||
return;
|
||||
|
||||
switch (m_desc.Query) {
|
||||
case D3D11_QUERY_EVENT:
|
||||
case D3D11_QUERY_TIMESTAMP:
|
||||
@ -180,6 +184,8 @@ namespace dxvk {
|
||||
default:
|
||||
ctx->beginQuery(m_query);
|
||||
}
|
||||
|
||||
m_state = D3D11_VK_QUERY_BEGUN;
|
||||
}
|
||||
|
||||
|
||||
@ -197,11 +203,16 @@ namespace dxvk {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (unlikely(m_state != D3D11_VK_QUERY_BEGUN))
|
||||
return;
|
||||
|
||||
ctx->endQuery(m_query);
|
||||
}
|
||||
|
||||
if (m_predicate.defined())
|
||||
ctx->writePredicate(m_predicate, m_query);
|
||||
|
||||
m_state = D3D11_VK_QUERY_ENDED;
|
||||
}
|
||||
|
||||
|
||||
@ -305,6 +316,9 @@ namespace dxvk {
|
||||
if (unlikely(m_desc.Query != D3D11_QUERY_OCCLUSION_PREDICATE))
|
||||
return DxvkBufferSlice();
|
||||
|
||||
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);
|
||||
|
@ -9,6 +9,12 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
enum D3D11_VK_QUERY_STATE : uint32_t {
|
||||
D3D11_VK_QUERY_INITIAL,
|
||||
D3D11_VK_QUERY_BEGUN,
|
||||
D3D11_VK_QUERY_ENDED,
|
||||
};
|
||||
|
||||
class D3D11Query : public D3D11DeviceChild<ID3D11Predicate> {
|
||||
|
||||
public:
|
||||
@ -49,6 +55,8 @@ namespace dxvk {
|
||||
|
||||
D3D11Device* const m_device;
|
||||
D3D11_QUERY_DESC m_desc;
|
||||
|
||||
D3D11_VK_QUERY_STATE m_state;
|
||||
|
||||
Rc<DxvkGpuQuery> m_query = nullptr;
|
||||
Rc<DxvkGpuEvent> m_event = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user