Web: Remove unused stage functionality, SPIR-V logger, and hex_utils
Saves another 20K.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 12c6e49..a91f180 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -248,6 +248,10 @@
// Translate glslang profile to SPIR-V source language.
spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile profile)
{
+#ifdef GLSLANG_WEB
+ return spv::SourceLanguageESSL;
+#endif
+
switch (source) {
case glslang::EShSourceGlsl:
switch (profile) {
@@ -601,6 +605,7 @@
{
switch (builtIn) {
case glslang::EbvPointSize:
+#ifndef GLSLANG_WEB
// Defer adding the capability until the built-in is actually used.
if (! memberDeclaration) {
switch (glslangIntermediate->getStage()) {
@@ -615,6 +620,7 @@
break;
}
}
+#endif
return spv::BuiltInPointSize;
case glslang::EbvPosition: return spv::BuiltInPosition;
@@ -1664,6 +1670,7 @@
builder.setAccessChainLValue(id);
}
+#ifndef GLSLANG_WEB
// Process linkage-only nodes for any special additional interface work.
if (linkageOnly) {
if (glslangIntermediate->getHlslFunctionality1()) {
@@ -1695,6 +1702,7 @@
}
}
}
+#endif
}
bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node)
@@ -2151,12 +2159,14 @@
return false;
+#ifndef GLSLANG_WEB
case glslang::EOpEmitStreamVertex:
builder.createNoResultOp(spv::OpEmitStreamVertex, operand);
return false;
case glslang::EOpEndStreamPrimitive:
builder.createNoResultOp(spv::OpEndStreamPrimitive, operand);
return false;
+#endif
default:
logger->missingFunctionality("unknown glslang unary");
@@ -4123,8 +4133,12 @@
std::vector<std::vector<spv::Decoration>> paramDecorations; // list of decorations per parameter
glslang::TIntermSequence& parameters = glslFunction->getSequence()[0]->getAsAggregate()->getSequence();
+#ifdef ENABLE_HLSL
bool implicitThis = (int)parameters.size() > 0 && parameters[0]->getAsSymbolNode()->getName() ==
glslangIntermediate->implicitThisName;
+#else
+ bool implicitThis = false;
+#endif
paramDecorations.resize(parameters.size());
for (int p = 0; p < (int)parameters.size(); ++p) {
@@ -7396,11 +7410,11 @@
// Intrinsics with no arguments (or no return value, and no precision).
spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId)
{
+#ifndef GLSLANG_WEB
// GLSL memory barriers use queuefamily scope in new model, device scope in old model
spv::Scope memoryBarrierScope = glslangIntermediate->usingVulkanMemoryModel() ? spv::ScopeQueueFamilyKHR : spv::ScopeDevice;
switch (op) {
-#ifndef GLSLANG_WEB
case glslang::EOpEmitVertex:
builder.createNoResultOp(spv::OpEmitVertex);
return 0;
@@ -7538,11 +7552,14 @@
builder.addCapability(spv::CapabilityShaderClockKHR);
return builder.createOp(spv::OpReadClockKHR, typeId, args);
}
-#endif
default:
- logger->missingFunctionality("unknown operation with no arguments");
- return 0;
+ break;
}
+#endif
+
+ logger->missingFunctionality("unknown operation with no arguments");
+
+ return 0;
}
spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol)
@@ -7745,6 +7762,7 @@
// We now know we have a specialization constant to build
+#ifndef GLSLANG_WEB
// gl_WorkGroupSize is a special case until the front-end handles hierarchical specialization constants,
// even then, it's specialization ids are handled by special case syntax in GLSL: layout(local_size_x = ...
if (node.getType().getQualifier().builtIn == glslang::EbvWorkGroupSize) {
@@ -7759,6 +7777,7 @@
}
return builder.makeCompositeConstant(builder.makeVectorType(builder.makeUintType(32), 3), dimConstId, true);
}
+#endif
// An AST node labelled as specialization constant should be a symbol node.
// Its initializer should either be a sub tree with constant nodes, or a constant union array.
@@ -8114,6 +8133,7 @@
// 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
std::ofstream out;
out.open(baseName, std::ios::binary | std::ios::out);
if (out.fail())
@@ -8141,6 +8161,7 @@
out << "};";
}
out.close();
+#endif
}
//