Web: Selectively remove a few key features, using #ifndef GLSLANG_WEB
Save about 100K. N.B.: This is done by eliminating a function call, at a high level, not by #ifdef'ing a bunch of code. Also, removed no longer needed *_EXTENSION #ifdef in the code not needed by GLSLANG_WEB.
This commit is contained in:
parent
bfc21ff1a9
commit
23d27751e8
@ -79,6 +79,10 @@ if(ENABLE_HLSL)
|
||||
add_definitions(-DENABLE_HLSL)
|
||||
endif(ENABLE_HLSL)
|
||||
|
||||
if(ENABLE_GLSLANG_WEB)
|
||||
add_definitions(-DGLSLANG_WEB)
|
||||
endif(ENABLE_GLSLANG_WEB)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
if(MSVC)
|
||||
|
||||
@ -1592,9 +1592,11 @@ void TGlslangToSpvTraverser::finishSpv()
|
||||
for (auto it = iOSet.cbegin(); it != iOSet.cend(); ++it)
|
||||
entryPoint->addIdOperand(*it);
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// Add capabilities, extensions, remove unneeded decorations, etc.,
|
||||
// based on the resulting SPIR-V.
|
||||
builder.postProcess();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Write the SPV into 'out'.
|
||||
|
||||
@ -2089,6 +2089,7 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter
|
||||
if (parameters.lod)
|
||||
query->addIdOperand(parameters.lod);
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(query));
|
||||
addCapability(CapabilityImageQuery);
|
||||
|
||||
return query->getResultId();
|
||||
}
|
||||
|
||||
@ -51,12 +51,8 @@ namespace spv {
|
||||
#include "GLSL.std.450.h"
|
||||
#include "GLSL.ext.KHR.h"
|
||||
#include "GLSL.ext.EXT.h"
|
||||
#ifdef AMD_EXTENSIONS
|
||||
#include "GLSL.ext.AMD.h"
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
#include "GLSL.ext.NV.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace spv {
|
||||
@ -160,7 +156,6 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
|
||||
}
|
||||
break;
|
||||
case OpExtInst:
|
||||
#if AMD_EXTENSIONS
|
||||
switch (inst.getImmediateOperand(1)) {
|
||||
case GLSLstd450Frexp:
|
||||
case GLSLstd450FrexpStruct:
|
||||
@ -176,7 +171,6 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
if (basicTypeOp == OpTypeFloat && width == 16)
|
||||
@ -222,12 +216,10 @@ void Builder::postProcess(Instruction& inst)
|
||||
addCapability(CapabilityImageQuery);
|
||||
break;
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case OpGroupNonUniformPartitionNV:
|
||||
addExtension(E_SPV_NV_shader_subgroup_partitioned);
|
||||
addCapability(CapabilityGroupNonUniformPartitionedNV);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case OpLoad:
|
||||
case OpStore:
|
||||
|
||||
@ -52,26 +52,16 @@ namespace spv {
|
||||
extern "C" {
|
||||
// Include C-based headers that don't have a namespace
|
||||
#include "GLSL.std.450.h"
|
||||
#ifdef AMD_EXTENSIONS
|
||||
#include "GLSL.ext.AMD.h"
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
#include "GLSL.ext.NV.h"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
const char* GlslStd450DebugNames[spv::GLSLstd450Count];
|
||||
|
||||
namespace spv {
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
static const char* GLSLextAMDGetDebugNames(const char*, unsigned);
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
static const char* GLSLextNVGetDebugNames(const char*, unsigned);
|
||||
#endif
|
||||
|
||||
static void Kill(std::ostream& out, const char* message)
|
||||
{
|
||||
@ -82,15 +72,8 @@ static void Kill(std::ostream& out, const char* message)
|
||||
// used to identify the extended instruction library imported when printing
|
||||
enum ExtInstSet {
|
||||
GLSL450Inst,
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
GLSLextAMDInst,
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
GLSLextNVInst,
|
||||
#endif
|
||||
|
||||
OpenCLExtInst,
|
||||
};
|
||||
|
||||
@ -499,37 +482,29 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
|
||||
const char* name = idDescriptor[stream[word - 2]].c_str();
|
||||
if (0 == memcmp("OpenCL", name, 6)) {
|
||||
extInstSet = OpenCLExtInst;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (strcmp(spv::E_SPV_AMD_shader_ballot, name) == 0 ||
|
||||
strcmp(spv::E_SPV_AMD_shader_trinary_minmax, name) == 0 ||
|
||||
strcmp(spv::E_SPV_AMD_shader_explicit_vertex_parameter, name) == 0 ||
|
||||
strcmp(spv::E_SPV_AMD_gcn_shader, name) == 0) {
|
||||
extInstSet = GLSLextAMDInst;
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
}else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
|
||||
} else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
|
||||
strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
|
||||
strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 ||
|
||||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
|
||||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0 ||
|
||||
strcmp(spv::E_SPV_NV_mesh_shader, name) == 0) {
|
||||
extInstSet = GLSLextNVInst;
|
||||
#endif
|
||||
}
|
||||
unsigned entrypoint = stream[word - 1];
|
||||
if (extInstSet == GLSL450Inst) {
|
||||
if (entrypoint < GLSLstd450Count) {
|
||||
out << "(" << GlslStd450DebugNames[entrypoint] << ")";
|
||||
}
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (extInstSet == GLSLextAMDInst) {
|
||||
out << "(" << GLSLextAMDGetDebugNames(name, entrypoint) << ")";
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
}
|
||||
else if (extInstSet == GLSLextNVInst) {
|
||||
out << "(" << GLSLextNVGetDebugNames(name, entrypoint) << ")";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -653,7 +628,6 @@ static void GLSLstd450GetDebugNames(const char** names)
|
||||
names[GLSLstd450NClamp] = "NClamp";
|
||||
}
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
static const char* GLSLextAMDGetDebugNames(const char* name, unsigned entrypoint)
|
||||
{
|
||||
if (strcmp(name, spv::E_SPV_AMD_shader_ballot) == 0) {
|
||||
@ -695,9 +669,7 @@ static const char* GLSLextAMDGetDebugNames(const char* name, unsigned entrypoint
|
||||
|
||||
return "Bad";
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
|
||||
{
|
||||
if (strcmp(name, spv::E_SPV_NV_sample_mask_override_coverage) == 0 ||
|
||||
@ -751,7 +723,6 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
|
||||
}
|
||||
return "Bad";
|
||||
}
|
||||
#endif
|
||||
|
||||
void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
|
||||
{
|
||||
|
||||
@ -234,7 +234,6 @@ std::string GetDefaultTBuiltInResourceString()
|
||||
<< "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n"
|
||||
<< "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n"
|
||||
<< "MaxSamples " << DefaultTBuiltInResource.maxSamples << "\n"
|
||||
#ifdef NV_EXTENSIONS
|
||||
<< "MaxMeshOutputVerticesNV " << DefaultTBuiltInResource.maxMeshOutputVerticesNV << "\n"
|
||||
<< "MaxMeshOutputPrimitivesNV " << DefaultTBuiltInResource.maxMeshOutputPrimitivesNV << "\n"
|
||||
<< "MaxMeshWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_NV << "\n"
|
||||
@ -244,7 +243,6 @@ std::string GetDefaultTBuiltInResourceString()
|
||||
<< "MaxTaskWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n"
|
||||
<< "MaxTaskWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n"
|
||||
<< "MaxMeshViewCountNV " << DefaultTBuiltInResource.maxMeshViewCountNV << "\n"
|
||||
#endif
|
||||
<< "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n"
|
||||
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n"
|
||||
<< "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n"
|
||||
@ -451,7 +449,6 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config)
|
||||
resources->maxCombinedClipAndCullDistances = value;
|
||||
else if (tokenStr == "MaxSamples")
|
||||
resources->maxSamples = value;
|
||||
#ifdef NV_EXTENSIONS
|
||||
else if (tokenStr == "MaxMeshOutputVerticesNV")
|
||||
resources->maxMeshOutputVerticesNV = value;
|
||||
else if (tokenStr == "MaxMeshOutputPrimitivesNV")
|
||||
@ -470,7 +467,6 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config)
|
||||
resources->maxTaskWorkGroupSizeZ_NV = value;
|
||||
else if (tokenStr == "MaxMeshViewCountNV")
|
||||
resources->maxMeshViewCountNV = value;
|
||||
#endif
|
||||
else if (tokenStr == "nonInductiveForLoops")
|
||||
resources->limits.nonInductiveForLoops = (value != 0);
|
||||
else if (tokenStr == "whileLoops")
|
||||
|
||||
@ -146,11 +146,13 @@ void ProcessConfigFile()
|
||||
{
|
||||
if (ConfigFile.size() == 0)
|
||||
Resources = glslang::DefaultTBuiltInResource;
|
||||
#ifndef GLSLANG_WEB
|
||||
else {
|
||||
char* configString = ReadFileData(ConfigFile.c_str());
|
||||
glslang::DecodeResourceLimits(&Resources, configString);
|
||||
FreeFileData(configString);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int ReflectOptions = EShReflectionDefault;
|
||||
@ -1118,8 +1120,10 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
||||
} else {
|
||||
glslang::OutputSpvBin(spirv, GetBinaryName((EShLanguage)stage));
|
||||
}
|
||||
#ifndef GLSLANG_WEB
|
||||
if (!SpvToolsDisassembler && (Options & EOptionHumanReadableSpv))
|
||||
spv::Disassemble(std::cout, spirv);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1207,11 +1211,13 @@ int singleMain()
|
||||
workList.add(item.get());
|
||||
});
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
if (Options & EOptionDumpConfig) {
|
||||
printf("%s", glslang::GetDefaultTBuiltInResourceString().c_str());
|
||||
if (workList.empty())
|
||||
return ESuccess;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Options & EOptionDumpBareVersion) {
|
||||
printf("%d.%d.%d\n",
|
||||
|
||||
@ -1 +1 @@
|
||||
1202688 ../build/install/bin/glslangValidator.exe
|
||||
1097728 ../build/install/bin/glslangValidator.exe
|
||||
|
||||
@ -55,8 +55,8 @@ diff -b $BASEDIR/hlsl.automap.frag.out $TARGETDIR/hlsl.automap.frag.out || HASER
|
||||
# multi-threaded test
|
||||
#
|
||||
echo Comparing single thread to multithread for all tests in current directory...
|
||||
$EXE -i -C *.vert *.geom *.frag *.tes* *.comp > singleThread.out
|
||||
$EXE -i -C *.vert *.geom *.frag *.tes* *.comp -t > multiThread.out
|
||||
$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp > singleThread.out
|
||||
$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp -t > multiThread.out
|
||||
diff singleThread.out multiThread.out || HASERROR=1
|
||||
if [ $HASERROR -eq 0 ]
|
||||
then
|
||||
|
||||
@ -2729,6 +2729,7 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/)
|
||||
if (aggRoot && aggRoot->getOp() == EOpNull)
|
||||
aggRoot->setOperator(EOpSequence);
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// Propagate 'noContraction' label in backward from 'precise' variables.
|
||||
glslang::PropagateNoContraction(*this);
|
||||
|
||||
@ -2739,6 +2740,7 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/)
|
||||
performTextureUpgradeAndSamplerRemovalTransformation(root);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4737,9 +4737,11 @@ void TParseContext::finish()
|
||||
if (parsingBuiltins)
|
||||
return;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// Check on array indexes for ES 2.0 (version 100) limitations.
|
||||
for (size_t i = 0; i < needsIndexLimitationChecking.size(); ++i)
|
||||
constantIndexExpressionCheck(needsIndexLimitationChecking[i]);
|
||||
#endif
|
||||
|
||||
// Check for stages that are enabled by extension.
|
||||
// Can't do this at the beginning, it is chicken and egg to add a stage by
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user