From 8183f4ff6ff220d4b17db6bab2b5779a4886b1a7 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 13 Feb 2021 14:04:58 -0500 Subject: [PATCH] [spv-out] annotate function and constant names --- src/back/spv/writer.rs | 11 ++++++++++ tests/out/boids.spvasm.snap | 31 +++++++++++++++++++++++++++++ tests/out/collatz.spvasm.snap | 10 ++++++++++ tests/out/empty.spvasm.snap | 3 +++ tests/out/quad.spvasm.snap | 14 +++++++++++++ tests/out/shadow.spvasm.snap | 23 +++++++++++++++++++++ tests/out/skybox.spvasm.snap | 19 ++++++++++++++++++ tests/out/texture-array.spvasm.snap | 11 ++++++++++ tests/snapshots.rs | 2 +- 9 files changed, 123 insertions(+), 1 deletion(-) diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 1a4f0d24b7..b60f173dbd 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -413,6 +413,12 @@ impl Writer { }; let function_id = self.generate_id(); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = ir_function.name { + self.debugs.push(Instruction::name(function_id, name)); + } + } + let function_type = self.get_function_type(lookup_function_type); function.signature = Some(Instruction::function( return_type_id, @@ -2023,6 +2029,11 @@ impl Writer { for (handle, constant) in ir_module.constants.iter() { let id = self.generate_id(); self.lookup_constant.insert(handle, id); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = constant.name { + self.debugs.push(Instruction::name(id, name)); + } + } self.write_constant_type(id, &constant.inner, &ir_module.types)?; } diff --git a/tests/out/boids.spvasm.snap b/tests/out/boids.spvasm.snap index fc28d81476..dd76914117 100644 --- a/tests/out/boids.spvasm.snap +++ b/tests/out/boids.spvasm.snap @@ -11,6 +11,37 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %29 "main" %36 OpExecutionMode %29 LocalSize 64 1 1 +OpSource GLSL 450 +OpName %3 "NUM_PARTICLES" +OpName %15 "vPos" +OpName %18 "vVel" +OpName %19 "cMass" +OpName %20 "cVel" +OpName %21 "colVel" +OpName %22 "cMassCount" +OpName %24 "cVelCount" +OpName %25 "pos" +OpName %26 "vel" +OpName %27 "i" +OpName %29 "main" +OpName %36 "gl_GlobalInvocationID" +OpName %45 "Particle" +OpMemberName %45 0 "pos" +OpMemberName %45 1 "vel" +OpName %49 "Particles" +OpMemberName %49 0 "particles" +OpName %50 "particlesSrc" +OpName %121 "SimParams" +OpMemberName %121 0 "deltaT" +OpMemberName %121 1 "rule1Distance" +OpMemberName %121 2 "rule2Distance" +OpMemberName %121 3 "rule3Distance" +OpMemberName %121 4 "rule1Scale" +OpMemberName %121 5 "rule2Scale" +OpMemberName %121 6 "rule3Scale" +OpName %122 "params" +OpName %274 "particlesDst" +OpName %29 "main" OpDecorate %36 BuiltIn GlobalInvocationId OpMemberDecorate %45 0 Offset 0 OpMemberDecorate %45 1 Offset 8 diff --git a/tests/out/collatz.spvasm.snap b/tests/out/collatz.spvasm.snap index 99f6590cf5..8bdea00cd6 100644 --- a/tests/out/collatz.spvasm.snap +++ b/tests/out/collatz.spvasm.snap @@ -11,6 +11,16 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %39 "main" %53 OpExecutionMode %39 LocalSize 1 1 1 +OpSource GLSL 450 +OpName %8 "n" +OpName %10 "i" +OpName %12 "collatz_iterations" +OpName %39 "main" +OpName %45 "PrimeIndices" +OpMemberName %45 0 "data" +OpName %46 "v_indices" +OpName %53 "global_id" +OpName %39 "main" OpDecorate %43 ArrayStride 4 OpDecorate %45 BufferBlock OpMemberDecorate %45 0 Offset 0 diff --git a/tests/out/empty.spvasm.snap b/tests/out/empty.spvasm.snap index ae2b9628bf..e764f3e4d2 100644 --- a/tests/out/empty.spvasm.snap +++ b/tests/out/empty.spvasm.snap @@ -11,6 +11,9 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %3 "main" OpExecutionMode %3 LocalSize 1 1 1 +OpSource GLSL 450 +OpName %3 "main" +OpName %3 "main" %2 = OpTypeVoid %4 = OpTypeFunction %2 %3 = OpFunction %2 None %4 diff --git a/tests/out/quad.spvasm.snap b/tests/out/quad.spvasm.snap index 0a0caa24a0..1cbbb26860 100644 --- a/tests/out/quad.spvasm.snap +++ b/tests/out/quad.spvasm.snap @@ -12,6 +12,20 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %7 "main" %20 %13 %11 %17 OpEntryPoint Fragment %23 "main" %35 %25 OpExecutionMode %23 OriginUpperLeft +OpSource GLSL 450 +OpName %3 "c_scale" +OpName %7 "main" +OpName %11 "v_uv" +OpName %13 "a_uv" +OpName %17 "o_position" +OpName %20 "a_pos" +OpName %7 "main" +OpName %23 "main" +OpName %25 "o_color" +OpName %27 "u_texture" +OpName %32 "u_sampler" +OpName %35 "v_uv" +OpName %23 "main" OpDecorate %11 Location 0 OpDecorate %13 Location 1 OpDecorate %17 BuiltIn Position diff --git a/tests/out/shadow.spvasm.snap b/tests/out/shadow.spvasm.snap index 97fdef6f78..e1fd5a5583 100644 --- a/tests/out/shadow.spvasm.snap +++ b/tests/out/shadow.spvasm.snap @@ -11,6 +11,29 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %64 "fs_main" %114 %111 %217 OpExecutionMode %64 OriginUpperLeft +OpSource GLSL 450 +OpName %9 "c_ambient" +OpName %11 "c_max_lights" +OpName %18 "fetch_shadow" +OpName %28 "t_shadow" +OpName %33 "sampler_shadow" +OpName %60 "color" +OpName %62 "i" +OpName %64 "fs_main" +OpName %76 "Globals" +OpMemberName %76 0 "num_lights" +OpName %77 "u_globals" +OpName %97 "Light" +OpMemberName %97 0 "proj" +OpMemberName %97 1 "pos" +OpMemberName %97 2 "color" +OpName %101 "Lights" +OpMemberName %101 0 "data" +OpName %102 "s_lights" +OpName %111 "in_position_fs" +OpName %114 "in_normal_fs" +OpName %217 "out_color_fs" +OpName %64 "fs_main" OpDecorate %28 DescriptorSet 0 OpDecorate %28 Binding 2 OpDecorate %33 DescriptorSet 0 diff --git a/tests/out/skybox.spvasm.snap b/tests/out/skybox.spvasm.snap index 3733edaa19..71da0dc4aa 100644 --- a/tests/out/skybox.spvasm.snap +++ b/tests/out/skybox.spvasm.snap @@ -12,6 +12,25 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %16 "vs_main" %159 %47 %21 OpEntryPoint Fragment %170 "fs_main" %182 %172 OpExecutionMode %170 OriginUpperLeft +OpSource GLSL 450 +OpName %10 "tmp1" +OpName %12 "tmp2" +OpName %13 "unprojected" +OpName %16 "vs_main" +OpName %21 "in_vertex_index" +OpName %31 "Data" +OpMemberName %31 0 "proj_inv" +OpMemberName %31 1 "view" +OpName %32 "r_data" +OpName %47 "out_uv" +OpName %159 "out_position" +OpName %16 "vs_main" +OpName %170 "fs_main" +OpName %172 "out_color" +OpName %174 "r_texture" +OpName %179 "r_sampler" +OpName %182 "in_uv" +OpName %170 "fs_main" OpDecorate %21 BuiltIn VertexIndex OpDecorate %31 Block OpMemberDecorate %31 0 Offset 0 diff --git a/tests/out/texture-array.spvasm.snap b/tests/out/texture-array.spvasm.snap index e83fab9047..78e25937d9 100644 --- a/tests/out/texture-array.spvasm.snap +++ b/tests/out/texture-array.spvasm.snap @@ -11,6 +11,17 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %5 "main" %35 %23 OpExecutionMode %5 OriginUpperLeft +OpSource GLSL 450 +OpName %5 "main" +OpName %12 "PushConstants" +OpMemberName %12 0 "index" +OpName %13 "pc" +OpName %23 "color" +OpName %26 "texture0" +OpName %31 "sampler" +OpName %35 "tex_coord" +OpName %40 "texture1" +OpName %5 "main" OpDecorate %12 Block OpMemberDecorate %12 0 Offset 0 OpDecorate %23 Location 1 diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 40b472fb56..7523bb0b9e 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -61,7 +61,7 @@ fn check_output_spv(module: &naga::Module, name: &str, params: &Parameters) { let spv = spv::write_vec( &module, - spv::WriterFlags::NONE, + spv::WriterFlags::DEBUG, params.spv_capabilities.clone(), ) .unwrap();