Add ShaderProfileFeatures for more expendable shader feature sets

This commit is contained in:
Wojtek Figat
2026-03-04 16:55:04 +01:00
parent aff8090adb
commit ceebc68d18
12 changed files with 121 additions and 49 deletions

View File

@@ -147,6 +147,37 @@ API_ENUM() enum class ShaderProfile
const Char* ToString(ShaderProfile value);
/// <summary>
/// Shader profile feature flags. Defines a set of features supported by a shader profile.
/// </summary>
API_ENUM() enum class ShaderProfileFeatures
{
/// <summary>
/// Nothing.
/// </summary>
None = 0,
/// <summary>
/// Compute shaders are supported.
/// </summary>
ComputeShaders = 1,
/// <summary>
/// Geometry shaders are supported.
/// </summary>
GeometryShaders = 2,
/// <summary>
/// Tessellation shaders are supported (Hull and Domain).
/// </summary>
TessellationShaders = 4,
API_ENUM(Attributes = "HideInEditor")
MAX
};
DECLARE_ENUM_OPERATORS(ShaderProfileFeatures);
/// <summary>
/// Graphics feature levels indicates what level of support can be relied upon.
/// They are named after the graphics API to indicate the minimum level of the features set to support.

View File

@@ -9,7 +9,6 @@
#include "RenderTask.h"
#include "Engine/Content/Assets/Model.h"
#include "Engine/Content/Assets/SkinnedModel.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Packed.h"
#include "Engine/Core/Math/OrientedBoundingBox.h"
#include "Engine/Engine/Time.h"
@@ -281,6 +280,24 @@ FeatureLevel RenderTools::GetFeatureLevel(ShaderProfile profile)
}
}
ShaderProfileFeatures RenderTools::GetShaderProfileFeatures(ShaderProfile profile)
{
switch (profile)
{
case ShaderProfile::DirectX_SM6:
case ShaderProfile::DirectX_SM5:
case ShaderProfile::Vulkan_SM5:
return ShaderProfileFeatures::ComputeShaders | ShaderProfileFeatures::GeometryShaders | ShaderProfileFeatures::TessellationShaders;
case ShaderProfile::PS4:
case ShaderProfile::PS5:
return ShaderProfileFeatures::ComputeShaders | ShaderProfileFeatures::GeometryShaders;
case ShaderProfile::DirectX_SM4:
return ShaderProfileFeatures::GeometryShaders;
default:
return ShaderProfileFeatures::None;
}
}
bool RenderTools::CanSupportTessellation(ShaderProfile profile)
{
switch (profile)

View File

@@ -47,12 +47,20 @@ public:
/// <returns>The feature level matching the given shader profile.</returns>
static FeatureLevel GetFeatureLevel(ShaderProfile profile);
/// <summary>
/// Gets the features for the given shader profile. Runtime device might not support all of them.
/// </summary>
/// <param name="profile">The shader profile.</param>
/// <returns>The feature flags for the given shader profile.</returns>
static ShaderProfileFeatures GetShaderProfileFeatures(ShaderProfile profile);
/// <summary>
/// Check if the given shader profile supports the tessellation. Runtime can reject tessellation support but it defines if given shader profile CAN support tessellation.
/// [Deprecated in v1.12]
/// </summary>
/// <param name="profile">The profile.</param>
/// <returns>True if can support tessellation shaders, otherwise false.</returns>
static bool CanSupportTessellation(ShaderProfile profile);
DEPRECATED("Use GetShaderProfileFeatures instead") static bool CanSupportTessellation(ShaderProfile profile);
/// <summary>
/// Computes the image row pitch in bytes, and the slice pitch (size in bytes of the image) based on format, width, and height.