diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 1cba6da37..405813612 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -770,12 +770,6 @@ impl Writer { ref members, span: _, } => { - if self.flags.contains(WriterFlags::DEBUG) { - if let Some(ref name) = ty.name { - self.debugs.push(Instruction::name(id, name)); - } - } - if top_level { self.decorate(id, Decoration::Block, &[]); } @@ -853,6 +847,12 @@ impl Writer { // Add this handle as a new alias for that type. self.lookup_type.insert(LookupType::Handle(handle), id); + if self.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = ty.name { + self.debugs.push(Instruction::name(id, name)); + } + } + Ok(id) } diff --git a/tests/out/spv/access.spvasm b/tests/out/spv/access.spvasm index df869e495..6e28bdb60 100644 --- a/tests/out/spv/access.spvasm +++ b/tests/out/spv/access.spvasm @@ -10,11 +10,11 @@ OpEntryPoint Vertex %39 "foo" %34 %37 OpEntryPoint GLCompute %84 "atomics" OpExecutionMode %84 LocalSize 1 1 1 OpSource GLSL 450 -OpName %25 "Bar" OpMemberName %25 0 "matrix" OpMemberName %25 1 "atom" OpMemberName %25 2 "arr" OpMemberName %25 3 "data" +OpName %25 "Bar" OpName %27 "bar" OpName %29 "foo" OpName %31 "c" diff --git a/tests/out/spv/boids.spvasm b/tests/out/spv/boids.spvasm index a40311f79..1bb7edcde 100644 --- a/tests/out/spv/boids.spvasm +++ b/tests/out/spv/boids.spvasm @@ -10,10 +10,9 @@ OpEntryPoint GLCompute %43 "main" %40 OpExecutionMode %43 LocalSize 64 1 1 OpSource GLSL 450 OpName %3 "NUM_PARTICLES" -OpName %16 "Particle" OpMemberName %16 0 "pos" OpMemberName %16 1 "vel" -OpName %17 "SimParams" +OpName %16 "Particle" OpMemberName %17 0 "deltaT" OpMemberName %17 1 "rule1Distance" OpMemberName %17 2 "rule2Distance" @@ -21,8 +20,9 @@ OpMemberName %17 3 "rule3Distance" OpMemberName %17 4 "rule1Scale" OpMemberName %17 5 "rule2Scale" OpMemberName %17 6 "rule3Scale" -OpName %19 "Particles" +OpName %17 "SimParams" OpMemberName %19 0 "particles" +OpName %19 "Particles" OpName %21 "params" OpName %23 "particlesSrc" OpName %25 "particlesDst" diff --git a/tests/out/spv/collatz.spvasm b/tests/out/spv/collatz.spvasm index ce1b3e5e2..5ac6c3d3f 100644 --- a/tests/out/spv/collatz.spvasm +++ b/tests/out/spv/collatz.spvasm @@ -9,8 +9,8 @@ OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %48 "main" %45 OpExecutionMode %48 LocalSize 1 1 1 OpSource GLSL 450 -OpName %9 "PrimeIndices" OpMemberName %9 0 "data" +OpName %9 "PrimeIndices" OpName %11 "v_indices" OpName %13 "n" OpName %15 "i" diff --git a/tests/out/spv/interpolate.spvasm b/tests/out/spv/interpolate.spvasm index 80f62b6a4..019b9ae0e 100644 --- a/tests/out/spv/interpolate.spvasm +++ b/tests/out/spv/interpolate.spvasm @@ -10,7 +10,6 @@ OpEntryPoint Vertex %42 "main" %29 %31 %33 %35 %37 %39 %40 %41 OpEntryPoint Fragment %106 "main" %85 %88 %91 %94 %97 %100 %102 %104 OpExecutionMode %106 OriginUpperLeft OpSource GLSL 450 -OpName %25 "FragmentInput" OpMemberName %25 0 "position" OpMemberName %25 1 "flat" OpMemberName %25 2 "linear" @@ -19,6 +18,7 @@ OpMemberName %25 4 "linear_sample" OpMemberName %25 5 "perspective" OpMemberName %25 6 "perspective_centroid" OpMemberName %25 7 "perspective_sample" +OpName %25 "FragmentInput" OpName %26 "out" OpName %29 "position" OpName %31 "flat" diff --git a/tests/out/spv/policy-mix.spvasm b/tests/out/spv/policy-mix.spvasm new file mode 100644 index 000000000..5d81184d3 --- /dev/null +++ b/tests/out/spv/policy-mix.spvasm @@ -0,0 +1,137 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 93 +OpCapability Shader +OpCapability ImageQuery +OpCapability Linkage +OpExtension "SPV_KHR_storage_buffer_storage_class" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpSource GLSL 450 +OpMemberName %15 0 "a" +OpName %15 "InStorage" +OpMemberName %17 0 "a" +OpName %17 "InUniform" +OpName %23 "in_storage" +OpName %25 "in_uniform" +OpName %27 "image_2d_array" +OpName %29 "in_workgroup" +OpName %31 "in_private" +OpName %33 "in_function" +OpName %39 "mock_function" +OpDecorate %14 ArrayStride 16 +OpDecorate %15 Block +OpMemberDecorate %15 0 Offset 0 +OpDecorate %16 ArrayStride 16 +OpDecorate %17 Block +OpMemberDecorate %17 0 Offset 0 +OpDecorate %19 ArrayStride 4 +OpDecorate %20 ArrayStride 4 +OpDecorate %22 ArrayStride 16 +OpDecorate %23 NonWritable +OpDecorate %23 DescriptorSet 0 +OpDecorate %23 Binding 0 +OpDecorate %25 DescriptorSet 0 +OpDecorate %25 Binding 1 +OpDecorate %27 DescriptorSet 0 +OpDecorate %27 Binding 2 +%2 = OpTypeVoid +%4 = OpTypeInt 32 1 +%3 = OpConstant %4 10 +%5 = OpConstant %4 20 +%6 = OpConstant %4 30 +%7 = OpConstant %4 40 +%8 = OpConstant %4 2 +%10 = OpTypeFloat 32 +%9 = OpConstant %10 0.707 +%11 = OpConstant %10 0.0 +%12 = OpConstant %10 1.0 +%13 = OpTypeVector %10 4 +%14 = OpTypeArray %13 %3 +%15 = OpTypeStruct %14 +%16 = OpTypeArray %13 %5 +%17 = OpTypeStruct %16 +%18 = OpTypeImage %10 2D 0 1 0 1 Unknown +%19 = OpTypeArray %10 %6 +%20 = OpTypeArray %10 %7 +%21 = OpTypeVector %4 2 +%22 = OpTypeArray %13 %8 +%24 = OpTypePointer StorageBuffer %15 +%23 = OpVariable %24 StorageBuffer +%26 = OpTypePointer Uniform %17 +%25 = OpVariable %26 Uniform +%28 = OpTypePointer UniformConstant %18 +%27 = OpVariable %28 UniformConstant +%30 = OpTypePointer Workgroup %19 +%29 = OpVariable %30 Workgroup +%32 = OpTypePointer Private %20 +%31 = OpVariable %32 Private +%34 = OpTypePointer Function %22 +%40 = OpTypeFunction %13 %21 %4 %4 +%46 = OpTypePointer StorageBuffer %14 +%47 = OpTypePointer StorageBuffer %13 +%49 = OpTypeInt 32 0 +%48 = OpConstant %49 0 +%52 = OpTypePointer Uniform %16 +%53 = OpTypePointer Uniform %13 +%57 = OpTypeVector %4 3 +%59 = OpTypeBool +%60 = OpConstantNull %13 +%66 = OpTypeVector %59 3 +%73 = OpTypePointer Workgroup %10 +%74 = OpConstant %49 29 +%80 = OpTypePointer Private %10 +%81 = OpConstant %49 39 +%87 = OpTypePointer Function %13 +%88 = OpConstant %49 1 +%39 = OpFunction %13 None %40 +%36 = OpFunctionParameter %21 +%37 = OpFunctionParameter %4 +%38 = OpFunctionParameter %4 +%35 = OpLabel +%33 = OpVariable %34 Function +%41 = OpLoad %18 %27 +OpBranch %42 +%42 = OpLabel +%43 = OpCompositeConstruct %13 %9 %11 %11 %12 +%44 = OpCompositeConstruct %13 %11 %9 %11 %12 +%45 = OpCompositeConstruct %22 %43 %44 +OpStore %33 %45 +%50 = OpAccessChain %47 %23 %48 %37 +%51 = OpLoad %13 %50 +%54 = OpAccessChain %53 %25 %48 %37 +%55 = OpLoad %13 %54 +%56 = OpFAdd %13 %51 %55 +%58 = OpCompositeConstruct %57 %36 %37 +%61 = OpImageQueryLevels %4 %41 +%62 = OpULessThan %59 %38 %61 +OpSelectionMerge %63 None +OpBranchConditional %62 %64 %63 +%64 = OpLabel +%65 = OpImageQuerySizeLod %57 %41 %38 +%67 = OpULessThan %66 %58 %65 +%68 = OpAll %59 %67 +OpBranchConditional %68 %69 %63 +%69 = OpLabel +%70 = OpImageFetch %13 %41 %58 Lod %38 +OpBranch %63 +%63 = OpLabel +%71 = OpPhi %13 %60 %42 %60 %64 %70 %69 +%72 = OpFAdd %13 %56 %71 +%75 = OpExtInst %49 %1 UMin %37 %74 +%76 = OpAccessChain %73 %29 %75 +%77 = OpLoad %10 %76 +%78 = OpCompositeConstruct %13 %77 %77 %77 %77 +%79 = OpFAdd %13 %72 %78 +%82 = OpExtInst %49 %1 UMin %37 %81 +%83 = OpAccessChain %80 %31 %82 +%84 = OpLoad %10 %83 +%85 = OpCompositeConstruct %13 %84 %84 %84 %84 +%86 = OpFAdd %13 %79 %85 +%89 = OpExtInst %49 %1 UMin %37 %88 +%90 = OpAccessChain %87 %33 %89 +%91 = OpLoad %13 %90 +%92 = OpFAdd %13 %86 %91 +OpReturnValue %92 +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/quad.spvasm b/tests/out/spv/quad.spvasm index 51b6b61e4..cbf63236d 100644 --- a/tests/out/spv/quad.spvasm +++ b/tests/out/spv/quad.spvasm @@ -12,9 +12,9 @@ OpExecutionMode %45 OriginUpperLeft OpExecutionMode %61 OriginUpperLeft OpSource GLSL 450 OpName %3 "c_scale" -OpName %10 "VertexOutput" OpMemberName %10 0 "uv" OpMemberName %10 1 "position" +OpName %10 "VertexOutput" OpName %13 "u_texture" OpName %15 "u_sampler" OpName %18 "pos" diff --git a/tests/out/spv/shadow.spvasm b/tests/out/spv/shadow.spvasm index cf7a3e5fb..0361ff2f4 100644 --- a/tests/out/spv/shadow.spvasm +++ b/tests/out/spv/shadow.spvasm @@ -10,14 +10,14 @@ OpEntryPoint Fragment %77 "fs_main" %69 %72 %75 OpExecutionMode %77 OriginUpperLeft OpSource GLSL 450 OpName %9 "c_max_lights" -OpName %14 "Globals" OpMemberName %14 0 "num_lights" -OpName %17 "Light" +OpName %14 "Globals" OpMemberName %17 0 "proj" OpMemberName %17 1 "pos" OpMemberName %17 2 "color" -OpName %19 "Lights" +OpName %17 "Light" OpMemberName %19 0 "data" +OpName %19 "Lights" OpName %24 "c_ambient" OpName %25 "u_globals" OpName %27 "s_lights"