r.RayTracing.RequireSM6
r.RayTracing.RequireSM6
#Overview
name: r.RayTracing.RequireSM6
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether ray tracing shaders and features should only be available when targetting and running SM6. If disabled, ray tracing shaders will also be available when running in SM5 mode. (default = 1, allow only SM6)
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.RequireSM6 is to control whether ray tracing shaders and features should be restricted to Shader Model 6 (SM6) or also be available in Shader Model 5 (SM5) mode. This setting variable is primarily used for managing ray tracing capabilities across different shader models in Unreal Engine 5.
This setting variable is relied upon by several Unreal Engine subsystems and modules, including:
- The Rendering Core (RenderCore)
- The Windows Target Platform
- The DirectX 12 RHI (D3D12RHI)
- The Engine’s Renderer Settings
- The Vulkan RHI
The value of this variable is set through the console variable system. It’s defined as a static integer (GRayTracingRequireSM6) and exposed as a console variable using FAutoConsoleVariableRef.
This variable interacts with other ray tracing and shader model-related variables and systems. For example, it’s used in conjunction with GMaxRHIShaderPlatform to determine if ray tracing is allowed on the current shader platform.
Developers must be aware that:
- This variable affects shader compilation and availability of ray tracing features.
- Changing this setting may impact performance and compatibility across different hardware configurations.
- It’s marked as read-only and render thread safe, indicating it shouldn’t be changed during runtime.
Best practices when using this variable include:
- Consider the target hardware and performance requirements when deciding whether to restrict ray tracing to SM6.
- Be aware of the implications on shader compilation and ensure all necessary shader formats are available when modifying this setting.
- Test thoroughly on various hardware configurations to ensure compatibility and performance when changing this setting.
- Use this in conjunction with other ray tracing and shader model settings for a comprehensive ray tracing setup.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:915, section: [Android_Vulkan_SM5 DeviceProfile]
- INI Section:
Android_Vulkan_SM5 DeviceProfile
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:71
Scope: file
Source code excerpt:
static int32 GRayTracingRequireSM6 = 1;
static FAutoConsoleVariableRef CVarRayTracingRequireSM6(
TEXT("r.RayTracing.RequireSM6"),
GRayTracingRequireSM6,
TEXT("Whether ray tracing shaders and features should only be available when targetting and running SM6. If disabled, ray tracing shaders will also be available when running in SM5 mode. (default = 1, allow only SM6)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly
);
const uint16 GCubeIndices[12*3] =
#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Public/GenericWindowsTargetPlatform.h:290
Scope (from outer to inner):
file
class class TGenericWindowsTargetPlatform : public TTargetPlatformBase<TProperties>
function virtual void GetRayTracingShaderFormats
Source code excerpt:
OutFormats.AddUnique(FName(TEXT("PCD3D_SM6")));
static IConsoleVariable* RequireSM6CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.RequireSM6"));
const bool bRequireSM6 = RequireSM6CVar && RequireSM6CVar->GetBool();
if (!bRequireSM6)
{
OutFormats.AddUnique(FName(TEXT("PCD3D_SM5")));
}
}
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Adapter.cpp:1090
Scope (from outer to inner):
file
function void FD3D12Adapter::InitializeDevices
Source code excerpt:
if (SUCCEEDED(RootDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &D3D12Caps5, sizeof(D3D12Caps5))))
{
static IConsoleVariable* RequireSM6CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.RequireSM6"));
const bool bRequireSM6 = RequireSM6CVar && RequireSM6CVar->GetBool();
const bool bRayTracingAllowedOnCurrentShaderPlatform = (bRequireSM6 == false) || (GMaxRHIShaderPlatform == SP_PCD3D_SM6);
if (D3D12Caps5.RaytracingTier >= D3D12_RAYTRACING_TIER_1_0
&& GetResourceBindingTier() >= D3D12_RESOURCE_BINDING_TIER_2
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:399
Scope (from outer to inner):
file
function void URendererSettings::CheckForMissingShaderModels
Source code excerpt:
// Don't show the SM6 toasts on non-Windows/Linux platforms to avoid confusion around platform requirements.
#if PLATFORM_WINDOWS || PLATFORM_LINUX
static IConsoleVariable* RayTracingRequireSM6CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.RequireSM6"));
const bool bRayTracingRequireSM6 = bEnableRayTracing && RayTracingRequireSM6CVar && RayTracingRequireSM6CVar->GetBool();
if (GIsEditor && (ShadowMapMethod == EShadowMapMethod::VirtualShadowMaps || bRayTracingRequireSM6))
{
auto CopySM6Format = [](const TCHAR* ShaderFormatName, const TArray<FString>& SrcArray, TArray<FString>& DstArray)
{
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanRHI.cpp:685
Scope (from outer to inner):
file
function void FVulkanDynamicRHI::CreateInstance
Source code excerpt:
if (FVulkanPlatform::SupportsProfileChecks() && GVulkanRayTracingCVar.GetValueOnAnyThread())
{
static IConsoleVariable* RequireSM6CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.RequireSM6"));
const bool bRequireSM6 = RequireSM6CVar && RequireSM6CVar->GetBool();
const bool bRayTracingAllowedOnCurrentShaderPlatform = (bRequireSM6 == false) || (GMaxRHIShaderPlatform == SP_VULKAN_SM6 || IsVulkanMobileSM5Platform(GMaxRHIShaderPlatform));
if (CheckVulkanProfile(GMaxRHIFeatureLevel, true) && bRayTracingAllowedOnCurrentShaderPlatform)
{
// Raytracing is supported, update the required API version