mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
166 lines
4.1 KiB
Plaintext
166 lines
4.1 KiB
Plaintext
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: rspirv
|
|
; Bound: 65
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Vertex %25 "vert_main" %16 %19 %21 %23
|
|
OpEntryPoint Fragment %45 "frag_main" %42 %44
|
|
OpEntryPoint Fragment %61 "fs_extra" %60
|
|
OpExecutionMode %45 OriginUpperLeft
|
|
OpExecutionMode %61 OriginUpperLeft
|
|
%3 = OpString "quad.wgsl"
|
|
OpSource Unknown 0 %3 "// vertex
|
|
const c_scale: f32 = 1.2;
|
|
|
|
struct VertexOutput {
|
|
@location(0) uv : vec2<f32>,
|
|
@builtin(position) position : vec4<f32>,
|
|
}
|
|
|
|
@vertex
|
|
fn vert_main(
|
|
@location(0) pos : vec2<f32>,
|
|
@location(1) uv : vec2<f32>,
|
|
) -> VertexOutput {
|
|
return VertexOutput(uv, vec4<f32>(c_scale * pos, 0.0, 1.0));
|
|
}
|
|
|
|
// fragment
|
|
@group(0) @binding(0) var u_texture : texture_2d<f32>;
|
|
@group(0) @binding(1) var u_sampler : sampler;
|
|
|
|
@fragment
|
|
fn frag_main(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
|
|
let color = textureSample(u_texture, u_sampler, uv);
|
|
if color.a == 0.0 {
|
|
discard;
|
|
}
|
|
// forcing the expression here to be emitted in order to check the
|
|
// uniformity of the control flow a bit more strongly.
|
|
let premultiplied = color.a * color;
|
|
return premultiplied;
|
|
}
|
|
|
|
|
|
// We need to make sure that backends are successfully handling multiple entry points for the same shader stage.
|
|
@fragment
|
|
fn fs_extra() -> @location(0) vec4<f32> {
|
|
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
|
|
}
|
|
"
|
|
OpMemberName %7 0 "uv"
|
|
OpMemberName %7 1 "position"
|
|
OpName %7 "VertexOutput"
|
|
OpName %10 "c_scale"
|
|
OpName %11 "u_texture"
|
|
OpName %13 "u_sampler"
|
|
OpName %16 "pos"
|
|
OpName %19 "uv"
|
|
OpName %21 "uv"
|
|
OpName %23 "position"
|
|
OpName %25 "vert_main"
|
|
OpName %42 "uv"
|
|
OpName %45 "frag_main"
|
|
OpName %61 "fs_extra"
|
|
OpMemberDecorate %7 0 Offset 0
|
|
OpMemberDecorate %7 1 Offset 16
|
|
OpDecorate %11 DescriptorSet 0
|
|
OpDecorate %11 Binding 0
|
|
OpDecorate %13 DescriptorSet 0
|
|
OpDecorate %13 Binding 1
|
|
OpDecorate %16 Location 0
|
|
OpDecorate %19 Location 1
|
|
OpDecorate %21 Location 0
|
|
OpDecorate %23 BuiltIn Position
|
|
OpDecorate %42 Location 0
|
|
OpDecorate %44 Location 0
|
|
OpDecorate %60 Location 0
|
|
%2 = OpTypeVoid
|
|
%4 = OpTypeFloat 32
|
|
%5 = OpTypeVector %4 2
|
|
%6 = OpTypeVector %4 4
|
|
%7 = OpTypeStruct %5 %6
|
|
%8 = OpTypeImage %4 2D 0 0 0 1 Unknown
|
|
%9 = OpTypeSampler
|
|
%10 = OpConstant %4 1.2
|
|
%12 = OpTypePointer UniformConstant %8
|
|
%11 = OpVariable %12 UniformConstant
|
|
%14 = OpTypePointer UniformConstant %9
|
|
%13 = OpVariable %14 UniformConstant
|
|
%17 = OpTypePointer Input %5
|
|
%16 = OpVariable %17 Input
|
|
%19 = OpVariable %17 Input
|
|
%22 = OpTypePointer Output %5
|
|
%21 = OpVariable %22 Output
|
|
%24 = OpTypePointer Output %6
|
|
%23 = OpVariable %24 Output
|
|
%26 = OpTypeFunction %2
|
|
%27 = OpConstant %4 0.0
|
|
%28 = OpConstant %4 1.0
|
|
%35 = OpTypePointer Output %4
|
|
%37 = OpTypeInt 32 0
|
|
%36 = OpConstant %37 1
|
|
%42 = OpVariable %17 Input
|
|
%44 = OpVariable %24 Output
|
|
%49 = OpTypeSampledImage %8
|
|
%53 = OpTypeBool
|
|
%60 = OpVariable %24 Output
|
|
%62 = OpConstant %4 0.5
|
|
%63 = OpConstantComposite %6 %27 %62 %27 %62
|
|
%25 = OpFunction %2 None %26
|
|
%15 = OpLabel
|
|
%18 = OpLoad %5 %16
|
|
%20 = OpLoad %5 %19
|
|
OpBranch %29
|
|
%29 = OpLabel
|
|
OpLine %3 14 37
|
|
%30 = OpVectorTimesScalar %5 %18 %10
|
|
OpLine %3 14 10
|
|
%31 = OpCompositeConstruct %6 %30 %27 %28
|
|
%32 = OpCompositeConstruct %7 %20 %31
|
|
%33 = OpCompositeExtract %5 %32 0
|
|
OpStore %21 %33
|
|
%34 = OpCompositeExtract %6 %32 1
|
|
OpStore %23 %34
|
|
%38 = OpAccessChain %35 %23 %36
|
|
%39 = OpLoad %4 %38
|
|
%40 = OpFNegate %4 %39
|
|
OpStore %38 %40
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%45 = OpFunction %2 None %26
|
|
%41 = OpLabel
|
|
%43 = OpLoad %5 %42
|
|
%46 = OpLoad %8 %11
|
|
%47 = OpLoad %9 %13
|
|
OpBranch %48
|
|
%48 = OpLabel
|
|
OpLine %3 23 15
|
|
%50 = OpSampledImage %49 %46 %47
|
|
%51 = OpImageSampleImplicitLod %6 %50 %43
|
|
OpLine %3 24 6
|
|
%52 = OpCompositeExtract %4 %51 3
|
|
OpLine %3 24 6
|
|
%54 = OpFOrdEqual %53 %52 %27
|
|
OpLine %3 24 3
|
|
OpSelectionMerge %55 None
|
|
OpBranchConditional %54 %56 %55
|
|
%56 = OpLabel
|
|
OpKill
|
|
%55 = OpLabel
|
|
OpLine %3 29 23
|
|
%57 = OpCompositeExtract %4 %51 3
|
|
%58 = OpVectorTimesScalar %6 %51 %57
|
|
OpStore %44 %58
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%61 = OpFunction %2 None %26
|
|
%59 = OpLabel
|
|
OpBranch %64
|
|
%64 = OpLabel
|
|
OpLine %3 37 12
|
|
OpStore %60 %63
|
|
OpReturn
|
|
OpFunctionEnd |