Use GLSLANG_ANGLE to strip features to what ANGLE requires

This change strips a few features similar to GLSLANG_WEB but doesn't
remove every detail like the latter.  It also hardcodes profile/version
to core/450.

In particular, TBuiltIns::initialize is specialized to remove most of
what is not supported or won't be supported by ANGLE.  The result of
this function is parsed with TParseContext::parseShaderStrings which is
a performance bottleneck.

This change shaves about 300KB off of ANGLE's binary size and reduces
the cost of SetupBuiltinSymbolTable to nearly a sixth.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
This commit is contained in:
Shahbaz Youssefi 2020-07-03 15:42:53 -04:00
parent f5ed7a69d5
commit 8c49d15fbf
No known key found for this signature in database
GPG Key ID: C6149357EC6727E0
17 changed files with 215 additions and 103 deletions

View File

@ -83,7 +83,6 @@ template("glslang_sources_common") {
"SPIRV/SpvBuilder.cpp",
"SPIRV/SpvBuilder.h",
"SPIRV/SpvPostProcess.cpp",
"SPIRV/SpvTools.cpp",
"SPIRV/SpvTools.h",
"SPIRV/bitutils.h",
"SPIRV/disassemble.cpp",
@ -183,8 +182,12 @@ template("glslang_sources_common") {
defines = []
if (invoker.enable_opt) {
sources += [ "SPIRV/SpvTools.cpp" ]
defines += [ "ENABLE_OPT=1" ]
}
if (invoker.is_angle) {
defines += [ "GLSLANG_ANGLE" ]
}
if (is_win) {
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
@ -228,11 +231,13 @@ template("glslang_sources_common") {
glslang_sources_common("glslang_lib_sources") {
enable_opt = !glslang_angle
enable_hlsl = !glslang_angle
is_angle = glslang_angle
}
glslang_sources_common("glslang_sources") {
enable_opt = true
enable_hlsl = true
is_angle = false
}
source_set("glslang_default_resource_limits_sources") {

View File

@ -281,6 +281,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
{
#ifdef GLSLANG_WEB
return spv::SourceLanguageESSL;
#elif defined(GLSLANG_ANGLE)
return spv::SourceLanguageGLSL;
#endif
switch (source) {
@ -8684,7 +8686,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
// Write SPIR-V out to a text file with 32-bit hexadecimal words
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
{
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
std::ofstream out;
out.open(baseName, std::ios::binary | std::ios::out);
if (out.fail())

View File

@ -147,6 +147,10 @@ EProfile EDesktopProfile = static_cast<EProfile>(ENoProfile | ECoreProfile | ECo
#ifdef GLSLANG_WEB
const Versioning* Es300Desktop130 = nullptr;
const Versioning* Es310Desktop420 = nullptr;
#elif defined(GLSLANG_ANGLE)
const Versioning* Es300Desktop130 = nullptr;
const Versioning* Es310Desktop420 = nullptr;
const Versioning* Es310Desktop450 = nullptr;
#else
const Versioning Es300Desktop130Version[] = { { EEsProfile, 0, 300, 0, nullptr },
{ EDesktopProfile, 0, 130, 0, nullptr },
@ -415,7 +419,7 @@ void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
// See if the tabled versioning information allows the current version.
bool ValidVersion(const BuiltInFunction& function, int version, EProfile profile, const SpvVersion& /* spVersion */)
{
#ifdef GLSLANG_WEB
#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
// all entries in table are valid
return true;
#endif
@ -499,7 +503,7 @@ TBuiltIns::TBuiltIns()
prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u";
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
prefixes[EbtFloat16] = "f16";
prefixes[EbtInt8] = "i8";
prefixes[EbtUint8] = "u8";
@ -516,7 +520,9 @@ TBuiltIns::TBuiltIns()
dimMap[Esd3D] = 3;
dimMap[EsdCube] = 3;
#ifndef GLSLANG_WEB
#ifndef GLSLANG_ANGLE
dimMap[Esd1D] = 1;
#endif
dimMap[EsdRect] = 2;
dimMap[EsdBuffer] = 1;
dimMap[EsdSubpass] = 2; // potentially unused for now
@ -541,6 +547,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
#ifdef GLSLANG_WEB
version = 310;
profile = EEsProfile;
#elif defined(GLSLANG_ANGLE)
version = 450;
profile = ECoreProfile;
#endif
addTabledBuiltins(version, profile, spvVersion);
@ -586,6 +595,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec4 fwidthCoarse(vec4 p);"
);
#ifndef GLSLANG_ANGLE
TString derivativesAndControl16bits (
"float16_t dFdx(float16_t);"
"f16vec2 dFdx(f16vec2);"
@ -1173,6 +1183,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n"
);
}
#endif // !GLSLANG_ANGLE
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 430)) {
@ -1210,6 +1221,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_ANGLE
if (profile != EEsProfile && version >= 440) {
commonBuiltins.append(
"uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
@ -1259,7 +1271,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);"
"\n");
}
#endif
#endif // !GLSLANG_ANGLE
#endif // !GLSLANG_WEB
if ((profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
@ -1299,6 +1312,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_ANGLE
if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
commonBuiltins.append(
"double fma(double, double, double);"
@ -1307,6 +1321,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"dvec4 fma(dvec4, dvec4, dvec4 );"
"\n");
}
#endif
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 400)) {
@ -1324,6 +1339,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_ANGLE
if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
commonBuiltins.append(
"double frexp(double, out int);"
@ -1341,6 +1357,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#endif
#endif
if ((profile == EEsProfile && version >= 300) ||
@ -1450,6 +1467,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
}
#ifndef GLSLANG_WEB
#ifndef GLSLANG_ANGLE
//
// Original-style texture functions existing in all stages.
// (Per-stage functions below.)
@ -1598,6 +1616,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
}
#endif // !GLSLANG_ANGLE
// Bitfield
if ((profile == EEsProfile && version >= 310) ||
@ -1740,6 +1759,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_ANGLE
// GL_ARB_shader_ballot
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append(
@ -3060,6 +3080,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
"\n");
}
#endif // !GLSLANG_ANGLE
if ((profile == EEsProfile && version >= 300 && version < 310) ||
(profile != EEsProfile && version >= 150 && version < 450)) { // GL_EXT_shader_integer_mix
@ -3079,6 +3100,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_ANGLE
// GL_AMD_gpu_shader_half_float/Explicit types
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append(
@ -3929,28 +3951,30 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"f64vec3 log2(f64vec3);"
"f64vec4 log2(f64vec4);"
"\n");
}
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
stageBuiltins[EShLangFragment].append(
"float64_t interpolateAtCentroid(float64_t);"
"f64vec2 interpolateAtCentroid(f64vec2);"
"f64vec3 interpolateAtCentroid(f64vec3);"
"f64vec4 interpolateAtCentroid(f64vec4);"
}
"float64_t interpolateAtSample(float64_t, int);"
"f64vec2 interpolateAtSample(f64vec2, int);"
"f64vec3 interpolateAtSample(f64vec3, int);"
"f64vec4 interpolateAtSample(f64vec4, int);"
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
stageBuiltins[EShLangFragment].append(
"float64_t interpolateAtCentroid(float64_t);"
"f64vec2 interpolateAtCentroid(f64vec2);"
"f64vec3 interpolateAtCentroid(f64vec3);"
"f64vec4 interpolateAtCentroid(f64vec4);"
"float64_t interpolateAtOffset(float64_t, f64vec2);"
"f64vec2 interpolateAtOffset(f64vec2, f64vec2);"
"f64vec3 interpolateAtOffset(f64vec3, f64vec2);"
"f64vec4 interpolateAtOffset(f64vec4, f64vec2);"
"float64_t interpolateAtSample(float64_t, int);"
"f64vec2 interpolateAtSample(f64vec2, int);"
"f64vec3 interpolateAtSample(f64vec3, int);"
"f64vec4 interpolateAtSample(f64vec4, int);"
"\n");
"float64_t interpolateAtOffset(float64_t, f64vec2);"
"f64vec2 interpolateAtOffset(f64vec2, f64vec2);"
"f64vec3 interpolateAtOffset(f64vec3, f64vec2);"
"f64vec4 interpolateAtOffset(f64vec4, f64vec2);"
"\n");
}
#endif // !GLSLANG_ANGLE
//============================================================================
//
@ -3966,6 +3990,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
stageBuiltins[EShLangVertex].append("vec4 ftransform();");
#ifndef GLSLANG_ANGLE
//
// Original-style texture Functions with lod.
//
@ -4025,6 +4050,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
}
#endif // !GLSLANG_ANGLE
if ((profile != EEsProfile && version >= 150) ||
(profile == EEsProfile && version >= 310)) {
@ -4045,7 +4071,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void EndPrimitive();"
"\n");
}
#endif
#endif // !GLSLANG_WEB
//============================================================================
//
@ -4105,6 +4131,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
commonBuiltins.append("void debugPrintfEXT();\n");
#ifndef GLSLANG_ANGLE
if (profile != EEsProfile && version >= 450) {
// coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
// adding it introduces undesirable tempArgs on the stack. What we want
@ -4228,6 +4255,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#endif // !GLSLANG_ANGLE
// GL_ARB_derivative_control
if (profile != EEsProfile && version >= 400) {
@ -4265,6 +4293,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"bool helperInvocationEXT();"
"\n");
#ifndef GLSLANG_ANGLE
// GL_AMD_shader_explicit_vertex_parameter
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangFragment].append(
@ -4399,12 +4428,14 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void executeCallableEXT(uint, int);"
"\n");
}
#endif // !GLSLANG_ANGLE
//E_SPV_NV_compute_shader_derivatives
if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
stageBuiltins[EShLangCompute].append(derivativeControls);
stageBuiltins[EShLangCompute].append("\n");
}
#ifndef GLSLANG_ANGLE
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
@ -4417,7 +4448,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void writePackedPrimitiveIndices4x8NV(uint, uint);"
"\n");
}
#endif
#endif // !GLSLANG_ANGLE
#endif // !GLSLANG_WEB
//============================================================================
//
@ -4454,7 +4486,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
//
// Matrix state. p. 31, 32, 37, 39, 40.
@ -4572,7 +4604,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#endif
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
//============================================================================
//
@ -4603,6 +4635,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
}
#ifndef GLSLANG_WEB
#ifndef GLSLANG_ANGLE
//============================================================================
//
// Define the interface to the mesh/task shader.
@ -4690,6 +4723,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
}
#endif // !GLSLANG_ANGLE
//============================================================================
//
@ -5360,6 +5394,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
#ifndef GLSLANG_WEB
if ((profile != EEsProfile && version >= 140) ||
(profile == EEsProfile && version >= 310)) {
stageBuiltins[EShLangFragment].append(
"flat in highp int gl_DeviceIndex;" // GL_EXT_device_group
"flat in highp int gl_ViewIndex;" // GL_EXT_multiview
"\n");
}
#ifndef GLSLANG_ANGLE
// GL_ARB_shader_ballot
if (profile != EEsProfile && version >= 450) {
const char* ballotDecls =
@ -5390,14 +5433,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangTaskNV] .append(ballotDecls);
}
if ((profile != EEsProfile && version >= 140) ||
(profile == EEsProfile && version >= 310)) {
stageBuiltins[EShLangFragment].append(
"flat in highp int gl_DeviceIndex;" // GL_EXT_device_group
"flat in highp int gl_ViewIndex;" // GL_EXT_multiview
"\n");
}
// GL_KHR_shader_subgroup
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 140)) {
@ -5601,6 +5636,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangCallable].append(callableDecls);
}
if ((profile != EEsProfile && version >= 140)) {
const char *deviceIndex =
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
@ -5613,12 +5649,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangMiss].append(deviceIndex);
}
if (version >= 300 /* both ES and non-ES */) {
stageBuiltins[EShLangFragment].append(
"flat in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
"\n");
}
if ((profile != EEsProfile && version >= 420) ||
(profile == EEsProfile && version >= 310)) {
commonBuiltins.append("const int gl_ScopeDevice = 1;\n");
@ -5642,7 +5672,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
commonBuiltins.append("const int gl_StorageSemanticsImage = 0x800;\n");
commonBuiltins.append("const int gl_StorageSemanticsOutput = 0x1000;\n");
}
#endif
#endif // !GLSLANG_ANGLE
if (version >= 300 /* both ES and non-ES */) {
stageBuiltins[EShLangFragment].append(
"flat in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
"\n");
}
#endif // !GLSLANG_WEB
// printf("%s\n", commonBuiltins.c_str());
// printf("%s\n", stageBuiltins[EShLangFragment].c_str());
@ -5660,13 +5698,16 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
//
// enumerate all the types
const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint,
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
EbtFloat16
#endif
};
#ifdef GLSLANG_WEB
const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint };
bool skipBuffer = true;
bool skipCubeArrayed = true;
const int image = 0;
#else
const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint, EbtFloat16 };
bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
@ -5691,8 +5732,13 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
#ifdef GLSLANG_WEB
for (int dim = Esd2D; dim <= EsdCube; ++dim) { // 2D, 3D, and Cube
#else
#if defined(GLSLANG_ANGLE)
// TODO: what is subpass?
for (int dim = Esd2D; dim < EsdSubpass; ++dim) { // 2D, ..., buffer
#else
for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, ..., buffer, subpass
#endif
if (dim == EsdSubpass && spvVersion.vulkan == 0)
continue;
if (dim == EsdSubpass && (image || shadow || arrayed))
@ -6086,6 +6132,9 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
//
@ -6162,8 +6211,8 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
continue;
// loop over 16-bit floating-point texel addressing
#ifdef GLSLANG_WEB
const int f16TexAddr = 0;
#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
const bool f16TexAddr = false;
#else
for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr)
#endif
@ -6175,8 +6224,8 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
totalDims--;
}
// loop over "bool" lod clamp
#ifdef GLSLANG_WEB
const int lodClamp = 0;
#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
const bool lodClamp = false;
#else
for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp)
#endif
@ -6187,8 +6236,8 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
continue;
// loop over "bool" sparse or not
#ifdef GLSLANG_WEB
const int sparse = 0;
#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
const bool sparse = false;
#else
for (int sparse = 0; sparse <= 1; ++sparse)
#endif
@ -6371,6 +6420,9 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, in
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
switch (sampler.dim) {
@ -6614,6 +6666,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
#ifdef GLSLANG_WEB
version = 310;
profile = EEsProfile;
#elif defined(GLSLANG_ANGLE)
version = 450;
profile = ECoreProfile;
#endif
//
@ -7042,6 +7097,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append("\n");
}
#ifndef GLSLANG_ANGLE
// atomic counters (some in compute below)
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 420)) {
@ -7078,6 +7134,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append("\n");
}
#endif // !GLSLANG_ANGLE
// GL_ARB_cull_distance
if (profile != EEsProfile && version >= 450) {
@ -7094,6 +7151,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
}
#ifndef GLSLANG_ANGLE
// SPV_NV_mesh_shader
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
@ -7116,6 +7174,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append("\n");
}
#endif
#endif
s.append("\n");
@ -7200,6 +7259,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
#ifdef GLSLANG_WEB
version = 310;
profile = EEsProfile;
#elif defined(GLSLANG_ANGLE)
version = 450;
profile = ECoreProfile;
#endif
//
@ -7389,7 +7451,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
case EShLangTessEvaluation:
case EShLangGeometry:
#endif
#endif // !GLSLANG_WEB
SpecialQualifier("gl_Position", EvqPosition, EbvPosition, symbolTable);
SpecialQualifier("gl_PointSize", EvqPointSize, EbvPointSize, symbolTable);
@ -7550,7 +7612,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
}
#endif
#endif // !GLSLANG_WEB
break;
case EShLangFragment:
@ -8056,7 +8118,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
}
symbolTable.setFunctionExtensions("helperInvocationEXT", 1, &E_GL_EXT_demote_to_helper_invocation);
#endif
#endif // !GLSLANG_WEB
break;
case EShLangCompute:
@ -8188,10 +8250,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_NV_compute_shader_derivatives);
symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_NV_compute_shader_derivatives);
}
#endif
#endif // !GLSLANG_WEB
break;
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
case EShLangRayGen:
case EShLangIntersect:
case EShLangAnyHit:
@ -9094,7 +9156,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
default:
assert(false && "Language not supported");
}
#endif
#endif // !GLSLANG_WEB
}
//
@ -9109,6 +9171,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
{
#ifndef GLSLANG_WEB
#if defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
if (profile != EEsProfile && version >= 430 && version < 440) {
symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);

View File

@ -291,6 +291,9 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
(*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]);
@ -312,6 +315,9 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
@ -351,7 +357,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
(profile == EEsProfile && version >= 310))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, source,
infoSink, commonTable, symbolTables);
#endif
// check for compute
if ((profile != EEsProfile && version >= 420) ||
@ -359,6 +364,7 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
infoSink, commonTable, symbolTables);
#ifndef GLSLANG_ANGLE
// check for ray tracing stages
if (profile != EEsProfile && version >= 450) {
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source,
@ -386,6 +392,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
infoSink, commonTable, symbolTables);
#endif // !GLSLANG_ANGLE
#endif // !GLSLANG_WEB
return true;
}
@ -487,7 +495,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
// Function to Print all builtins
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
{
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
infoSink.debug << "BuiltinSymbolTable {\n";
symbolTable.dump(infoSink, true);
@ -591,7 +599,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break;
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Correct for stage type...
switch (stage) {
case EShLangGeometry:
@ -867,7 +875,7 @@ bool ProcessDeferred(
: userInput.scanVersion(version, profile, versionNotFirstToken);
bool versionNotFound = version == 0;
if (forceDefaultVersionAndProfile && source == EShSourceGlsl) {
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound &&
(version != defaultVersion || profile != defaultProfile)) {
compiler->infoSink.info << "Warning, (version, profile) forced to be ("
@ -890,10 +898,13 @@ bool ProcessDeferred(
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool warnVersionNotFirst = false;
if (! versionWillBeError && versionNotFirstToken) {
if (messages & EShMsgRelaxedErrors)
@ -963,7 +974,7 @@ bool ProcessDeferred(
parseContext->setLimits(*resources);
if (! goodVersion)
parseContext->addError();
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (warnVersionNotFirst) {
TSourceLoc loc;
loc.init();
@ -1000,7 +1011,7 @@ bool ProcessDeferred(
return success;
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Responsible for keeping track of the most recent source string and line in
// the preprocessor and outputting newlines appropriately if the source string
@ -1223,14 +1234,16 @@ struct DoFullParse{
parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
}
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST)
intermediate.output(parseContext.infoSink, true);
#endif
return success;
}
};
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Take a single compilation unit, and run the preprocessor on it.
// Return: True if there were no issues found in preprocessing,
// False if during preprocessing any unknown version, pragmas or
@ -1860,7 +1873,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
&environment);
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Fill in a string with the result of preprocessing ShaderStrings
// Returns true if all extensions, pragmas and version strings were valid.
//
@ -1898,7 +1911,7 @@ const char* TShader::getInfoDebugLog()
}
TProgram::TProgram() :
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
reflection(0),
#endif
linked(false)
@ -1914,7 +1927,7 @@ TProgram::TProgram() :
TProgram::~TProgram()
{
delete infoSink;
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
delete reflection;
#endif
@ -1961,7 +1974,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
if (stages[stage].size() == 0)
return true;
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
int numEsShaders = 0, numNonEsShaders = 0;
for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) {
if ((*it)->intermediate->getProfile() == EEsProfile) {
@ -2015,8 +2028,10 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
#endif
intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0);
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST)
intermediate[stage]->output(*infoSink, true);
#endif
return intermediate[stage]->getNumErrors() == 0;
}
@ -2031,7 +2046,7 @@ const char* TProgram::getInfoDebugLog()
return infoSink->debug.c_str();
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// Reflection implementation.
@ -2113,6 +2128,6 @@ bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper)
return ioMapper->doMap(pResolver, *infoSink);
}
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
} // end namespace glslang

