#include <cstring>
#include <iostream>
#include <sstream>
#include <memory>
#include <mutex>
#include "SymbolTable.h"
#include "ParseHelper.h"
#include "Scan.h"
#include "ScanContext.h"
#ifdef ENABLE_HLSL
#include "../HLSL/hlslParseHelper.h"
#include "../HLSL/hlslParseables.h"
#include "../HLSL/hlslScanContext.h"
#endif
#include "../Include/ShHandle.h"
#include "preprocessor/PpContext.h"
#define SH_EXPORTING
#include "../Public/ShaderLang.h"
#include "reflection.h"
#include "iomapper.h"
#include "Initialize.h"
#include "preprocessor/PpTokens.h"
#include "glslang/build_info.h"
namespace {
int NumberOfClients = …;
#ifndef DISABLE_THREAD_SUPPORT
std::mutex init_lock;
#endif
usingnamespaceglslang;
TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource source)
{ … }
TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& intermediate,
int version, EProfile profile, EShSource source,
EShLanguage language, TInfoSink& infoSink,
SpvVersion spvVersion, bool forwardCompatible, EShMessages messages,
bool parsingBuiltIns, std::string sourceEntryPointName = "")
{ … }
const int VersionCount = …;
int MapVersionToIndex(int version)
{ … }
const int SpvVersionCount = …;
int MapSpvVersionToIndex(const SpvVersion& spvVersion)
{ … }
const int ProfileCount = …;
int MapProfileToIndex(EProfile profile)
{ … }
const int SourceCount = …;
int MapSourceToIndex(EShSource source)
{ … }
enum EPrecisionClass { … };
TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EPcCount] = …;
TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EShLangCount] = …;
TPoolAllocator* PerProcessGPA = …;
bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
EShSource source, TInfoSink& infoSink, TSymbolTable& symbolTable)
{ … }
int CommonIndex(EProfile profile, EShLanguage language)
{ … }
void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int version, EProfile profile, const SpvVersion& spvVersion,
EShLanguage language, EShSource source, TInfoSink& infoSink, TSymbolTable** commonTable,
TSymbolTable** symbolTables)
{ … }
bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TSymbolTable** symbolTables, int version, EProfile profile, const SpvVersion& spvVersion, EShSource source)
{ … }
bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable& symbolTable, int version,
EProfile profile, const SpvVersion& spvVersion, EShLanguage language, EShSource source)
{ … }
void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& spvVersion, EShSource source)
{ … }
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
{ … }
bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNotFirst, int defaultVersion,
EShSource source, int& version, EProfile& profile, const SpvVersion& spvVersion)
{ … }
void TranslateEnvironment(const TEnvironment* environment, EShMessages& messages, EShSource& source,
EShLanguage& stage, SpvVersion& spvVersion)
{ … }
void RecordProcesses(TIntermediate& intermediate, EShMessages messages, const std::string& sourceEntryPointName)
{ … }
template<typename ProcessingContext>
bool ProcessDeferred(
TCompiler* compiler,
const char* const shaderStrings[],
const int numStrings,
const int* inputLengths,
const char* const stringNames[],
const char* customPreamble,
const EShOptimizationLevel optLevel,
const TBuiltInResource* resources,
int defaultVersion,
EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
int overrideVersion,
bool forwardCompatible,
EShMessages messages,
TIntermediate& intermediate,
ProcessingContext& processingContext,
bool requireNonempty,
TShader::Includer& includer,
const std::string sourceEntryPointName = "",
const TEnvironment* environment = nullptr,
bool compileOnly = false)
{ … }
class SourceLineSynchronizer { … };
struct DoPreprocessing { … };
struct DoFullParse{ … };
bool PreprocessDeferred(
TCompiler* compiler,
const char* const shaderStrings[],
const int numStrings,
const int* inputLengths,
const char* const stringNames[],
const char* preamble,
const EShOptimizationLevel optLevel,
const TBuiltInResource* resources,
int defaultVersion,
EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
int overrideVersion,
bool forwardCompatible,
EShMessages messages,
TShader::Includer& includer,
TIntermediate& intermediate,
std::string* outputString,
TEnvironment* environment = nullptr)
{ … }
bool CompileDeferred(
TCompiler* compiler,
const char* const shaderStrings[],
const int numStrings,
const int* inputLengths,
const char* const stringNames[],
const char* preamble,
const EShOptimizationLevel optLevel,
const TBuiltInResource* resources,
int defaultVersion,
EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
int overrideVersion,
bool forwardCompatible,
EShMessages messages,
TIntermediate& intermediate,
TShader::Includer& includer,
const std::string sourceEntryPointName = "",
TEnvironment* environment = nullptr,
bool compileOnly = false)
{ … }
}
int ShInitialize()
{ … }
ShHandle ShConstructCompiler(const EShLanguage language, int )
{ … }
ShHandle ShConstructLinker(const EShExecutable executable, int )
{ … }
ShHandle ShConstructUniformMap()
{ … }
void ShDestruct(ShHandle handle)
{ … }
int ShFinalize()
{ … }
int ShCompile(
const ShHandle handle,
const char* const shaderStrings[],
const int numStrings,
const int* inputLengths,
const EShOptimizationLevel optLevel,
const TBuiltInResource* resources,
int ,
int defaultVersion,
bool forwardCompatible,
EShMessages messages,
const char *shaderFileName
)
{ … }
int ShLinkExt(
const ShHandle linkHandle,
const ShHandle compHandles[],
const int numHandles)
{ … }
void ShSetEncryptionMethod(ShHandle handle)
{ … }
const char* ShGetInfoLog(const ShHandle handle)
{ … }
const void* ShGetExecutable(const ShHandle handle)
{ … }
int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{ … }
int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{ … }
int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
{ … }
int ShGetUniformLocation(const ShHandle handle, const char* name)
{ … }
namespace glslang {
Version GetVersion()
{ … }
#define QUOTE(s) …
#define STR(n) …
const char* GetEsslVersionString()
{ … }
const char* GetGlslVersionString()
{ … }
int GetKhronosToolId()
{ … }
bool InitializeProcess()
{ … }
void FinalizeProcess()
{ … }
class TDeferredCompiler : public TCompiler { … };
TShader::TShader(EShLanguage s)
: … { … }
TShader::~TShader()
{ … }
void TShader::setStrings(const char* const* s, int n)
{ … }
void TShader::setStringsWithLengths(const char* const* s, const int* l, int n)
{ … }
void TShader::setStringsWithLengthsAndNames(
const char* const* s, const int* l, const char* const* names, int n)
{ … }
void TShader::setEntryPoint(const char* entryPoint)
{ … }
void TShader::setSourceEntryPoint(const char* name)
{ … }
void TShader::addProcesses(const std::vector<std::string>& p)
{ … }
void TShader::setUniqueId(unsigned long long id)
{ … }
void TShader::setOverrideVersion(int version)
{ … }
void TShader::setDebugInfo(bool debugInfo) { … }
void TShader::setInvertY(bool invert) { … }
void TShader::setDxPositionW(bool invert) { … }
void TShader::setEnhancedMsgs() { … }
void TShader::setNanMinMaxClamp(bool useNonNan) { … }
void TShader::setShiftBinding(TResourceType res, unsigned int base) { … }
void TShader::setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set) { … }
void TShader::setShiftSamplerBinding(unsigned int base) { … }
void TShader::setShiftTextureBinding(unsigned int base) { … }
void TShader::setShiftImageBinding(unsigned int base) { … }
void TShader::setShiftUboBinding(unsigned int base) { … }
void TShader::setShiftCbufferBinding(unsigned int base) { … }
void TShader::setShiftUavBinding(unsigned int base) { … }
void TShader::setShiftSsboBinding(unsigned int base) { … }
void TShader::setAutoMapBindings(bool map) { … }
void TShader::setAutoMapLocations(bool map) { … }
void TShader::addUniformLocationOverride(const char* name, int loc)
{ … }
void TShader::setUniformLocationBase(int base)
{ … }
void TShader::setNoStorageFormat(bool useUnknownFormat) { … }
void TShader::setResourceSetBinding(const std::vector<std::string>& base) { … }
void TShader::setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { … }
void TShader::addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing) { … }
void TShader::setGlobalUniformBlockName(const char* name) { … }
void TShader::setGlobalUniformSet(unsigned int set) { … }
void TShader::setGlobalUniformBinding(unsigned int binding) { … }
void TShader::setAtomicCounterBlockName(const char* name) { … }
void TShader::setAtomicCounterBlockSet(unsigned int set) { … }
void TShader::addSourceText(const char* text, size_t len) { … }
void TShader::setSourceFile(const char* file) { … }
#ifdef ENABLE_HLSL
void TShader::setHlslIoMapping(bool hlslIoMap) { … }
void TShader::setFlattenUniformArrays(bool flatten) { … }
#endif
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages messages, Includer& includer)
{ … }
bool TShader::preprocess(const TBuiltInResource* builtInResources,
int defaultVersion, EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages message,
std::string* output_string,
Includer& includer)
{ … }
const char* TShader::getInfoLog()
{ … }
const char* TShader::getInfoDebugLog()
{ … }
TProgram::TProgram() : … { … }
TProgram::~TProgram()
{ … }
bool TProgram::link(EShMessages messages)
{ … }
bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
{ … }
bool TProgram::crossStageCheck(EShMessages) { … }
const char* TProgram::getInfoLog()
{ … }
const char* TProgram::getInfoDebugLog()
{ … }
unsigned int TObjectReflection::layoutLocation() const { … }
bool TProgram::buildReflection(int opts)
{ … }
unsigned TProgram::getLocalSize(int dim) const { … }
int TProgram::getReflectionIndex(const char* name) const { … }
int TProgram::getReflectionPipeIOIndex(const char* name, const bool inOrOut) const
{ … }
int TProgram::getNumUniformVariables() const { … }
const TObjectReflection& TProgram::getUniform(int index) const { … }
int TProgram::getNumUniformBlocks() const { … }
const TObjectReflection& TProgram::getUniformBlock(int index) const { … }
int TProgram::getNumPipeInputs() const { … }
const TObjectReflection& TProgram::getPipeInput(int index) const { … }
int TProgram::getNumPipeOutputs() const { … }
const TObjectReflection& TProgram::getPipeOutput(int index) const { … }
int TProgram::getNumBufferVariables() const { … }
const TObjectReflection& TProgram::getBufferVariable(int index) const { … }
int TProgram::getNumBufferBlocks() const { … }
const TObjectReflection& TProgram::getBufferBlock(int index) const { … }
int TProgram::getNumAtomicCounters() const { … }
const TObjectReflection& TProgram::getAtomicCounter(int index) const { … }
void TProgram::dumpReflection() { … }
bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper)
{ … }
}