Skip to content

Commit a12f7ea

Browse files
committed
Rendering: (re)Added missing override in ShadowMap shaders
1 parent 2424735 commit a12f7ea

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

sources/engine/Stride.Rendering/Rendering/Shadows/ShadowMapFilterDefault.sdsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace Stride.Rendering.Shadows
1010
/// <summary>
1111
/// Calculate the shadow factor based on the shadow map texture, the position, a sampler
1212
/// </summary>
13-
float FilterShadow(float2 position, float positionDepth)
13+
override float FilterShadow(float2 position, float positionDepth)
1414
{
1515
return ShadowMapTexture.SampleCmpLevelZero(LinearClampCompareLessEqualSampler, position, positionDepth);
1616
}
1717

18-
float FilterThickness(float3 pixelPositionWS,
18+
override float FilterThickness(float3 pixelPositionWS,
1919
float3 meshNormalWS,
2020
float2 depthRanges,
2121
float4x4 worldToShadowCascadeUV, // Transforms from world space to shadow cascade UV.

sources/engine/Stride.Rendering/Rendering/Shadows/ShadowMapFilterPcf.sdsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace Stride.Rendering.Shadows
9898
return ShadowMapTexture.SampleCmpLevelZero(LinearClampCompareLessEqualSampler, position, positionDepth);
9999
}
100100

101-
float FilterShadow(float2 position, float positionDepth)
101+
override float FilterShadow(float2 position, float positionDepth)
102102
{
103103
float shadow = 0.0f;
104104

@@ -234,7 +234,7 @@ namespace Stride.Rendering.Shadows
234234
return(thickness / normalizationFactor);
235235
}
236236

237-
float FilterThickness(float3 pixelPositionWS,
237+
override float FilterThickness(float3 pixelPositionWS,
238238
float3 meshNormalWS,
239239
float2 depthRanges,
240240
float4x4 worldToShadowCascadeUV, // Transforms from world space to shadow cascade UV.

sources/engine/Stride.Rendering/Rendering/Shadows/ShadowMapFilterVsm.sdsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Stride.Rendering.Shadows
1313
float MinVariance;
1414
};
1515

16-
float FilterShadow(float2 position, float shadowMapDistance)
16+
override float FilterShadow(float2 position, float shadowMapDistance)
1717
{
1818
float2 moments = (float2)ShadowMapTexture.SampleLevel(LinearBorderSampler, position, 0.0);
1919
float variance = moments.y - moments.x * moments.x;

sources/engine/Stride.Shaders.Parser/Mixins/MixinVirtualTable.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ public void MergeWithLocalVirtualTable(MixinVirtualTable virtualTable, string mi
6363
continue;
6464
}
6565
}
66-
else if (method.Method.Qualifiers.Contains(StrideStorageQualifier.Override))
66+
// Require override on method implementing abstract definition
67+
// We explicitly disallowed this in the past ("override" keyword forbidden when implementing abstract methods)
68+
// but we actually want it to better follow standard C# abstract/override
69+
else if (!method.Method.Qualifiers.Contains(StrideStorageQualifier.Override))
6770
{
68-
log.Error(StrideMessageCode.ErrorOverrideDeclaration, method.Method.Span, method.Method, mixinName);
71+
log.Warning(StrideMessageCode.WarningMissingOverrideKeyword, method.Method.Span, method.Method, mixinName);
6972
continue;
7073
}
7174
}

sources/engine/Stride.Shaders.Parser/Utility/StrideMessageCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ static public class StrideMessageCode
1010
public static readonly MessageCode WarningDeclarationCall = new MessageCode("W0201", "The method invocation [{0}] calls the method [{1}] which is only declared, and not defined in class [{2}]");
1111
public static readonly MessageCode WarningMissingStageKeyword = new MessageCode("W0202", "The stage keyword is missing in The method declaration [{0}] in class [{1}]");
1212
public static readonly MessageCode WarningUseSemanticType = new MessageCode("W0203", "The generic [{0}] is not of Semantic type but was used as semantic. Change the type or change name of the generic if there is a conflict.");
13-
13+
public static readonly MessageCode WarningMissingOverrideKeyword = new MessageCode("W0204", "Override keyword should be used when overriding the method declaration [{0}] in class [{1}]");
14+
1415
// analysis errors: E0###
1516
public static readonly MessageCode ErrorCyclicDependency = new MessageCode("E0201", "Cyclic mixin [{0}] dependency");
1617
public static readonly MessageCode ErrorFunctionRedefined = new MessageCode("E0202", "There is already a function with the same signature as [{0}] in class [{1}]");
@@ -24,7 +25,6 @@ static public class StrideMessageCode
2425
public static readonly MessageCode ErrorExternStageVariableNotFound = new MessageCode("E0210", "There is no matching instance for variable [{0}] in class [{1}]");
2526
public static readonly MessageCode ErrorExternStageFunctionNotFound = new MessageCode("E0211", "Unable to find the virtual call [{0}] of extern class [{1}] in context [{2}]");
2627
public static readonly MessageCode ErrorMissingOverride = new MessageCode("E0212", "There is already a method with the same signature as [{0}] in class [{1}]. Missing override keyword?");
27-
public static readonly MessageCode ErrorOverrideDeclaration = new MessageCode("E0213", "There is no need for the override keyword when overriding the method declaration [{0}] in class [{1}]");
2828
public static readonly MessageCode ErrorNoMethodToOverride = new MessageCode("E0214", "There is no method [{0}] to override in class [{1}]");
2929
public static readonly MessageCode ErrorShaderClassTypeParameter = new MessageCode("E0215", "The function [{0}] has a paramater [{1}] of shader class type which is not allowed in class [{2}]");
3030
public static readonly MessageCode ErrorShaderClassReturnType = new MessageCode("E0216", "The function [{0}] is not allowed to return a class in class [{1}]");

0 commit comments

Comments
 (0)