From aca34e771d0ad76d396415e45c5f3cbf294709c9 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 12 Jul 2017 13:40:30 -0700 Subject: Don't emit interpolation modifiers on struct fields when outputting GLSL HLSL (and thus Slang) commonly puts interpolation modifiers like `sample` on the fields of `struct` types used as stage input/output, while GLSL only allows them on global-scope `in` and `out` variables (or ones in blocks). This change emits a really hacky filtering step to skip over certain modifiers when emitting a declaration. This lets us skip interpolation-mode modifiers when outputting a struct field to GLSL. Note: this probably gets the `in` or `out` block case wrong... --- source/slang/modifier-defs.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/slang/modifier-defs.h') diff --git a/source/slang/modifier-defs.h b/source/slang/modifier-defs.h index c401b3353..2b5c77d86 100644 --- a/source/slang/modifier-defs.h +++ b/source/slang/modifier-defs.h @@ -208,17 +208,20 @@ SIMPLE_SYNTAX_CLASS(GLSLColumnMajorLayoutModifier, RowMajorLayoutModifier) // More HLSL Keyword +ABSTRACT_SYNTAX_CLASS(InterpolationModeModifier, Modifier) +END_SYNTAX_CLASS() + // HLSL `nointerpolation` modifier -SIMPLE_SYNTAX_CLASS(HLSLNoInterpolationModifier, Modifier) +SIMPLE_SYNTAX_CLASS(HLSLNoInterpolationModifier, InterpolationModeModifier) // HLSL `linear` modifier -SIMPLE_SYNTAX_CLASS(HLSLLinearModifier, Modifier) +SIMPLE_SYNTAX_CLASS(HLSLLinearModifier, InterpolationModeModifier) // HLSL `sample` modifier -SIMPLE_SYNTAX_CLASS(HLSLSampleModifier, Modifier) +SIMPLE_SYNTAX_CLASS(HLSLSampleModifier, InterpolationModeModifier) // HLSL `centroid` modifier -SIMPLE_SYNTAX_CLASS(HLSLCentroidModifier, Modifier) +SIMPLE_SYNTAX_CLASS(HLSLCentroidModifier, InterpolationModeModifier) // HLSL `precise` modifier SIMPLE_SYNTAX_CLASS(HLSLPreciseModifier, Modifier) -- cgit v1.2.3