diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-06-30 11:09:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-30 11:09:45 -0700 |
| commit | 5eee6b03c391d0bb6ed0ded2d8d91c2e525fdb97 (patch) | |
| tree | 0d47d3ebc385699ff195c8a19400dd3780107667 /tools/gfx/d3d11/d3d11-query.cpp | |
| parent | abc100f81d4b22229105f9ed569a7efafc653a3a (diff) | |
Split render-d3d11.cpp into smaller files (#2307)
* render-d3d11 split, does not compile
* Compiles but unit tests failing
* ran premake.bat
* Readded constructor code that was accidentally removed
Diffstat (limited to 'tools/gfx/d3d11/d3d11-query.cpp')
| -rw-r--r-- | tools/gfx/d3d11/d3d11-query.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/gfx/d3d11/d3d11-query.cpp b/tools/gfx/d3d11/d3d11-query.cpp new file mode 100644 index 000000000..37b8ddc25 --- /dev/null +++ b/tools/gfx/d3d11/d3d11-query.cpp @@ -0,0 +1,55 @@ +// d3d11-query.cpp +#include "d3d11-query.h" + +namespace gfx +{ + +using namespace Slang; + +namespace d3d11 +{ + +Result QueryPoolImpl::init(const IQueryPool::Desc& desc, DeviceImpl* device) +{ + m_device = device; + m_queryDesc.MiscFlags = 0; + switch (desc.type) + { + case QueryType::Timestamp: + m_queryDesc.Query = D3D11_QUERY_TIMESTAMP; + break; + default: + return SLANG_E_INVALID_ARG; + } + m_queries.setCount(desc.count); + return SLANG_OK; +} + +ID3D11Query* QueryPoolImpl::getQuery(SlangInt index) +{ + if (!m_queries[index]) + m_device->m_device->CreateQuery(&m_queryDesc, m_queries[index].writeRef()); + return m_queries[index].get(); +} + +SLANG_NO_THROW Result SLANG_MCALL QueryPoolImpl::getResult( + GfxIndex queryIndex, GfxCount count, uint64_t* data) +{ + D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData; + while (S_OK != m_device->m_immediateContext->GetData( + m_device->m_disjointQuery, &disjointData, sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT), 0)) + { + Sleep(1); + } + m_device->m_info.timestampFrequency = disjointData.Frequency; + + for (SlangInt i = 0; i < count; i++) + { + SLANG_RETURN_ON_FAIL(m_device->m_immediateContext->GetData( + m_queries[queryIndex + i], data + i, sizeof(uint64_t), 0)); + } + return SLANG_OK; +} + +} // namespace d3d11 +} // namespace gfx |
