From 6a8fe15772c8b7a9e131ae018141422924c33c63 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 29 Jul 2022 10:35:27 +0200 Subject: [PATCH] (glslang) SpvBuildLogger never used, remove --- Makefile.common | 1 - deps/glslang/glslang/SPIRV/CMakeLists.txt | 2 - deps/glslang/glslang/SPIRV/GlslangToSpv.cpp | 111 ++------------------ deps/glslang/glslang/SPIRV/GlslangToSpv.h | 11 +- deps/glslang/glslang/SPIRV/Logger.cpp | 68 ------------ deps/glslang/glslang/SPIRV/Logger.h | 74 ------------- deps/glslang/glslang/SPIRV/SpvBuilder.cpp | 5 +- deps/glslang/glslang/SPIRV/SpvBuilder.h | 6 +- deps/glslang/glslang/SPIRV/hex_float.h | 6 -- griffin/griffin_glslang.cpp | 1 - 10 files changed, 11 insertions(+), 274 deletions(-) delete mode 100644 deps/glslang/glslang/SPIRV/Logger.cpp delete mode 100644 deps/glslang/glslang/SPIRV/Logger.h diff --git a/Makefile.common b/Makefile.common index baa31e4991..51ee469865 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1865,7 +1865,6 @@ ifeq ($(HAVE_BUILTINGLSLANG), 1) gfx/drivers_shader/glslang.cpp \ $(DEPS_DIR)/glslang/glslang/SPIRV/GlslangToSpv.cpp \ $(DEPS_DIR)/glslang/glslang/SPIRV/InReadableOrder.cpp \ - $(DEPS_DIR)/glslang/glslang/SPIRV/Logger.cpp \ $(DEPS_DIR)/glslang/glslang/SPIRV/SpvBuilder.cpp \ $(wildcard $(DEPS_DIR)/glslang/glslang/OGLCompilersDLL/*.cpp) \ $(wildcard $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/*.cpp) \ diff --git a/deps/glslang/glslang/SPIRV/CMakeLists.txt b/deps/glslang/glslang/SPIRV/CMakeLists.txt index 3f41c63626..dd239c08ba 100755 --- a/deps/glslang/glslang/SPIRV/CMakeLists.txt +++ b/deps/glslang/glslang/SPIRV/CMakeLists.txt @@ -1,7 +1,6 @@ set(SOURCES GlslangToSpv.cpp InReadableOrder.cpp - Logger.cpp SpvBuilder.cpp doc.cpp ) @@ -18,7 +17,6 @@ set(HEADERS GLSL.ext.KHR.h GlslangToSpv.h hex_float.h - Logger.h SpvBuilder.h spvIR.h doc.h diff --git a/deps/glslang/glslang/SPIRV/GlslangToSpv.cpp b/deps/glslang/glslang/SPIRV/GlslangToSpv.cpp index 14dd24cb33..c5649c5cb9 100755 --- a/deps/glslang/glslang/SPIRV/GlslangToSpv.cpp +++ b/deps/glslang/glslang/SPIRV/GlslangToSpv.cpp @@ -114,8 +114,7 @@ struct OpDecorations { // class TGlslangToSpvTraverser : public glslang::TIntermTraverser { public: - TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate*, spv::SpvBuildLogger* logger, - glslang::SpvOptions& options); + TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate*, glslang::SpvOptions& options); virtual ~TGlslangToSpvTraverser() { } bool visitAggregate(glslang::TVisit, glslang::TIntermAggregate*); @@ -219,8 +218,6 @@ protected: spv::Instruction* entryPoint; int sequenceDepth; - spv::SpvBuildLogger* logger; - // There is a 1:1 mapping between a spv builder and a module; this is thread safe spv::Builder builder; bool inEntryPoint; @@ -1010,13 +1007,12 @@ bool HasNonLayoutQualifiers(const glslang::TType& type, const glslang::TQualifie // Implement the TGlslangToSpvTraverser class. // -TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate* glslangIntermediate, - spv::SpvBuildLogger* buildLogger, glslang::SpvOptions& options) +TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate* glslangIntermediate, glslang::SpvOptions& options) : TIntermTraverser(true, false, true), options(options), shaderEntry(nullptr), currentFunction(nullptr), - sequenceDepth(0), logger(buildLogger), - builder(spvVersion, (glslang::GetKhronosToolId() << 16) | glslang::GetSpirvGeneratorVersion(), logger), + sequenceDepth(0), + builder(spvVersion, (glslang::GetKhronosToolId() << 16) | glslang::GetSpirvGeneratorVersion()), inEntryPoint(false), entryPointTerminated(false), linkageOnly(false), glslangIntermediate(glslangIntermediate) { @@ -1025,29 +1021,6 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const gl builder.clearAccessChain(); builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()), glslangIntermediate->getVersion()); - - if (options.generateDebugInfo) { - builder.setEmitOpLines(); - builder.setSourceFile(glslangIntermediate->getSourceFile()); - - // Set the source shader's text. If for SPV version 1.0, include - // a preamble in comments stating the OpModuleProcessed instructions. - // Otherwise, emit those as actual instructions. - std::string text; - const std::vector& processes = glslangIntermediate->getProcesses(); - for (int p = 0; p < (int)processes.size(); ++p) { - if (glslangIntermediate->getSpv().spv < 0x00010100) { - text.append("// OpModuleProcessed "); - text.append(processes[p]); - text.append("\n"); - } else - builder.addModuleProcessed(processes[p]); - } - if (glslangIntermediate->getSpv().spv < 0x00010100 && (int)processes.size() > 0) - text.append("#line 1\n"); - text.append(glslangIntermediate->getSourceText()); - builder.setSourceText(text); - } stdBuiltins = builder.import("GLSL.std.450"); builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450); shaderEntry = builder.makeEntryPoint(glslangIntermediate->getEntryPointName().c_str()); @@ -1437,7 +1410,6 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T } return false; case glslang::EOpMatrixSwizzle: - logger->missingFunctionality("matrix swizzle"); return true; case glslang::EOpLogicalOr: case glslang::EOpLogicalAnd: @@ -1480,7 +1452,6 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T builder.clearAccessChain(); if (! result) { - logger->missingFunctionality("unknown glslang binary operation"); return true; // pick up a child as the place-holder result } else { builder.setAccessChainRValue(result); @@ -1637,7 +1608,6 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI return false; default: - logger->missingFunctionality("unknown glslang unary"); return true; // pick up operand as placeholder result } } @@ -1755,8 +1725,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt if (result) { builder.clearAccessChain(); builder.setAccessChainRValue(result); - } else - logger->missingFunctionality("missing user function; linker needs to catch that"); + } return false; } @@ -2122,7 +2091,6 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt return false; if (! result) { - logger->missingFunctionality("unknown glslang aggregate"); return true; // pick up a child as a placeholder operand } else { builder.clearAccessChain(); @@ -5564,7 +5532,6 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op break; #endif default: - logger->missingFunctionality("invocation operation"); return spv::NoResult; } @@ -6406,7 +6373,6 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv: } #endif default: - logger->missingFunctionality("unknown operation with no arguments"); return 0; } } @@ -6588,7 +6554,6 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n // Neither a front-end constant node, nor a specialization constant node with constant union array or // constant sub tree as initializer. - logger->missingFunctionality("Neither a front-end constant nor a spec constant."); exit(1); return spv::NoResult; } @@ -6869,14 +6834,6 @@ spv::Id TGlslangToSpvTraverser::getExtBuiltins(const char* name) namespace glslang { -void GetSpirvVersion(std::string& version) -{ - const int bufSize = 100; - char buf[bufSize]; - snprintf(buf, bufSize, "0x%08x, Revision %d", spv::Version, spv::Revision); - version = buf; -} - // For low-order part of the generator's magic number. Bump up // when there is a change in the style (e.g., if SSA form changes, // or a different instruction sequence to do something gets used). @@ -6892,63 +6849,8 @@ int GetSpirvGeneratorVersion() return 7; // GLSL volatile keyword maps to both SPIR-V decorations Volatile and Coherent } -// Write SPIR-V out to a binary file -void OutputSpvBin(const std::vector& spirv, const char* baseName) -{ - std::ofstream out; - out.open(baseName, std::ios::binary | std::ios::out); - if (out.fail()) - printf("ERROR: Failed to open file: %s\n", baseName); - for (int i = 0; i < (int)spirv.size(); ++i) { - unsigned int word = spirv[i]; - out.write((const char*)&word, 4); - } - out.close(); -} - -// Write SPIR-V out to a text file with 32-bit hexadecimal words -void OutputSpvHex(const std::vector& spirv, const char* baseName, const char* varName) -{ - std::ofstream out; - out.open(baseName, std::ios::binary | std::ios::out); - if (out.fail()) - printf("ERROR: Failed to open file: %s\n", baseName); - out << "\t// " << - glslang::GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL << - std::endl; - if (varName != nullptr) { - out << "\t #pragma once" << std::endl; - out << "const uint32_t " << varName << "[] = {" << std::endl; - } - const int WORDS_PER_LINE = 8; - for (int i = 0; i < (int)spirv.size(); i += WORDS_PER_LINE) { - out << "\t"; - for (int j = 0; j < WORDS_PER_LINE && i + j < (int)spirv.size(); ++j) { - const unsigned int word = spirv[i + j]; - out << "0x" << std::hex << std::setw(8) << std::setfill('0') << word; - if (i + j + 1 < (int)spirv.size()) { - out << ","; - } - } - out << std::endl; - } - if (varName != nullptr) { - out << "};"; - } - out.close(); -} - -// // Set up the glslang traversal -// void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv, SpvOptions* options) -{ - spv::SpvBuildLogger logger; - GlslangToSpv(intermediate, spirv, &logger, options); -} - -void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv, - spv::SpvBuildLogger* logger, SpvOptions* options) { TIntermNode* root = intermediate.getTreeRoot(); @@ -6961,7 +6863,7 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vectortraverse(&it); it.finishSpv(); it.dumpSpv(spirv); @@ -7019,4 +6921,5 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector #include -#include "Logger.h" - namespace glslang { struct SpvOptions { - SpvOptions() : generateDebugInfo(false), disableOptimizer(true), + SpvOptions() : disableOptimizer(true), optimizeSize(false) { } - bool generateDebugInfo; bool disableOptimizer; bool optimizeSize; }; -void GetSpirvVersion(std::string&); int GetSpirvGeneratorVersion(); void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv, SpvOptions* options = nullptr); -void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv, - spv::SpvBuildLogger* logger, SpvOptions* options = nullptr); -void OutputSpvBin(const std::vector& spirv, const char* baseName); -void OutputSpvHex(const std::vector& spirv, const char* baseName, const char* varName); - } diff --git a/deps/glslang/glslang/SPIRV/Logger.cpp b/deps/glslang/glslang/SPIRV/Logger.cpp deleted file mode 100644 index 48bd4e3ade..0000000000 --- a/deps/glslang/glslang/SPIRV/Logger.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (C) 2016 Google, Inc. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#include "Logger.h" - -#include -#include -#include - -namespace spv { - -void SpvBuildLogger::tbdFunctionality(const std::string& f) -{ - if (std::find(std::begin(tbdFeatures), std::end(tbdFeatures), f) == std::end(tbdFeatures)) - tbdFeatures.push_back(f); -} - -void SpvBuildLogger::missingFunctionality(const std::string& f) -{ - if (std::find(std::begin(missingFeatures), std::end(missingFeatures), f) == std::end(missingFeatures)) - missingFeatures.push_back(f); -} - -std::string SpvBuildLogger::getAllMessages() const { - std::ostringstream messages; - for (auto it = tbdFeatures.cbegin(); it != tbdFeatures.cend(); ++it) - messages << "TBD functionality: " << *it << "\n"; - for (auto it = missingFeatures.cbegin(); it != missingFeatures.cend(); ++it) - messages << "Missing functionality: " << *it << "\n"; - for (auto it = warnings.cbegin(); it != warnings.cend(); ++it) - messages << "warning: " << *it << "\n"; - for (auto it = errors.cbegin(); it != errors.cend(); ++it) - messages << "error: " << *it << "\n"; - return messages.str(); -} - -} // end spv namespace diff --git a/deps/glslang/glslang/SPIRV/Logger.h b/deps/glslang/glslang/SPIRV/Logger.h deleted file mode 100644 index 2e4ddaf517..0000000000 --- a/deps/glslang/glslang/SPIRV/Logger.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (C) 2016 Google, Inc. -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -#ifndef GLSLANG_SPIRV_LOGGER_H -#define GLSLANG_SPIRV_LOGGER_H - -#include -#include - -namespace spv { - -// A class for holding all SPIR-V build status messages, including -// missing/TBD functionalities, warnings, and errors. -class SpvBuildLogger { -public: - SpvBuildLogger() {} - - // Registers a TBD functionality. - void tbdFunctionality(const std::string& f); - // Registers a missing functionality. - void missingFunctionality(const std::string& f); - - // Logs a warning. - void warning(const std::string& w) { warnings.push_back(w); } - // Logs an error. - void error(const std::string& e) { errors.push_back(e); } - - // Returns all messages accumulated in the order of: - // TBD functionalities, missing functionalities, warnings, errors. - std::string getAllMessages() const; - -private: - SpvBuildLogger(const SpvBuildLogger&); - - std::vector tbdFeatures; - std::vector missingFeatures; - std::vector warnings; - std::vector errors; -}; - -} // end spv namespace - -#endif // GLSLANG_SPIRV_LOGGER_H diff --git a/deps/glslang/glslang/SPIRV/SpvBuilder.cpp b/deps/glslang/glslang/SPIRV/SpvBuilder.cpp index 10d655b00b..c4d5b2f039 100755 --- a/deps/glslang/glslang/SPIRV/SpvBuilder.cpp +++ b/deps/glslang/glslang/SPIRV/SpvBuilder.cpp @@ -54,7 +54,7 @@ namespace spv { -Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogger* buildLogger) : +Builder::Builder(unsigned int spvVersion, unsigned int magicNumber) : spvVersion(spvVersion), source(SourceLanguageUnknown), sourceVersion(0), @@ -67,8 +67,7 @@ Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogg buildPoint(0), uniqueId(0), entryPointFunction(0), - generatingOpCodeForSpecConst(false), - logger(buildLogger) + generatingOpCodeForSpecConst(false) { clearAccessChain(); } diff --git a/deps/glslang/glslang/SPIRV/SpvBuilder.h b/deps/glslang/glslang/SPIRV/SpvBuilder.h index 099b1d957f..f6252fdd64 100755 --- a/deps/glslang/glslang/SPIRV/SpvBuilder.h +++ b/deps/glslang/glslang/SPIRV/SpvBuilder.h @@ -46,7 +46,6 @@ #ifndef SpvBuilder_H #define SpvBuilder_H -#include "Logger.h" #include "spirv.hpp" #include "spvIR.h" @@ -62,7 +61,7 @@ namespace spv { class Builder { public: - Builder(unsigned int spvVersion, unsigned int userNumber, SpvBuildLogger* logger); + Builder(unsigned int spvVersion, unsigned int userNumber); virtual ~Builder(); static const int maxMatrixSize = 4; @@ -638,9 +637,6 @@ public: // Our loop stack. std::stack loops; - - // The stream for outputting warnings and errors. - SpvBuildLogger* logger; }; // end Builder class }; // end spv namespace diff --git a/deps/glslang/glslang/SPIRV/hex_float.h b/deps/glslang/glslang/SPIRV/hex_float.h index 905b21a45a..3a3a9f6594 100644 --- a/deps/glslang/glslang/SPIRV/hex_float.h +++ b/deps/glslang/glslang/SPIRV/hex_float.h @@ -25,10 +25,6 @@ #if defined(_MSC_VER) && _MSC_VER < 1800 namespace std { -bool isnan(double f) -{ - return ::_isnan(f) != 0; -} bool isinf(double f) { return ::_finite(f) == 0; @@ -75,7 +71,6 @@ struct FloatProxyTraits { template <> struct FloatProxyTraits { typedef uint32_t uint_type; - static bool isNan(float f) { return std::isnan(f); } // Returns true if the given value is any kind of infinity. static bool isInfinity(float f) { return std::isinf(f); } // Returns the maximum normal value. @@ -87,7 +82,6 @@ struct FloatProxyTraits { template <> struct FloatProxyTraits { typedef uint64_t uint_type; - static bool isNan(double f) { return std::isnan(f); } // Returns true if the given value is any kind of infinity. static bool isInfinity(double f) { return std::isinf(f); } // Returns the maximum normal value. diff --git a/griffin/griffin_glslang.cpp b/griffin/griffin_glslang.cpp index d3d8b882ee..0c35ecbbe4 100644 --- a/griffin/griffin_glslang.cpp +++ b/griffin/griffin_glslang.cpp @@ -11,7 +11,6 @@ #include "../gfx/drivers_shader/glslang.cpp" #include "../deps/glslang/glslang/SPIRV/GlslangToSpv.cpp" #include "../deps/glslang/glslang/SPIRV/InReadableOrder.cpp" -#include "../deps/glslang/glslang/SPIRV/Logger.cpp" #include "../deps/glslang/glslang/SPIRV/SpvBuilder.cpp" #include "../deps/glslang/glslang/OGLCompilersDLL/InitializeDll.cpp"