Web: Remove unused stage functionality, SPIR-V logger, and hex_utils
Saves another 20K.
This commit is contained in:
parent
39697cdb9d
commit
155d351f86
20 changed files with 450 additions and 390 deletions
|
|
@ -248,6 +248,10 @@ protected:
|
|||
// 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 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
|||
{
|
||||
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 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return spv::BuiltInPointSize;
|
||||
|
||||
case glslang::EbvPosition: return spv::BuiltInPosition;
|
||||
|
|
@ -1664,6 +1670,7 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
|
|||
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 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node)
|
||||
|
|
@ -2151,12 +2159,14 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
|||
|
||||
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 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||
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 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
|||
// 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 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv:
|
|||
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 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
|
|||
|
||||
// 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 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
|
|||
}
|
||||
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 @@ 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
|
||||
std::ofstream out;
|
||||
out.open(baseName, std::ios::binary | std::ios::out);
|
||||
if (out.fail())
|
||||
|
|
@ -8141,6 +8161,7 @@ void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName,
|
|||
out << "};";
|
||||
}
|
||||
out.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
|
@ -66,3 +68,5 @@ std::string SpvBuildLogger::getAllMessages() const {
|
|||
}
|
||||
|
||||
} // end spv namespace
|
||||
|
||||
#endif
|
||||
|
|
@ -46,6 +46,14 @@ class SpvBuildLogger {
|
|||
public:
|
||||
SpvBuildLogger() {}
|
||||
|
||||
#ifdef GLSLANG_WEB
|
||||
void tbdFunctionality(const std::string& f) { }
|
||||
void missingFunctionality(const std::string& f) { }
|
||||
void warning(const std::string& w) { }
|
||||
void error(const std::string& e) { errors.push_back(e); }
|
||||
std::string getAllMessages() { return ""; }
|
||||
#else
|
||||
|
||||
// Registers a TBD functionality.
|
||||
void tbdFunctionality(const std::string& f);
|
||||
// Registers a missing functionality.
|
||||
|
|
@ -59,6 +67,7 @@ public:
|
|||
// Returns all messages accumulated in the order of:
|
||||
// TBD functionalities, missing functionalities, warnings, errors.
|
||||
std::string getAllMessages() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
SpvBuildLogger(const SpvBuildLogger&);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@
|
|||
|
||||
#include "SpvBuilder.h"
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
#include "hex_float.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <cstdio>
|
||||
|
|
@ -950,6 +952,10 @@ Id Builder::makeFloatConstant(float f, bool specConstant)
|
|||
|
||||
Id Builder::makeDoubleConstant(double d, bool specConstant)
|
||||
{
|
||||
#ifdef GLSLANG_WEB
|
||||
assert(0);
|
||||
return NoResult;
|
||||
#else
|
||||
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||
Id typeId = makeFloatType(64);
|
||||
union { double db; unsigned long long ull; } u;
|
||||
|
|
@ -974,10 +980,15 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
|
|||
module.mapInstruction(c);
|
||||
|
||||
return c->getResultId();
|
||||
#endif
|
||||
}
|
||||
|
||||
Id Builder::makeFloat16Constant(float f16, bool specConstant)
|
||||
{
|
||||
#ifdef GLSLANG_WEB
|
||||
assert(0);
|
||||
return NoResult;
|
||||
#else
|
||||
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||
Id typeId = makeFloatType(16);
|
||||
|
||||
|
|
@ -1002,6 +1013,7 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
|
|||
module.mapInstruction(c);
|
||||
|
||||
return c->getResultId();
|
||||
#endif
|
||||
}
|
||||
|
||||
Id Builder::makeFpConstant(Id type, double d, bool specConstant)
|
||||
|
|
|
|||
|
|
@ -41,8 +41,10 @@
|
|||
#ifndef GLSLANG_SPV_TOOLS_H
|
||||
#define GLSLANG_SPV_TOOLS_H
|
||||
|
||||
#ifdef ENABLE_OPT
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#endif
|
||||
|
||||
#include "../glslang/MachineIndependent/localintermediate.h"
|
||||
#include "Logger.h"
|
||||
|
|
@ -59,7 +61,7 @@ struct SpvOptions {
|
|||
bool validate;
|
||||
};
|
||||
|
||||
#if ENABLE_OPT
|
||||
#ifdef ENABLE_OPT
|
||||
|
||||
// Use the SPIRV-Tools disassembler to print SPIR-V.
|
||||
void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& spirv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue