mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +01:00
[d3d10] Implement D3D10Query
This commit is contained in:
parent
2863a09c5d
commit
2af07c5faf
@ -536,16 +536,46 @@ namespace dxvk {
|
||||
HRESULT STDMETHODCALLTYPE D3D10Device::CreateQuery(
|
||||
const D3D10_QUERY_DESC* pQueryDesc,
|
||||
ID3D10Query** ppQuery) {
|
||||
Logger::err("D3D10Device::CreateQuery: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppQuery);
|
||||
|
||||
D3D11_QUERY_DESC d3d11Desc;
|
||||
d3d11Desc.Query = D3D11_QUERY(pQueryDesc->Query);
|
||||
d3d11Desc.MiscFlags = pQueryDesc->MiscFlags;
|
||||
|
||||
ID3D11Query* d3d11Query = nullptr;
|
||||
HRESULT hr = m_device->CreateQuery(&d3d11Desc,
|
||||
ppQuery ? &d3d11Query : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppQuery != nullptr) {
|
||||
*ppQuery = static_cast<D3D11Query*>(d3d11Query)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Device::CreatePredicate(
|
||||
const D3D10_QUERY_DESC* pPredicateDesc,
|
||||
ID3D10Predicate** ppPredicate) {
|
||||
Logger::err("D3D10Device::CreatePredicate: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppPredicate);
|
||||
|
||||
D3D11_QUERY_DESC d3d11Desc;
|
||||
d3d11Desc.Query = D3D11_QUERY(pPredicateDesc->Query);
|
||||
d3d11Desc.MiscFlags = pPredicateDesc->MiscFlags;
|
||||
|
||||
ID3D11Predicate* d3d11Predicate = nullptr;
|
||||
HRESULT hr = m_device->CreatePredicate(&d3d11Desc,
|
||||
ppPredicate ? &d3d11Predicate : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppPredicate != nullptr) {
|
||||
*ppPredicate = static_cast<D3D11Query*>(d3d11Predicate)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
97
src/d3d10/d3d10_query.cpp
Normal file
97
src/d3d10/d3d10_query.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "d3d10_query.h"
|
||||
|
||||
#include "../d3d11/d3d11_device.h"
|
||||
#include "../d3d11/d3d11_context.h"
|
||||
#include "../d3d11/d3d11_query.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Query::QueryInterface(
|
||||
REFIID riid,
|
||||
void** ppvObject) {
|
||||
return m_d3d11->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE D3D10Query::AddRef() {
|
||||
return m_d3d11->AddRef();
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE D3D10Query::Release() {
|
||||
return m_d3d11->Release();
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10Query::GetDevice(
|
||||
ID3D10Device** ppDevice) {
|
||||
GetD3D10Device(m_d3d11, ppDevice);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Query::GetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT* pDataSize,
|
||||
void* pData) {
|
||||
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Query::SetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT DataSize,
|
||||
const void* pData) {
|
||||
return m_d3d11->SetPrivateData(guid, DataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Query::SetPrivateDataInterface(
|
||||
REFGUID guid,
|
||||
const IUnknown* pData) {
|
||||
return m_d3d11->SetPrivateDataInterface(guid, pData);
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10Query::Begin() {
|
||||
Com<ID3D11DeviceContext> ctx;
|
||||
GetD3D11Context(m_d3d11, &ctx);
|
||||
|
||||
ctx->Begin(m_d3d11);
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10Query::End() {
|
||||
Com<ID3D11DeviceContext> ctx;
|
||||
GetD3D11Context(m_d3d11, &ctx);
|
||||
|
||||
ctx->End(m_d3d11);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10Query::GetData(
|
||||
void* pData,
|
||||
UINT DataSize,
|
||||
UINT GetDataFlags) {
|
||||
Com<ID3D11DeviceContext> ctx;
|
||||
GetD3D11Context(m_d3d11, &ctx);
|
||||
|
||||
return ctx->GetData(m_d3d11,
|
||||
pData, DataSize, GetDataFlags);
|
||||
}
|
||||
|
||||
|
||||
UINT STDMETHODCALLTYPE D3D10Query::GetDataSize() {
|
||||
return m_d3d11->GetDataSize();
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10Query::GetDesc(
|
||||
D3D10_QUERY_DESC* pDesc) {
|
||||
D3D11_QUERY_DESC d3d11Desc;
|
||||
m_d3d11->GetDesc(&d3d11Desc);
|
||||
|
||||
pDesc->Query = D3D10_QUERY(d3d11Desc.Query);
|
||||
pDesc->MiscFlags = d3d11Desc.MiscFlags;
|
||||
}
|
||||
|
||||
}
|
67
src/d3d10/d3d10_query.h
Normal file
67
src/d3d10/d3d10_query.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d10_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11Device;
|
||||
class D3D11DeviceContext;
|
||||
class D3D11Query;
|
||||
|
||||
class D3D10Query : public ID3D10Predicate {
|
||||
|
||||
public:
|
||||
|
||||
D3D10Query(D3D11Query* pParent)
|
||||
: m_d3d11(pParent) { }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
REFIID riid,
|
||||
void** ppvObject);
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice(
|
||||
ID3D10Device** ppDevice);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT* pDataSize,
|
||||
void* pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT DataSize,
|
||||
const void* pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
|
||||
REFGUID guid,
|
||||
const IUnknown* pData);
|
||||
|
||||
void STDMETHODCALLTYPE Begin();
|
||||
|
||||
void STDMETHODCALLTYPE End();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetData(
|
||||
void* pData,
|
||||
UINT DataSize,
|
||||
UINT GetDataFlags);
|
||||
|
||||
UINT STDMETHODCALLTYPE GetDataSize();
|
||||
|
||||
void STDMETHODCALLTYPE GetDesc(
|
||||
D3D10_QUERY_DESC* pDesc);
|
||||
|
||||
D3D11Query* GetD3D11Iface() {
|
||||
return m_d3d11;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
D3D11Query* m_d3d11;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ namespace dxvk {
|
||||
D3D11Query::D3D11Query(
|
||||
D3D11Device* device,
|
||||
const D3D11_QUERY_DESC& desc)
|
||||
: m_device(device), m_desc(desc) {
|
||||
: m_device(device), m_desc(desc), m_d3d10(this) {
|
||||
switch (m_desc.Query) {
|
||||
case D3D11_QUERY_EVENT:
|
||||
m_event = new DxvkEvent();
|
||||
@ -58,12 +58,26 @@ namespace dxvk {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ID3D11Predicate)
|
||||
&& m_desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE) {
|
||||
*ppvObject = ref(this);
|
||||
if (riid == __uuidof(IUnknown)
|
||||
|| riid == __uuidof(ID3D10DeviceChild)
|
||||
|| riid == __uuidof(ID3D10Asynchronous)
|
||||
|| riid == __uuidof(ID3D10Query)) {
|
||||
*ppvObject = ref(&m_d3d10);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (m_desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE) {
|
||||
if (riid == __uuidof(ID3D10Predicate)) {
|
||||
*ppvObject = ref(this);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ID3D10Predicate)) {
|
||||
*ppvObject = ref(&m_d3d10);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Logger::warn("D3D11Query: Unknown interface query");
|
||||
Logger::warn(str::format(riid));
|
||||
return E_NOINTERFACE;
|
||||
|
@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d11_device_child.h"
|
||||
|
||||
#include "../dxvk/dxvk_event.h"
|
||||
#include "../dxvk/dxvk_query.h"
|
||||
|
||||
#include "../d3d10/d3d10_query.h"
|
||||
|
||||
#include "d3d11_device_child.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11Query : public D3D11DeviceChild<ID3D11Predicate> {
|
||||
@ -43,6 +45,10 @@ namespace dxvk {
|
||||
void* pData,
|
||||
UINT GetDataFlags);
|
||||
|
||||
D3D10Query* GetD3D10Iface() {
|
||||
return &m_d3d10;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
D3D11Device* const m_device;
|
||||
@ -53,6 +59,8 @@ namespace dxvk {
|
||||
|
||||
uint32_t m_revision = 0;
|
||||
|
||||
D3D10Query m_d3d10;
|
||||
|
||||
UINT64 GetTimestampQueryFrequency() const;
|
||||
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ d3d10_src = [
|
||||
'../d3d10/d3d10_depth_stencil.cpp',
|
||||
'../d3d10/d3d10_device.cpp',
|
||||
'../d3d10/d3d10_input_layout.cpp',
|
||||
'../d3d10/d3d10_query.cpp',
|
||||
'../d3d10/d3d10_rasterizer.cpp',
|
||||
'../d3d10/d3d10_sampler.cpp',
|
||||
'../d3d10/d3d10_texture.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user