Disallow all layout qualifiers (other than 'color') in runtime effects

Bug: skia:11301
Change-Id: Ie6a5ef920093b63983d8dbbdbaa94960fa7af83c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/558304
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Brian Osman 2022-07-13 10:58:28 -04:00 committed by SkCQ
parent cef14e607d
commit 101ad96b34
4 changed files with 71 additions and 0 deletions

View File

@ -748,6 +748,7 @@ sksl_rte_error_tests = [
"/sksl/runtime_errors/FirstClassArrays.rts",
"/sksl/runtime_errors/IllegalArrayOps.rts",
"/sksl/runtime_errors/IllegalIndexing.rts",
"/sksl/runtime_errors/IllegalLayoutFlags.rts",
"/sksl/runtime_errors/IllegalOperators.rts",
"/sksl/runtime_errors/IllegalPrecisionQualifiers.rts",
"/sksl/runtime_errors/IllegalShaderSampling.rts",

View File

@ -0,0 +1,30 @@
layout(builtin=15) float4 sk_FragCoord;
layout(builtin=17) bool sk_Clockwise;
layout(builtin=10010) half4 input_color;
layout(origin_upper_left) float upper_left;
layout(push_constant) float push_constant;
layout(location=0) float location;
layout(offset=0) float offset;
layout(binding=0) float binding;
layout(index=0) float index;
layout(set=0) float set;
layout(input_attachment_index=0) float input_attachment_index;
float4 main(float2 xy) {
return sk_FragCoord;
}
/*%%*
layout qualifier 'builtin' is not permitted here
layout qualifier 'builtin' is not permitted here
layout qualifier 'builtin' is not permitted here
layout qualifier 'origin_upper_left' is not permitted here
layout qualifier 'push_constant' is not permitted here
layout qualifier 'location' is not permitted here
layout qualifier 'offset' is not permitted here
layout qualifier 'binding' is not permitted here
layout qualifier 'index' is not permitted here
layout qualifier 'set' is not permitted here
layout qualifier 'input_attachment_index' is not permitted here
*%%*/

View File

@ -236,6 +236,10 @@ void VarDeclaration::ErrorCheck(const Context& context,
permittedLayoutFlags &= ~Layout::kBinding_Flag;
permittedLayoutFlags &= ~Layout::kSet_Flag;
}
if (ProgramConfig::IsRuntimeEffect(context.fConfig->fKind)) {
// Disallow all layout flags except 'color' in runtime effects
permittedLayoutFlags &= Layout::kColor_Flag;
}
modifiers.checkPermitted(context, modifiersPosition, permitted, permittedLayoutFlags);
}

View File

@ -0,0 +1,36 @@
### Compilation failed:
error: 1: layout qualifier 'builtin' is not permitted here
layout(builtin=15) float4 sk_FragCoord;
^^^^^^^^^^^^^^^^^^
error: 2: layout qualifier 'builtin' is not permitted here
layout(builtin=17) bool sk_Clockwise;
^^^^^^^^^^^^^^^^^^
error: 3: layout qualifier 'builtin' is not permitted here
layout(builtin=10010) half4 input_color;
^^^^^^^^^^^^^^^^^^^^^
error: 5: layout qualifier 'origin_upper_left' is not permitted here
layout(origin_upper_left) float upper_left;
^^^^^^^^^^^^^^^^^^^^^^^^^
error: 6: layout qualifier 'push_constant' is not permitted here
layout(push_constant) float push_constant;
^^^^^^^^^^^^^^^^^^^^^
error: 7: layout qualifier 'location' is not permitted here
layout(location=0) float location;
^^^^^^^^^^^^^^^^^^
error: 8: layout qualifier 'offset' is not permitted here
layout(offset=0) float offset;
^^^^^^^^^^^^^^^^
error: 9: layout qualifier 'binding' is not permitted here
layout(binding=0) float binding;
^^^^^^^^^^^^^^^^^
error: 10: layout qualifier 'index' is not permitted here
layout(index=0) float index;
^^^^^^^^^^^^^^^
error: 11: layout qualifier 'set' is not permitted here
layout(set=0) float set;
^^^^^^^^^^^^^
error: 12: layout qualifier 'input_attachment_index' is not permitted here
layout(input_attachment_index=0) float input_attachment_index;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 errors