r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult
r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult
#Overview
name: r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Multiplier to apply to the number of tiles in the quadtree at LOD0. The derived number is how many slots for water quad mesh instance data are allocated. Default: 1.0, Min: 0.0, Max: 8.0
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult is to control the allocation of instance data slots for water quad mesh rendering in Unreal Engine 5’s water system. This setting variable is specifically used for the GPU-based quadtree implementation of water meshes.
This setting variable is primarily used in the Water plugin, which is part of Unreal Engine 5’s rendering system. Based on the callsites, it’s clear that this variable is utilized within the WaterMeshSceneProxy component of the Water plugin.
The value of this variable is set through a console variable (CVarWaterMeshGPUQuadInstanceDataAllocMult) with a default value of 1.0. It can be adjusted at runtime through console commands or programmatically.
This variable interacts closely with the water quadtree system. It’s used as a multiplier to determine the number of instance data slots allocated for water quad mesh rendering. The actual number of slots is calculated based on the maximum leaf count of the water quadtree, the number of visible views, and this multiplier.
Developers should be aware that:
- This variable directly affects memory allocation for water rendering.
- It has a valid range from 0.0 to 8.0, with 1.0 being the default.
- Increasing this value will allocate more memory for water mesh instances, which might improve rendering quality or performance at the cost of increased memory usage.
Best practices when using this variable include:
- Only adjust it if you’re experiencing issues with water rendering quality or performance.
- Monitor memory usage when increasing this value, especially on platforms with limited memory.
- Test thoroughly across different scenarios and hardware configurations when modifying this value.
Regarding the associated variable CVarWaterMeshGPUQuadInstanceDataAllocMult: This is the actual console variable that controls the setting. It’s defined using TAutoConsoleVariable, which allows it to be adjusted at runtime. The variable is marked as render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed and modified from the render thread.
When using this associated variable, developers should:
- Access its value using GetValueOnRenderThread() when in render thread context.
- Be aware that changes to this variable will take effect on the next frame or water mesh update.
- Consider exposing this setting in a user-friendly manner if it’s something that needs frequent adjustment during development or gameplay.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:70
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadInstanceDataAllocMult(
TEXT("r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult"), 1.0f,
TEXT("Multiplier to apply to the number of tiles in the quadtree at LOD0. The derived number is how many slots for water quad mesh instance data are allocated. Default: 1.0, Min: 0.0, Max: 8.0"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCullingMaxQueries(
TEXT("r.Water.WaterMesh.OcclusionCulling.MaxQueries"), 256,
TEXT("Maximum number of occlusion queries for the CPU water quadtree nodes. Using fewer queries than nodes will result in coarser culling."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshGPUQuadInstanceDataAllocMult
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:69
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadInstanceDataAllocMult(
TEXT("r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult"), 1.0f,
TEXT("Multiplier to apply to the number of tiles in the quadtree at LOD0. The derived number is how many slots for water quad mesh instance data are allocated. Default: 1.0, Min: 0.0, Max: 8.0"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCullingMaxQueries(
TEXT("r.Water.WaterMesh.OcclusionCulling.MaxQueries"), 256,
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:443
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
const int32 NumIndirectDrawCalls = NumBucketsIndirect * NumVisibleViews;
const int32 LeafCountUpperBound = WaterQuadTree.GetMaxLeafCount() * NumVisibleViews;
const int32 NumInstanceDataSlots = FMath::Max(1, static_cast<int32>(LeafCountUpperBound * FMath::Clamp(CVarWaterMeshGPUQuadInstanceDataAllocMult.GetValueOnRenderThread(), 0.0f, 8.0f)));
// Allocate buffers for the indirect draws
struct FIndirectDrawResources
{
TRefCountPtr<FRDGPooledBuffer> IndirectArgs;
TRefCountPtr<FRDGPooledBuffer> InstanceDataOffsets;