Printing preprocessed shaders (not a supported path): Fix #1490: strings
Put quote marks around strings, due to a change in how tokenization works.
This commit is contained in:
parent
1ca0f8e8eb
commit
546b78854a
@ -14,5 +14,6 @@ struct A
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
"a string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
Test/hlsl.pp.expand.frag
Normal file → Executable file
1
Test/hlsl.pp.expand.frag
Normal file → Executable file
@ -14,4 +14,5 @@ struct A
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
"a string"
|
||||||
}
|
}
|
||||||
|
17
glslang/MachineIndependent/ShaderLang.cpp
Normal file → Executable file
17
glslang/MachineIndependent/ShaderLang.cpp
Normal file → Executable file
@ -67,6 +67,11 @@
|
|||||||
#include "iomapper.h"
|
#include "iomapper.h"
|
||||||
#include "Initialize.h"
|
#include "Initialize.h"
|
||||||
|
|
||||||
|
// TODO: this really shouldn't be here, it is only because of the trial addition
|
||||||
|
// of printing pre-processed tokens, which requires knowing the string literal
|
||||||
|
// token to print ", but none of that seems appropriate for this file.
|
||||||
|
#include "preprocessor/PpTokens.h"
|
||||||
|
|
||||||
namespace { // anonymous namespace for file-local functions and symbols
|
namespace { // anonymous namespace for file-local functions and symbols
|
||||||
|
|
||||||
// Total number of successful initializers of glslang: a refcount
|
// Total number of successful initializers of glslang: a refcount
|
||||||
@ -965,6 +970,8 @@ private:
|
|||||||
// DoPreprocessing is a valid ProcessingContext template argument,
|
// DoPreprocessing is a valid ProcessingContext template argument,
|
||||||
// which only performs the preprocessing step of compilation.
|
// which only performs the preprocessing step of compilation.
|
||||||
// It places the result in the "string" argument to its constructor.
|
// It places the result in the "string" argument to its constructor.
|
||||||
|
//
|
||||||
|
// This is not an officially supported or fully working path.
|
||||||
struct DoPreprocessing {
|
struct DoPreprocessing {
|
||||||
explicit DoPreprocessing(std::string* string): outputString(string) {}
|
explicit DoPreprocessing(std::string* string): outputString(string) {}
|
||||||
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
|
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
|
||||||
@ -1072,7 +1079,11 @@ struct DoPreprocessing {
|
|||||||
outputBuffer += ' ';
|
outputBuffer += ' ';
|
||||||
}
|
}
|
||||||
lastToken = token;
|
lastToken = token;
|
||||||
|
if (token == PpAtomConstString)
|
||||||
|
outputBuffer += "\"";
|
||||||
outputBuffer += ppToken.name;
|
outputBuffer += ppToken.name;
|
||||||
|
if (token == PpAtomConstString)
|
||||||
|
outputBuffer += "\"";
|
||||||
} while (true);
|
} while (true);
|
||||||
outputBuffer += '\n';
|
outputBuffer += '\n';
|
||||||
*outputString = std::move(outputBuffer);
|
*outputString = std::move(outputBuffer);
|
||||||
@ -1122,6 +1133,9 @@ struct DoFullParse{
|
|||||||
// Return: True if there were no issues found in preprocessing,
|
// Return: True if there were no issues found in preprocessing,
|
||||||
// False if during preprocessing any unknown version, pragmas or
|
// False if during preprocessing any unknown version, pragmas or
|
||||||
// extensions were found.
|
// extensions were found.
|
||||||
|
//
|
||||||
|
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
|
||||||
|
// is not an officially supported or fully working path.
|
||||||
bool PreprocessDeferred(
|
bool PreprocessDeferred(
|
||||||
TCompiler* compiler,
|
TCompiler* compiler,
|
||||||
const char* const shaderStrings[],
|
const char* const shaderStrings[],
|
||||||
@ -1726,6 +1740,9 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
|
|||||||
|
|
||||||
// Fill in a string with the result of preprocessing ShaderStrings
|
// Fill in a string with the result of preprocessing ShaderStrings
|
||||||
// Returns true if all extensions, pragmas and version strings were valid.
|
// Returns true if all extensions, pragmas and version strings were valid.
|
||||||
|
//
|
||||||
|
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
|
||||||
|
// is not an officially supported or fully working path.
|
||||||
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
||||||
int defaultVersion, EProfile defaultProfile,
|
int defaultVersion, EProfile defaultProfile,
|
||||||
bool forceDefaultVersionAndProfile,
|
bool forceDefaultVersionAndProfile,
|
||||||
|
2
glslang/Public/ShaderLang.h
Normal file → Executable file
2
glslang/Public/ShaderLang.h
Normal file → Executable file
@ -532,6 +532,8 @@ public:
|
|||||||
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer);
|
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
|
||||||
|
// is not an officially supported or fully working path.
|
||||||
bool preprocess(const TBuiltInResource* builtInResources,
|
bool preprocess(const TBuiltInResource* builtInResources,
|
||||||
int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||||
bool forwardCompatible, EShMessages message, std::string* outputString,
|
bool forwardCompatible, EShMessages message, std::string* outputString,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user