From: Olli Etuaho Date: Mon, 28 Sep 2015 08:08:52 +0000 (+0300) Subject: Add preprocessor "defined" operator corner cases X-Git-Tag: upstream/0.1.0~1377^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=644d6cf0d5f53381c03061c4a8a59ff68c412363;p=platform%2Fupstream%2FVK-GL-CTS.git Add preprocessor "defined" operator corner cases The GLES3 shader tests have already required "defined" operator generated by macro replacement to work. This is not specified by the C++ standard, and has some corner cases where implementations might differ. Test the corner cases to ensure fully compatible implementations. These cases were already tested against some existing implementations on Nexus devices, and the implementations mostly passed. Change-Id: Ic54afc9436bb2ad2d7bfc7dc1e1833f700d3ca49 --- diff --git a/data/gles3/shaders/preprocessor.test b/data/gles3/shaders/preprocessor.test index 12e0d8c..f8fe6eb 100644 --- a/data/gles3/shaders/preprocessor.test +++ b/data/gles3/shaders/preprocessor.test @@ -1666,6 +1666,115 @@ group conditional_inclusion "Conditional Inclusion Tests" "" end + case defined_macro_defined_test + version 300 es + values { output float out0 = 1.0; } + both "" + #version 300 es + precision mediump float; + ${DECLARATIONS} + void main() + { + #define AAA defined + + #if AAA AAA + out0 = 1.0; + #else + out0 = 0.0; + #endif + ${OUTPUT} + } + "" + end + + case defined_macro_undef + version 300 es + values { output float out0 = 1.0; } + both "" + #version 300 es + precision mediump float; + ${DECLARATIONS} + void main() + { + #define BBB 1 + #define AAA defined(BBB) + #undef BBB + + #if !AAA + out0 = 1.0; + #else + out0 = 0.0; + #endif + ${OUTPUT} + } + "" + end + + case define_defined + version 300 es + values { output float out0 = 1.0; } + both "" + #version 300 es + precision mediump float; + ${DECLARATIONS} + void main() + { + #define CCC 1 + #define defined BBB + #define AAA defined + + #if AAA CCC + out0 = 1.0; + #else + out0 = 0.0; + #endif + ${OUTPUT} + } + "" + end + + case define_defined_outside_if + version 300 es + values { output float out0 = 1.0; } + both "" + #version 300 es + precision mediump float; + ${DECLARATIONS} + void main() + { + #define CCC - 0.5 + #define defined 0.5 + #define AAA defined + out0 = 1.0 - (AAA CCC); + ${OUTPUT} + } + "" + end + + case defined_invalid_before_all_macros_replaced + version 300 es + expect compile_fail + values { output float out0 = 1.0; } + both "" + #version 300 es + precision mediump float; + ${DECLARATIONS} + void main() + { + #define FOO 1 + #define OPEN defined( + #define CLOSE FOO) + + #if OPEN CLOSE + out0 = 1.0; + #else + out0 = 0.0; + #endif + ${OUTPUT} + } + "" + end + case basic_3 version 300 es values { output float out0 = 1.0; }