From b8724eb1fd2871dbf6e05c1cfc2248368f11a792 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 27 May 2021 21:52:31 -0700 Subject: [PATCH] Tweak access.wgsl to avoid #913 and make SPIR-V more distinctive. --- tests/in/access.wgsl | 2 +- tests/out/access.msl | 2 +- tests/out/access.spvasm | 29 +++++++++++++++-------------- tests/out/access.wgsl | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/in/access.wgsl b/tests/in/access.wgsl index dc5fb984f..9257cd75f 100644 --- a/tests/in/access.wgsl +++ b/tests/in/access.wgsl @@ -19,7 +19,7 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { let index = 3u; let b = bar.matrix[index].x; - let a = bar.data[arrayLength(&bar.data) - 1u]; + let a = bar.data[arrayLength(&bar.data) - 2u]; var c: array = array(a, i32(b), 3, 4, 5); let value = c[vi]; diff --git a/tests/out/access.msl b/tests/out/access.msl index 54f422f4d..31106f896 100644 --- a/tests/out/access.msl +++ b/tests/out/access.msl @@ -30,7 +30,7 @@ vertex fooOutput foo( foo1 = 1.0; metal::float4 _e9 = bar.matrix[3]; float b = _e9.x; - int a = bar.data[(1 + (_buffer_sizes.size0 - 64 - 4) / 4) - 1u]; + int a = bar.data[(1 + (_buffer_sizes.size0 - 64 - 4) / 4) - 2u]; for(int _i=0; _i<5; ++_i) c.inner[_i] = type6 {a, static_cast(b), 3, 4, 5}.inner[_i]; int value = c.inner[vi]; return fooOutput { static_cast(metal::int4(value)) }; diff --git a/tests/out/access.spvasm b/tests/out/access.spvasm index 297b8a726..96a5a22c4 100644 --- a/tests/out/access.spvasm +++ b/tests/out/access.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 54 +; Bound: 55 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" @@ -33,7 +33,7 @@ OpDecorate %28 BuiltIn Position %5 = OpConstant %4 1.0 %7 = OpTypeInt 32 0 %6 = OpConstant %7 3 -%8 = OpConstant %7 1 +%8 = OpConstant %7 2 %10 = OpTypeInt 32 1 %9 = OpConstant %10 5 %11 = OpConstant %10 3 @@ -57,8 +57,9 @@ OpDecorate %28 BuiltIn Position %36 = OpConstant %7 0 %40 = OpTypePointer StorageBuffer %15 %43 = OpTypePointer StorageBuffer %10 -%48 = OpTypePointer Function %10 -%51 = OpTypeVector %10 4 +%44 = OpConstant %7 1 +%49 = OpTypePointer Function %10 +%52 = OpTypeVector %10 4 %30 = OpFunction %2 None %31 %24 = OpLabel %20 = OpVariable %21 Function %3 @@ -73,15 +74,15 @@ OpStore %20 %5 %39 = OpCompositeExtract %4 %38 0 %41 = OpArrayLength %7 %18 1 %42 = OpISub %7 %41 %8 -%44 = OpAccessChain %43 %18 %8 %42 -%45 = OpLoad %10 %44 -%46 = OpConvertFToS %10 %39 -%47 = OpCompositeConstruct %17 %45 %46 %11 %12 %9 -OpStore %22 %47 -%49 = OpAccessChain %48 %22 %27 -%50 = OpLoad %10 %49 -%52 = OpCompositeConstruct %51 %50 %50 %50 %50 -%53 = OpConvertSToF %14 %52 -OpStore %28 %53 +%45 = OpAccessChain %43 %18 %44 %42 +%46 = OpLoad %10 %45 +%47 = OpConvertFToS %10 %39 +%48 = OpCompositeConstruct %17 %46 %47 %11 %12 %9 +OpStore %22 %48 +%50 = OpAccessChain %49 %22 %27 +%51 = OpLoad %10 %50 +%53 = OpCompositeConstruct %52 %51 %51 %51 %51 +%54 = OpConvertSToF %14 %53 +OpStore %28 %54 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/access.wgsl b/tests/out/access.wgsl index 8bb52234a..66a799199 100644 --- a/tests/out/access.wgsl +++ b/tests/out/access.wgsl @@ -16,7 +16,7 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { foo1 = 1.0; let _e9: vec4 = bar.matrix[3]; let b: f32 = _e9.x; - let a: i32 = bar.data[(arrayLength(&bar.data) - 1u)]; + let a: i32 = bar.data[(arrayLength(&bar.data) - 2u)]; c = array(a, i32(b), 3, 4, 5); let value: i32 = c[vi]; return vec4(vec4(value));