mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 11:30:06 +00:00
Vulkan: Add the #define VULKAN 100 when compiled for Vulkan.
Note this requires test-based piecing together of the preamble string, so it changed to being a std::string to make it easier to do. This closes issue #254.
This commit is contained in:
parent
af459216a1
commit
e512cd943e
@ -2,4 +2,8 @@
|
||||
|
||||
layout(constant_id = 17) const int arraySize = 12; // ERROR
|
||||
layout(input_attachment_index = 1) int foo; // ERROR
|
||||
layout(push_constant) uniform ubn { int a; } ubi; // ERROR
|
||||
layout(push_constant) uniform ubn { int a; } ubi; // ERROR
|
||||
|
||||
#ifdef VULKAN
|
||||
#error VULKAN should not be defined
|
||||
#endif
|
||||
|
@ -37,3 +37,11 @@ void foo()
|
||||
}
|
||||
|
||||
layout(set = 1, push_constant) uniform badpc { int a; } badpcI; // ERROR, no descriptor set with push_constant
|
||||
|
||||
#ifndef VULKAN
|
||||
#error VULKAN should be defined
|
||||
#endif
|
||||
|
||||
#if VULKAN != 100
|
||||
#error VULKAN should be 100
|
||||
#endif
|
||||
|
@ -629,7 +629,9 @@ bool ProcessDeferred(
|
||||
parseContext->initializeExtensionBehavior();
|
||||
|
||||
// Fill in the strings as outlined above.
|
||||
strings[0] = parseContext->getPreamble();
|
||||
std::string preamble;
|
||||
parseContext->getPreamble(preamble);
|
||||
strings[0] = preamble.c_str();
|
||||
lengths[0] = strlen(strings[0]);
|
||||
names[0] = nullptr;
|
||||
strings[1] = customPreamble;
|
||||
|
@ -215,10 +215,10 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
|
||||
// Get code that is not part of a shared symbol table, is specific to this shader,
|
||||
// or needed by the preprocessor (which does not use a shared symbol table).
|
||||
const char* TParseVersions::getPreamble()
|
||||
void TParseVersions::getPreamble(std::string& preamble)
|
||||
{
|
||||
if (profile == EEsProfile) {
|
||||
return
|
||||
preamble =
|
||||
"#define GL_ES 1\n"
|
||||
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
|
||||
"#define GL_OES_texture_3D 1\n"
|
||||
@ -227,10 +227,6 @@ const char* TParseVersions::getPreamble()
|
||||
"#define GL_OES_EGL_image_external 1\n"
|
||||
"#define GL_EXT_shader_texture_lod 1\n"
|
||||
|
||||
// #line and #include
|
||||
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
|
||||
"#define GL_GOOGLE_include_directive 1\n"
|
||||
|
||||
// AEP
|
||||
"#define GL_ANDROID_extension_pack_es31a 1\n"
|
||||
"#define GL_KHR_blend_equation_advanced 1\n"
|
||||
@ -260,7 +256,7 @@ const char* TParseVersions::getPreamble()
|
||||
"#define GL_OES_texture_cube_map_array 1\n"
|
||||
;
|
||||
} else {
|
||||
return
|
||||
preamble =
|
||||
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
|
||||
"#define GL_ARB_texture_rectangle 1\n"
|
||||
"#define GL_ARB_shading_language_420pack 1\n"
|
||||
@ -283,12 +279,18 @@ const char* TParseVersions::getPreamble()
|
||||
"#define GL_ARB_gl_spirv 1\n"
|
||||
"#define GL_ARB_sparse_texture2 1\n"
|
||||
"#define GL_ARB_sparse_texture_clamp 1\n"
|
||||
|
||||
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
|
||||
"#define GL_GOOGLE_include_directive 1\n"
|
||||
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
|
||||
;
|
||||
}
|
||||
|
||||
// #line and #include
|
||||
preamble +=
|
||||
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
|
||||
"#define GL_GOOGLE_include_directive 1\n"
|
||||
;
|
||||
|
||||
if (vulkan > 0)
|
||||
preamble += "#define VULKAN 100\n";
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
void setCurrentSourceName(const char* name) { currentScanner->setFile(name); }
|
||||
void setCurrentString(int string) { currentScanner->setString(string); }
|
||||
|
||||
const char* getPreamble();
|
||||
void getPreamble(std::string&);
|
||||
bool relaxedErrors() const { return (messages & EShMsgRelaxedErrors) != 0; }
|
||||
bool suppressWarnings() const { return (messages & EShMsgSuppressWarnings) != 0; }
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
virtual ~HlslParseContext();
|
||||
void setLimits(const TBuiltInResource&);
|
||||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
|
||||
const char* getPreamble();
|
||||
void getPreamble(std::string&);
|
||||
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
|
Loading…
Reference in New Issue
Block a user