View File

@ -178,7 +178,7 @@ void TType::buildMangledName(TString& mangledName) const
}
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// Dump functions.

View File

@ -117,7 +117,7 @@ public:
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
virtual const char** getExtensions() const { return extensions->data(); }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
void dumpExtensions(TInfoSink& infoSink) const;
#endif
@ -196,7 +196,7 @@ public:
}
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
@ -319,7 +319,7 @@ public:
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
@ -381,7 +381,7 @@ public:
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
virtual int getAnonId() const { return anonId; }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
@ -551,7 +551,7 @@ public:
void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
TSymbolTableLevel* clone() const;
@ -854,7 +854,7 @@ public:
}
int getMaxSymbolId() { return uniqueId; }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
void copyTable(const TSymbolTable& copyOf);

View File

@ -36,7 +36,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "localintermediate.h"
#include "../Include/InfoSink.h"
@ -1562,4 +1562,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
} // end namespace glslang
#endif // not GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

View File

@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h"
#include "../Include/InfoSink.h"
@ -1281,4 +1281,4 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
} // end namespace glslang
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

View File

@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _IOMAPPER_INCLUDED
#define _IOMAPPER_INCLUDED
@ -186,7 +186,7 @@ protected:
}
};
// Defaulf I/O resolver for OpenGL
// Default I/O resolver for OpenGL
struct TDefaultGlslIoResolver : public TDefaultIoResolverBase {
public:
typedef std::map<TString, int> TVarSlotMap; // <resourceName, location/binding>
@ -299,4 +299,4 @@ public:
#endif // _IOMAPPER_INCLUDED
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

View File

@ -82,7 +82,7 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message)
//
void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
{
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
mergeCallGraphs(infoSink, unit);
mergeModes(infoSink, unit);
mergeTrees(infoSink, unit);
@ -104,7 +104,7 @@ void TIntermediate::mergeCallGraphs(TInfoSink& infoSink, TIntermediate& unit)
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
}
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#define MERGE_MAX(member) member = std::max(member, unit.member)
#define MERGE_TRUE(member) if (unit.member) member = unit.member;
@ -533,7 +533,7 @@ void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
//
void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage)
{
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool writeTypeComparison = false;
// Types have to match

View File

@ -241,7 +241,10 @@ class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
language(l),
profile(p), version(v), treeRoot(0),
#ifndef GLSLANG_ANGLE
profile(p), version(v),
#endif
treeRoot(0),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invertY(false),
useStorageBuffer(false),
@ -295,9 +298,20 @@ public:
#endif
}
void setVersion(int v) { version = v; }
void setVersion(int v)
{
#ifndef GLSLANG_ANGLE
version = v;
#endif
}
void setProfile(EProfile p)
{
#ifndef GLSLANG_ANGLE
profile = p;
#endif
}
int getVersion() const { return version; }
void setProfile(EProfile p) { profile = p; }
EProfile getProfile() const { return profile; }
void setSpv(const SpvVersion& s)
{
@ -929,8 +943,13 @@ protected:
typedef std::list<TCall> TGraph;
TGraph callGraph;
#ifdef GLSLANG_ANGLE
const EProfile profile = ECoreProfile;
const int version = 450;
#else
EProfile profile; // source profile
int version; // source version
#endif
SpvVersion spvVersion;
TIntermNode* treeRoot;
std::map<std::string, TExtensionBehavior> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them

View File

@ -58,7 +58,7 @@ public:
const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
bool forwardCompatible, EShMessages messages)
:
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
forwardCompatible(forwardCompatible),
profile(profile),
#endif
@ -116,9 +116,14 @@ public:
bool relaxedErrors() const { return false; }
bool suppressWarnings() const { return true; }
bool isForwardCompatible() const { return false; }
#else
#ifdef GLSLANG_ANGLE
const bool forwardCompatible = true;
const EProfile profile = ECoreProfile;
#else
bool forwardCompatible; // true if errors are to be given for use of deprecated features
EProfile profile; // the declared profile in the shader (core by default)
#endif
bool isEsProfile() const { return profile == EEsProfile; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,

View File

@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h"
#include "reflection.h"
@ -1266,4 +1266,4 @@ void TReflection::dump()
} // end namespace glslang
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

