mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 06:50:59 +01:00
Make the parser code more closely follow the spec's grammar around
`unary_expression`, `postfix_expression`, and `singular_expression`.
Change the handling of postfix expressions (indexing, member/component access,
and swizzling) to apply the indirection at the appropriate time, resulting in
code improvements on all output formats. For example, where we used to generate
the following MSL:
metal::float4 _e13 = bar.matrix[3];
float b = _e13.x;
we now generate, simply:
float b = bar.matrix[3].x;
Propagate WGSL reference types correctly, so that parenthesizing expressions no
longer causes the Load Rule to be applied.
Together with #1332 (already landed), this is a replacement for #1312, and
unblocks #1352.
Fixes #1351.
193 lines
5.2 KiB
Plaintext
193 lines
5.2 KiB
Plaintext
; SPIR-V
|
|
; Version: 1.2
|
|
; Generator: rspirv
|
|
; Bound: 122
|
|
OpCapability Shader
|
|
OpExtension "SPV_KHR_storage_buffer_storage_class"
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %77 "fs_main" %69 %72 %75
|
|
OpExecutionMode %77 OriginUpperLeft
|
|
OpSource GLSL 450
|
|
OpName %9 "c_max_lights"
|
|
OpMemberName %14 0 "num_lights"
|
|
OpName %14 "Globals"
|
|
OpMemberName %17 0 "proj"
|
|
OpMemberName %17 1 "pos"
|
|
OpMemberName %17 2 "color"
|
|
OpName %17 "Light"
|
|
OpMemberName %19 0 "data"
|
|
OpName %19 "Lights"
|
|
OpName %24 "c_ambient"
|
|
OpName %25 "u_globals"
|
|
OpName %27 "s_lights"
|
|
OpName %29 "t_shadow"
|
|
OpName %31 "sampler_shadow"
|
|
OpName %36 "fetch_shadow"
|
|
OpName %64 "color"
|
|
OpName %66 "i"
|
|
OpName %69 "raw_normal"
|
|
OpName %72 "position"
|
|
OpName %77 "fs_main"
|
|
OpDecorate %14 Block
|
|
OpMemberDecorate %14 0 Offset 0
|
|
OpMemberDecorate %17 0 Offset 0
|
|
OpMemberDecorate %17 0 ColMajor
|
|
OpMemberDecorate %17 0 MatrixStride 16
|
|
OpMemberDecorate %17 1 Offset 64
|
|
OpMemberDecorate %17 2 Offset 80
|
|
OpDecorate %18 ArrayStride 96
|
|
OpDecorate %19 Block
|
|
OpMemberDecorate %19 0 Offset 0
|
|
OpDecorate %25 DescriptorSet 0
|
|
OpDecorate %25 Binding 0
|
|
OpDecorate %27 NonWritable
|
|
OpDecorate %27 DescriptorSet 0
|
|
OpDecorate %27 Binding 1
|
|
OpDecorate %29 DescriptorSet 0
|
|
OpDecorate %29 Binding 2
|
|
OpDecorate %31 DescriptorSet 0
|
|
OpDecorate %31 Binding 3
|
|
OpDecorate %69 Location 0
|
|
OpDecorate %72 Location 1
|
|
OpDecorate %75 Location 0
|
|
%2 = OpTypeVoid
|
|
%4 = OpTypeFloat 32
|
|
%3 = OpConstant %4 0.0
|
|
%5 = OpConstant %4 1.0
|
|
%6 = OpConstant %4 0.5
|
|
%7 = OpConstant %4 -0.5
|
|
%8 = OpConstant %4 0.05
|
|
%10 = OpTypeInt 32 0
|
|
%9 = OpConstant %10 10
|
|
%11 = OpConstant %10 0
|
|
%12 = OpConstant %10 1
|
|
%13 = OpTypeVector %10 4
|
|
%14 = OpTypeStruct %13
|
|
%16 = OpTypeVector %4 4
|
|
%15 = OpTypeMatrix %16 4
|
|
%17 = OpTypeStruct %15 %16 %16
|
|
%18 = OpTypeRuntimeArray %17
|
|
%19 = OpTypeStruct %18
|
|
%20 = OpTypeImage %4 2D 1 1 0 1 Unknown
|
|
%21 = OpTypeSampler
|
|
%22 = OpTypeVector %4 2
|
|
%23 = OpTypeVector %4 3
|
|
%24 = OpConstantComposite %23 %8 %8 %8
|
|
%26 = OpTypePointer Uniform %14
|
|
%25 = OpVariable %26 Uniform
|
|
%28 = OpTypePointer StorageBuffer %19
|
|
%27 = OpVariable %28 StorageBuffer
|
|
%30 = OpTypePointer UniformConstant %20
|
|
%29 = OpVariable %30 UniformConstant
|
|
%32 = OpTypePointer UniformConstant %21
|
|
%31 = OpVariable %32 UniformConstant
|
|
%37 = OpTypeFunction %4 %10 %16
|
|
%42 = OpTypeBool
|
|
%54 = OpTypeInt 32 1
|
|
%59 = OpTypeSampledImage %20
|
|
%65 = OpTypePointer Function %23
|
|
%67 = OpTypePointer Function %10
|
|
%70 = OpTypePointer Input %23
|
|
%69 = OpVariable %70 Input
|
|
%73 = OpTypePointer Input %16
|
|
%72 = OpVariable %73 Input
|
|
%76 = OpTypePointer Output %16
|
|
%75 = OpVariable %76 Output
|
|
%78 = OpTypeFunction %2
|
|
%88 = OpTypePointer Uniform %13
|
|
%89 = OpTypePointer Uniform %10
|
|
%96 = OpTypePointer StorageBuffer %18
|
|
%98 = OpTypePointer StorageBuffer %17
|
|
%36 = OpFunction %4 None %37
|
|
%34 = OpFunctionParameter %10
|
|
%35 = OpFunctionParameter %16
|
|
%33 = OpLabel
|
|
%38 = OpLoad %20 %29
|
|
%39 = OpLoad %21 %31
|
|
OpBranch %40
|
|
%40 = OpLabel
|
|
%41 = OpCompositeExtract %4 %35 3
|
|
%43 = OpFOrdLessThanEqual %42 %41 %3
|
|
OpSelectionMerge %44 None
|
|
OpBranchConditional %43 %45 %44
|
|
%45 = OpLabel
|
|
OpReturnValue %5
|
|
%44 = OpLabel
|
|
%46 = OpCompositeConstruct %22 %6 %7
|
|
%47 = OpVectorShuffle %22 %35 %35 0 1
|
|
%48 = OpFMul %22 %47 %46
|
|
%49 = OpCompositeExtract %4 %35 3
|
|
%50 = OpCompositeConstruct %22 %49 %49
|
|
%51 = OpFDiv %22 %48 %50
|
|
%52 = OpCompositeConstruct %22 %6 %6
|
|
%53 = OpFAdd %22 %51 %52
|
|
%55 = OpBitcast %54 %34
|
|
%56 = OpCompositeExtract %4 %35 2
|
|
%57 = OpCompositeExtract %4 %35 3
|
|
%58 = OpFDiv %4 %56 %57
|
|
%60 = OpConvertUToF %4 %55
|
|
%61 = OpCompositeConstruct %23 %53 %60
|
|
%62 = OpSampledImage %59 %38 %39
|
|
%63 = OpImageSampleDrefExplicitLod %4 %62 %61 %58 Lod %3
|
|
OpReturnValue %63
|
|
OpFunctionEnd
|
|
%77 = OpFunction %2 None %78
|
|
%68 = OpLabel
|
|
%64 = OpVariable %65 Function %24
|
|
%66 = OpVariable %67 Function %11
|
|
%71 = OpLoad %23 %69
|
|
%74 = OpLoad %16 %72
|
|
%79 = OpLoad %20 %29
|
|
%80 = OpLoad %21 %31
|
|
OpBranch %81
|
|
%81 = OpLabel
|
|
%82 = OpExtInst %23 %1 Normalize %71
|
|
OpBranch %83
|
|
%83 = OpLabel
|
|
OpLoopMerge %84 %86 None
|
|
OpBranch %85
|
|
%85 = OpLabel
|
|
%87 = OpLoad %10 %66
|
|
%90 = OpAccessChain %89 %25 %11 %11
|
|
%91 = OpLoad %10 %90
|
|
%92 = OpExtInst %10 %1 UMin %91 %9
|
|
%93 = OpUGreaterThanEqual %42 %87 %92
|
|
OpSelectionMerge %94 None
|
|
OpBranchConditional %93 %95 %94
|
|
%95 = OpLabel
|
|
OpBranch %84
|
|
%94 = OpLabel
|
|
%97 = OpLoad %10 %66
|
|
%99 = OpAccessChain %98 %27 %11 %97
|
|
%100 = OpLoad %17 %99
|
|
%101 = OpLoad %10 %66
|
|
%102 = OpCompositeExtract %15 %100 0
|
|
%103 = OpMatrixTimesVector %16 %102 %74
|
|
%104 = OpFunctionCall %4 %36 %101 %103
|
|
%105 = OpCompositeExtract %16 %100 1
|
|
%106 = OpVectorShuffle %23 %105 %105 0 1 2
|
|
%107 = OpVectorShuffle %23 %74 %74 0 1 2
|
|
%108 = OpFSub %23 %106 %107
|
|
%109 = OpExtInst %23 %1 Normalize %108
|
|
%110 = OpDot %4 %82 %109
|
|
%111 = OpExtInst %4 %1 FMax %3 %110
|
|
%112 = OpLoad %23 %64
|
|
%113 = OpFMul %4 %104 %111
|
|
%114 = OpCompositeExtract %16 %100 2
|
|
%115 = OpVectorShuffle %23 %114 %114 0 1 2
|
|
%116 = OpVectorTimesScalar %23 %115 %113
|
|
%117 = OpFAdd %23 %112 %116
|
|
OpStore %64 %117
|
|
OpBranch %86
|
|
%86 = OpLabel
|
|
%118 = OpLoad %10 %66
|
|
%119 = OpIAdd %10 %118 %12
|
|
OpStore %66 %119
|
|
OpBranch %83
|
|
%84 = OpLabel
|
|
%120 = OpLoad %23 %64
|
|
%121 = OpCompositeConstruct %16 %120 %5
|
|
OpStore %75 %121
|
|
OpReturn
|
|
OpFunctionEnd |