Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

DebugTypeTemplateParameter contains forward reference #311

@baldurk

Description

@baldurk

Using dxc from appveyor on the latest debug_info branch @ b13ee4e:

$ dxc.exe -help | head -n 4
OVERVIEW: HLSL Compiler for Windows

Version: dxcompiler.dll: 1.6 - 1.5.0.2676 (b13ee4e2)

And this shader:

Texture2D<float4> tex : register(t0);

float4 main(float4 pos : SV_Position) : SV_Target0
{
        return tex.Load(int3(pos.xy, 0));
}

Building with no optimisation the resulting SPIR-V generates a forward reference with DebugTypeTemplateParameter which fails validation:

$ dxc.exe -fcgl -spirv -Vd -fspv-debug=rich -T ps_6_0 -E main repro.hlsl -Fo repro.spv
$ spirv-val.exe repro.spv
error: line 52: ID 28[%28] has not been defined
  %27 = OpExtInst %void %1 DebugTypeTemplateParameter %26 %28 %17 %20 0 0

A snippet of the disassembly shows the issue:

         %19 = OpString "repro.hlsl"
         %22 = OpString "@type.2d.image"
         %23 = OpString "type.2d.image"
         %26 = OpString "Texture2D.TemplateParam"
         %30 = OpString "float"
         %33 = OpString "tex"

         ...

         %17 = OpExtInst %void %1 DebugInfoNone
         %20 = OpExtInst %void %1 DebugSource %19
         %21 = OpExtInst %void %1 DebugCompilationUnit 1 4 %20 HLSL
         %25 = OpExtInst %void %1 DebugTypeComposite %22 Class %20 0 0 %21 %23 %17 FlagIsProtected|FlagIsPrivate
         %27 = OpExtInst %void %1 DebugTypeTemplateParameter %26 %28 %17 %20 0 0
         %29 = OpExtInst %void %1 DebugTypeTemplate %25 %27
         %28 = OpExtInst %void %1 DebugTypeBasic %30 %uint_32 Float

         ...

         %34 = OpExtInst %void %1 DebugGlobalVariable %33 %25 %20 1 19 %21 %33 %tex FlagIsDefinition

Where the DebugTypeTemplateParameter and DebugTypeTemplate are switched in order.

I note though that the DebugTypeTemplate is dangling and isn't used, the DebugGlobalVariable references the original DebugTypeComposite. That seems odd but I'm not sure if that's a bug or not. I can file something separately though if it's a different bug and remains after this one is looked at.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions