mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 11:30:06 +00:00
Add support for GL_ARB_shading_language_include
Add support for GL_ARB_shading_language_include. Usage is identical to the way GL_GOOGLE_include_directive currently works glslang (since GL_ARB_shading_language_include is inherently a runtime feature and glslang is an offline compiler). Users can simulate their runtime environment by using a custom glslang::TShader::Includer or using filenames that match their GL runtime names. Closes #249.
This commit is contained in:
parent
fa04cdf355
commit
b0df68c490
@ -0,0 +1,4 @@
|
||||
ERROR: 0:7: '#include' : Could not process include directive for header name: bar.h
|
||||
ERROR: 1 compilation errors. No code generated.
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
ERROR: 0:3: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:3: '#include' : Could not process include directive for header name: bar.h
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
@ -1,12 +1,22 @@
|
||||
ERROR: 0:8000: '#include' : required extension not requested: GL_GOOGLE_include_directive
|
||||
ERROR: 0:8000: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:8000: '#include' : must be followed by a header name
|
||||
ERROR: 0:8001: '#include' : required extension not requested: GL_GOOGLE_include_directive
|
||||
ERROR: 0:8001: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:8001: '#include' : must be followed by a header name
|
||||
ERROR: 0:8002: '#include' : required extension not requested: GL_GOOGLE_include_directive
|
||||
ERROR: 0:8002: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:8002: '#include' : Could not process include directive for header name: foo
|
||||
ERROR: 0:8003: '#include' : required extension not requested: GL_GOOGLE_include_directive
|
||||
ERROR: 0:8003: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:8003: '#include' : extra content after header name: foo
|
||||
ERROR: 0:8004: '#include' : required extension not requested: GL_GOOGLE_include_directive
|
||||
ERROR: 0:8004: '#include' : required extension not requested: Possible extensions include:
|
||||
GL_GOOGLE_include_directive
|
||||
GL_ARB_shading_language_include
|
||||
ERROR: 0:8004: '#include' : expected newline after header name: no-eol
|
||||
ERROR: 10 compilation errors. No code generated.
|
||||
|
||||
|
14
Test/preprocess.arb_shading_language_include.vert
Normal file
14
Test/preprocess.arb_shading_language_include.vert
Normal file
@ -0,0 +1,14 @@
|
||||
#version 150
|
||||
|
||||
#extension GL_ARB_shading_language_include : enable
|
||||
|
||||
#define float4 vec4
|
||||
|
||||
#include "bar.h"
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = i1 + vec4(1.0);
|
||||
}
|
6
Test/preprocess.include_directive_missing_extension.vert
Normal file
6
Test/preprocess.include_directive_missing_extension.vert
Normal file
@ -0,0 +1,6 @@
|
||||
#version 150
|
||||
|
||||
#include "bar.h"
|
||||
|
||||
void main() {}
|
||||
|
@ -269,6 +269,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
// #line and #include
|
||||
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
||||
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shading_language_include] = EBhDisable;
|
||||
|
||||
extensionBehavior[E_GL_AMD_shader_ballot] = EBhDisable;
|
||||
extensionBehavior[E_GL_AMD_shader_trinary_minmax] = EBhDisable;
|
||||
@ -983,6 +984,8 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
|
||||
updateExtensionBehavior(line, "GL_OES_shader_io_blocks", behaviorString);
|
||||
else if (strcmp(extension, "GL_GOOGLE_include_directive") == 0)
|
||||
updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString);
|
||||
else if (strcmp(extension, "GL_ARB_shading_language_include") == 0)
|
||||
updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString);
|
||||
// subgroup_* to subgroup_basic
|
||||
else if (strcmp(extension, "GL_KHR_shader_subgroup_vote") == 0)
|
||||
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
|
||||
|
@ -241,6 +241,7 @@ const int Num_OVR_multiview_EXTs = sizeof(OVR_multiview_EXTs) / sizeof(OVR_multi
|
||||
// #line and #include
|
||||
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
|
||||
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
|
||||
const char* const E_GL_ARB_shading_language_include = "GL_ARB_shading_language_include";
|
||||
|
||||
const char* const E_GL_AMD_shader_ballot = "GL_AMD_shader_ballot";
|
||||
const char* const E_GL_AMD_shader_trinary_minmax = "GL_AMD_shader_trinary_minmax";
|
||||
|
@ -83,6 +83,11 @@ public:
|
||||
const char* featureDesc);
|
||||
virtual void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
|
||||
const char* featureDesc);
|
||||
template<typename Container>
|
||||
constexpr void ppRequireExtensions(const TSourceLoc& loc, Container extensions, const char* featureDesc) {
|
||||
ppRequireExtensions(loc, static_cast<int>(extensions.size()), extensions.data(), featureDesc);
|
||||
}
|
||||
|
||||
virtual TExtensionBehavior getExtensionBehavior(const char*);
|
||||
virtual bool extensionTurnedOn(const char* const extension);
|
||||
virtual bool extensionsTurnedOn(int numExtensions, const char* const extensions[]);
|
||||
|
@ -973,7 +973,8 @@ int TPpContext::readCPPline(TPpToken* ppToken)
|
||||
break;
|
||||
case PpAtomInclude:
|
||||
if(!parseContext.isReadingHLSL()) {
|
||||
parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_include_directive, "#include");
|
||||
const std::array exts = { E_GL_GOOGLE_include_directive, E_GL_ARB_shading_language_include };
|
||||
parseContext.ppRequireExtensions(ppToken->loc, exts, "#include");
|
||||
}
|
||||
token = CPPinclude(ppToken);
|
||||
break;
|
||||
|
@ -67,6 +67,8 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
"preprocessor.defined.vert",
|
||||
"preprocessor.many.endif.vert",
|
||||
"preprocessor.eof_missing.vert",
|
||||
"preprocess.arb_shading_language_include.vert",
|
||||
"preprocess.include_directive_missing_extension.vert",
|
||||
})),
|
||||
FileNameAsCustomTestSuffix
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user