diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 9d2055ff6a..c3d5bd39b7 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -146,15 +146,17 @@ impl ConstantEvaluator<'_> { Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { Ok(self.register_evaluated_expr(expr.clone(), span)) } - Expression::Compose { ref components, .. } => { - for component in components { - self.check_and_get(*component)?; - } - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Compose { ty, ref components } => { + let components = components + .iter() + .map(|component| self.check_and_get(*component)) + .collect::, _>>()?; + + Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) } - Expression::Splat { value, .. } => { - self.check_and_get(value)?; - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Splat { value, size } => { + let value = self.check_and_get(value)?; + Ok(self.register_evaluated_expr(Expression::Splat { value, size }, span)) } Expression::AccessIndex { base, index } => { let base = self.check_and_get(base)?; diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 673ab1fb00..ef00c16b59 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,67 +1,66 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 41 +; Bound: 40 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %20 "main" -OpExecutionMode %20 LocalSize 1 1 1 +OpEntryPoint GLCompute %17 "main" +OpExecutionMode %17 LocalSize 1 1 1 +OpDecorate %7 DescriptorSet 0 +OpDecorate %7 Binding 0 +OpDecorate %8 Block +OpMemberDecorate %8 0 Offset 0 OpDecorate %10 DescriptorSet 0 -OpDecorate %10 Binding 0 +OpDecorate %10 Binding 1 OpDecorate %11 Block OpMemberDecorate %11 0 Offset 0 OpDecorate %13 DescriptorSet 0 -OpDecorate %13 Binding 1 +OpDecorate %13 Binding 2 OpDecorate %14 Block OpMemberDecorate %14 0 Offset 0 -OpDecorate %16 DescriptorSet 0 -OpDecorate %16 Binding 2 -OpDecorate %17 Block -OpMemberDecorate %17 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 %5 = OpTypeVector %4 2 %6 = OpTypeVector %4 3 -%7 = OpConstant %4 0 -%8 = OpConstant %4 1 -%9 = OpConstant %4 2 -%11 = OpTypeStruct %3 +%8 = OpTypeStruct %3 +%9 = OpTypePointer StorageBuffer %8 +%7 = OpVariable %9 StorageBuffer +%11 = OpTypeStruct %4 %12 = OpTypePointer StorageBuffer %11 %10 = OpVariable %12 StorageBuffer %14 = OpTypeStruct %4 %15 = OpTypePointer StorageBuffer %14 %13 = OpVariable %15 StorageBuffer -%17 = OpTypeStruct %4 -%18 = OpTypePointer StorageBuffer %17 -%16 = OpVariable %18 StorageBuffer -%21 = OpTypeFunction %2 -%22 = OpTypePointer StorageBuffer %3 -%24 = OpTypeInt 32 0 -%23 = OpConstant %24 0 -%26 = OpTypePointer StorageBuffer %4 -%29 = OpConstantComposite %5 %8 %9 -%30 = OpConstant %4 3 -%31 = OpConstant %4 4 -%32 = OpConstantComposite %5 %30 %31 -%33 = OpConstantComposite %3 %31 %30 %9 %8 -%34 = OpConstant %4 6 -%35 = OpConstant %4 7 -%36 = OpConstantComposite %5 %34 %35 -%37 = OpConstant %4 8 -%38 = OpConstantComposite %6 %34 %35 %37 -%39 = OpConstant %4 9 -%20 = OpFunction %2 None %21 -%19 = OpLabel -%25 = OpAccessChain %22 %10 %23 -%27 = OpAccessChain %26 %13 %23 -%28 = OpAccessChain %26 %16 %23 -OpBranch %40 -%40 = OpLabel +%18 = OpTypeFunction %2 +%19 = OpTypePointer StorageBuffer %3 +%21 = OpTypeInt 32 0 +%20 = OpConstant %21 0 +%23 = OpTypePointer StorageBuffer %4 +%26 = OpConstant %4 1 +%27 = OpConstant %4 2 +%28 = OpConstantComposite %5 %26 %27 +%29 = OpConstant %4 3 +%30 = OpConstant %4 4 +%31 = OpConstantComposite %5 %29 %30 +%32 = OpConstantComposite %3 %30 %29 %27 %26 +%33 = OpConstant %4 6 +%34 = OpConstant %4 7 +%35 = OpConstantComposite %5 %33 %34 +%36 = OpConstant %4 8 +%37 = OpConstantComposite %6 %33 %34 %36 +%38 = OpConstant %4 9 +%17 = OpFunction %2 None %18 +%16 = OpLabel +%22 = OpAccessChain %19 %7 %20 +%24 = OpAccessChain %23 %10 %20 +%25 = OpAccessChain %23 %13 %20 +OpBranch %39 +%39 = OpLabel +OpStore %22 %32 +OpStore %24 %27 OpStore %25 %33 -OpStore %27 %9 -OpStore %28 %34 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index bad1b1ec50..882b5968c2 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -10,7 +10,7 @@ var Texture: texture_2d; var Sampler: sampler; fn returns() -> S { - return S(Value); + return S(1); } fn statement() {