Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source code not embeded in spirv #6092

Open
EtienneParmentier opened this issue Jan 15, 2025 · 20 comments
Open

Source code not embeded in spirv #6092

EtienneParmentier opened this issue Jan 15, 2025 · 20 comments
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@EtienneParmentier
Copy link

I initially posted this on the discord server, but I think it's easier to track progress here. I also updated my reproducer to remove unimportant stuff.

I am trying to use the compilation API to create spirv from slang source code. When I use the slangc tool, I can use the folowing command line to embed source code into the generated spirV:

slangc -g3 -matrix-layout-column-major -fvk-use-entrypoint-name test.slang -entry vsMain -entry fsMain -target spirv-asm -o
test.asm

which produces the folowing sprirv assembly:

; SPIR-V
; Version: 1.5
; Generator: Khronos; 40
; Bound: 407
; Schema: 0
OpCapability Shader
OpExtension "SPV_KHR_non_semantic_info"
%2 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vsMain "vsMain" %unifs %gl_Position %entryPointParam_vsMain_color %entryPointParam_vsMain_uv %input_pos %input_color %input_uv
OpEntryPoint Fragment %fsMain "fsMain" %skull %entryPointParam_fsMain %gl_FragCoord %input_color_0 %input_uv_0
OpExecutionMode %fsMain OriginUpperLeft

; Debug Information
%1 = OpString "
struct MVP {
	float4x4 projection;
	float4x4 view;
	float4x4 model;
};

[vk::binding(0, 0)] ConstantBuffer<MVP> unifs;

struct vertexInfo {
	float3 pos;
	float3 color;
	float2 uv;
};

struct fragmentInfo {
	float4 pos : SV_Position;
	float3 color;
	float2 uv;
};

