Disable shader compilation if any errors are present

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:30 +02:00
1 親 5390d8b27c
コミット fd9d8a6f65
5ファイル変更
+18 -5

検索条件に一致するファイルはありません

@@ -78,8 +78,11 @@ partial class ID2D1ShaderGenerator
{
ImmutableArray<byte> bytecode = ImmutableArray<byte>.Empty;
// No embedded shader was requested
if (sourceInfo.ShaderProfile is null)
// No embedded shader was requested, or there were some errors earlier in the pipeline.
// In this case, skip the compilation, as diagnostic will be emitted for those anyway.
// Compiling would just add overhead and result in more errors, as the HLSL would be invalid.
if (sourceInfo.HasErrors ||
sourceInfo.ShaderProfile is null)
{
diagnostic = null;
+3 -1
ファイルの表示
@@ -78,11 +78,13 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
// Get the shader profile and linking info for LoadBytecode()
D2D1ShaderProfile? shaderProfile = LoadBytecode.GetShaderProfile(item.Left.Symbol);
bool isLinkingSupported = LoadBytecode.IsSimpleInputShader(item.Left.Symbol);
bool hasErrors = !dispatchDataDiagnostics.IsDefaultOrEmpty || !hlslSourceDiagnostics.IsDefaultOrEmpty;
HlslShaderSourceInfo sourceInfo = new(
hlslSource,
shaderProfile,
isLinkingSupported);
isLinkingSupported,
hasErrors);
token.ThrowIfCancellationRequested();
+2 -1
ファイルの表示
@@ -6,4 +6,5 @@
/// <param name="HlslSource">The HLSL source.</param>
/// <param name="ShaderProfile">The shader profile to use to compile the shader, if requested.</param>
/// <param name="IsLinkingSupported">Whether the shader supports linking.</param>
internal sealed record HlslShaderSourceInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, bool IsLinkingSupported);
/// <param name="HasErrors">Whether any errors have been detected, and therefore the shader compilation should be skipped.</param>
internal sealed record HlslShaderSourceInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, bool IsLinkingSupported, bool HasErrors);
+7
ファイルの表示
@@ -119,6 +119,13 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
token.ThrowIfCancellationRequested();
// Ensure the bytecode generation is disabled if any errors are present
if (!dispatchDataDiagnostics.IsDefaultOrEmpty ||
!hlslSourceDiagnostics.IsDefaultOrEmpty)
{
threadIds = new ThreadIdsInfo(true, 0, 0, 0);
}
return (
new Result<DispatchDataInfo>(dispatchDataInfo, dispatchDataDiagnostics),
new Result<HlslShaderSourceInfo>(hlslSourceInfo, hlslSourceDiagnostics),
+1 -1
ファイルの表示
@@ -3,7 +3,7 @@
/// <summary>
/// A model representing gathered info on a embedded thread ids.
/// </summary>
/// <param name="IsDefault">Whether the values are diascarded.</param>
/// <param name="IsDefault">Whether the values are discarded.</param>
/// <param name="X">The thread ids value for the X axis.</param>
/// <param name="Y">The thread ids value for the Y axis.</param>
/// <param name="Z">The thread ids value for the Z axis.</param>