View File

@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _REFLECTION_INCLUDED
#define _REFLECTION_INCLUDED
@ -220,4 +220,4 @@ protected:
#endif // _REFLECTION_INCLUDED
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

View File

@ -687,7 +687,7 @@ private:
TShader& operator=(TShader&);
};
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// A reflection database and its interface, consistent with the OpenGL API reflection queries.
@ -805,7 +805,7 @@ public:
virtual void addStage(EShLanguage stage) = 0;
};
#endif // GLSLANG_WEB
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
// Make one TProgram per set of shaders that will get linked together. Add all
// the shaders that are to be linked together. After calling shader.parse()
@ -826,7 +826,7 @@ public:
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Reflection Interface
@ -920,7 +920,7 @@ public:
// If resolver is not provided it uses the previous approach
// and respects auto assignment and offsets.
GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
#endif
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
protected:
GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
@ -930,7 +930,7 @@ protected:
TIntermediate* intermediate[EShLangCount];
bool newedIntermediate[EShLangCount]; // track which intermediate were "new" versus reusing a singleton unit in a stage
TInfoSink* infoSink;
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
TReflection* reflection;
#endif
bool linked;

View File

@ -75,7 +75,7 @@ TEST_P(LinkTestVulkan, FromFile)
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif

View File

@ -253,7 +253,7 @@ public:
glslang::TProgram program;
program.addShader(&shader);
success &= program.link(controls);
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
@ -315,7 +315,7 @@ public:
program.addShader(&shader);
success &= program.link(controls);
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
@ -360,7 +360,7 @@ public:
glslang::TProgram program;
program.addShader(&shader);
success &= program.link(controls);
#ifndef GLSLANG_WEB
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif