mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
Simplify `naga::back::spv::LocalType` to have only one variant for representing pointers, and use the SPIR-V type as the base type, so that `LocalType` values are equal when the SPIR-V pointer types they map to would be equal as well. This avoids emitting multiple `OpTypePointer` instructions, which SPIR-V would interpret as distinct types, for equivalent Naga IR pointer types. Change the `get_pointer_type_id` utility function accordingly, and adjust its callers. Change `LocalType::from_inner` into `Writer::localtype_from_inner`, so that it can call `Writer` methods to build base types. Adjust users.
335 lines
9.3 KiB
Plaintext
335 lines
9.3 KiB
Plaintext
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: rspirv
|
|
; Bound: 133
|
|
OpCapability Shader
|
|
OpCapability SampleRateShading
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Vertex %29 "vert_main" %11 %13 %15 %16 %18 %20 %22 %23 %24 %25 %26 %27
|
|
OpEntryPoint Fragment %131 "frag_main" %104 %107 %110 %112 %115 %118 %121 %123 %125 %127 %129
|
|
OpExecutionMode %131 OriginUpperLeft
|
|
%3 = OpString "interpolate_compat.wgsl"
|
|
OpSource Unknown 0 %3 "// NOTE: This is basically the same as `interpolate.wgsl`, except for the removal of
|
|
// `@interpolate(flat, first)`, which is unsupported in GLSL and `compat`.
|
|
|
|
// NOTE: invalid combinations are tested in the
|
|
// `validation::incompatible_interpolation_and_sampling_types` test.
|
|
struct FragmentInput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) @interpolate(flat) _flat : u32,
|
|
// NOTE: not supported in `compat` or GLSL
|
|
// // @location(1) @interpolate(flat, first) flat_first : u32,
|
|
@location(2) @interpolate(flat, either) flat_either : u32,
|
|
@location(3) @interpolate(linear) _linear : f32,
|
|
@location(4) @interpolate(linear, centroid) linear_centroid : vec2<f32>,
|
|
@location(6) @interpolate(linear, sample) linear_sample : vec3<f32>,
|
|
@location(7) @interpolate(linear, center) linear_center : vec3<f32>,
|
|
@location(8) @interpolate(perspective) perspective : vec4<f32>,
|
|
@location(9) @interpolate(perspective, centroid) perspective_centroid : f32,
|
|
@location(10) @interpolate(perspective, sample) perspective_sample : f32,
|
|
@location(11) @interpolate(perspective, center) perspective_center : f32,
|
|
}
|
|
|
|
@vertex
|
|
fn vert_main() -> FragmentInput {
|
|
var out: FragmentInput;
|
|
|
|
out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
|
out._flat = 8u;
|
|
// out.flat_first = 9u;
|
|
out.flat_either = 10u;
|
|
out._linear = 27.0;
|
|
out.linear_centroid = vec2<f32>(64.0, 125.0);
|
|
out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
|
out.linear_center = vec3<f32>(255.0, 511.0, 1024.0);
|
|
out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
|
out.perspective_centroid = 2197.0;
|
|
out.perspective_sample = 2744.0;
|
|
out.perspective_center = 2812.0;
|
|
|
|
return out;
|
|
}
|
|
|
|
@fragment
|
|
fn frag_main(val : FragmentInput) { }
|
|
"
|
|
OpMemberName %9 0 "position"
|
|
OpMemberName %9 1 "_flat"
|
|
OpMemberName %9 2 "flat_either"
|
|
OpMemberName %9 3 "_linear"
|
|
OpMemberName %9 4 "linear_centroid"
|
|
OpMemberName %9 5 "linear_sample"
|
|
OpMemberName %9 6 "linear_center"
|
|
OpMemberName %9 7 "perspective"
|
|
OpMemberName %9 8 "perspective_centroid"
|
|
OpMemberName %9 9 "perspective_sample"
|
|
OpMemberName %9 10 "perspective_center"
|
|
OpName %9 "FragmentInput"
|
|
OpName %11 "position"
|
|
OpName %13 "_flat"
|
|
OpName %15 "flat_either"
|
|
OpName %16 "_linear"
|
|
OpName %18 "linear_centroid"
|
|
OpName %20 "linear_sample"
|
|
OpName %22 "linear_center"
|
|
OpName %23 "perspective"
|
|
OpName %24 "perspective_centroid"
|
|
OpName %25 "perspective_sample"
|
|
OpName %26 "perspective_center"
|
|
OpName %29 "vert_main"
|
|
OpName %58 "out"
|
|
OpName %104 "position"
|
|
OpName %107 "_flat"
|
|
OpName %110 "flat_either"
|
|
OpName %112 "_linear"
|
|
OpName %115 "linear_centroid"
|
|
OpName %118 "linear_sample"
|
|
OpName %121 "linear_center"
|
|
OpName %123 "perspective"
|
|
OpName %125 "perspective_centroid"
|
|
OpName %127 "perspective_sample"
|
|
OpName %129 "perspective_center"
|
|
OpName %131 "frag_main"
|
|
OpMemberDecorate %9 0 Offset 0
|
|
OpMemberDecorate %9 1 Offset 16
|
|
OpMemberDecorate %9 2 Offset 20
|
|
OpMemberDecorate %9 3 Offset 24
|
|
OpMemberDecorate %9 4 Offset 32
|
|
OpMemberDecorate %9 5 Offset 48
|
|
OpMemberDecorate %9 6 Offset 64
|
|
OpMemberDecorate %9 7 Offset 80
|
|
OpMemberDecorate %9 8 Offset 96
|
|
OpMemberDecorate %9 9 Offset 100
|
|
OpMemberDecorate %9 10 Offset 104
|
|
OpDecorate %11 BuiltIn Position
|
|
OpDecorate %13 Location 0
|
|
OpDecorate %13 Flat
|
|
OpDecorate %15 Location 2
|
|
OpDecorate %15 Flat
|
|
OpDecorate %16 Location 3
|
|
OpDecorate %16 NoPerspective
|
|
OpDecorate %18 Location 4
|
|
OpDecorate %18 NoPerspective
|
|
OpDecorate %18 Centroid
|
|
OpDecorate %20 Location 6
|
|
OpDecorate %20 NoPerspective
|
|
OpDecorate %20 Sample
|
|
OpDecorate %22 Location 7
|
|
OpDecorate %22 NoPerspective
|
|
OpDecorate %23 Location 8
|
|
OpDecorate %24 Location 9
|
|
OpDecorate %24 Centroid
|
|
OpDecorate %25 Location 10
|
|
OpDecorate %25 Sample
|
|
OpDecorate %26 Location 11
|
|
OpDecorate %27 BuiltIn PointSize
|
|
OpDecorate %104 BuiltIn FragCoord
|
|
OpDecorate %107 Location 0
|
|
OpDecorate %107 Flat
|
|
OpDecorate %110 Location 2
|
|
OpDecorate %110 Flat
|
|
OpDecorate %112 Location 3
|
|
OpDecorate %112 NoPerspective
|
|
OpDecorate %115 Location 4
|
|
OpDecorate %115 NoPerspective
|
|
OpDecorate %115 Centroid
|
|
OpDecorate %118 Location 6
|
|
OpDecorate %118 NoPerspective
|
|
OpDecorate %118 Sample
|
|
OpDecorate %121 Location 7
|
|
OpDecorate %121 NoPerspective
|
|
OpDecorate %123 Location 8
|
|
OpDecorate %125 Location 9
|
|
OpDecorate %125 Centroid
|
|
OpDecorate %127 Location 10
|
|
OpDecorate %127 Sample
|
|
OpDecorate %129 Location 11
|
|
%2 = OpTypeVoid
|
|
%4 = OpTypeFloat 32
|
|
%5 = OpTypeVector %4 4
|
|
%6 = OpTypeInt 32 0
|
|
%7 = OpTypeVector %4 2
|
|
%8 = OpTypeVector %4 3
|
|
%9 = OpTypeStruct %5 %6 %6 %4 %7 %8 %8 %5 %4 %4 %4
|
|
%12 = OpTypePointer Output %5
|
|
%11 = OpVariable %12 Output
|
|
%14 = OpTypePointer Output %6
|
|
%13 = OpVariable %14 Output
|
|
%15 = OpVariable %14 Output
|
|
%17 = OpTypePointer Output %4
|
|
%16 = OpVariable %17 Output
|
|
%19 = OpTypePointer Output %7
|
|
%18 = OpVariable %19 Output
|
|
%21 = OpTypePointer Output %8
|
|
%20 = OpVariable %21 Output
|
|
%22 = OpVariable %21 Output
|
|
%23 = OpVariable %12 Output
|
|
%24 = OpVariable %17 Output
|
|
%25 = OpVariable %17 Output
|
|
%26 = OpVariable %17 Output
|
|
%27 = OpVariable %17 Output
|
|
%28 = OpConstant %4 1.0
|
|
%30 = OpTypeFunction %2
|
|
%31 = OpConstant %4 2.0
|
|
%32 = OpConstant %4 4.0
|
|
%33 = OpConstant %4 5.0
|
|
%34 = OpConstant %4 6.0
|
|
%35 = OpConstantComposite %5 %31 %32 %33 %34
|
|
%36 = OpConstant %6 8
|
|
%37 = OpConstant %6 10
|
|
%38 = OpConstant %4 27.0
|
|
%39 = OpConstant %4 64.0
|
|
%40 = OpConstant %4 125.0
|
|
%41 = OpConstantComposite %7 %39 %40
|
|
%42 = OpConstant %4 216.0
|
|
%43 = OpConstant %4 343.0
|
|
%44 = OpConstant %4 512.0
|
|
%45 = OpConstantComposite %8 %42 %43 %44
|
|
%46 = OpConstant %4 255.0
|
|
%47 = OpConstant %4 511.0
|
|
%48 = OpConstant %4 1024.0
|
|
%49 = OpConstantComposite %8 %46 %47 %48
|
|
%50 = OpConstant %4 729.0
|
|
%51 = OpConstant %4 1000.0
|
|
%52 = OpConstant %4 1331.0
|
|
%53 = OpConstant %4 1728.0
|
|
%54 = OpConstantComposite %5 %50 %51 %52 %53
|
|
%55 = OpConstant %4 2197.0
|
|
%56 = OpConstant %4 2744.0
|
|
%57 = OpConstant %4 2812.0
|
|
%59 = OpTypePointer Function %9
|
|
%60 = OpConstantNull %9
|
|
%62 = OpTypePointer Function %5
|
|
%63 = OpConstant %6 0
|
|
%65 = OpTypePointer Function %6
|
|
%66 = OpConstant %6 1
|
|
%68 = OpConstant %6 2
|
|
%70 = OpTypePointer Function %4
|
|
%71 = OpConstant %6 3
|
|
%73 = OpTypePointer Function %7
|
|
%74 = OpConstant %6 4
|
|
%76 = OpTypePointer Function %8
|
|
%77 = OpConstant %6 5
|
|
%79 = OpConstant %6 6
|
|
%81 = OpConstant %6 7
|
|
%84 = OpConstant %6 9
|
|
%105 = OpTypePointer Input %5
|
|
%104 = OpVariable %105 Input
|
|
%108 = OpTypePointer Input %6
|
|
%107 = OpVariable %108 Input
|
|
%110 = OpVariable %108 Input
|
|
%113 = OpTypePointer Input %4
|
|
%112 = OpVariable %113 Input
|
|
%116 = OpTypePointer Input %7
|
|
%115 = OpVariable %116 Input
|
|
%119 = OpTypePointer Input %8
|
|
%118 = OpVariable %119 Input
|
|
%121 = OpVariable %119 Input
|
|
%123 = OpVariable %105 Input
|
|
%125 = OpVariable %113 Input
|
|
%127 = OpVariable %113 Input
|
|
%129 = OpVariable %113 Input
|
|
%29 = OpFunction %2 None %30
|
|
%10 = OpLabel
|
|
%58 = OpVariable %59 Function %60
|
|
OpStore %27 %28
|
|
OpBranch %61
|
|
%61 = OpLabel
|
|
OpLine %3 26 4
|
|
OpLine %3 26 19
|
|
OpLine %3 26 4
|
|
%64 = OpAccessChain %62 %58 %63
|
|
OpStore %64 %35
|
|
OpLine %3 27 4
|
|
OpLine %3 27 4
|
|
%67 = OpAccessChain %65 %58 %66
|
|
OpStore %67 %36
|
|
OpLine %3 29 4
|
|
OpLine %3 29 4
|
|
%69 = OpAccessChain %65 %58 %68
|
|
OpStore %69 %37
|
|
OpLine %3 30 4
|
|
OpLine %3 30 4
|
|
%72 = OpAccessChain %70 %58 %71
|
|
OpStore %72 %38
|
|
OpLine %3 31 4
|
|
OpLine %3 31 26
|
|
OpLine %3 31 4
|
|
%75 = OpAccessChain %73 %58 %74
|
|
OpStore %75 %41
|
|
OpLine %3 32 4
|
|
OpLine %3 32 24
|
|
OpLine %3 32 4
|
|
%78 = OpAccessChain %76 %58 %77
|
|
OpStore %78 %45
|
|
OpLine %3 33 4
|
|
OpLine %3 33 24
|
|
OpLine %3 33 4
|
|
%80 = OpAccessChain %76 %58 %79
|
|
OpStore %80 %49
|
|
OpLine %3 34 4
|
|
OpLine %3 34 22
|
|
OpLine %3 34 4
|
|
%82 = OpAccessChain %62 %58 %81
|
|
OpStore %82 %54
|
|
OpLine %3 35 4
|
|
OpLine %3 35 4
|
|
%83 = OpAccessChain %70 %58 %36
|
|
OpStore %83 %55
|
|
OpLine %3 36 4
|
|
OpLine %3 36 4
|
|
%85 = OpAccessChain %70 %58 %84
|
|
OpStore %85 %56
|
|
OpLine %3 37 4
|
|
OpLine %3 37 4
|
|
%86 = OpAccessChain %70 %58 %37
|
|
OpStore %86 %57
|
|
OpLine %3 1 1
|
|
%87 = OpLoad %9 %58
|
|
%88 = OpCompositeExtract %5 %87 0
|
|
OpStore %11 %88
|
|
%89 = OpAccessChain %17 %11 %66
|
|
%90 = OpLoad %4 %89
|
|
%91 = OpFNegate %4 %90
|
|
OpStore %89 %91
|
|
%92 = OpCompositeExtract %6 %87 1
|
|
OpStore %13 %92
|
|
%93 = OpCompositeExtract %6 %87 2
|
|
OpStore %15 %93
|
|
%94 = OpCompositeExtract %4 %87 3
|
|
OpStore %16 %94
|
|
%95 = OpCompositeExtract %7 %87 4
|
|
OpStore %18 %95
|
|
%96 = OpCompositeExtract %8 %87 5
|
|
OpStore %20 %96
|
|
%97 = OpCompositeExtract %8 %87 6
|
|
OpStore %22 %97
|
|
%98 = OpCompositeExtract %5 %87 7
|
|
OpStore %23 %98
|
|
%99 = OpCompositeExtract %4 %87 8
|
|
OpStore %24 %99
|
|
%100 = OpCompositeExtract %4 %87 9
|
|
OpStore %25 %100
|
|
%101 = OpCompositeExtract %4 %87 10
|
|
OpStore %26 %101
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%131 = OpFunction %2 None %30
|
|
%102 = OpLabel
|
|
%106 = OpLoad %5 %104
|
|
%109 = OpLoad %6 %107
|
|
%111 = OpLoad %6 %110
|
|
%114 = OpLoad %4 %112
|
|
%117 = OpLoad %7 %115
|
|
%120 = OpLoad %8 %118
|
|
%122 = OpLoad %8 %121
|
|
%124 = OpLoad %5 %123
|
|
%126 = OpLoad %4 %125
|
|
%128 = OpLoad %4 %127
|
|
%130 = OpLoad %4 %129
|
|
%103 = OpCompositeConstruct %9 %106 %109 %111 %114 %117 %120 %122 %124 %126 %128 %130
|
|
OpBranch %132
|
|
%132 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd |