# "RenderQuery Result" What is it?

**URL:** <https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754>\
**Category:** World Creation\
**Tags:** Debugging, draw, Optimization, unreal-engine, Performance, Foliage, question\
**Created:** [February 2, 2017, 7:35pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754 "2017-02-02T19:35:04Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soviet03](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Soviet03](https://forums.unrealengine.com/u/Soviet03)\
**Post date:** [February 2, 2017, 7:35pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/1 "2017-02-02T19:35:04Z")

</div>

This is under Render Thread, FDrawscenecommand, RenderViewFamily, InitViews, View Visibility, Occlusion Cull, Fetch Visibility for primitives, and there it is “RenderQuery Result” and it’s costing me 8ms.

What is it, and how do I go about optimizing the problem? My scene is fairly simple and consists of a small landscape with a material and grass as Foliage, I assume it has something to do with the grass.

 ![124702-shader+complexity.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/c/88c39d1cd66c2e28eb11baa90c10380b80ad84a8.png)

HZBOcclusion is turned off, when enabled my FPS/GPU performance is reduced but DRAW no longer matches GPU times. GPU bottleneck instead?

[Specs i7 4790k, 16gb RAM, FuryX]

---

<div class="post-metadata">

**Author:** ![TheMainStark](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/themainstark/32/1120943_2.png) [@TheMainStark](https://forums.unrealengine.com/u/TheMainStark)\
**Post date:** [November 8, 2017, 7:01pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/2 "2017-11-08T19:01:54Z")

</div>

Did you ever find a solution? I have a similar issue with my game on lower end PCs, RenderQuery Result is costing a wopping 28-30ms.

---

<div class="post-metadata">

**Author:** ![Zhao\_Qingyou](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zhao\_Qingyou](https://forums.unrealengine.com/u/Zhao_Qingyou)\
**Post date:** [January 24, 2018, 9:34am UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/3 "2018-01-24T09:34:07Z")

</div>

When you disable HZB occlusion, the engine falls back to the GPU occlusion query, which "renders“ the bounding box of each primitive in scene to the GPU pipeline to see how many pixels of the primitive will end up on the scene. If the pixel count is 0, the primitive is treated as occluded. There might be some stalls related to the queries.

HZB is GHZBOcclusion and the platform by this line  
bool bHZBOcclusion = (!IsOpenGLPlatform(GShaderPlatformForFeatureLevel[Scene-\>GetFeatureLevel()]) && GHZBOcclusion) || (GHZBOcclusion == 2);  
in the function  
static int32 OcclusionCull(FRHICommandListImmediate& RHICmdList, const FScene\* Scene, FViewInfo& View)  
located in SceneVisibility.cpp

For more information on GPU occlusion, you can check out this page  
[http://developer.download.nvidia.com/books/HTML/gpugems/gpugems\_ch29.html](http://developer.download.nvidia.com/books/HTML/gpugems/gpugems_ch29.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e168914d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e168914d](https://forums.unrealengine.com/u/anonymous_user_e168914d)\
**Post date:** [December 12, 2018, 6:48pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/4 "2018-12-12T18:48:14Z")

</div>

RenderQuery Result is when the render thread stalls waiting for the GPU to finish the Occlusion Query, and return the results to the render thread, so that it knows what to render.

At the same time, the game thread is stalled waiting for the render thread.

This can be turned on or off with the console command

r.AllowOcclusionQueries

0 - off  
1 - on

---

<div class="post-metadata">

**Author:** ![Rumbleball](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rumbleball](https://forums.unrealengine.com/u/Rumbleball)\
**Post date:** [November 19, 2019, 2:19pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/5 "2019-11-19T14:19:04Z")

</div>

But why does it take so god ■■■■ long? We have a basically empty scene. A cube to stand on, 2 lights, no background, 2 quite complex widgets placed in widget components (which should only render as plane with a material on it), 2 VR Controller. Neither is there much in the scene nor are these objects complex. Still we have 3ms…6ms

 ![292631-unbenannt.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/a/eaa034c2836527ba2d350f5e5e788a483b3968eb.png)

In 4.19 everything was fine, even with mesh data of 3.000.000 vertices. Since update to 4.23 (we were forced to cause of HUGE memory leak when switching map), we trouble with that thing…

Edit: r.AllowOcclusionCulling=0 btw (shown by console). Though i noticed that the engine seems to have trouble reading in our config files, as something else does not work as well, but even if it has trouble, I would asume the console shows the true value.

Edit2: After more investigation:  
**UE 4.23**  
the stat appears in D3D11Query.cpp FD3D11DynamicRHI::GetQueryData as STAT\_RenderQueryResultTime.  
From Unreal 4.19 to 4.23 they made some changes to that file, I gues cause of the new Render Graph.  
Changing r.AllowOcclusionQuery

- to 0: Causes FD3D11RenderQueryBatcher::PerFrameFlush to call uppon GetQueryData with bWait=true
- to 1: Causes FD3D11RenderQueryBatcher::PollQueryResults to call uppon GetQueryData with bWait=false

So setting it to 0 will cause waits, which is the huge time shown by STAT\_RenderQueryResultTime ( **RenderQuery Result** ). Setting it to 1 will not cause the waits and **RenderQuery Result** will not appear. This seems to be the wrong way round?!? I’ll make a bug report and see where it goes.

---

<div class="post-metadata">

**Author:** ![Rumbleball](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rumbleball](https://forums.unrealengine.com/u/Rumbleball)\
**Post date:** [November 19, 2019, 10:19pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/6 "2019-11-19T22:19:27Z")

</div>

Comparing it to Unreal 4.19, bWait=true in both cases.

```
bool FD3D11DynamicRHI::GetQueryData(ID3D11Query* Query,void* Data,SIZE_T DataSize,bool bWait, ERenderQueryType QueryType)
{
	// Request the data from the query.
	HRESULT Result = Direct3DDeviceIMContext->GetData(Query,Data,DataSize,0);

	// Isn't the query finished yet, and can we wait for it?
	if ( Result == S_FALSE && bWait )
	{
...

```

The difference is that in 4.19 **Result** is always **S\_OK** (in my small test map) and the wait loop is not entered.

Are there multiple issues?!?!?

---

<div class="post-metadata">

**Author:** ![Rumbleball](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rumbleball](https://forums.unrealengine.com/u/Rumbleball)\
**Post date:** [December 3, 2019, 4:29pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/7 "2019-12-03T16:29:09Z")

</div>

Tracking link:

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-85356)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

---

<div class="post-metadata">

**Author:** ![Jonas\_Molgaard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonas\_Molgaard](https://forums.unrealengine.com/u/Jonas_Molgaard)\
**Post date:** [June 9, 2020, 6:43pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/8 "2020-06-09T18:43:31Z")

</div>

As far as i can tell, the issue has been targeted 4.26, but what if you can’t wait for that (ie. your game is scheduled for release within a few months?) Does there exist an easy hacky fix?

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [June 15, 2020, 10:47pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/9 "2020-06-15T22:47:21Z")

</div>

This isn’t a bug. You’re asking the graphics API to push all the geometry that’s been rendered already, out to the GPU, wait for the GPU to finish (at least up to this point,) and then read the result back. The call itself doesn’t take any time – waiting for the GPU (which generally runs asynchronously, and behind the CPU,) to “catch up” to this point in the stream, is what’s “taking the time.”

You should measure actual frame rate. If the frame rate doesn’t change, then what’s happening is that a stall that would happen somewhere else (waiting on vsync, for example) is now bubbled around in the pipeline to instead happen (at least partially) at your render query. If the frame rate really does go down, then you’re asking for the visibility too soon after the query has been issued, and causing an actual pipeline stall, rather than just a synchronization point.

---

<div class="post-metadata">

**Author:** ![Jonas\_Molgaard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonas\_Molgaard](https://forums.unrealengine.com/u/Jonas_Molgaard)\
**Post date:** [June 16, 2020, 7:58am UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/10 "2020-06-16T07:58:40Z")

</div>

@jwatte I realize running with r.AllowOcclusionQueries=0 is bad, and that’s not the solution im looking for personally. Your suggestion with a sort of stall, that ends up getting “bubbled” around sounds plausible. Also given the fact that it does not stall always (for me), only about every 30-40fram. In the profiler i can see FDrawSceneCommand spike coming from a call to DeleteResources, which normally take about 0.1ms, and at the spike time, ends up at around 3-7ms. When im home infront of PC, i will post a screenshot of my scenario/profile.  
EDIT: Actually just reviewed the picture from @Rumbleball below, and it’s the excact same scenario i have.

---

<div class="post-metadata">

**Author:** ![zgzg2020](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zgzg2020](https://forums.unrealengine.com/u/zgzg2020)\
**Post date:** [February 15, 2021, 6:51am UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/11 "2021-02-15T06:51:56Z")

</div>

Did you find a workaround?

---

<div class="post-metadata">

**Author:** ![Rumbleball](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rumbleball](https://forums.unrealengine.com/u/Rumbleball)\
**Post date:** [February 15, 2021, 7:28am UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/12 "2021-02-15T07:28:15Z")

</div>

In the end we made a custom engine anyway. Used that to change the code. Think is just have set bWait= false

---

<div class="post-metadata">

**Author:** ![Jonas\_Molgaard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonas\_Molgaard](https://forums.unrealengine.com/u/Jonas_Molgaard)\
**Post date:** [February 15, 2021, 8:19am UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/13 "2021-02-15T08:19:33Z")

</div>

r.HZBOcclusion=1 in DefaultEngine.ini fixes the issue, but may cause other issues. For now i can see it solves the hitches though. Let me know it it solves the issue for you.

Backlogged issue [Unreal Engine Issues and Bug Tracker (UE-85356)](https://issues.unrealengine.com/issue/UE-85356)

---

<div class="post-metadata">

**Author:** ![Rectus\_SA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rectus\_SA](https://forums.unrealengine.com/u/Rectus_SA)\
**Post date:** [April 11, 2021, 1:50pm UTC](https://forums.unrealengine.com/t/renderquery-result-what-is-it/383754/14 "2021-04-11T13:50:28Z")

</div>

Seeing the same issue. It appears with regularity, but not every frame. I’m not sure it’s caused by the occlusion queries themselves, since turning them off seems to move the problem. I’m guessing something is stalling the GPU and delaying whatever command the thread is waiting on.

It increases the render time enough that it throws off the running start rendering in SteamVR, which is probably why it’s causing hitching.
