From b9c5cb5a7841a8728137a58840fbbdbb9b310267 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 12 Apr 2023 16:48:57 +0200 Subject: [PATCH] validate vertex stage returns the position built-in --- src/valid/interface.rs | 14 +- tests/in/functions-webgl.wgsl | 2 +- .../{277-casting.vert => 277-casting.frag} | 0 ...-matrix-cast.vert => 280-matrix-cast.frag} | 0 ...essor-if.vert => 484-preprocessor-if.frag} | 0 ...h-constant.vert => 896-push-constant.frag} | 0 ...ons.vert => 900-implicit-conversions.frag} | 0 ...-select.vert => 901-lhs-field-select.frag} | 0 ...itting.vert => 931-constant-emitting.frag} | 0 ...-for-loop-if.vert => 932-for-loop-if.frag} | 0 ...ray-size.vert => constant-array-size.frag} | 0 .../{declarations.vert => declarations.frag} | 0 ...-array.vert => global-constant-array.frag} | 0 ...form-matrix.vert => long-form-matrix.frag} | 0 ...ath-functions.vert => math-functions.frag} | 0 ...r-functions.vert => vector-functions.frag} | 0 tests/in/math-functions.wgsl | 2 +- tests/in/multiview.wgsl | 2 +- tests/in/multiview_webgl.wgsl | 2 +- tests/in/spv/degrees.spv | Bin 676 -> 676 bytes tests/in/spv/degrees.spvasm | 47 +++ .../in/spv/inv-hyperbolic-trig-functions.spv | Bin 480 -> 480 bytes .../spv/inv-hyperbolic-trig-functions.spvasm | 37 +++ tests/in/spv/quad-vert.spvasm | 61 ++++ tests/in/spv/shadow.spvasm | 291 ++++++++++++++++++ ...lsl => functions-webgl.main.Fragment.glsl} | 0 ...glsl => math-functions.main.Fragment.glsl} | 0 ...rtex.glsl => multiview.main.Fragment.glsl} | 1 - ...lsl => multiview_webgl.main.Fragment.glsl} | 2 - .../inv-hyperbolic-trig-functions.hlsl.config | 4 +- tests/out/hlsl/math-functions.hlsl.config | 4 +- tests/out/msl/math-functions.msl | 2 +- tests/out/spv/math-functions.spvasm | 3 +- tests/out/spv/multiview.spvasm | 4 +- ...asting-vert.wgsl => 277-casting-frag.wgsl} | 2 +- ...st-vert.wgsl => 280-matrix-cast-frag.wgsl} | 2 +- ...ert.wgsl => 484-preprocessor-if-frag.wgsl} | 2 +- ...-vert.wgsl => 896-push-constant-frag.wgsl} | 2 +- ...gsl => 900-implicit-conversions-frag.wgsl} | 2 +- ...rt.wgsl => 901-lhs-field-select-frag.wgsl} | 2 +- ...t.wgsl => 931-constant-emitting-frag.wgsl} | 2 +- ...if-vert.wgsl => 932-for-loop-if-frag.wgsl} | 2 +- tests/out/wgsl/binop-frag.wgsl | 187 ----------- ...ert.wgsl => constant-array-size-frag.wgsl} | 2 +- ...tions-vert.wgsl => declarations-frag.wgsl} | 8 +- ...t.wgsl => global-constant-array-frag.wgsl} | 2 +- .../wgsl/inv-hyperbolic-trig-functions.wgsl | 2 +- ...x-vert.wgsl => long-form-matrix-frag.wgsl} | 2 +- ...ons-vert.wgsl => math-functions-frag.wgsl} | 2 +- tests/out/wgsl/math-functions.wgsl | 2 +- tests/out/wgsl/multiview.wgsl | 2 +- ...s-vert.wgsl => vector-functions-frag.wgsl} | 2 +- tests/snapshots.rs | 3 +- tests/wgsl-errors.rs | 66 +++- 54 files changed, 535 insertions(+), 239 deletions(-) rename tests/in/glsl/{277-casting.vert => 277-casting.frag} (100%) rename tests/in/glsl/{280-matrix-cast.vert => 280-matrix-cast.frag} (100%) rename tests/in/glsl/{484-preprocessor-if.vert => 484-preprocessor-if.frag} (100%) rename tests/in/glsl/{896-push-constant.vert => 896-push-constant.frag} (100%) rename tests/in/glsl/{900-implicit-conversions.vert => 900-implicit-conversions.frag} (100%) rename tests/in/glsl/{901-lhs-field-select.vert => 901-lhs-field-select.frag} (100%) rename tests/in/glsl/{931-constant-emitting.vert => 931-constant-emitting.frag} (100%) rename tests/in/glsl/{932-for-loop-if.vert => 932-for-loop-if.frag} (100%) rename tests/in/glsl/{constant-array-size.vert => constant-array-size.frag} (100%) rename tests/in/glsl/{declarations.vert => declarations.frag} (100%) rename tests/in/glsl/{global-constant-array.vert => global-constant-array.frag} (100%) rename tests/in/glsl/{long-form-matrix.vert => long-form-matrix.frag} (100%) rename tests/in/glsl/{math-functions.vert => math-functions.frag} (100%) rename tests/in/glsl/{vector-functions.vert => vector-functions.frag} (100%) create mode 100644 tests/in/spv/degrees.spvasm create mode 100644 tests/in/spv/inv-hyperbolic-trig-functions.spvasm create mode 100644 tests/in/spv/quad-vert.spvasm create mode 100644 tests/in/spv/shadow.spvasm rename tests/out/glsl/{functions-webgl.main.Vertex.glsl => functions-webgl.main.Fragment.glsl} (100%) rename tests/out/glsl/{math-functions.main.Vertex.glsl => math-functions.main.Fragment.glsl} (100%) rename tests/out/glsl/{multiview.main.Vertex.glsl => multiview.main.Fragment.glsl} (67%) rename tests/out/glsl/{multiview_webgl.main.Vertex.glsl => multiview_webgl.main.Fragment.glsl} (86%) rename tests/out/wgsl/{277-casting-vert.wgsl => 277-casting-frag.wgsl} (90%) rename tests/out/wgsl/{280-matrix-cast-vert.wgsl => 280-matrix-cast-frag.wgsl} (95%) rename tests/out/wgsl/{484-preprocessor-if-vert.wgsl => 484-preprocessor-if-frag.wgsl} (86%) rename tests/out/wgsl/{896-push-constant-vert.wgsl => 896-push-constant-frag.wgsl} (93%) rename tests/out/wgsl/{900-implicit-conversions-vert.wgsl => 900-implicit-conversions-frag.wgsl} (98%) rename tests/out/wgsl/{901-lhs-field-select-vert.wgsl => 901-lhs-field-select-frag.wgsl} (92%) rename tests/out/wgsl/{931-constant-emitting-vert.wgsl => 931-constant-emitting-frag.wgsl} (92%) rename tests/out/wgsl/{932-for-loop-if-vert.wgsl => 932-for-loop-if-frag.wgsl} (96%) delete mode 100644 tests/out/wgsl/binop-frag.wgsl rename tests/out/wgsl/{constant-array-size-vert.wgsl => constant-array-size-frag.wgsl} (98%) rename tests/out/wgsl/{declarations-vert.wgsl => declarations-frag.wgsl} (93%) rename tests/out/wgsl/{global-constant-array-vert.wgsl => global-constant-array-frag.wgsl} (95%) rename tests/out/wgsl/{long-form-matrix-vert.wgsl => long-form-matrix-frag.wgsl} (99%) rename tests/out/wgsl/{math-functions-vert.wgsl => math-functions-frag.wgsl} (99%) rename tests/out/wgsl/{vector-functions-vert.wgsl => vector-functions-frag.wgsl} (99%) diff --git a/src/valid/interface.rs b/src/valid/interface.rs index d9ee9f5402..268490c52e 100644 --- a/src/valid/interface.rs +++ b/src/valid/interface.rs @@ -63,6 +63,8 @@ pub enum VaryingError { pub enum EntryPointError { #[error("Multiple conflicting entry points")] Conflict, + #[error("Vertex shaders must return a `@builtin(position)` output value")] + MissingVertexOutputPosition, #[error("Early depth test is not applicable")] UnexpectedEarlyDepthTest, #[error("Workgroup size is not applicable")] @@ -353,7 +355,6 @@ impl VaryingContext<'_> { .map_err(|e| e.with_span_context(span_context)), None => { match self.types[ty].inner { - //TODO: check the member types crate::TypeInner::Struct { ref members, .. } => { for (index, member) in members.iter().enumerate() { let span_context = self.types.get_span_context(ty); @@ -369,7 +370,6 @@ impl VaryingContext<'_> { #[cfg(not(feature = "validate"))] let _ = index; } - // TODO: shouldn't this be validate? Some(ref binding) => self .validate_impl(member.ty, binding) .map_err(|e| e.with_span_context(span_context))?, @@ -603,6 +603,16 @@ impl super::Validator { }; ctx.validate(fr.ty, fr.binding.as_ref()) .map_err_inner(|e| EntryPointError::Result(e).with_span())?; + + #[cfg(feature = "validate")] + if ep.stage == crate::ShaderStage::Vertex + && !result_built_ins.contains(&crate::BuiltIn::Position { invariant: false }) + { + return Err(EntryPointError::MissingVertexOutputPosition.with_span()); + } + } else if ep.stage == crate::ShaderStage::Vertex { + #[cfg(feature = "validate")] + return Err(EntryPointError::MissingVertexOutputPosition.with_span()); } for bg in self.bind_group_masks.iter_mut() { diff --git a/tests/in/functions-webgl.wgsl b/tests/in/functions-webgl.wgsl index 9192f68685..2355aa2c99 100644 --- a/tests/in/functions-webgl.wgsl +++ b/tests/in/functions-webgl.wgsl @@ -7,7 +7,7 @@ fn test_fma() -> vec2 { } -@vertex +@fragment fn main() { let a = test_fma(); } diff --git a/tests/in/glsl/277-casting.vert b/tests/in/glsl/277-casting.frag similarity index 100% rename from tests/in/glsl/277-casting.vert rename to tests/in/glsl/277-casting.frag diff --git a/tests/in/glsl/280-matrix-cast.vert b/tests/in/glsl/280-matrix-cast.frag similarity index 100% rename from tests/in/glsl/280-matrix-cast.vert rename to tests/in/glsl/280-matrix-cast.frag diff --git a/tests/in/glsl/484-preprocessor-if.vert b/tests/in/glsl/484-preprocessor-if.frag similarity index 100% rename from tests/in/glsl/484-preprocessor-if.vert rename to tests/in/glsl/484-preprocessor-if.frag diff --git a/tests/in/glsl/896-push-constant.vert b/tests/in/glsl/896-push-constant.frag similarity index 100% rename from tests/in/glsl/896-push-constant.vert rename to tests/in/glsl/896-push-constant.frag diff --git a/tests/in/glsl/900-implicit-conversions.vert b/tests/in/glsl/900-implicit-conversions.frag similarity index 100% rename from tests/in/glsl/900-implicit-conversions.vert rename to tests/in/glsl/900-implicit-conversions.frag diff --git a/tests/in/glsl/901-lhs-field-select.vert b/tests/in/glsl/901-lhs-field-select.frag similarity index 100% rename from tests/in/glsl/901-lhs-field-select.vert rename to tests/in/glsl/901-lhs-field-select.frag diff --git a/tests/in/glsl/931-constant-emitting.vert b/tests/in/glsl/931-constant-emitting.frag similarity index 100% rename from tests/in/glsl/931-constant-emitting.vert rename to tests/in/glsl/931-constant-emitting.frag diff --git a/tests/in/glsl/932-for-loop-if.vert b/tests/in/glsl/932-for-loop-if.frag similarity index 100% rename from tests/in/glsl/932-for-loop-if.vert rename to tests/in/glsl/932-for-loop-if.frag diff --git a/tests/in/glsl/constant-array-size.vert b/tests/in/glsl/constant-array-size.frag similarity index 100% rename from tests/in/glsl/constant-array-size.vert rename to tests/in/glsl/constant-array-size.frag diff --git a/tests/in/glsl/declarations.vert b/tests/in/glsl/declarations.frag similarity index 100% rename from tests/in/glsl/declarations.vert rename to tests/in/glsl/declarations.frag diff --git a/tests/in/glsl/global-constant-array.vert b/tests/in/glsl/global-constant-array.frag similarity index 100% rename from tests/in/glsl/global-constant-array.vert rename to tests/in/glsl/global-constant-array.frag diff --git a/tests/in/glsl/long-form-matrix.vert b/tests/in/glsl/long-form-matrix.frag similarity index 100% rename from tests/in/glsl/long-form-matrix.vert rename to tests/in/glsl/long-form-matrix.frag diff --git a/tests/in/glsl/math-functions.vert b/tests/in/glsl/math-functions.frag similarity index 100% rename from tests/in/glsl/math-functions.vert rename to tests/in/glsl/math-functions.frag diff --git a/tests/in/glsl/vector-functions.vert b/tests/in/glsl/vector-functions.frag similarity index 100% rename from tests/in/glsl/vector-functions.vert rename to tests/in/glsl/vector-functions.frag diff --git a/tests/in/math-functions.wgsl b/tests/in/math-functions.wgsl index db50880d14..da67ca23e0 100644 --- a/tests/in/math-functions.wgsl +++ b/tests/in/math-functions.wgsl @@ -1,4 +1,4 @@ -@vertex +@fragment fn main() { let f = 1.0; let v = vec4(0.0); diff --git a/tests/in/multiview.wgsl b/tests/in/multiview.wgsl index b4531c8a76..0eedd08786 100644 --- a/tests/in/multiview.wgsl +++ b/tests/in/multiview.wgsl @@ -1,2 +1,2 @@ -@vertex +@fragment fn main(@builtin(view_index) view_index: i32) {} diff --git a/tests/in/multiview_webgl.wgsl b/tests/in/multiview_webgl.wgsl index b4531c8a76..0eedd08786 100644 --- a/tests/in/multiview_webgl.wgsl +++ b/tests/in/multiview_webgl.wgsl @@ -1,2 +1,2 @@ -@vertex +@fragment fn main(@builtin(view_index) view_index: i32) {} diff --git a/tests/in/spv/degrees.spv b/tests/in/spv/degrees.spv index 0e5eeab4801959135ed79998e86f119fe85e56dc..b7aa393c0718857ef1208f33562be45711a18f21 100644 GIT binary patch delta 12 TcmZ3&x`cIt3nR-$*LWrX8Bqg+ delta 12 TcmZ3&x`cIt3nRlu*LWrX89f7k diff --git a/tests/in/spv/degrees.spvasm b/tests/in/spv/degrees.spvasm new file mode 100644 index 0000000000..de2605a517 --- /dev/null +++ b/tests/in/spv/degrees.spvasm @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 27 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %colour + OpSource GLSL 450 + OpName %main "main" + OpName %deg "deg" + OpName %rad "rad" + OpName %deg_again "deg_again" + OpName %colour "colour" + OpDecorate %colour Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %float_15 = OpConstant %float 15 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %colour = OpVariable %_ptr_Output_v4float Output + %v3float = OpTypeVector %float 3 + %float_1 = OpConstant %float 1 + %main = OpFunction %void None %3 + %5 = OpLabel + %deg = OpVariable %_ptr_Function_float Function + %rad = OpVariable %_ptr_Function_float Function + %deg_again = OpVariable %_ptr_Function_float Function + OpStore %deg %float_15 + %11 = OpLoad %float %deg + %12 = OpExtInst %float %1 Radians %11 + OpStore %rad %12 + %14 = OpLoad %float %rad + %15 = OpExtInst %float %1 Degrees %14 + OpStore %deg_again %15 + %19 = OpLoad %float %deg_again + %21 = OpCompositeConstruct %v3float %19 %19 %19 + %23 = OpCompositeExtract %float %21 0 + %24 = OpCompositeExtract %float %21 1 + %25 = OpCompositeExtract %float %21 2 + %26 = OpCompositeConstruct %v4float %23 %24 %25 %float_1 + OpStore %colour %26 + OpReturn + OpFunctionEnd diff --git a/tests/in/spv/inv-hyperbolic-trig-functions.spv b/tests/in/spv/inv-hyperbolic-trig-functions.spv index a87d8deec536a7f8691a77be664e6f194e751217..da365355e8651a576c503a55132b726766f9715e 100644 GIT binary patch delta 12 TcmaFB{D66a3nR-$*V&8!9>@eT delta 12 TcmaFB{D66a3nRlu*V&8!9<&55 diff --git a/tests/in/spv/inv-hyperbolic-trig-functions.spvasm b/tests/in/spv/inv-hyperbolic-trig-functions.spvasm new file mode 100644 index 0000000000..efa9620893 --- /dev/null +++ b/tests/in/spv/inv-hyperbolic-trig-functions.spvasm @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 19 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpSource GLSL 450 + OpName %main "main" + OpName %b "b" + OpName %a "a" + OpName %c "c" + OpName %d "d" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Private_float = OpTypePointer Private %float + %a = OpVariable %_ptr_Private_float Private + %main = OpFunction %void None %3 + %5 = OpLabel + %b = OpVariable %_ptr_Function_float Function + %c = OpVariable %_ptr_Function_float Function + %d = OpVariable %_ptr_Function_float Function + %11 = OpLoad %float %a + %12 = OpExtInst %float %1 Asinh %11 + OpStore %b %12 + %14 = OpLoad %float %a + %15 = OpExtInst %float %1 Acosh %14 + OpStore %c %15 + %17 = OpLoad %float %a + %18 = OpExtInst %float %1 Atanh %17 + OpStore %d %18 + OpReturn + OpFunctionEnd diff --git a/tests/in/spv/quad-vert.spvasm b/tests/in/spv/quad-vert.spvasm new file mode 100644 index 0000000000..7633c94c59 --- /dev/null +++ b/tests/in/spv/quad-vert.spvasm @@ -0,0 +1,61 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 31 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %v_uv %a_uv %_ %a_pos + OpSource GLSL 460 + OpName %main "main" + OpName %v_uv "v_uv" + OpName %a_uv "a_uv" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpName %a_pos "a_pos" + OpDecorate %v_uv Location 0 + OpDecorate %a_uv Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %a_pos Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%_ptr_Output_v2float = OpTypePointer Output %v2float + %v_uv = OpVariable %_ptr_Output_v2float Output +%_ptr_Input_v2float = OpTypePointer Input %v2float + %a_uv = OpVariable %_ptr_Input_v2float Input + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %a_pos = OpVariable %_ptr_Input_v2float Input + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %12 = OpLoad %v2float %a_uv + OpStore %v_uv %12 + %23 = OpLoad %v2float %a_pos + %26 = OpCompositeExtract %float %23 0 + %27 = OpCompositeExtract %float %23 1 + %28 = OpCompositeConstruct %v4float %26 %27 %float_0 %float_1 + %30 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %30 %28 + OpReturn + OpFunctionEnd diff --git a/tests/in/spv/shadow.spvasm b/tests/in/spv/shadow.spvasm new file mode 100644 index 0000000000..e928b71c40 --- /dev/null +++ b/tests/in/spv/shadow.spvasm @@ -0,0 +1,291 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 221 +; Schema: 0 + OpCapability Shader + OpExtension "SPV_KHR_storage_buffer_storage_class" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fs_main "fs_main" %in_normal_fs %in_position_fs %out_color_fs + OpExecutionMode %fs_main OriginUpperLeft + OpSource GLSL 450 + OpName %t_shadow "t_shadow" + OpName %sampler_shadow "sampler_shadow" + OpName %color "color" + OpName %i "i" + OpName %Globals "Globals" + OpMemberName %Globals 0 "num_lights" + OpName %u_globals "u_globals" + OpName %Light "Light" + OpMemberName %Light 0 "proj" + OpMemberName %Light 1 "pos" + OpMemberName %Light 2 "color" + OpName %Lights "Lights" + OpMemberName %Lights 0 "data" + OpName %s_lights "s_lights" + OpName %in_position_fs "in_position_fs" + OpName %in_normal_fs "in_normal_fs" + OpName %out_color_fs "out_color_fs" + OpName %fs_main "fs_main" + OpDecorate %t_shadow DescriptorSet 0 + OpDecorate %t_shadow Binding 2 + OpDecorate %sampler_shadow DescriptorSet 0 + OpDecorate %sampler_shadow Binding 3 + OpDecorate %Globals Block + OpMemberDecorate %Globals 0 Offset 0 + OpDecorate %u_globals DescriptorSet 0 + OpDecorate %u_globals Binding 0 + OpMemberDecorate %Light 0 Offset 0 + OpMemberDecorate %Light 0 ColMajor + OpMemberDecorate %Light 0 MatrixStride 16 + OpMemberDecorate %Light 1 Offset 64 + OpMemberDecorate %Light 2 Offset 80 + OpDecorate %_runtimearr_Light ArrayStride 96 + OpDecorate %Lights BufferBlock + OpMemberDecorate %Lights 0 Offset 0 + OpMemberDecorate %Lights 0 NonWritable + OpDecorate %s_lights DescriptorSet 0 + OpDecorate %s_lights Binding 1 + OpDecorate %in_position_fs Location 1 + OpDecorate %in_normal_fs Location 0 + OpDecorate %out_color_fs Location 0 + %void = OpTypeVoid + %float = OpTypeFloat 32 + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %float_0_5 = OpConstant %float 0.5 + %float_n0_5 = OpConstant %float -0.5 +%float_0_0500000007 = OpConstant %float 0.0500000007 + %v3float = OpTypeVector %float 3 + %9 = OpConstantComposite %v3float %float_0_0500000007 %float_0_0500000007 %float_0_0500000007 + %uint = OpTypeInt 32 0 + %uint_10 = OpConstant %uint 10 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %v4float = OpTypeVector %float 4 + %19 = OpTypeFunction %float %uint %v4float + %bool = OpTypeBool + %27 = OpTypeImage %float 2D 1 1 0 1 Unknown +%_ptr_UniformConstant_27 = OpTypePointer UniformConstant %27 + %t_shadow = OpVariable %_ptr_UniformConstant_27 UniformConstant + %31 = OpTypeSampledImage %27 + %32 = OpTypeSampler +%_ptr_UniformConstant_32 = OpTypePointer UniformConstant %32 +%sampler_shadow = OpVariable %_ptr_UniformConstant_32 UniformConstant + %v2float = OpTypeVector %float 2 + %int = OpTypeInt 32 1 + %float_0_0 = OpConstant %float 0 +%_ptr_Function_v3float = OpTypePointer Function %v3float +%_ptr_Function_uint = OpTypePointer Function %uint + %65 = OpTypeFunction %void + %v4uint = OpTypeVector %uint 4 + %Globals = OpTypeStruct %v4uint +%_ptr_Uniform_Globals = OpTypePointer Uniform %Globals + %u_globals = OpVariable %_ptr_Uniform_Globals Uniform +%_ptr_Uniform_v4uint = OpTypePointer Uniform %v4uint + %int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint + %int_0_0 = OpConstant %int 0 +%mat4v4float = OpTypeMatrix %v4float 4 + %Light = OpTypeStruct %mat4v4float %v4float %v4float +%_runtimearr_Light = OpTypeRuntimeArray %Light + %Lights = OpTypeStruct %_runtimearr_Light +%_ptr_StorageBuffer_Lights = OpTypePointer StorageBuffer %Lights + %s_lights = OpVariable %_ptr_StorageBuffer_Lights StorageBuffer +%_ptr_StorageBuffer__runtimearr_Light = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_1 = OpConstant %int 0 +%_ptr_StorageBuffer_Light = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_mat4v4float = OpTypePointer StorageBuffer %mat4v4float + %int_0_2 = OpConstant %int 0 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%in_position_fs = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_v3float = OpTypePointer Input %v3float +%in_normal_fs = OpVariable %_ptr_Input_v3float Input +%_ptr_StorageBuffer__runtimearr_Light_0 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_3 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_0 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float + %int_0_4 = OpConstant %int 0 +%_ptr_StorageBuffer__runtimearr_Light_1 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_5 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_1 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float_0 = OpTypePointer StorageBuffer %v4float + %int_1_0 = OpConstant %int 1 +%_ptr_StorageBuffer_float_0 = OpTypePointer StorageBuffer %float + %int_1_1 = OpConstant %int 1 +%_ptr_StorageBuffer__runtimearr_Light_2 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_6 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_2 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float_1 = OpTypePointer StorageBuffer %v4float + %int_1_2 = OpConstant %int 1 +%_ptr_StorageBuffer_float_1 = OpTypePointer StorageBuffer %float + %int_2 = OpConstant %int 2 +%_ptr_Input_float = OpTypePointer Input %float + %int_0_7 = OpConstant %int 0 +%_ptr_Input_float_0 = OpTypePointer Input %float + %int_1_3 = OpConstant %int 1 +%_ptr_Input_float_1 = OpTypePointer Input %float + %int_2_0 = OpConstant %int 2 +%_ptr_StorageBuffer__runtimearr_Light_3 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_8 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_3 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float_2 = OpTypePointer StorageBuffer %v4float + %int_2_1 = OpConstant %int 2 +%_ptr_StorageBuffer_float_2 = OpTypePointer StorageBuffer %float + %int_0_9 = OpConstant %int 0 +%_ptr_StorageBuffer__runtimearr_Light_4 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_10 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_4 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float_3 = OpTypePointer StorageBuffer %v4float + %int_2_2 = OpConstant %int 2 +%_ptr_StorageBuffer_float_3 = OpTypePointer StorageBuffer %float + %int_1_4 = OpConstant %int 1 +%_ptr_StorageBuffer__runtimearr_Light_5 = OpTypePointer StorageBuffer %_runtimearr_Light + %int_0_11 = OpConstant %int 0 +%_ptr_StorageBuffer_Light_5 = OpTypePointer StorageBuffer %Light +%_ptr_StorageBuffer_v4float_4 = OpTypePointer StorageBuffer %v4float + %int_2_3 = OpConstant %int 2 +%_ptr_StorageBuffer_float_4 = OpTypePointer StorageBuffer %float + %int_2_4 = OpConstant %int 2 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%out_color_fs = OpVariable %_ptr_Output_v4float Output + %18 = OpFunction %float None %19 + %15 = OpFunctionParameter %uint + %16 = OpFunctionParameter %v4float + %20 = OpLabel + %23 = OpCompositeExtract %float %16 3 + %22 = OpFOrdLessThanEqual %bool %23 %float_0 + OpSelectionMerge %24 None + OpBranchConditional %22 %25 %26 + %25 = OpLabel + OpReturnValue %float_1 + %26 = OpLabel + OpBranch %24 + %24 = OpLabel + %30 = OpLoad %27 %t_shadow + %35 = OpLoad %32 %sampler_shadow + %40 = OpCompositeExtract %float %16 0 + %41 = OpCompositeExtract %float %16 1 + %42 = OpCompositeConstruct %v2float %40 %41 + %43 = OpCompositeConstruct %v2float %float_0_5 %float_n0_5 + %39 = OpFMul %v2float %42 %43 + %45 = OpCompositeExtract %float %16 3 + %44 = OpFDiv %float %float_1 %45 + %38 = OpVectorTimesScalar %v2float %39 %44 + %46 = OpCompositeConstruct %v2float %float_0_5 %float_0_5 + %37 = OpFAdd %v2float %38 %46 + %47 = OpCompositeExtract %float %37 0 + %48 = OpCompositeExtract %float %37 1 + %51 = OpBitcast %int %15 + %49 = OpConvertUToF %float %51 + %52 = OpCompositeConstruct %v3float %47 %48 %49 + %53 = OpSampledImage %31 %30 %35 + %56 = OpCompositeExtract %float %16 2 + %58 = OpCompositeExtract %float %16 3 + %57 = OpFDiv %float %float_1 %58 + %55 = OpFMul %float %56 %57 + %54 = OpImageSampleDrefExplicitLod %float %53 %52 %55 Lod %float_0_0 + OpReturnValue %54 + OpFunctionEnd + %fs_main = OpFunction %void None %65 + %66 = OpLabel + %color = OpVariable %_ptr_Function_v3float Function %9 + %i = OpVariable %_ptr_Function_uint Function %uint_0 + OpBranch %67 + %67 = OpLabel + OpLoopMerge %68 %70 None + OpBranch %69 + %69 = OpLabel + %72 = OpLoad %uint %i + %75 = OpAccessChain %_ptr_Uniform_v4uint %u_globals %int_0 + %73 = OpAccessChain %_ptr_Uniform_uint %75 %int_0_0 + %83 = OpLoad %uint %73 + %84 = OpExtInst %uint %1 UMin %83 %uint_10 + %71 = OpUGreaterThanEqual %bool %72 %84 + OpSelectionMerge %85 None + OpBranchConditional %71 %86 %87 + %86 = OpLabel + OpBranch %68 + %87 = OpLabel + OpBranch %85 + %85 = OpLabel + %89 = OpLoad %v3float %color + %93 = OpLoad %uint %i + %100 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light %s_lights %int_0_1 + %106 = OpLoad %uint %i + %98 = OpAccessChain %_ptr_StorageBuffer_Light %100 %106 + %96 = OpAccessChain %_ptr_StorageBuffer_mat4v4float %98 %int_0_2 + %110 = OpLoad %mat4v4float %96 + %113 = OpLoad %v4float %in_position_fs + %94 = OpMatrixTimesVector %v4float %110 %113 + %92 = OpFunctionCall %float %18 %93 %94 + %116 = OpLoad %v3float %in_normal_fs + %117 = OpExtInst %v3float %1 Normalize %116 + %122 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_0 %s_lights %int_0_3 + %125 = OpLoad %uint %i + %121 = OpAccessChain %_ptr_StorageBuffer_Light_0 %122 %125 + %120 = OpAccessChain %_ptr_StorageBuffer_v4float %121 %int_1 + %119 = OpAccessChain %_ptr_StorageBuffer_float %120 %int_0_4 + %131 = OpLoad %float %119 + %135 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_1 %s_lights %int_0_5 + %138 = OpLoad %uint %i + %134 = OpAccessChain %_ptr_StorageBuffer_Light_1 %135 %138 + %133 = OpAccessChain %_ptr_StorageBuffer_v4float_0 %134 %int_1_0 + %132 = OpAccessChain %_ptr_StorageBuffer_float_0 %133 %int_1_1 + %144 = OpLoad %float %132 + %148 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_2 %s_lights %int_0_6 + %151 = OpLoad %uint %i + %147 = OpAccessChain %_ptr_StorageBuffer_Light_2 %148 %151 + %146 = OpAccessChain %_ptr_StorageBuffer_v4float_1 %147 %int_1_2 + %145 = OpAccessChain %_ptr_StorageBuffer_float_1 %146 %int_2 + %157 = OpLoad %float %145 + %158 = OpCompositeConstruct %v3float %131 %144 %157 + %159 = OpAccessChain %_ptr_Input_float %in_position_fs %int_0_7 + %162 = OpLoad %float %159 + %163 = OpAccessChain %_ptr_Input_float_0 %in_position_fs %int_1_3 + %166 = OpLoad %float %163 + %167 = OpAccessChain %_ptr_Input_float_1 %in_position_fs %int_2_0 + %170 = OpLoad %float %167 + %171 = OpCompositeConstruct %v3float %162 %166 %170 + %118 = OpFSub %v3float %158 %171 + %172 = OpExtInst %v3float %1 Normalize %118 + %173 = OpDot %float %117 %172 + %174 = OpExtInst %float %1 FMax %float_0 %173 + %91 = OpFMul %float %92 %174 + %178 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_3 %s_lights %int_0_8 + %181 = OpLoad %uint %i + %177 = OpAccessChain %_ptr_StorageBuffer_Light_3 %178 %181 + %176 = OpAccessChain %_ptr_StorageBuffer_v4float_2 %177 %int_2_1 + %175 = OpAccessChain %_ptr_StorageBuffer_float_2 %176 %int_0_9 + %187 = OpLoad %float %175 + %191 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_4 %s_lights %int_0_10 + %194 = OpLoad %uint %i + %190 = OpAccessChain %_ptr_StorageBuffer_Light_4 %191 %194 + %189 = OpAccessChain %_ptr_StorageBuffer_v4float_3 %190 %int_2_2 + %188 = OpAccessChain %_ptr_StorageBuffer_float_3 %189 %int_1_4 + %200 = OpLoad %float %188 + %204 = OpAccessChain %_ptr_StorageBuffer__runtimearr_Light_5 %s_lights %int_0_11 + %207 = OpLoad %uint %i + %203 = OpAccessChain %_ptr_StorageBuffer_Light_5 %204 %207 + %202 = OpAccessChain %_ptr_StorageBuffer_v4float_4 %203 %int_2_3 + %201 = OpAccessChain %_ptr_StorageBuffer_float_4 %202 %int_2_4 + %213 = OpLoad %float %201 + %214 = OpCompositeConstruct %v3float %187 %200 %213 + %90 = OpVectorTimesScalar %v3float %214 %91 + %88 = OpFAdd %v3float %89 %90 + OpStore %color %88 + OpBranch %70 + %70 = OpLabel + %216 = OpLoad %uint %i + %215 = OpIAdd %uint %216 %uint_1 + OpStore %i %215 + OpBranch %67 + %68 = OpLabel + %219 = OpLoad %v3float %color + %220 = OpCompositeConstruct %v4float %219 %float_1 + OpStore %out_color_fs %220 + OpReturn + OpFunctionEnd diff --git a/tests/out/glsl/functions-webgl.main.Vertex.glsl b/tests/out/glsl/functions-webgl.main.Fragment.glsl similarity index 100% rename from tests/out/glsl/functions-webgl.main.Vertex.glsl rename to tests/out/glsl/functions-webgl.main.Fragment.glsl diff --git a/tests/out/glsl/math-functions.main.Vertex.glsl b/tests/out/glsl/math-functions.main.Fragment.glsl similarity index 100% rename from tests/out/glsl/math-functions.main.Vertex.glsl rename to tests/out/glsl/math-functions.main.Fragment.glsl diff --git a/tests/out/glsl/multiview.main.Vertex.glsl b/tests/out/glsl/multiview.main.Fragment.glsl similarity index 67% rename from tests/out/glsl/multiview.main.Vertex.glsl rename to tests/out/glsl/multiview.main.Fragment.glsl index a466f7df9e..466aea062f 100644 --- a/tests/out/glsl/multiview.main.Vertex.glsl +++ b/tests/out/glsl/multiview.main.Fragment.glsl @@ -7,7 +7,6 @@ precision highp int; void main() { int view_index = gl_ViewIndex; - gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w); return; } diff --git a/tests/out/glsl/multiview_webgl.main.Vertex.glsl b/tests/out/glsl/multiview_webgl.main.Fragment.glsl similarity index 86% rename from tests/out/glsl/multiview_webgl.main.Vertex.glsl rename to tests/out/glsl/multiview_webgl.main.Fragment.glsl index bb8b6e687d..30515289c9 100644 --- a/tests/out/glsl/multiview_webgl.main.Vertex.glsl +++ b/tests/out/glsl/multiview_webgl.main.Fragment.glsl @@ -4,8 +4,6 @@ precision highp float; precision highp int; -layout(num_views = 2) in; - void main() { int view_index = int(gl_ViewID_OVR); diff --git a/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl.config b/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl.config index f72fafd91f..98453a04ee 100644 --- a/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl.config +++ b/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl.config @@ -1,3 +1,3 @@ -vertex=(main:vs_5_1 ) -fragment=() +vertex=() +fragment=(main:ps_5_1 ) compute=() diff --git a/tests/out/hlsl/math-functions.hlsl.config b/tests/out/hlsl/math-functions.hlsl.config index f72fafd91f..98453a04ee 100644 --- a/tests/out/hlsl/math-functions.hlsl.config +++ b/tests/out/hlsl/math-functions.hlsl.config @@ -1,3 +1,3 @@ -vertex=(main:vs_5_1 ) -fragment=() +vertex=() +fragment=(main:ps_5_1 ) compute=() diff --git a/tests/out/msl/math-functions.msl b/tests/out/msl/math-functions.msl index c2aac6ef98..3db4644cd6 100644 --- a/tests/out/msl/math-functions.msl +++ b/tests/out/msl/math-functions.msl @@ -6,7 +6,7 @@ using metal::uint; constant metal::int2 const_type_1_ = {0, 0}; -vertex void main_( +fragment void main_( ) { metal::float4 v = metal::float4(0.0); float a = ((1.0) * 57.295779513082322865); diff --git a/tests/out/spv/math-functions.spvasm b/tests/out/spv/math-functions.spvasm index bee60f29e8..5f06ee2888 100644 --- a/tests/out/spv/math-functions.spvasm +++ b/tests/out/spv/math-functions.spvasm @@ -5,7 +5,8 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %18 "main" +OpEntryPoint Fragment %18 "main" +OpExecutionMode %18 OriginUpperLeft %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpConstant %4 1.0 diff --git a/tests/out/spv/multiview.spvasm b/tests/out/spv/multiview.spvasm index bb67d7eba8..792dea5593 100644 --- a/tests/out/spv/multiview.spvasm +++ b/tests/out/spv/multiview.spvasm @@ -7,8 +7,10 @@ OpCapability MultiView OpExtension "SPV_KHR_multiview" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %8 "main" %5 +OpEntryPoint Fragment %8 "main" %5 +OpExecutionMode %8 OriginUpperLeft OpDecorate %5 BuiltIn ViewIndex +OpDecorate %5 Flat %2 = OpTypeVoid %3 = OpTypeInt 32 1 %6 = OpTypePointer Input %3 diff --git a/tests/out/wgsl/277-casting-vert.wgsl b/tests/out/wgsl/277-casting-frag.wgsl similarity index 90% rename from tests/out/wgsl/277-casting-vert.wgsl rename to tests/out/wgsl/277-casting-frag.wgsl index 045edd83f3..26a3db792d 100644 --- a/tests/out/wgsl/277-casting-vert.wgsl +++ b/tests/out/wgsl/277-casting-frag.wgsl @@ -5,7 +5,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/280-matrix-cast-vert.wgsl b/tests/out/wgsl/280-matrix-cast-frag.wgsl similarity index 95% rename from tests/out/wgsl/280-matrix-cast-vert.wgsl rename to tests/out/wgsl/280-matrix-cast-frag.wgsl index 86df4628e3..316d936518 100644 --- a/tests/out/wgsl/280-matrix-cast-vert.wgsl +++ b/tests/out/wgsl/280-matrix-cast-frag.wgsl @@ -6,7 +6,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/484-preprocessor-if-vert.wgsl b/tests/out/wgsl/484-preprocessor-if-frag.wgsl similarity index 86% rename from tests/out/wgsl/484-preprocessor-if-vert.wgsl rename to tests/out/wgsl/484-preprocessor-if-frag.wgsl index 58eb963ceb..6b3c4ac973 100644 --- a/tests/out/wgsl/484-preprocessor-if-vert.wgsl +++ b/tests/out/wgsl/484-preprocessor-if-frag.wgsl @@ -2,7 +2,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/896-push-constant-vert.wgsl b/tests/out/wgsl/896-push-constant-frag.wgsl similarity index 93% rename from tests/out/wgsl/896-push-constant-vert.wgsl rename to tests/out/wgsl/896-push-constant-frag.wgsl index eec2204e02..729e35a43f 100644 --- a/tests/out/wgsl/896-push-constant-vert.wgsl +++ b/tests/out/wgsl/896-push-constant-frag.wgsl @@ -8,7 +8,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/900-implicit-conversions-vert.wgsl b/tests/out/wgsl/900-implicit-conversions-frag.wgsl similarity index 98% rename from tests/out/wgsl/900-implicit-conversions-vert.wgsl rename to tests/out/wgsl/900-implicit-conversions-frag.wgsl index a5369f98cf..97ff5a4fe5 100644 --- a/tests/out/wgsl/900-implicit-conversions-vert.wgsl +++ b/tests/out/wgsl/900-implicit-conversions-frag.wgsl @@ -62,7 +62,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/901-lhs-field-select-vert.wgsl b/tests/out/wgsl/901-lhs-field-select-frag.wgsl similarity index 92% rename from tests/out/wgsl/901-lhs-field-select-vert.wgsl rename to tests/out/wgsl/901-lhs-field-select-frag.wgsl index 1b41758097..196f21d79a 100644 --- a/tests/out/wgsl/901-lhs-field-select-vert.wgsl +++ b/tests/out/wgsl/901-lhs-field-select-frag.wgsl @@ -6,7 +6,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/931-constant-emitting-vert.wgsl b/tests/out/wgsl/931-constant-emitting-frag.wgsl similarity index 92% rename from tests/out/wgsl/931-constant-emitting-vert.wgsl rename to tests/out/wgsl/931-constant-emitting-frag.wgsl index c6b2687e89..ba5d223ef7 100644 --- a/tests/out/wgsl/931-constant-emitting-vert.wgsl +++ b/tests/out/wgsl/931-constant-emitting-frag.wgsl @@ -8,7 +8,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/932-for-loop-if-vert.wgsl b/tests/out/wgsl/932-for-loop-if-frag.wgsl similarity index 96% rename from tests/out/wgsl/932-for-loop-if-vert.wgsl rename to tests/out/wgsl/932-for-loop-if-frag.wgsl index 7fdd3c6135..f9a29ae87e 100644 --- a/tests/out/wgsl/932-for-loop-if-vert.wgsl +++ b/tests/out/wgsl/932-for-loop-if-frag.wgsl @@ -17,7 +17,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/binop-frag.wgsl b/tests/out/wgsl/binop-frag.wgsl deleted file mode 100644 index e61d2e0fb2..0000000000 --- a/tests/out/wgsl/binop-frag.wgsl +++ /dev/null @@ -1,187 +0,0 @@ -var o_color: vec4; - -fn testBinOpVecFloat(a: vec4, b: f32) { - var a1: vec4; - var b1: f32; - var v: vec4; - - a1 = a; - b1 = b; - let e5: vec4 = a1; - v = (e5 * 2.0); - let e8: vec4 = a1; - v = (e8 / vec4(2.0)); - let e12: vec4 = a1; - v = (e12 + vec4(2.0)); - let e16: vec4 = a1; - v = (e16 - vec4(2.0)); - return; -} - -fn testBinOpFloatVec(a2: vec4, b2: f32) { - var a3: vec4; - var b3: f32; - var v1: vec4; - - a3 = a2; - b3 = b2; - let e5: vec4 = a3; - let e6: f32 = b3; - v1 = (e5 * e6); - let e8: vec4 = a3; - let e9: f32 = b3; - v1 = (e8 / vec4(e9)); - let e12: vec4 = a3; - let e13: f32 = b3; - v1 = (e12 + vec4(e13)); - let e16: vec4 = a3; - let e17: f32 = b3; - v1 = (e16 - vec4(e17)); - return; -} - -fn testBinOpIVecInt(a4: vec4, b4: i32) { - var a5: vec4; - var b5: i32; - var v2: vec4; - - a5 = a4; - b5 = b4; - let e5: vec4 = a5; - let e6: i32 = b5; - v2 = (e5 * e6); - let e8: vec4 = a5; - let e9: i32 = b5; - v2 = (e8 / vec4(e9)); - let e12: vec4 = a5; - let e13: i32 = b5; - v2 = (e12 + vec4(e13)); - let e16: vec4 = a5; - let e17: i32 = b5; - v2 = (e16 - vec4(e17)); - let e20: vec4 = a5; - let e21: i32 = b5; - v2 = (e20 & vec4(e21)); - let e24: vec4 = a5; - let e25: i32 = b5; - v2 = (e24 | vec4(e25)); - let e28: vec4 = a5; - let e29: i32 = b5; - v2 = (e28 ^ vec4(e29)); - let e32: vec4 = a5; - let e33: i32 = b5; - v2 = (e32 >> vec4(u32(e33))); - let e37: vec4 = a5; - let e38: i32 = b5; - v2 = (e37 << vec4(u32(e38))); - return; -} - -fn testBinOpIntIVec(a6: i32, b6: vec4) { - var a7: i32; - var b7: vec4; - var v3: vec4; - - a7 = a6; - b7 = b6; - let e5: i32 = a7; - let e6: vec4 = b7; - v3 = (e5 * e6); - let e8: i32 = a7; - let e9: vec4 = b7; - v3 = (vec4(e8) + e9); - let e12: i32 = a7; - let e13: vec4 = b7; - v3 = (vec4(e12) - e13); - let e16: i32 = a7; - let e17: vec4 = b7; - v3 = (vec4(e16) & e17); - let e20: i32 = a7; - let e21: vec4 = b7; - v3 = (vec4(e20) | e21); - let e24: i32 = a7; - let e25: vec4 = b7; - v3 = (vec4(e24) ^ e25); - return; -} - -fn testBinOpUVecUint(a8: vec4, b8: u32) { - var a9: vec4; - var b9: u32; - var v4: vec4; - - a9 = a8; - b9 = b8; - let e5: vec4 = a9; - let e6: u32 = b9; - v4 = (e5 * e6); - let e8: vec4 = a9; - let e9: u32 = b9; - v4 = (e8 / vec4(e9)); - let e12: vec4 = a9; - let e13: u32 = b9; - v4 = (e12 + vec4(e13)); - let e16: vec4 = a9; - let e17: u32 = b9; - v4 = (e16 - vec4(e17)); - let e20: vec4 = a9; - let e21: u32 = b9; - v4 = (e20 & vec4(e21)); - let e24: vec4 = a9; - let e25: u32 = b9; - v4 = (e24 | vec4(e25)); - let e28: vec4 = a9; - let e29: u32 = b9; - v4 = (e28 ^ vec4(e29)); - let e32: vec4 = a9; - let e33: u32 = b9; - v4 = (e32 >> vec4(e33)); - let e36: vec4 = a9; - let e37: u32 = b9; - v4 = (e36 << vec4(e37)); - return; -} - -fn testBinOpUintUVec(a10: u32, b10: vec4) { - var a11: u32; - var b11: vec4; - var v5: vec4; - - a11 = a10; - b11 = b10; - let e5: u32 = a11; - let e6: vec4 = b11; - v5 = (e5 * e6); - let e8: u32 = a11; - let e9: vec4 = b11; - v5 = (vec4(e8) + e9); - let e12: u32 = a11; - let e13: vec4 = b11; - v5 = (vec4(e12) - e13); - let e16: u32 = a11; - let e17: vec4 = b11; - v5 = (vec4(e16) & e17); - let e20: u32 = a11; - let e21: vec4 = b11; - v5 = (vec4(e20) | e21); - let e24: u32 = a11; - let e25: vec4 = b11; - v5 = (vec4(e24) ^ e25); - return; -} - -fn main1() { - let e1: vec4 = o_color; - let e4: vec4 = vec4(1.0); - o_color.x = e4.x; - o_color.y = e4.y; - o_color.z = e4.z; - o_color.w = e4.w; - return; -} - -@fragment -fn main() { - main1(); - return; -} diff --git a/tests/out/wgsl/constant-array-size-vert.wgsl b/tests/out/wgsl/constant-array-size-frag.wgsl similarity index 98% rename from tests/out/wgsl/constant-array-size-vert.wgsl rename to tests/out/wgsl/constant-array-size-frag.wgsl index d9ed866542..98d413bdf2 100644 --- a/tests/out/wgsl/constant-array-size-vert.wgsl +++ b/tests/out/wgsl/constant-array-size-frag.wgsl @@ -37,7 +37,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/declarations-vert.wgsl b/tests/out/wgsl/declarations-frag.wgsl similarity index 93% rename from tests/out/wgsl/declarations-vert.wgsl rename to tests/out/wgsl/declarations-frag.wgsl index 4b61704b96..107bcaa4f4 100644 --- a/tests/out/wgsl/declarations-vert.wgsl +++ b/tests/out/wgsl/declarations-frag.wgsl @@ -13,7 +13,7 @@ struct TestStruct { b: f32, } -struct VertexOutput { +struct FragmentOutput { @location(0) position: vec2, @location(1) a: vec2, @location(2) out_array: vec4, @@ -50,8 +50,8 @@ fn main_1() { return; } -@vertex -fn main(@location(0) position: vec2, @location(1) a: vec2, @location(2) in_array: vec4, @location(3) in_array_1: vec4) -> VertexOutput { +@fragment +fn main(@location(0) position: vec2, @location(1) a: vec2, @location(2) in_array: vec4, @location(3) in_array_1: vec4) -> FragmentOutput { vert.position = position; vert.a = a; in_array_2[0] = in_array; @@ -65,5 +65,5 @@ fn main(@location(0) position: vec2, @location(1) a: vec2, @location(2 let _e32 = frag.a; let _e35 = out_array[0]; let _e37 = out_array[1]; - return VertexOutput(_e30, _e32, _e35, _e37); + return FragmentOutput(_e30, _e32, _e35, _e37); } diff --git a/tests/out/wgsl/global-constant-array-vert.wgsl b/tests/out/wgsl/global-constant-array-frag.wgsl similarity index 95% rename from tests/out/wgsl/global-constant-array-vert.wgsl rename to tests/out/wgsl/global-constant-array-frag.wgsl index 8805568129..bda27f3f58 100644 --- a/tests/out/wgsl/global-constant-array-vert.wgsl +++ b/tests/out/wgsl/global-constant-array-frag.wgsl @@ -7,7 +7,7 @@ fn main_1() { let _e2 = i; } -@vertex +@fragment fn main() { _ = array(1.0, 2.0); main_1(); diff --git a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl index 2ac357020a..10f5d25946 100644 --- a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl +++ b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl @@ -14,7 +14,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); } diff --git a/tests/out/wgsl/long-form-matrix-vert.wgsl b/tests/out/wgsl/long-form-matrix-frag.wgsl similarity index 99% rename from tests/out/wgsl/long-form-matrix-vert.wgsl rename to tests/out/wgsl/long-form-matrix-frag.wgsl index 5048a419a1..4a173b63ce 100644 --- a/tests/out/wgsl/long-form-matrix-vert.wgsl +++ b/tests/out/wgsl/long-form-matrix-frag.wgsl @@ -34,7 +34,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/math-functions-vert.wgsl b/tests/out/wgsl/math-functions-frag.wgsl similarity index 99% rename from tests/out/wgsl/math-functions-vert.wgsl rename to tests/out/wgsl/math-functions-frag.wgsl index 0d499fc58a..b9049ef23d 100644 --- a/tests/out/wgsl/math-functions-vert.wgsl +++ b/tests/out/wgsl/math-functions-frag.wgsl @@ -219,7 +219,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/out/wgsl/math-functions.wgsl b/tests/out/wgsl/math-functions.wgsl index 71ae0fd749..e03648e1c3 100644 --- a/tests/out/wgsl/math-functions.wgsl +++ b/tests/out/wgsl/math-functions.wgsl @@ -1,4 +1,4 @@ -@vertex +@fragment fn main() { let v = vec4(0.0); let a = degrees(1.0); diff --git a/tests/out/wgsl/multiview.wgsl b/tests/out/wgsl/multiview.wgsl index 3ea9676b8c..51192d2f7a 100644 --- a/tests/out/wgsl/multiview.wgsl +++ b/tests/out/wgsl/multiview.wgsl @@ -1,4 +1,4 @@ -@vertex +@fragment fn main(@builtin(view_index) view_index: i32) { return; } diff --git a/tests/out/wgsl/vector-functions-vert.wgsl b/tests/out/wgsl/vector-functions-frag.wgsl similarity index 99% rename from tests/out/wgsl/vector-functions-vert.wgsl rename to tests/out/wgsl/vector-functions-frag.wgsl index 29915bf2f2..f7dfdd15cb 100644 --- a/tests/out/wgsl/vector-functions-vert.wgsl +++ b/tests/out/wgsl/vector-functions-frag.wgsl @@ -215,7 +215,7 @@ fn main_1() { return; } -@vertex +@fragment fn main() { main_1(); return; diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 877b2597b4..555dc1239b 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -117,7 +117,7 @@ fn check_targets(module: &naga::Module, name: &str, targets: Targets) { let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), capabilities) .validate(module) - .expect("Naga module validation failed"); + .expect(&format!("Naga module validation failed on test '{name}'")); #[cfg(feature = "serialize")] { @@ -595,6 +595,7 @@ fn convert_spv(name: &str, adjust_coordinate_space: bool, targets: Targets) { let _ = env_logger::try_init(); let root = env!("CARGO_MANIFEST_DIR"); + let module = naga::front::spv::parse_u8_slice( &fs::read(format!("{root}/{BASE_DIR_IN}/spv/{name}.spv")).expect("Couldn't find spv file"), &naga::front::spv::Options { diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index 8baa8e29d4..a981d92dd5 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -961,8 +961,11 @@ fn main(@builtin(global_invocation_id) global_id: vec3) { check_validation! { "@vertex -fn main() { - discard; +fn main() -> @builtin(position) vec4 { + if true { + discard; + } + return vec4(); }": Err(naga::valid::ValidationError::EntryPoint { stage: naga::ShaderStage::Vertex, @@ -1124,13 +1127,13 @@ fn pointer_type_equivalence() { fn missing_bindings() { check_validation! { " - @vertex - fn vertex(_input: vec4) -> @location(0) vec4 { + @fragment + fn fragment(_input: vec4) -> @location(0) vec4 { return _input; } ": Err(naga::valid::ValidationError::EntryPoint { - stage: naga::ShaderStage::Vertex, + stage: naga::ShaderStage::Fragment, source: naga::valid::EntryPointError::Argument( 0, naga::valid::VaryingError::MissingBinding, @@ -1141,13 +1144,13 @@ fn missing_bindings() { check_validation! { " - @vertex - fn vertex(@location(0) _input: vec4, more_input: f32) -> @location(0) vec4 { + @fragment + fn fragment(@location(0) _input: vec4, more_input: f32) -> @location(0) vec4 { return _input + more_input; } ": Err(naga::valid::ValidationError::EntryPoint { - stage: naga::ShaderStage::Vertex, + stage: naga::ShaderStage::Fragment, source: naga::valid::EntryPointError::Argument( 1, naga::valid::VaryingError::MissingBinding, @@ -1158,13 +1161,13 @@ fn missing_bindings() { check_validation! { " - @vertex - fn vertex(@location(0) _input: vec4) -> vec4 { + @fragment + fn fragment(@location(0) _input: vec4) -> vec4 { return _input; } ": Err(naga::valid::ValidationError::EntryPoint { - stage: naga::ShaderStage::Vertex, + stage: naga::ShaderStage::Fragment, source: naga::valid::EntryPointError::Result( naga::valid::VaryingError::MissingBinding, ), @@ -1174,18 +1177,18 @@ fn missing_bindings() { check_validation! { " - struct VertexIn { + struct FragmentIn { @location(0) pos: vec4, uv: vec2 } - @vertex - fn vertex(_input: VertexIn) -> @location(0) vec4 { + @fragment + fn fragment(_input: FragmentIn) -> @location(0) vec4 { return _input.pos; } ": Err(naga::valid::ValidationError::EntryPoint { - stage: naga::ShaderStage::Vertex, + stage: naga::ShaderStage::Fragment, source: naga::valid::EntryPointError::Argument( 0, naga::valid::VaryingError::MemberMissingBinding(1), @@ -1195,6 +1198,39 @@ fn missing_bindings() { } } +#[test] +fn missing_bindings2() { + check_validation! { + " + @vertex + fn vertex() {} + ": + Err(naga::valid::ValidationError::EntryPoint { + stage: naga::ShaderStage::Vertex, + source: naga::valid::EntryPointError::MissingVertexOutputPosition, + .. + }) + } + + check_validation! { + " + struct VertexOut { + @location(0) a: vec4, + } + + @vertex + fn vertex() -> VertexOut { + return VertexOut(vec4()); + } + ": + Err(naga::valid::ValidationError::EntryPoint { + stage: naga::ShaderStage::Vertex, + source: naga::valid::EntryPointError::MissingVertexOutputPosition, + .. + }) + } +} + #[test] fn invalid_access() { check_validation! {