GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DiligentSamples/Tutorials/Tutorial18_Queries at master · DiligentGraphics/DiligentSamples

Expand file tree

/

Tutorial18_Queries

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

Tutorial18_Queries

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
assets
assets
 
 
src
src
 
 
Animation_Large.gif
Animation_Large.gif
 
 
Animation_Small.gif
Animation_Small.gif
 
 
CMakeLists.txt
CMakeLists.txt
 
 
readme.md
readme.md
 
 

readme.md

Outline

Tutorial18 - Queries

This tutorial demonstrates how to use queries to retrieve various information about the GPU operation, such as the number of primitives rendered, command processing duration, etc.

▶️ Run in the browser

Queries

Queries operate by enclosing a sequence of commands in interest in BeginQuery()/EndQuery() block. Queries are intrinsically asynchronous, which means that the query result can't be accessed immediately, but rather becomes available later after the commands are executed by the GPU. The queries provide tools to check the data availability and retrieve it, see the description of IQuery interface for details.

Checking Query Support

Not all devices support all types of queries. The support of a specific query type is indicated by the corresponding member of DeviceFeatures struct that can be obtained using IRenderDevice::GetDeviceCaps method.

Query Helpers

Applications may choose to use the IQuery interface directly. The engine also provides two helper classes to facilitate the query usage: ScopedQueryHelper should be used for pipeline statistics, occlusion and binary occlusion queries. DurationQueryHelper is designed to measure the duration of a sequence of GPU commands. The class usage is straightforward as the following code example shows:

std::unique_ptr<ScopedQueryHelper>   m_pPipelineStatsQuery;
std::unique_ptr<ScopedQueryHelper>   m_pOcclusionQuery;
std::unique_ptr<DurationQueryHelper> m_pDurationQuery;

// ...

m_pPipelineStatsQuery->Begin(m_pImmediateContext);
m_pOcclusionQuery->Begin(m_pImmediateContext);
m_pDurationQuery->Begin(m_pImmediateContext);

m_pImmediateContext->DrawIndexed(DrawAttrs);

m_pDurationQuery->End(m_pImmediateContext, m_RenderDuration);
m_pOcclusionQuery->End(m_pImmediateContext, &m_OcclusionData, sizeof(m_OcclusionData));
m_pPipelineStatsQuery->End(m_pImmediateContext, &m_PipelineStatsData, sizeof(m_PipelineStatsData));
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.