SPV: Fix #1575, fix #1593: Support HLSL #line
SPIR-V OpLines now contain filenames from HLSL-style #lines.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 4c1dbd4..b72f7ae 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1594,7 +1594,7 @@
bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node)
{
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
if (node->getType().getQualifier().isSpecConstant())
@@ -1789,7 +1789,7 @@
bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TIntermUnary* node)
{
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
if (node->getType().getQualifier().isSpecConstant())
@@ -2053,7 +2053,7 @@
return false;
case glslang::EOpFunctionCall:
{
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
if (node->isUserDefined())
result = handleUserFunctionCall(node);
// assert(result); // this can happen for bad shaders because the call graph completeness checking is not yet done
@@ -2172,7 +2172,7 @@
case glslang::EOpConstructStruct:
case glslang::EOpConstructTextureSampler:
{
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
std::vector<spv::Id> arguments;
translateArguments(*node, arguments);
spv::Id constructed;
@@ -2317,7 +2317,7 @@
right->traverse(this);
spv::Id rightId = accessChainLoad(right->getType());
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
OpDecorations decorations = { precision,
TranslateNoContractionDecoration(node->getType().getQualifier()),
TranslateNonUniformDecoration(node->getType().getQualifier()) };
@@ -2405,12 +2405,12 @@
if (lvalue)
operands.push_back(builder.accessChainGetLValue());
else {
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
operands.push_back(accessChainLoad(glslangOperands[arg]->getAsTyped()->getType()));
}
}
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
if (atomic) {
// Handle all atomics
result = createAtomicOperation(node->getOp(), precision, resultType(), operands, node->getBasicType());
@@ -2511,7 +2511,7 @@
node->getFalseBlock()->traverse(this);
spv::Id falseValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType());
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
// done if void
if (node->getBasicType() == glslang::EbtVoid)
@@ -2685,7 +2685,7 @@
// by a block-ending branch. But we don't want to put any other body/test
// instructions in it, since the body/test may have arbitrary instructions,
// including merges of its own.
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
builder.setBuildPoint(&blocks.head);
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, control, dependencyLength);
if (node->testFirst() && node->getTest()) {
@@ -2709,7 +2709,7 @@
node->getTerminal()->traverse(this);
builder.createBranch(&blocks.head);
} else {
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
builder.createBranch(&blocks.body);
breakForLoop.push(true);
@@ -2744,7 +2744,7 @@
if (node->getExpression())
node->getExpression()->traverse(this);
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
switch (node->getFlowOp()) {
case glslang::EOpKill:
@@ -3913,7 +3913,7 @@
if (! node->isImage() && ! node->isTexture())
return spv::NoResult;
- builder.setLine(node->getLoc().line);
+ builder.setLine(node->getLoc().line, node->getLoc().getFilename());
// Process a GLSL texturing op (will be SPV image)