[d3d11] Implement ID3D11Query1

This commit is contained in:
Philip Rebohle 2019-09-16 15:13:48 +02:00
parent 84c80a4aaf
commit b0f6655b92
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 51 additions and 25 deletions

View File

@ -665,8 +665,7 @@ namespace dxvk {
if (FAILED(hr) || hr == S_FALSE)
return hr;
*ppPredicate = static_cast<D3D11Query*>(d3d11Predicate)->GetD3D10Iface();
*ppPredicate = D3D11Query::FromPredicate(d3d11Predicate)->GetD3D10Iface();
return S_OK;
}
@ -760,7 +759,7 @@ namespace dxvk {
D3D10Query* d3d10Predicate = static_cast<D3D10Query*>(pPredicate);
D3D11Query* d3d11Predicate = d3d10Predicate ? d3d10Predicate->GetD3D11Iface() : nullptr;
m_context->SetPredication(d3d11Predicate, PredicateValue);
m_context->SetPredication(D3D11Query::AsPredicate(d3d11Predicate), PredicateValue);
}
@ -774,7 +773,7 @@ namespace dxvk {
pPredicateValue);
if (ppPredicate != nullptr)
*ppPredicate = d3d11Predicate ? static_cast<D3D11Query*>(d3d11Predicate)->GetD3D10Iface() : nullptr;
*ppPredicate = d3d11Predicate ? D3D11Query::FromPredicate(d3d11Predicate)->GetD3D10Iface() : nullptr;
}

View File

@ -291,7 +291,7 @@ namespace dxvk {
BOOL PredicateValue) {
D3D10DeviceLock lock = LockContext();
auto predicate = static_cast<D3D11Query*>(pPredicate);
auto predicate = D3D11Query::FromPredicate(pPredicate);
m_state.pr.predicateObject = predicate;
m_state.pr.predicateValue = PredicateValue;
@ -325,7 +325,7 @@ namespace dxvk {
D3D10DeviceLock lock = LockContext();
if (ppPredicate != nullptr)
*ppPredicate = m_state.pr.predicateObject.ref();
D3D11Query::AsPredicate(m_state.pr.predicateObject.ref());
if (pPredicateValue != nullptr)
*pPredicateValue = m_state.pr.predicateValue;

View File

@ -977,14 +977,19 @@ namespace dxvk {
ID3D11Query** ppQuery) {
InitReturnPtr(ppQuery);
if (pQueryDesc == nullptr)
if (!pQueryDesc)
return E_INVALIDARG;
if (ppQuery == nullptr)
D3D11_QUERY_DESC1 desc;
desc.Query = pQueryDesc->Query;
desc.MiscFlags = pQueryDesc->MiscFlags;
desc.ContextType = D3D11_CONTEXT_TYPE_ALL;
if (!ppQuery)
return S_FALSE;
try {
*ppQuery = ref(new D3D11Query(this, *pQueryDesc));
*ppQuery = ref(new D3D11Query(this, desc));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
@ -998,19 +1003,25 @@ namespace dxvk {
ID3D11Predicate** ppPredicate) {
InitReturnPtr(ppPredicate);
if (pPredicateDesc == nullptr)
if (!pPredicateDesc)
return E_INVALIDARG;
if (pPredicateDesc->Query != D3D11_QUERY_OCCLUSION_PREDICATE) {
D3D11_QUERY_DESC1 desc;
desc.Query = pPredicateDesc->Query;
desc.MiscFlags = pPredicateDesc->MiscFlags;
desc.ContextType = D3D11_CONTEXT_TYPE_ALL;
if (desc.Query != D3D11_QUERY_OCCLUSION_PREDICATE) {
Logger::warn(str::format("D3D11: Unhandled predicate type: ", pPredicateDesc->Query));
return E_INVALIDARG;
}
if (ppPredicate == nullptr)
if (!ppPredicate)
return S_FALSE;
try {
*ppPredicate = ref(new D3D11Query(this, *pPredicateDesc));
*ppPredicate = D3D11Query::AsPredicate(
ref(new D3D11Query(this, desc)));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());

View File

@ -4,8 +4,8 @@
namespace dxvk {
D3D11Query::D3D11Query(
D3D11Device* device,
const D3D11_QUERY_DESC& desc)
D3D11Device* device,
const D3D11_QUERY_DESC1& desc)
: m_device(device), m_desc(desc),
m_state(D3D11_VK_QUERY_INITIAL),
m_d3d10(this, device->GetD3D10Interface()) {
@ -94,7 +94,8 @@ namespace dxvk {
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Asynchronous)
|| riid == __uuidof(ID3D11Query)) {
|| riid == __uuidof(ID3D11Query)
|| riid == __uuidof(ID3D11Query1)) {
*ppvObject = ref(this);
return S_OK;
}
@ -109,7 +110,7 @@ namespace dxvk {
if (m_desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE) {
if (riid == __uuidof(ID3D11Predicate)) {
*ppvObject = ref(this);
*ppvObject = AsPredicate(ref(this));
return S_OK;
}
@ -170,7 +171,13 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11Query::GetDesc(D3D11_QUERY_DESC *pDesc) {
void STDMETHODCALLTYPE D3D11Query::GetDesc(D3D11_QUERY_DESC* pDesc) {
pDesc->Query = m_desc.Query;
pDesc->MiscFlags = m_desc.MiscFlags;
}
void STDMETHODCALLTYPE D3D11Query::GetDesc1(D3D11_QUERY_DESC1* pDesc) {
*pDesc = m_desc;
}

View File

@ -15,14 +15,14 @@ namespace dxvk {
D3D11_VK_QUERY_ENDED,
};
class D3D11Query : public D3D11DeviceChild<ID3D11Predicate> {
class D3D11Query : public D3D11DeviceChild<ID3D11Query1> {
constexpr static uint32_t MaxGpuQueries = 2;
constexpr static uint32_t MaxGpuEvents = 1;
public:
D3D11Query(
D3D11Device* device,
const D3D11_QUERY_DESC& desc);
D3D11Device* device,
const D3D11_QUERY_DESC1& desc);
~D3D11Query();
@ -31,12 +31,13 @@ namespace dxvk {
void** ppvObject) final;
void STDMETHODCALLTYPE GetDevice(
ID3D11Device **ppDevice) final;
ID3D11Device** ppDevice) final;
UINT STDMETHODCALLTYPE GetDataSize();
void STDMETHODCALLTYPE GetDesc(
D3D11_QUERY_DESC *pDesc) final;
void STDMETHODCALLTYPE GetDesc(D3D11_QUERY_DESC* pDesc) final;
void STDMETHODCALLTYPE GetDesc1(D3D11_QUERY_DESC1* pDesc) final;
void Begin(DxvkContext* ctx);
@ -68,11 +69,19 @@ namespace dxvk {
D3D10Query* GetD3D10Iface() {
return &m_d3d10;
}
static ID3D11Predicate* AsPredicate(ID3D11Query* pQuery) {
return static_cast<ID3D11Predicate*>(pQuery);
}
static D3D11Query* FromPredicate(ID3D11Predicate* pPredicate) {
return static_cast<D3D11Query*>(static_cast<ID3D11Query*>(pPredicate));
}
private:
D3D11Device* const m_device;
D3D11_QUERY_DESC m_desc;
D3D11_QUERY_DESC1 m_desc;
D3D11_VK_QUERY_STATE m_state;