Extend the syntax of #line and __FILE__ to support filename strings.

According to the GLSL spec, the second parameter to #line should be
an integer source string number and __FILE__ will be substituted
with the integer source string number currently processed. This
patch extends the syntax of #line and __FILE__. Now #line accepts
as the second parameter a filename string quoted by double quotation
marks. And if such a #line is set, __FILE__ will be substituted with
the currently set filename string. The implementation is done via
introducing a new extension GL_GOOGLE_cpp_style_line_directive using
the extension framework.

The purpose is to support cpp-style #line directives, which is
required by #include.
This commit is contained in:
Lei Zhang 2015-06-25 17:53:54 -04:00
parent c777fc2c4c
commit 5011fbebc3
16 changed files with 176 additions and 19 deletions

View file

@ -190,6 +190,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_tessellation_point_size] = EBhDisable;
extensionBehavior[E_GL_EXT_texture_buffer] = EBhDisablePartial;
extensionBehavior[E_GL_EXT_texture_cube_map_array] = EBhDisablePartial;
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
// OES matching AEP
extensionBehavior[E_GL_OES_geometry_shader] = EBhDisable;
@ -233,6 +234,7 @@ const char* TParseContext::getPreamble()
"#define GL_EXT_tessellation_point_size 1\n"
"#define GL_EXT_texture_buffer 1\n"
"#define GL_EXT_texture_cube_map_array 1\n"
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
// OES matching AEP
"#define GL_OES_geometry_shader 1\n"
@ -264,6 +266,7 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_derivative_control 1\n"
"#define GL_ARB_shader_texture_image_samples 1\n"
"#define GL_ARB_viewport_array 1\n"
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
;
}