Web: Remove/rationalize a set of *_EXTENSIONS, using GLSLANG_WEB.
Focus was on the front end (not SPIR-V), minus the grammar. Reduces #ifdef count by around 320 and makes the web build 270K smaller, which is about 90% the target size. The grammar and scanner will be another step, as will the SPIR-V backend. This makes heavy use of methods #ifdef'd to return false as a global way of turning off code, relying on C++ DCE to do the rest.
This commit is contained in:
parent
e66dace97e
commit
7015bd658e
32 changed files with 2661 additions and 2712 deletions
|
|
@ -145,6 +145,8 @@
|
|||
|
||||
namespace glslang {
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
//
|
||||
// Initialize all extensions, almost always to 'disable', as once their features
|
||||
// are incorporated into a core version, their features are supported through allowing that
|
||||
|
|
@ -221,7 +223,6 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
||||
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
extensionBehavior[E_GL_AMD_shader_ballot] = EBhDisable;
|
||||
extensionBehavior[E_GL_AMD_shader_trinary_minmax] = EBhDisable;
|
||||
extensionBehavior[E_GL_AMD_shader_explicit_vertex_parameter] = EBhDisable;
|
||||
|
|
@ -232,9 +233,7 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_AMD_shader_image_load_store_lod] = EBhDisable;
|
||||
extensionBehavior[E_GL_AMD_shader_fragment_mask] = EBhDisable;
|
||||
extensionBehavior[E_GL_AMD_gpu_shader_half_float_fetch] = EBhDisable;
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable;
|
||||
extensionBehavior[E_SPV_NV_geometry_shader_passthrough] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_viewport_array2] = EBhDisable;
|
||||
|
|
@ -250,7 +249,6 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable;
|
||||
#endif
|
||||
|
||||
extensionBehavior[E_GL_NV_cooperative_matrix] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shader_sm_builtins] = EBhDisable;
|
||||
|
|
@ -302,6 +300,7 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_float32] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_float64] = EBhDisable;
|
||||
}
|
||||
#endif // GLSLANG_WEB
|
||||
|
||||
// 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).
|
||||
|
|
@ -311,6 +310,9 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
preamble =
|
||||
"#define GL_ES 1\n"
|
||||
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
|
||||
#ifdef GLSLANG_WEB
|
||||
;
|
||||
#else
|
||||
"#define GL_OES_texture_3D 1\n"
|
||||
"#define GL_OES_standard_derivatives 1\n"
|
||||
"#define GL_EXT_frag_depth 1\n"
|
||||
|
|
@ -350,11 +352,9 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
|
||||
;
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (profile == EEsProfile && version >= 300) {
|
||||
preamble += "#define GL_NV_shader_noperspective_interpolation 1\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
preamble =
|
||||
|
|
@ -412,7 +412,6 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define E_GL_EXT_shader_atomic_int64 1\n"
|
||||
"#define E_GL_EXT_shader_realtime_clock 1\n"
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
"#define GL_AMD_shader_ballot 1\n"
|
||||
"#define GL_AMD_shader_trinary_minmax 1\n"
|
||||
"#define GL_AMD_shader_explicit_vertex_parameter 1\n"
|
||||
|
|
@ -423,9 +422,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_AMD_shader_image_load_store_lod 1\n"
|
||||
"#define GL_AMD_shader_fragment_mask 1\n"
|
||||
"#define GL_AMD_gpu_shader_half_float_fetch 1\n"
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
"#define GL_NV_sample_mask_override_coverage 1\n"
|
||||
"#define GL_NV_geometry_shader_passthrough 1\n"
|
||||
"#define GL_NV_viewport_array2 1\n"
|
||||
|
|
@ -438,7 +435,6 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_NV_compute_shader_derivatives 1\n"
|
||||
"#define GL_NV_shader_texture_footprint 1\n"
|
||||
"#define GL_NV_mesh_shader 1\n"
|
||||
#endif
|
||||
"#define GL_NV_cooperative_matrix 1\n"
|
||||
|
||||
"#define GL_EXT_shader_explicit_arithmetic_types 1\n"
|
||||
|
|
@ -458,8 +454,10 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
if (profile == ECompatibilityProfile)
|
||||
preamble += "#define GL_compatibility_profile 1\n";
|
||||
}
|
||||
#endif // GLSLANG_WEB
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
if ((profile != EEsProfile && version >= 140) ||
|
||||
(profile == EEsProfile && version >= 310)) {
|
||||
preamble +=
|
||||
|
|
@ -481,6 +479,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
|
||||
"#define GL_GOOGLE_include_directive 1\n"
|
||||
;
|
||||
#endif
|
||||
|
||||
// #define VULKAN XXXX
|
||||
const int numberBufSize = 12;
|
||||
|
|
@ -491,6 +490,8 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
preamble += numberBuf;
|
||||
preamble += "\n";
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// #define GL_SPIRV XXXX
|
||||
if (spvVersion.openGl > 0) {
|
||||
preamble += "#define GL_SPIRV ";
|
||||
|
|
@ -498,7 +499,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
preamble += numberBuf;
|
||||
preamble += "\n";
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -528,7 +529,6 @@ const char* StageName(EShLanguage stage)
|
|||
case EShLangGeometry: return "geometry";
|
||||
case EShLangFragment: return "fragment";
|
||||
case EShLangCompute: return "compute";
|
||||
#ifdef NV_EXTENSIONS
|
||||
case EShLangRayGenNV: return "ray-generation";
|
||||
case EShLangIntersectNV: return "intersection";
|
||||
case EShLangAnyHitNV: return "any-hit";
|
||||
|
|
@ -537,7 +537,6 @@ const char* StageName(EShLanguage stage)
|
|||
case EShLangCallableNV: return "callable";
|
||||
case EShLangMeshNV: return "mesh";
|
||||
case EShLangTaskNV: return "task";
|
||||
#endif
|
||||
default: return "unknown stage";
|
||||
}
|
||||
}
|
||||
|
|
@ -609,6 +608,13 @@ void TParseVersions::requireStage(const TSourceLoc& loc, EShLanguage stage, cons
|
|||
requireStage(loc, static_cast<EShLanguageMask>(1 << stage), featureDesc);
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
void TParseVersions::unimplemented(const TSourceLoc& loc, const char* featureDesc)
|
||||
{
|
||||
error(loc, "feature not yet implemented", featureDesc, "");
|
||||
}
|
||||
|
||||
//
|
||||
// Within a set of profiles, see if a feature is deprecated and give an error or warning based on whether
|
||||
// a future compatibility context is being use.
|
||||
|
|
@ -642,11 +648,6 @@ void TParseVersions::requireNotRemoved(const TSourceLoc& loc, int profileMask, i
|
|||
}
|
||||
}
|
||||
|
||||
void TParseVersions::unimplemented(const TSourceLoc& loc, const char* featureDesc)
|
||||
{
|
||||
error(loc, "feature not yet implemented", featureDesc, "");
|
||||
}
|
||||
|
||||
// Returns true if at least one of the extensions in the extensions parameter is requested. Otherwise, returns false.
|
||||
// Warns appropriately if the requested behavior of an extension is "warn".
|
||||
bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
|
||||
|
|
@ -815,10 +816,8 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
|
|||
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
|
||||
else if (strcmp(extension, "GL_KHR_shader_subgroup_quad") == 0)
|
||||
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
|
||||
#ifdef NV_EXTENSIONS
|
||||
else if (strcmp(extension, "GL_NV_shader_subgroup_partitioned") == 0)
|
||||
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
|
||||
#endif
|
||||
else if (strcmp(extension, "GL_EXT_buffer_reference2") == 0)
|
||||
updateExtensionBehavior(line, "GL_EXT_buffer_reference", behaviorString);
|
||||
}
|
||||
|
|
@ -866,7 +865,6 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
|
|||
// Check if extension is used with correct shader stage.
|
||||
void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * const extension)
|
||||
{
|
||||
#ifdef NV_EXTENSIONS
|
||||
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
|
||||
if (strcmp(extension, "GL_NV_mesh_shader") == 0) {
|
||||
requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask | EShLangFragmentMask),
|
||||
|
|
@ -874,7 +872,6 @@ void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * con
|
|||
profileRequires(loc, ECoreProfile, 450, 0, "#extension GL_NV_mesh_shader");
|
||||
profileRequires(loc, EEsProfile, 320, 0, "#extension GL_NV_mesh_shader");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Call for any operation needing full GLSL integer data-type support.
|
||||
|
|
@ -896,9 +893,7 @@ void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool bu
|
|||
{
|
||||
if (!builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_float16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
|
||||
|
|
@ -908,9 +903,7 @@ void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool bu
|
|||
bool TParseVersions::float16Arithmetic()
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_float16};
|
||||
return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions);
|
||||
|
|
@ -919,9 +912,7 @@ bool TParseVersions::float16Arithmetic()
|
|||
bool TParseVersions::int16Arithmetic()
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_int16};
|
||||
return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions);
|
||||
|
|
@ -943,9 +934,7 @@ void TParseVersions::requireFloat16Arithmetic(const TSourceLoc& loc, const char*
|
|||
combined += featureDesc;
|
||||
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_float16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, combined.c_str());
|
||||
|
|
@ -959,9 +948,7 @@ void TParseVersions::requireInt16Arithmetic(const TSourceLoc& loc, const char* o
|
|||
combined += featureDesc;
|
||||
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_int16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, combined.c_str());
|
||||
|
|
@ -984,9 +971,7 @@ void TParseVersions::float16ScalarVectorCheck(const TSourceLoc& loc, const char*
|
|||
{
|
||||
if (!builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_EXT_shader_16bit_storage,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_float16};
|
||||
|
|
@ -1026,7 +1011,6 @@ void TParseVersions::explicitInt8Check(const TSourceLoc& loc, const char* op, bo
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
// Call for any operation needing GLSL float16 opaque-type support
|
||||
void TParseVersions::float16OpaqueCheck(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
|
|
@ -1036,16 +1020,13 @@ void TParseVersions::float16OpaqueCheck(const TSourceLoc& loc, const char* op, b
|
|||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Call for any operation needing GLSL explicit int16 data-type support.
|
||||
void TParseVersions::explicitInt16Check(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (! builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_int16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
|
||||
|
|
@ -1056,9 +1037,7 @@ void TParseVersions::int16ScalarVectorCheck(const TSourceLoc& loc, const char* o
|
|||
{
|
||||
if (! builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_EXT_shader_16bit_storage,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types,
|
||||
E_GL_EXT_shader_explicit_arithmetic_types_int16};
|
||||
|
|
@ -1107,6 +1086,7 @@ void TParseVersions::fcoopmatCheck(const TSourceLoc& loc, const char* op, bool b
|
|||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
|
||||
}
|
||||
}
|
||||
#endif // GLSLANG_WEB
|
||||
|
||||
// Call for any operation removed because SPIR-V is in use.
|
||||
void TParseVersions::spvRemoved(const TSourceLoc& loc, const char* op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue