From 5eee6b03c391d0bb6ed0ded2d8d91c2e525fdb97 Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Thu, 30 Jun 2022 11:09:45 -0700 Subject: 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 --- tools/gfx/d3d11/d3d11-query.cpp | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tools/gfx/d3d11/d3d11-query.cpp (limited to 'tools/gfx/d3d11/d3d11-query.cpp') 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 -- cgit v1.2.3