[shader(\"vertex\")] fragmentInfo vsMain(in vertexInfo input) {
	fragmentInfo out = {};
	out.pos = mul(unifs.projection, mul(unifs.view, mul(unifs.model, float4(input.pos, 1))));

	out.color = input.color;
	out.uv = input.uv;
	return out;
}

    [vk::binding(1, 0)] Sampler2D<float4> skull;

[shader(\"fragment\")] float4 fsMain(in fragmentInfo input) {
	float4 color = skull.Sample(input.uv) * float4(input.color, 1);
	if (color.a <= 0.001) {
		discard;
	}
	return color;
}
"
%5 = OpString "/home/etienne/dev/vulkan-tutorial/asset-sources/pipeline.slang"
OpSource Slang 1
%24 = OpString "vsMain"
%29 = OpString "slangc"
%30 = OpString "-target spirv  -I \"/usr/bin\" -matrix-layout-column-major -fvk-use-entrypoint-name -stage vertex -entry vsMain -g2"
%43 = OpString "float"
%49 = OpString "pos"
%54 = OpString "color"
%58 = OpString "uv"
%62 = OpString "vertexInfo"
%66 = OpString "input"
%82 = OpString "fragmentInfo"
%85 = OpString "out"
%193 = OpString "fsMain"
%197 = OpString "-target spirv  -I \"/usr/bin\" -matrix-layout-column-major -fvk-use-entrypoint-name -stage pixel -entry fsMain -g2"
OpName %fragmentInfo "fragmentInfo"                 ; id %14
OpMemberName %fragmentInfo 0 "pos"
OpMemberName %fragmentInfo 1 "color"
OpMemberName %fragmentInfo 2 "uv"
OpName %input_pos "input.pos"                       ; id %34
OpName %input_color "input.color"                   ; id %36
OpName %input_uv "input.uv"                         ; id %39
OpName %vertexInfo "vertexInfo"                     ; id %40
OpMemberName %vertexInfo 0 "pos"
OpMemberName %vertexInfo 1 "color"
OpMemberName %vertexInfo 2 "uv"
OpName %input "input"                               ; id %65
OpName %out "out"                                   ; id %84
OpName %_MatrixStorage_float4x4_ColMajorstd140 "_MatrixStorage_float4x4_ColMajorstd140"     ; id %101
OpMemberName %_MatrixStorage_float4x4_ColMajorstd140 0 "data"
OpName %MVP_std140 "MVP_std140"                     ; id %100
OpMemberName %MVP_std140 0 "projection"
OpMemberName %MVP_std140 1 "view"
OpMemberName %MVP_std140 2 "model"
OpName %unifs "unifs"                               ; id %105
OpName %entryPointParam_vsMain_color "entryPointParam_vsMain.color"     ; id %183
OpName %entryPointParam_vsMain_uv "entryPointParam_vsMain.uv"           ; id %187
OpName %vsMain "vsMain"                                                 ; id %11
OpName %input_color_0 "input.color"                                     ; id %209
OpName %input_uv_0 "input.uv"                                           ; id %211
OpName %input_0 "input"                                                 ; id %213
OpName %color "color"                                                   ; id %219
OpName %skull "skull"                                                   ; id %225
OpName %sampled "sampled"                                               ; id %227
OpName %color_0 "color"                                                 ; id %231
OpName %entryPointParam_fsMain "entryPointParam_fsMain"                 ; id %246
OpName %fsMain "fsMain"                                                 ; id %190

; Annotations
OpMemberDecorate %fragmentInfo 0 Offset 0
OpMemberDecorate %fragmentInfo 1 Offset 16
OpMemberDecorate %fragmentInfo 2 Offset 28
OpDecorate %input_pos Location 0
OpDecorate %input_color Location 1
OpDecorate %input_uv Location 2
OpMemberDecorate %vertexInfo 0 Offset 0
OpMemberDecorate %vertexInfo 1 Offset 12
OpMemberDecorate %vertexInfo 2 Offset 24
OpDecorate %_arr_v4float_int_4 ArrayStride 16
OpMemberDecorate %_MatrixStorage_float4x4_ColMajorstd140 0 Offset 0
OpDecorate %MVP_std140 Block
OpMemberDecorate %MVP_std140 0 Offset 0
OpMemberDecorate %MVP_std140 1 Offset 64
OpMemberDecorate %MVP_std140 2 Offset 128
OpDecorate %unifs Binding 0
OpDecorate %unifs DescriptorSet 0
OpDecorate %gl_Position BuiltIn Position
OpDecorate %entryPointParam_vsMain_color Location 0
OpDecorate %entryPointParam_vsMain_uv Location 1
OpDecorate %gl_FragCoord BuiltIn FragCoord
OpDecorate %input_color_0 Location 0
OpDecorate %input_uv_0 Location 1
OpDecorate %skull Binding 1
OpDecorate %skull DescriptorSet 0
OpDecorate %entryPointParam_fsMain Location 0

; Types, variables and constants
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%uint_11 = OpConstant %uint 11
%uint_5 = OpConstant %uint 5
%uint_100 = OpConstant %uint 100
%12 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%v3float = OpTypeVector %float 3
%v2float = OpTypeVector %float 2
%fragmentInfo = OpTypeStruct %v4float %v3float %v2float
%uint_0 = OpConstant %uint 0
%uint_22 = OpConstant %uint 22
%uint_33 = OpConstant %uint 33
%_ptr_Input_v3float = OpTypePointer Input %v3float
%_ptr_Input_v2float = OpTypePointer Input %v2float
%vertexInfo = OpTypeStruct %v3float %v3float %v2float
%uint_32 = OpConstant %uint 32
%uint_3 = OpConstant %uint 3
%uint_131072 = OpConstant %uint 131072
%uint_10 = OpConstant %uint 10
%uint_8 = OpConstant %uint 8
%uint_96 = OpConstant %uint 96
%uint_2 = OpConstant %uint 2
%uint_192 = OpConstant %uint 192
%uint_64 = OpConstant %uint 64
%uint_1 = OpConstant %uint 1
%uint_256 = OpConstant %uint 256
%uint_23 = OpConstant %uint 23
%uint_4 = OpConstant %uint 4
%uint_16 = OpConstant %uint 16
%uint_128 = OpConstant %uint 128
%uint_224 = OpConstant %uint 224
%uint_288 = OpConstant %uint 288
%uint_15 = OpConstant %uint 15
%float_0 = OpConstant %float 0
%88 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%90 = OpConstantComposite %v3float %float_0 %float_0 %float_0
%91 = OpConstantComposite %v2float %float_0 %float_0
%87 = OpConstantComposite %fragmentInfo %88 %90 %91
%uint_24 = OpConstant %uint 24
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%int_4 = OpConstant %int 4
%_arr_v4float_int_4 = OpTypeArray %v4float %int_4   ; ArrayStride 16
%_MatrixStorage_float4x4_ColMajorstd140 = OpTypeStruct %_arr_v4float_int_4
%MVP_std140 = OpTypeStruct %_MatrixStorage_float4x4_ColMajorstd140 %_MatrixStorage_float4x4_ColMajorstd140 %_MatrixStorage_float4x4_ColMajorstd140  ; Block
%_ptr_Uniform_MVP_std140 = OpTypePointer Uniform %MVP_std140
%_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 = OpTypePointer Uniform %_MatrixStorage_float4x4_ColMajorstd140
%mat4v4float = OpTypeMatrix %v4float 4
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%float_1 = OpConstant %float 1
%uint_26 = OpConstant %uint 26
%uint_27 = OpConstant %uint 27
%uint_28 = OpConstant %uint 28
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Output_v3float = OpTypePointer Output %v3float
%_ptr_Output_v2float = OpTypePointer Output %v2float
%uint_29 = OpConstant %uint 29
%_ptr_Input_v4float = OpTypePointer Input %v4float
%uint_34 = OpConstant %uint 34
%uint_9 = OpConstant %uint 9
%221 = OpTypeImage %float 2D 2 0 0 1 Unknown
%222 = OpTypeSampledImage %221
%_ptr_UniformConstant_222 = OpTypePointer UniformConstant %222
%uint_35 = OpConstant %uint 35
%bool = OpTypeBool
%float_0_00100000005 = OpConstant %float 0.00100000005
%uint_36 = OpConstant %uint 36
%uint_38 = OpConstant %uint 38
%input_pos = OpVariable %_ptr_Input_v3float Input   ; Location 0
%input_color = OpVariable %_ptr_Input_v3float Input     ; Location 1
%input_uv = OpVariable %_ptr_Input_v2float Input        ; Location 2
%unifs = OpVariable %_ptr_Uniform_MVP_std140 Uniform    ; Binding 0, DescriptorSet 0
%gl_Position = OpVariable %_ptr_Output_v4float Output   ; BuiltIn Position
%entryPointParam_vsMain_color = OpVariable %_ptr_Output_v3float Output  ; Location 0
%entryPointParam_vsMain_uv = OpVariable %_ptr_Output_v2float Output     ; Location 1
%gl_FragCoord = OpVariable %_ptr_Input_v4float Input                    ; BuiltIn FragCoord
%input_color_0 = OpVariable %_ptr_Input_v3float Input                   ; Location 0
%input_uv_0 = OpVariable %_ptr_Input_v2float Input                      ; Location 1
%skull = OpVariable %_ptr_UniformConstant_222 UniformConstant           ; Binding 1, DescriptorSet 0
%entryPointParam_fsMain = OpVariable %_ptr_Output_v4float Output        ; Location 0
%67 = OpExtInst %void %2 DebugExpression
%4 = OpExtInst %void %2 DebugSource %5 %1
%10 = OpExtInst %void %2 DebugCompilationUnit %uint_100 %uint_5 %4 %uint_11
%21 = OpExtInst %void %2 DebugTypeFunction %uint_0 %void
%23 = OpExtInst %void %2 DebugFunction %24 %21 %4 %uint_22 %uint_33 %10 %24 %uint_0 %uint_22
%28 = OpExtInst %void %2 DebugEntryPoint %23 %10 %29 %30
%42 = OpExtInst %void %2 DebugTypeBasic %43 %uint_32 %uint_3 %uint_131072
%47 = OpExtInst %void %2 DebugTypeVector %42 %uint_3
%48 = OpExtInst %void %2 DebugTypeMember %49 %47 %4 %uint_10 %uint_8 %uint_0 %uint_96 %uint_0
%53 = OpExtInst %void %2 DebugTypeMember %54 %47 %4 %uint_10 %uint_8 %uint_96 %uint_96 %uint_0
%55 = OpExtInst %void %2 DebugTypeVector %42 %uint_2
%57 = OpExtInst %void %2 DebugTypeMember %58 %55 %4 %uint_10 %uint_8 %uint_192 %uint_64 %uint_0
%61 = OpExtInst %void %2 DebugTypeComposite %62 %uint_1 %4 %uint_10 %uint_8 %10 %62 %uint_256 %uint_131072 %48 %53 %57
%input = OpExtInst %void %2 DebugLocalVariable %66 %61 %4 %uint_22 %uint_33 %23 %uint_0 %uint_0
%73 = OpExtInst %void %2 DebugTypeVector %42 %uint_4
%75 = OpExtInst %void %2 DebugTypeMember %49 %73 %4 %uint_16 %uint_8 %uint_0 %uint_128 %uint_0
%78 = OpExtInst %void %2 DebugTypeMember %54 %47 %4 %uint_16 %uint_8 %uint_128 %uint_96 %uint_0
%79 = OpExtInst %void %2 DebugTypeMember %58 %55 %4 %uint_16 %uint_8 %uint_224 %uint_64 %uint_0
%81 = OpExtInst %void %2 DebugTypeComposite %82 %uint_1 %4 %uint_16 %uint_8 %10 %82 %uint_288 %uint_131072 %75 %78 %79
%out = OpExtInst %void %2 DebugLocalVariable %85 %81 %4 %uint_23 %uint_15 %23 %uint_0
%192 = OpExtInst %void %2 DebugFunction %193 %21 %4 %uint_33 %uint_29 %10 %193 %uint_0 %uint_33
%196 = OpExtInst %void %2 DebugEntryPoint %192 %10 %29 %197
%200 = OpExtInst %void %2 DebugEntryPoint %192 %10 %29 %197
%203 = OpExtInst %void %2 DebugEntryPoint %192 %10 %29 %197
%input_0 = OpExtInst %void %2 DebugLocalVariable %66 %81 %4 %uint_33 %uint_29 %192 %uint_0 %uint_0
%color = OpExtInst %void %2 DebugLocalVariable %54 %73 %4 %uint_34 %uint_9 %192 %uint_0
%330 = OpExtInst %void %2 DebugInlinedAt %uint_24 %23
%360 = OpExtInst %void %2 DebugInlinedAt %uint_24 %23
%390 = OpExtInst %void %2 DebugInlinedAt %uint_24 %23

; Function vsMain
%vsMain = OpFunction %void None %12
%13 = OpLabel
%27 = OpExtInst %void %2 DebugFunctionDefinition %23 %vsMain
%391 = OpExtInst %void %2 DebugScope %23
%32 = OpLoad %v3float %input_pos
%35 = OpLoad %v3float %input_color
%37 = OpLoad %v2float %input_uv
%41 = OpCompositeConstruct %vertexInfo %32 %35 %37
%68 = OpExtInst %void %2 DebugValue %input %41 %67
%249 = OpExtInst %void %2 DebugLine %4 %uint_23 %uint_23 %uint_2 %uint_3
%93 = OpExtInst %void %2 DebugValue %out %87 %67
%251 = OpExtInst %void %2 DebugLine %4 %uint_24 %uint_24 %uint_2 %uint_3
%107 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_0
%108 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %107
%392 = OpExtInst %void %2 DebugNoLine
%393 = OpExtInst %void %2 DebugNoScope
%304 = OpCompositeExtract %_arr_v4float_int_4 %108 0
%305 = OpCompositeExtract %v4float %304 0
%306 = OpCompositeExtract %float %305 0
%307 = OpCompositeExtract %float %305 1
%308 = OpCompositeExtract %float %305 2
%309 = OpCompositeExtract %float %305 3
%310 = OpCompositeExtract %v4float %304 1
%311 = OpCompositeExtract %float %310 0
%312 = OpCompositeExtract %float %310 1
%313 = OpCompositeExtract %float %310 2
%314 = OpCompositeExtract %float %310 3
%315 = OpCompositeExtract %v4float %304 2
%316 = OpCompositeExtract %float %315 0
%317 = OpCompositeExtract %float %315 1
%318 = OpCompositeExtract %float %315 2
%319 = OpCompositeExtract %float %315 3
%320 = OpCompositeExtract %v4float %304 3
%321 = OpCompositeExtract %float %320 0
%322 = OpCompositeExtract %float %320 1
%323 = OpCompositeExtract %float %320 2
%324 = OpCompositeExtract %float %320 3
%325 = OpCompositeConstruct %v4float %306 %311 %316 %321
%326 = OpCompositeConstruct %v4float %307 %312 %317 %322
%327 = OpCompositeConstruct %v4float %308 %313 %318 %323
%328 = OpCompositeConstruct %v4float %309 %314 %319 %324
%329 = OpCompositeConstruct %mat4v4float %325 %326 %327 %328
%394 = OpExtInst %void %2 DebugScope %23
%254 = OpExtInst %void %2 DebugLine %4 %uint_24 %uint_24 %uint_2 %uint_3
%143 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_1
%144 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %143
%395 = OpExtInst %void %2 DebugNoLine
%396 = OpExtInst %void %2 DebugNoScope
%334 = OpCompositeExtract %_arr_v4float_int_4 %144 0
%335 = OpCompositeExtract %v4float %334 0
%336 = OpCompositeExtract %float %335 0
%337 = OpCompositeExtract %float %335 1
%338 = OpCompositeExtract %float %335 2
%339 = OpCompositeExtract %float %335 3
%340 = OpCompositeExtract %v4float %334 1
%341 = OpCompositeExtract %float %340 0
%342 = OpCompositeExtract %float %340 1
%343 = OpCompositeExtract %float %340 2
%344 = OpCompositeExtract %float %340 3
%345 = OpCompositeExtract %v4float %334 2
%346 = OpCompositeExtract %float %345 0
%347 = OpCompositeExtract %float %345 1
%348 = OpCompositeExtract %float %345 2
%349 = OpCompositeExtract %float %345 3
%350 = OpCompositeExtract %v4float %334 3
%351 = OpCompositeExtract %float %350 0
%352 = OpCompositeExtract %float %350 1
%353 = OpCompositeExtract %float %350 2
%354 = OpCompositeExtract %float %350 3
%355 = OpCompositeConstruct %v4float %336 %341 %346 %351
%356 = OpCompositeConstruct %v4float %337 %342 %347 %352
%357 = OpCompositeConstruct %v4float %338 %343 %348 %353
%358 = OpCompositeConstruct %v4float %339 %344 %349 %354
%359 = OpCompositeConstruct %mat4v4float %355 %356 %357 %358
%397 = OpExtInst %void %2 DebugScope %23
%257 = OpExtInst %void %2 DebugLine %4 %uint_24 %uint_24 %uint_2 %uint_3
%147 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_2
%148 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %147
%398 = OpExtInst %void %2 DebugNoLine
%399 = OpExtInst %void %2 DebugNoScope
%364 = OpCompositeExtract %_arr_v4float_int_4 %148 0
%365 = OpCompositeExtract %v4float %364 0
%366 = OpCompositeExtract %float %365 0
%367 = OpCompositeExtract %float %365 1
%368 = OpCompositeExtract %float %365 2
%369 = OpCompositeExtract %float %365 3
%370 = OpCompositeExtract %v4float %364 1
%371 = OpCompositeExtract %float %370 0
%372 = OpCompositeExtract %float %370 1
%373 = OpCompositeExtract %float %370 2
%374 = OpCompositeExtract %float %370 3
%375 = OpCompositeExtract %v4float %364 2
%376 = OpCompositeExtract %float %375 0
%377 = OpCompositeExtract %float %375 1
%378 = OpCompositeExtract %float %375 2
%379 = OpCompositeExtract %float %375 3
%380 = OpCompositeExtract %v4float %364 3
%381 = OpCompositeExtract %float %380 0
%382 = OpCompositeExtract %float %380 1
%383 = OpCompositeExtract %float %380 2
%384 = OpCompositeExtract %float %380 3
%385 = OpCompositeConstruct %v4float %366 %371 %376 %381
%386 = OpCompositeConstruct %v4float %367 %372 %377 %382
%387 = OpCompositeConstruct %v4float %368 %373 %378 %383
%388 = OpCompositeConstruct %v4float %369 %374 %379 %384
%389 = OpCompositeConstruct %mat4v4float %385 %386 %387 %388
%400 = OpExtInst %void %2 DebugScope %23
%260 = OpExtInst %void %2 DebugLine %4 %uint_24 %uint_24 %uint_2 %uint_3
%150 = OpLoad %v3float %input_pos
%151 = OpCompositeConstruct %v4float %150 %float_1
%153 = OpVectorTimesMatrix %v4float %151 %389
%154 = OpVectorTimesMatrix %v4float %153 %359
%155 = OpVectorTimesMatrix %v4float %154 %329
%157 = OpExtInst %void %2 DebugValue %out %155 %67 %int_0
%268 = OpExtInst %void %2 DebugLine %4 %uint_26 %uint_26 %uint_2 %uint_3
%162 = OpLoad %v3float %input_color
%164 = OpLoad %v3float %input_color
%165 = OpExtInst %void %2 DebugValue %out %164 %67 %int_1
%273 = OpExtInst %void %2 DebugLine %4 %uint_27 %uint_27 %uint_2 %uint_3
%170 = OpLoad %v2float %input_uv
%172 = OpLoad %v2float %input_uv
%173 = OpExtInst %void %2 DebugValue %out %172 %67 %int_2
%279 = OpExtInst %void %2 DebugLine %4 %uint_28 %uint_28 %uint_2 %uint_3
OpStore %gl_Position %155
OpStore %entryPointParam_vsMain_color %162
OpStore %entryPointParam_vsMain_uv %170
OpReturn
%401 = OpExtInst %void %2 DebugNoScope
OpFunctionEnd

; Function fsMain
%fsMain = OpFunction %void None %12
%191 = OpLabel
%195 = OpExtInst %void %2 DebugFunctionDefinition %192 %fsMain
%402 = OpExtInst %void %2 DebugScope %192
%205 = OpLoad %v4float %gl_FragCoord
%208 = OpLoad %v3float %input_color_0
%210 = OpLoad %v2float %input_uv_0
%212 = OpCompositeConstruct %fragmentInfo %205 %208 %210
%214 = OpExtInst %void %2 DebugValue %input_0 %212 %67
%215 = OpExtInst %void %2 DebugLine %4 %uint_34 %uint_34 %uint_2 %uint_3
%223 = OpLoad %222 %skull
%226 = OpLoad %v2float %input_uv_0
%sampled = OpImageSampleImplicitLod %v4float %223 %226 None
%229 = OpLoad %v3float %input_color_0
%230 = OpCompositeConstruct %v4float %229 %float_1
%color_0 = OpFMul %v4float %sampled %230
%232 = OpExtInst %void %2 DebugValue %color %color_0 %67
%233 = OpExtInst %void %2 DebugLine %4 %uint_35 %uint_35 %uint_2 %uint_3
%235 = OpCompositeExtract %float %color_0 3
%237 = OpFOrdLessThanEqual %bool %235 %float_0_00100000005
%403 = OpExtInst %void %2 DebugNoScope
OpSelectionMerge %202 None
OpBranchConditional %237 %199 %202
%199 = OpLabel
%404 = OpExtInst %void %2 DebugScope %192
%240 = OpExtInst %void %2 DebugLine %4 %uint_36 %uint_36 %uint_3 %uint_4
OpKill
%202 = OpLabel
%405 = OpExtInst %void %2 DebugScope %192
%244 = OpExtInst %void %2 DebugLine %4 %uint_38 %uint_38 %uint_2 %uint_3
OpStore %entryPointParam_fsMain %color_0
OpReturn
%406 = OpExtInst %void %2 DebugNoScope
OpFunctionEnd

I am trying to do the same using the compilation API.
Here is my reproducer, it also contains the test.slang file inside the raw string:

#include <slang-com-helper.h>
#include <slang-com-ptr.h>

#include <slang.h>
#include <iterator>
#include <iostream>

slang::CompilerOptionEntry commonOptions[] = {
    {
        slang::CompilerOptionName::EmitSpirvDirectly,
        {
            slang::CompilerOptionValueKind::Int,
            1,
            0,
            nullptr,
            nullptr,
        },
    },
    {
        slang::CompilerOptionName::Optimization,
        {
            slang::CompilerOptionValueKind::Int,
            SLANG_OPTIMIZATION_LEVEL_NONE,
            0,
            nullptr,
            nullptr,
        },
    },
    {
        slang::CompilerOptionName::DebugInformation,
        {
            slang::CompilerOptionValueKind::Int,
            SLANG_DEBUG_INFO_LEVEL_MAXIMAL,
            0,
            nullptr,
            nullptr,
        },
    },
};

static std::string source = R"src(

struct MVP {
	float4x4 projection;
	float4x4 view;
	float4x4 model;
};

[vk::binding(0, 0)] ConstantBuffer<MVP> unifs;

struct vertexInfo {
	float3 pos;
	float3 color;
	float2 uv;
};

struct fragmentInfo {
	float4 pos : SV_Position;
	float3 color;
	float2 uv;
};

[shader("vertex")] fragmentInfo vsMain(in vertexInfo input) {
	fragmentInfo out = {};
	out.pos = mul(unifs.projection, mul(unifs.view, mul(unifs.model, float4(input.pos, 1))));

	out.color = input.color;
	out.uv = input.uv;
	return out;
}

    [vk::binding(1, 0)] Sampler2D<float4> skull;

[shader("fragment")] float4 fsMain(in fragmentInfo input) {
	float4 color = skull.Sample(input.uv) * float4(input.color, 1);
	if (color.a <= 0.001) {
		discard;
	}
	return color;
}

)src";

int main() {

	Slang::ComPtr<slang::IGlobalSession> globalSession;
	createGlobalSession(globalSession.writeRef());

    SlangProfileID profile = globalSession->findProfile("spirv_1_5");

    slang::TargetDesc spirvAsmDebugDesc = {};
	spirvAsmDebugDesc.profile = profile;
	spirvAsmDebugDesc.format = SLANG_SPIRV_ASM;
	spirvAsmDebugDesc.compilerOptionEntries = commonOptions;
	spirvAsmDebugDesc.compilerOptionEntryCount = std::size(commonOptions);

    slang::SessionDesc sessionDesc = {};
	sessionDesc.targets = &spirvAsmDebugDesc;
	sessionDesc.targetCount = 1;
	sessionDesc.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR;

    Slang::ComPtr<slang::ISession> session;
	globalSession->createSession(sessionDesc, session.writeRef());

    Slang::ComPtr<slang::IBlob> diags;

    Slang::ComPtr<slang::IModule> modul;
    modul = session->loadModuleFromSourceString("test", "test.slang", source.c_str(), diags.writeRef());
    if(diags){
        std::cout << (char*)diags->getBufferPointer() << std::endl;
        return -1;
    }

    Slang::ComPtr<slang::IComponentType> component;
    modul->link(component.writeRef(), diags.writeRef());
    if(diags){
        std::cout << (char*)diags->getBufferPointer() << std::endl;
        return -1;
    }

    Slang::ComPtr<slang::IBlob> spirvAssemblyDebug;
    component->getTargetCode(0, spirvAssemblyDebug.writeRef(), diags.writeRef());
    if(diags){
        std::cout << (char*)diags->getBufferPointer() << std::endl;
        return -1;
    }

    std::cout << (char*)spirvAssemblyDebug->getBufferPointer() << std::endl;
}

it produces the folowing assembly:

; SPIR-V
; Version: 1.5
; Generator: Khronos; 40
; Bound: 217
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vsMain "vsMain" %unifs %gl_Position %entryPointParam_vsMain_color %entryPointParam_vsMain_uv %input_pos %input_color %input_uv
OpEntryPoint Fragment %fsMain "fsMain" %skull %entryPointParam_fsMain %input_color_0 %input_uv_0
OpExecutionMode %fsMain OriginUpperLeft

; Debug Information
OpSource Slang 1
OpName %_MatrixStorage_float4x4_ColMajorstd140 "_MatrixStorage_float4x4_ColMajorstd140"     ; id %23
OpMemberName %_MatrixStorage_float4x4_ColMajorstd140 0 "data"
OpName %MVP_std140 "MVP_std140"                     ; id %22
OpMemberName %MVP_std140 0 "projection"
OpMemberName %MVP_std140 1 "view"
OpMemberName %MVP_std140 2 "model"
OpName %unifs "unifs"                               ; id %27
OpName %input_pos "input.pos"                       ; id %74
OpName %input_color "input.color"                   ; id %84
OpName %input_uv "input.uv"                         ; id %90
OpName %entryPointParam_vsMain_color "entryPointParam_vsMain.color"     ; id %99
OpName %entryPointParam_vsMain_uv "entryPointParam_vsMain.uv"           ; id %103
OpName %vsMain "vsMain"                                                 ; id %2
OpName %skull "skull"                                                   ; id %114
OpName %input_uv_0 "input.uv"                                           ; id %116
OpName %sampled "sampled"                                               ; id %117
OpName %input_color_0 "input.color"                                     ; id %120
OpName %color "color"                                                   ; id %122
OpName %entryPointParam_fsMain "entryPointParam_fsMain"                 ; id %129
OpName %fsMain "fsMain"                                                 ; id %106

; Annotations
OpDecorate %_arr_v4float_int_4 ArrayStride 16
OpMemberDecorate %_MatrixStorage_float4x4_ColMajorstd140 0 Offset 0
OpDecorate %MVP_std140 Block
OpMemberDecorate %MVP_std140 0 Offset 0
OpMemberDecorate %MVP_std140 1 Offset 64
OpMemberDecorate %MVP_std140 2 Offset 128
OpDecorate %unifs Binding 0
OpDecorate %unifs DescriptorSet 0
OpDecorate %input_pos Location 0
OpDecorate %input_color Location 1
OpDecorate %input_uv Location 2
OpDecorate %gl_Position BuiltIn Position
OpDecorate %entryPointParam_vsMain_color Location 0
OpDecorate %entryPointParam_vsMain_uv Location 1
OpDecorate %skull Binding 1
OpDecorate %skull DescriptorSet 0
OpDecorate %input_uv_0 Location 1
OpDecorate %input_color_0 Location 0
OpDecorate %entryPointParam_fsMain Location 0

; Types, variables and constants
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%v3float = OpTypeVector %float 3
%v2float = OpTypeVector %float 2
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%int_4 = OpConstant %int 4
%_arr_v4float_int_4 = OpTypeArray %v4float %int_4   ; ArrayStride 16
%_MatrixStorage_float4x4_ColMajorstd140 = OpTypeStruct %_arr_v4float_int_4
%MVP_std140 = OpTypeStruct %_MatrixStorage_float4x4_ColMajorstd140 %_MatrixStorage_float4x4_ColMajorstd140 %_MatrixStorage_float4x4_ColMajorstd140  ; Block
%_ptr_Uniform_MVP_std140 = OpTypePointer Uniform %MVP_std140
%_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 = OpTypePointer Uniform %_MatrixStorage_float4x4_ColMajorstd140
%mat4v4float = OpTypeMatrix %v4float 4
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Input_v3float = OpTypePointer Input %v3float
%float_1 = OpConstant %float 1
%_ptr_Input_v2float = OpTypePointer Input %v2float
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Output_v3float = OpTypePointer Output %v3float
%_ptr_Output_v2float = OpTypePointer Output %v2float
%110 = OpTypeImage %float 2D 2 0 0 1 Unknown
%111 = OpTypeSampledImage %110
%_ptr_UniformConstant_111 = OpTypePointer UniformConstant %111
%bool = OpTypeBool
%float_0_00100000005 = OpConstant %float 0.00100000005
%unifs = OpVariable %_ptr_Uniform_MVP_std140 Uniform    ; Binding 0, DescriptorSet 0
%input_pos = OpVariable %_ptr_Input_v3float Input       ; Location 0
%input_color = OpVariable %_ptr_Input_v3float Input     ; Location 1
%input_uv = OpVariable %_ptr_Input_v2float Input        ; Location 2
%gl_Position = OpVariable %_ptr_Output_v4float Output   ; BuiltIn Position
%entryPointParam_vsMain_color = OpVariable %_ptr_Output_v3float Output  ; Location 0
%entryPointParam_vsMain_uv = OpVariable %_ptr_Output_v2float Output     ; Location 1
%skull = OpVariable %_ptr_UniformConstant_111 UniformConstant           ; Binding 1, DescriptorSet 0
%input_uv_0 = OpVariable %_ptr_Input_v2float Input                      ; Location 1
%input_color_0 = OpVariable %_ptr_Input_v3float Input                   ; Location 0
%entryPointParam_fsMain = OpVariable %_ptr_Output_v4float Output        ; Location 0

; Function vsMain
%vsMain = OpFunction %void None %3
%4 = OpLabel
%29 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_0
%30 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %29
%135 = OpCompositeExtract %_arr_v4float_int_4 %30 0
%136 = OpCompositeExtract %v4float %135 0
%137 = OpCompositeExtract %float %136 0
%138 = OpCompositeExtract %float %136 1
%139 = OpCompositeExtract %float %136 2
%140 = OpCompositeExtract %float %136 3
%141 = OpCompositeExtract %v4float %135 1
%142 = OpCompositeExtract %float %141 0
%143 = OpCompositeExtract %float %141 1
%144 = OpCompositeExtract %float %141 2
%145 = OpCompositeExtract %float %141 3
%146 = OpCompositeExtract %v4float %135 2
%147 = OpCompositeExtract %float %146 0
%148 = OpCompositeExtract %float %146 1
%149 = OpCompositeExtract %float %146 2
%150 = OpCompositeExtract %float %146 3
%151 = OpCompositeExtract %v4float %135 3
%152 = OpCompositeExtract %float %151 0
%153 = OpCompositeExtract %float %151 1
%154 = OpCompositeExtract %float %151 2
%155 = OpCompositeExtract %float %151 3
%156 = OpCompositeConstruct %v4float %137 %142 %147 %152
%157 = OpCompositeConstruct %v4float %138 %143 %148 %153
%158 = OpCompositeConstruct %v4float %139 %144 %149 %154
%159 = OpCompositeConstruct %v4float %140 %145 %150 %155
%160 = OpCompositeConstruct %mat4v4float %156 %157 %158 %159
%65 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_1
%66 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %65
%163 = OpCompositeExtract %_arr_v4float_int_4 %66 0
%164 = OpCompositeExtract %v4float %163 0
%165 = OpCompositeExtract %float %164 0
%166 = OpCompositeExtract %float %164 1
%167 = OpCompositeExtract %float %164 2
%168 = OpCompositeExtract %float %164 3
%169 = OpCompositeExtract %v4float %163 1
%170 = OpCompositeExtract %float %169 0
%171 = OpCompositeExtract %float %169 1
%172 = OpCompositeExtract %float %169 2
%173 = OpCompositeExtract %float %169 3
%174 = OpCompositeExtract %v4float %163 2
%175 = OpCompositeExtract %float %174 0
%176 = OpCompositeExtract %float %174 1
%177 = OpCompositeExtract %float %174 2
%178 = OpCompositeExtract %float %174 3
%179 = OpCompositeExtract %v4float %163 3
%180 = OpCompositeExtract %float %179 0
%181 = OpCompositeExtract %float %179 1
%182 = OpCompositeExtract %float %179 2
%183 = OpCompositeExtract %float %179 3
%184 = OpCompositeConstruct %v4float %165 %170 %175 %180
%185 = OpCompositeConstruct %v4float %166 %171 %176 %181
%186 = OpCompositeConstruct %v4float %167 %172 %177 %182
%187 = OpCompositeConstruct %v4float %168 %173 %178 %183
%188 = OpCompositeConstruct %mat4v4float %184 %185 %186 %187
%69 = OpAccessChain %_ptr_Uniform__MatrixStorage_float4x4_ColMajorstd140 %unifs %int_2
%70 = OpLoad %_MatrixStorage_float4x4_ColMajorstd140 %69
%191 = OpCompositeExtract %_arr_v4float_int_4 %70 0
%192 = OpCompositeExtract %v4float %191 0
%193 = OpCompositeExtract %float %192 0
%194 = OpCompositeExtract %float %192 1
%195 = OpCompositeExtract %float %192 2
%196 = OpCompositeExtract %float %192 3
%197 = OpCompositeExtract %v4float %191 1
%198 = OpCompositeExtract %float %197 0
%199 = OpCompositeExtract %float %197 1
%200 = OpCompositeExtract %float %197 2
%201 = OpCompositeExtract %float %197 3
%202 = OpCompositeExtract %v4float %191 2
%203 = OpCompositeExtract %float %202 0
%204 = OpCompositeExtract %float %202 1
%205 = OpCompositeExtract %float %202 2
%206 = OpCompositeExtract %float %202 3
%207 = OpCompositeExtract %v4float %191 3
%208 = OpCompositeExtract %float %207 0
%209 = OpCompositeExtract %float %207 1
%210 = OpCompositeExtract %float %207 2
%211 = OpCompositeExtract %float %207 3
%212 = OpCompositeConstruct %v4float %193 %198 %203 %208
%213 = OpCompositeConstruct %v4float %194 %199 %204 %209
%214 = OpCompositeConstruct %v4float %195 %200 %205 %210
%215 = OpCompositeConstruct %v4float %196 %201 %206 %211
%216 = OpCompositeConstruct %mat4v4float %212 %213 %214 %215
%72 = OpLoad %v3float %input_pos
%75 = OpCompositeConstruct %v4float %72 %float_1
%77 = OpVectorTimesMatrix %v4float %75 %216
%78 = OpVectorTimesMatrix %v4float %77 %188
%79 = OpVectorTimesMatrix %v4float %78 %160
%83 = OpLoad %v3float %input_color
%88 = OpLoad %v2float %input_uv
OpStore %gl_Position %79
OpStore %entryPointParam_vsMain_color %83
OpStore %entryPointParam_vsMain_uv %88
OpReturn
OpFunctionEnd

; Function fsMain
%fsMain = OpFunction %void None %3
%107 = OpLabel
%112 = OpLoad %111 %skull
%115 = OpLoad %v2float %input_uv_0
%sampled = OpImageSampleImplicitLod %v4float %112 %115 None
%119 = OpLoad %v3float %input_color_0
%121 = OpCompositeConstruct %v4float %119 %float_1
%color = OpFMul %v4float %sampled %121
%123 = OpCompositeExtract %float %color 3
%125 = OpFOrdLessThanEqual %bool %123 %float_0_00100000005
OpSelectionMerge %109 None
OpBranchConditional %125 %108 %109
%108 = OpLabel
OpKill
%109 = OpLabel
OpStore %entryPointParam_fsMain %color
OpReturn
OpFunctionEnd

I think the spirv extension "SPV_KHR_non_semantic_info" is lacking in my cpp code, but I didn't found a way to activate it. I tried to debug slangc without success. Is their a way to activate this extension using the compilation API ?

@mklefrancois
Copy link

Not sure if this is related to the same bug, but I see a validation error with the latest Vulkan SDK 1.4.304

VUID-VkShaderModuleCreateInfo-pCode-08737(ERROR / SPEC): msgNum: -1520283006 - Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
NonSemantic.Shader.DebugInfo.100 DebugFunctionDefinition: must be in the entry basic block of the function
  %41 = OpExtInst %void %2 DebugFunctionDefinition %37 %main

@EtienneParmentier
Copy link
Author

EtienneParmentier commented Jan 16, 2025

Not sure if this is related to the same bug, but I see a validation error with the latest Vulkan SDK 1.4.304

VUID-VkShaderModuleCreateInfo-pCode-08737(ERROR / SPEC): msgNum: -1520283006 - Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
NonSemantic.Shader.DebugInfo.100 DebugFunctionDefinition: must be in the entry basic block of the function
  %41 = OpExtInst %void %2 DebugFunctionDefinition %37 %main

This behavior of the compilation API is the same using tagged version 2024.17 and 2025.2 of the slang repo

@mklefrancois
Copy link

@EtienneParmentier, do you know by any chance a way to avoid this issue?
Current command is:

C:/VulkanSDK/1.4.304.0/Bin/slangc.exe 
  -profile sm_6_6+spirv_1_6
  -capability spvInt64Atomics+spvShaderInvocationReorderNV+spvShaderClockKHR+spvRayTracingMotionBlurNV
  -target spirv
  -emit-spirv-directly
  -force-glsl-scalar-layout
  -fvk-use-entrypoint-name 
  -g3
  -source-embed-style text
  -source-embed-name shader_comp_slang
  -o shader.comp.slang.h
  shader.comp.slang

@EtienneParmentier
Copy link
Author

@mklefrancois I am not aware of any fixes.

@mklefrancois
Copy link

I found a temporary solution.
Removing debug information altogether helps.
For example, omitting the -g option will produce code that passes validation.

@EtienneParmentier
Copy link
Author

EtienneParmentier commented Jan 16, 2025

@mklefrancois This doesn't help at all: my goal is to embed slang source code into the spirv file to help me debug shader code in renderdoc, and doing the embeding using the compilation API, not slangc. I guess slangc producing broken files with debug options is another subject entirely, please submit another issue that references this one to keep the discussion focused.

@bmillsNV bmillsNV added this to the Q1 2025 (Winter) milestone Jan 16, 2025
@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Jan 16, 2025
@aleino-nv
Copy link
Collaborator

I've reproduced the issue. The diff between the SPIR-V from slangc and the SPIR-V from the Slang API is pretty sizeable -- SPV_KHR_non_semantic_info missing in the API version is just one of the differences.

It looks like the SPIR-V from the API has been optimized.

@aleino-nv
Copy link
Collaborator

aleino-nv commented Jan 24, 2025

@EtienneParmentier I found after some debugging that adding the lines

sessionDesc.compilerOptionEntries = commonOptions;
sessionDesc.compilerOptionEntryCount = std::size(commonOptions);

to your sample program will cause SPV_KHR_non_semantic_info + source to be generated.

I need to read up on the API docs, but it feels like a bug that the per-target options are seemingly being ignored.
Possibly they should be getting merged with the session-wide options.

@aleino-nv
Copy link
Collaborator

aleino-nv commented Jan 24, 2025

https://shader-slang.org/slang/user-guide/compiling.html#compiler-options

Both the SessionDesc, TargetDesc structures contain fields that encodes a CompilerOptionEntry array for additional compiler options to apply on the session or the target.

This makes it sound like the original sample here should just work without making the options session-wide.
I'll debug a bit more...

@aleino-nv
Copy link
Collaborator

Here is the call that adds the source when you specify session-wide that you want debug info:

auto debugSource = builder->emitDebugSource(

I guess we're just missing a similar place for per-target output.
I started adding a similar per-target bit of code to linkAndOptimizeIR in slang-emit.cpp, but I'm not sure I can get the sources at that point.
@csyonghe Any comments on how to solve this?

@aleino-nv
Copy link
Collaborator

Alternatively we change the logic around

auto debugSource = builder->emitDebugSource(
so that we emit the debug source inst if the session-wide options or any of the target-specific options need debug sources.

Then we need to add a check during SPIR-V emit whether or not the particular target we're emitting for should actually emit kIROp_DebugSource, which it should if the session-wide or target-specific options. (So that we don't emit in cases like the above where we only want debug sources for a particular target.)

@EtienneParmentier
Copy link
Author

That would be perfect ! Having to create 2 sessions would nullify the advantages of using the cpp api, since at that point invoking slangc twice would achieve the same results. Are there other options that are 'forgotten' when they are target specific ? I believe all compiler options should behave in the same way, whether they are specified at the target level or at the session level.

@csyonghe
Copy link
Collaborator

I find it a bug that causes us to ignore everything you set through targetDesc.compilerOptionEntries. Can you try and see if #6178 fixes your problem? I think this may simply be caused by that option set through targetDesc being ignored.

@EtienneParmentier
Copy link
Author

I find it a bug that causes us to ignore everything you set through targetDesc.compilerOptionEntries. Can you try and see if #6178 fixes your problem? I think this may simply be caused by that option set through targetDesc being ignored.

No it doesn't fix my issue. The source code is still missing from the assembly.

@csyonghe
Copy link
Collaborator

It appears that debug info option affects IR generation so it has to be set on the session desc in order to for the ir lowering logic to emit the necessary debug info into IR.

@csyonghe
Copy link
Collaborator

Here's a summary of the issue and a possible solution.

The problem is that in order to generate debug info, we need the front-end to produce debug instructions when lowering to IR. When the backend sees these debug instructions, it will translate them to SPIRV debug info accordingly.

Since this is an option for the front-end, it has to be set in session desc, and not in target desc, because target desc only affects the backend.

The ask here is the ability to parse and check a module once, and generate both code with and without debug info in two separate target requests. We can enable such use by:

  • The user still need to enable debug info in session desc.
  • The user can override debug info to 0 by providing such a compiler option entry in target desc.
  • In the backend, we should add a pass to strip out all debug info instructions, if the target's optionSet contains an entry that disables debug info.

By doing so, we can ensure we always emit debug insts when lowering to IR, and these debug insts will be removed when compiling for a target that disables debug info during backend process, and will be respected when compiling for a target that does not disable debug info.

@csyonghe
Copy link
Collaborator

@aleino-nv Note that the front-end will not have access to any compiler options set on a target, and it shouldn't access them.

Instead of saying "enable debug source lowering when any target specifies debug info", we should just let the front-end emit debug info if the session desc enables debug info. But then we also allow target desc to disable debug info by including an entry that sets DebugInfo to NONE. This way, the backend will always see that the debug info is disabled. In the backend, we can always run a pass to remove the debug insts when we see that the debug info is disabled in targetRequest.

@aleino-nv
Copy link
Collaborator

aleino-nv commented Jan 27, 2025

@aleino-nv Note that the front-end will not have access to any compiler options set on a target, and it shouldn't access them.

Instead of saying "enable debug source lowering when any target specifies debug info", we should just let the front-end emit debug info if the session desc enables debug info. But then we also allow target desc to disable debug info by including an entry that sets DebugInfo to NONE. This way, the backend will always see that the debug info is disabled. In the backend, we can always run a pass to remove the debug insts when we see that the debug info is disabled in targetRequest.

@csyonghe

So the user will need to do the following if they want debug info only for specific targets?

  1. Enable debug info in session options
  2. Disable debug info in the target options of all targets where they don't want debug info.

In particular, if they want debug info anywhere they need to realize to enable it in session options?

I was thinking it would be more natural if it worked like this:

  1. If the user specifies debug info in the session options, then each target gets debug info unless they explicitly opt out of it.
  2. If the user specifies debug info in the target options of a particular target, then that target gets debug info.

What do you think about the latter alternative?

@aleino-nv
Copy link
Collaborator

aleino-nv commented Jan 27, 2025

In the backend, we can always run a pass to remove the debug insts when we see that the debug info is disabled in targetRequest.

@csyonghe It's not clear to me how to do this properly.
I wrote a pass that finds IRDebugSource instructions, and then removes it as well as any users of it, recursively. However I'm not sure whether that's a sane thing to do.
Here is my WIP PR: #6193

Is this supposed to produce code that is identical to what you'd get if you specified SLANG_DEBUG_INFO_LEVEL_NONE for the session settings? That's what I'd expect as a user.

aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 27, 2025
aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 28, 2025
aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 29, 2025
aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 29, 2025
@aleino-nv
Copy link
Collaborator

aleino-nv commented Jan 29, 2025

@EtienneParmentier I believe the latest version of #6193 should fix the problem you encountered.

aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 30, 2025
aleino-nv added a commit to aleino-nv/slang that referenced this issue Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang
Projects
None yet
Development

No branches or pull requests

5 participants