Skip to content

Commit dd8a57e

Browse files
committed
[SPIR-V] Fix Mesh Shader debug info source locations
1 parent 4969749 commit dd8a57e

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8340,9 +8340,9 @@ SpirvInstruction *SpirvEmitter::tryToAssignToMSOutAttrsOrIndices(
83408340
}
83418341

83428342
if (isMSOutAttribute) {
8343-
assignToMSOutAttribute(varDecl, rhs, indices);
8343+
assignToMSOutAttribute(varDecl, rhs, indices, lhs->getLocStart());
83448344
} else if (isMSOutIndices) {
8345-
assignToMSOutIndices(varDecl, rhs, indices);
8345+
assignToMSOutIndices(varDecl, rhs, indices, lhs->getLocStart());
83468346
} else {
83478347
assert(isMSOutAttributeBlock);
83488348
QualType type = varDecl->getType();
@@ -8357,7 +8357,7 @@ SpirvInstruction *SpirvEmitter::tryToAssignToMSOutAttrsOrIndices(
83578357
SpirvInstruction *subValue = spvBuilder.createCompositeExtract(
83588358
fieldType, rhs, {getNumBaseClasses(type) + field->getFieldIndex()},
83598359
lhs->getLocStart());
8360-
assignToMSOutAttribute(field, subValue, indices);
8360+
assignToMSOutAttribute(field, subValue, indices, lhs->getLocStart());
83618361
}
83628362
}
83638363

@@ -8369,7 +8369,8 @@ SpirvInstruction *SpirvEmitter::tryToAssignToMSOutAttrsOrIndices(
83698369

83708370
void SpirvEmitter::assignToMSOutAttribute(
83718371
const DeclaratorDecl *decl, SpirvInstruction *value,
8372-
const llvm::SmallVector<SpirvInstruction *, 4> &indices) {
8372+
const llvm::SmallVector<SpirvInstruction *, 4> &indices,
8373+
SourceLocation loc) {
83738374
assert(spvContext.isMS() && !indices.empty());
83748375

83758376
// Extract attribute index and vecComponent (if any).
@@ -8381,7 +8382,6 @@ void SpirvEmitter::assignToMSOutAttribute(
83818382

83828383
auto semanticInfo = declIdMapper.getStageVarSemantic(decl);
83838384
assert(semanticInfo.isValid());
8384-
const auto loc = decl->getLocation();
83858385
// Special handle writes to clip/cull distance attributes.
83868386
if (declIdMapper.glPerVertex.tryToAccess(
83878387
hlsl::DXIL::SigPointKind::MSOut, semanticInfo.semantic->GetKind(),
@@ -8409,7 +8409,8 @@ void SpirvEmitter::assignToMSOutAttribute(
84098409

84108410
void SpirvEmitter::assignToMSOutIndices(
84118411
const DeclaratorDecl *decl, SpirvInstruction *value,
8412-
const llvm::SmallVector<SpirvInstruction *, 4> &indices) {
8412+
const llvm::SmallVector<SpirvInstruction *, 4> &indices,
8413+
SourceLocation loc) {
84138414
assert(spvContext.isMS() && !indices.empty());
84148415

84158416
bool extMesh = featureManager.isExtensionEnabled(Extension::EXT_mesh_shader);
@@ -8437,7 +8438,6 @@ void SpirvEmitter::assignToMSOutIndices(
84378438
}
84388439
}
84398440

8440-
const auto loc = decl->getLocation();
84418441
if (numVertices == 1) {
84428442
// for "point" output topology.
84438443
assert(numValues == 1);

tools/clang/lib/SPIRV/SpirvEmitter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,13 @@ class SpirvEmitter : public ASTConsumer {
370370
/// Emit instructions for assigning to the given mesh out attribute.
371371
void assignToMSOutAttribute(
372372
const DeclaratorDecl *decl, SpirvInstruction *value,
373-
const llvm::SmallVector<SpirvInstruction *, 4> &indices);
373+
const llvm::SmallVector<SpirvInstruction *, 4> &indices, SourceLocation loc);
374374

375375
/// Emit instructions for assigning to the given mesh out indices object.
376376
void
377377
assignToMSOutIndices(const DeclaratorDecl *decl, SpirvInstruction *value,
378-
const llvm::SmallVector<SpirvInstruction *, 4> &indices);
378+
const llvm::SmallVector<SpirvInstruction *, 4> &indices,
379+
SourceLocation loc);
379380

380381
/// Processes each vector within the given matrix by calling actOnEachVector.
381382
/// matrixVal should be the loaded value of the matrix. actOnEachVector takes
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %dxc -Zi -O0 -T ms_6_5 %s -spirv | FileCheck %s
2+
3+
// CHECK: OpStore %62 %63
4+
// CHECK: OpLine %6 22 5
5+
// CHECK: OpLine %6 23 5
6+
// CHECK: OpLine %6 25 5
7+
// CHECK: OpLine %6 26 5
8+
// CHECK: OpLine %6 28 5
9+
// CHECK: OpLine %6 29 5
10+
11+
struct MeshShaderOutput {
12+
float4 position: SV_Position;
13+
float3 color: COLOR0;
14+
};
15+
16+
[outputtopology("triangle")]
17+
[numthreads(1, 1, 1)]
18+
void main(out indices uint3 triangleBox[1], out vertices MeshShaderOutput triangleVertex[3]) {
19+
SetMeshOutputCounts(3, 1);
20+
triangleBox[0] = uint3(0, 1, 1);
21+
22+
triangleVertex[0].position = float4(1, 0.5, 0.0, 1.0);
23+
triangleVertex[0].color = float3(1, 0.0, 0.0);
24+
25+
triangleVertex[1].position = float4(1, 0.5, 0.0, 1.0);
26+
triangleVertex[1].color = float3(1.0, 1.0, 0.0);
27+
28+
triangleVertex[2].position = float4(1.0, -0.5, 0.0, 1.0);
29+
triangleVertex[2].color = float3(1.0, 0.0, 1.0);
30+
}

0 commit comments

Comments
 (0)