From 0d9bd79e8fd4d57e1a723ca6b6a45efec2b42872 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 10 Jun 2021 00:30:19 -0700 Subject: Support timestamp queries in `gfx`. (#1880) * Support timestamp queries in `gfx`. * Fix tab Co-authored-by: Yong He --- tools/gfx/debug-layer.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tools/gfx/debug-layer.cpp') diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp index 26e55ca7e..13875d6ec 100644 --- a/tools/gfx/debug-layer.cpp +++ b/tools/gfx/debug-layer.cpp @@ -140,6 +140,8 @@ SLANG_GFX_DEBUG_GET_INTERFACE_IMPL(ShaderObject) SLANG_GFX_DEBUG_GET_INTERFACE_IMPL(ShaderProgram) SLANG_GFX_DEBUG_GET_INTERFACE_IMPL(Swapchain) SLANG_GFX_DEBUG_GET_INTERFACE_IMPL(TransientResourceHeap) +SLANG_GFX_DEBUG_GET_INTERFACE_IMPL(QueryPool) + #undef SLANG_GFX_DEBUG_GET_INTERFACE_IMPL #undef SLANG_GFX_DEBUG_GET_INTERFACE_IMPL_PARENT @@ -477,6 +479,16 @@ const DeviceInfo& DebugDevice::getDeviceInfo() const return baseObject->getDeviceInfo(); } +Result DebugDevice::createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) +{ + SLANG_GFX_API_FUNC; + RefPtr result = new DebugQueryPool(); + result->desc = desc; + SLANG_RETURN_ON_FAIL(baseObject->createQueryPool(desc, result->baseObject.writeRef())); + returnComPtr(outPool, result); + return SLANG_OK; +} + IResource::Type DebugBufferResource::getType() { SLANG_GFX_API_FUNC; @@ -624,6 +636,12 @@ void DebugComputeCommandEncoder::dispatchCompute(int x, int y, int z) baseObject->dispatchCompute(x, y, z); } +void DebugComputeCommandEncoder::writeTimestamp(IQueryPool* pool, SlangInt index) +{ + SLANG_GFX_API_FUNC; + baseObject->writeTimestamp(static_cast(pool)->baseObject, index); +} + void DebugRenderCommandEncoder::endEncoding() { SLANG_GFX_API_FUNC; @@ -706,12 +724,24 @@ void DebugRenderCommandEncoder::setStencilReference(uint32_t referenceValue) return baseObject->setStencilReference(referenceValue); } +void DebugRenderCommandEncoder::writeTimestamp(IQueryPool* pool, SlangInt index) +{ + SLANG_GFX_API_FUNC; + baseObject->writeTimestamp(static_cast(pool)->baseObject, index); +} + void DebugResourceCommandEncoder::endEncoding() { SLANG_GFX_API_FUNC; baseObject->endEncoding(); } +void DebugResourceCommandEncoder::writeTimestamp(IQueryPool* pool, SlangInt index) +{ + SLANG_GFX_API_FUNC; + baseObject->writeTimestamp(static_cast(pool)->baseObject, index); +} + void DebugResourceCommandEncoder::copyBuffer( IBufferResource* dst, size_t dstOffset, @@ -977,4 +1007,11 @@ Result DebugRootShaderObject::setSpecializationArgs( return baseObject->setSpecializationArgs(offset, args, count); } +Result DebugQueryPool::getResult(SlangInt index, SlangInt count, uint64_t* data) +{ + if (index < 0 || index + count >= desc.count) + GFX_DIAGNOSE_ERROR("index is out of bounds."); + return baseObject->getResult(index, count, data); +} + } // namespace gfx -- cgit v1.2.3