Crash in FGenericDataDrivenShaderPlatformInfo when overriding ShaderPlatform settings in a project .ini

Hi,

We are seeing an issue trying to override some settings in the Engine’s DataDrivenPlatformInfo.ini with a DataDrivenPlatformInfo.ini in our project. It works but there is an issue with changing settings in the ShaderPlatform sections.

The code correctly overlays the settings for the ShaderPlatform on top of the existing ones, but it unconditionally creates a new preview platform which results a duplicate broken preview platform.

Changing the code in FGenericDataDrivenShaderPlatformInfo::Initialize() from

const EShaderPlatform PreviewShaderPlatform = EShaderPlatform(CustomShaderPlatform++);

to

EShaderPlatform PreviewShaderPlatform = SP_NumPlatforms;
for (int32 ExistingPreview = SP_CUSTOM_PLATFORM_FIRST; ExistingPreview < CustomShaderPlatform; ++ExistingPreview)
{
	if (DataDrivenShaderPlatformInfoEditorOnlyInfos[ExistingPreview].PreviewShaderPlatformParent == ShaderPlatform)
	{
		PreviewShaderPlatform = EShaderPlatform(ExistingPreview);
		break;
	}
}

if (PreviewShaderPlatform == SP_NumPlatforms)
{
	PreviewShaderPlatform = EShaderPlatform(CustomShaderPlatform++);
}

seems to resolve the issue.

We wanted to report this since it seems the code is still the same in Main.

Thanks,

Lucas

[Attachment Removed]

Steps to Reproduce
Add a project DataDrivenPlatformInfo.ini override in a project folder like <Project>/Platforms/Windows/Config/DataDrivenPlatformInfo.ini with the following contents

[DataDrivenPlatformInfo]

[ShaderPlatform PCD3D_SM6]
bStripNaniteVertexShaders=true


[Attachment Removed]

Hi Lucas,

While your change does partially provide mutability of ShaderPlatforms, you would additionally need to ensure FriendlyName and bCanUsePreviewPlatformForMaterialValidation are not read unconditionally in consequent as follows:

void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo(const FConfigSection& Section, uint32 Index)
{
....
#if WITH_EDITOR
	FDataDrivenShaderPlatformInfoEditorOnly& EditorInfo = DataDrivenShaderPlatformInfoEditorOnlyInfos[Index];
	FText FriendlyName, & CurrentFriendlyName = EditorInfo.DeviceProfileToFriendlyName.FindOrAdd(NAME_None);;;
	FTextStringHelper::ReadFromBuffer(*GetSectionString(Section, FName("FriendlyName")), FriendlyName);
	if (!FriendlyName.IsEmpty() || CurrentFriendlyName.IsEmpty())
	{
		CurrentFriendlyName = FriendlyName;
	}
...
}

However, we will not be integrating this as DataDrivenPlatformInfo is not intended to be per project editable.

ShaderPlatformConfig section is what is supposed to be used for PerProject settings, DataDrivenPlatformInfo is supposed to define “set in stone” platform capabilities. Its been polluted with other settings that are not really that “set in stone”, but that’s why we added ShaderPlatformConfig .

For example:

[ShaderPlatformConfig VULKAN_SM5]
BindlessConfiguration=Disabled
SubstrateMaxClosuresPerPixel=1

Best regards.

[Attachment Removed]

Thanks for the additional context Lucas, much appreciated.

[Attachment Removed]

Ah I see, thank you! That is indeed a better solution for overriding those flags.

[Attachment Removed]

But unfortunately, bStripNaniteVertexShaders is not a flag in FShaderPlatformConfig. Thanks for the context here about how this is supposed to work

[Attachment Removed]

I’ll consult with the team about that flag’s location and if it can be moved to the FShaderPlatformConfig. Can you shed some light on this need?

Best regards.

[Attachment Removed]

Thanks! We are trying to reduce our shader permutation count to ship less shaders and depending on a project’s minimum system requirements it could be reasonable for it to not support GPUs which don’t have mesh shaders since those GPUs are quite old at this point. Like for example if a project depended on HWRT already.

[Attachment Removed]