From 0e3fbc81664a263e8be278d11a6083b227a5b1a2 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 6 Oct 2021 13:30:36 -0700 Subject: [PATCH] Replace pointer-access.spv snapshot test with WGSL source. (#1450) The original pointer access test used SPIR-V for its input because WGSL didn't have a working pointer indirection operator at the time. Now that it does, we can just write this test in WGSL directly. Fixes #1432. --- tests/in/pointer-access.param.ron | 7 --- tests/in/pointers.param.ron | 1 + tests/in/pointers.wgsl | 11 +++++ tests/in/spv/pointer-access.spv | Bin 664 -> 0 bytes tests/out/spv/pointers.spvasm | 72 +++++++++++++++++++++++------- tests/out/wgsl/pointers.wgsl | 11 +++++ tests/snapshots.rs | 6 --- 7 files changed, 80 insertions(+), 28 deletions(-) delete mode 100644 tests/in/pointer-access.param.ron delete mode 100644 tests/in/spv/pointer-access.spv diff --git a/tests/in/pointer-access.param.ron b/tests/in/pointer-access.param.ron deleted file mode 100644 index 4fc2cfe566..0000000000 --- a/tests/in/pointer-access.param.ron +++ /dev/null @@ -1,7 +0,0 @@ -( - spv: ( - version: (1, 0), - debug: true, - adjust_coordinate_space: true, - ), -) diff --git a/tests/in/pointers.param.ron b/tests/in/pointers.param.ron index de304854bb..10454c4d1a 100644 --- a/tests/in/pointers.param.ron +++ b/tests/in/pointers.param.ron @@ -1,4 +1,5 @@ ( + index_bounds_check_policy: ReadZeroSkipWrite, spv: ( version: (1, 2), debug: true, diff --git a/tests/in/pointers.wgsl b/tests/in/pointers.wgsl index 8dd12442e5..d7148e8db2 100644 --- a/tests/in/pointers.wgsl +++ b/tests/in/pointers.wgsl @@ -3,3 +3,14 @@ fn f() { let px = &v.x; *px = 10; } + +[[block]] +struct DynamicArray { + array: array; +}; + +fn index_dynamic_array(p: ptr, i: i32, v: u32) -> u32 { + let old = (*p).array[i]; + (*p).array[i] = v; + return old; +} diff --git a/tests/in/spv/pointer-access.spv b/tests/in/spv/pointer-access.spv deleted file mode 100644 index ba5664c3a7ad4b4d88069e858c69699126167a69..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 664 zcmYk3%}c{T5XGly(`c*Js`Ud@T6^@af_Uhu1uvrDHN++@f@s;Kp#Qli@%@sGxG;G$ zZ|3dW-86%7WMRY1B0JHS)wjT4z);w+u01_G$M>_xI4?e2vdrR_^|G?u=IMEI8I8rdf`_Zp` Lj+N8Hha8_@_)arN diff --git a/tests/out/spv/pointers.spvasm b/tests/out/spv/pointers.spvasm index b019f8b5c6..d6e2bcf2ba 100644 --- a/tests/out/spv/pointers.spvasm +++ b/tests/out/spv/pointers.spvasm @@ -1,29 +1,71 @@ ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 16 +; Bound: 42 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpSource GLSL 450 -OpName %6 "v" -OpName %9 "f" +OpMemberName %8 0 "array" +OpName %8 "DynamicArray" +OpName %10 "v" +OpName %13 "f" +OpName %23 "index_dynamic_array" +OpDecorate %7 ArrayStride 4 +OpDecorate %8 Block +OpMemberDecorate %8 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpConstant %4 10 %5 = OpTypeVector %4 2 -%7 = OpTypePointer Function %5 -%10 = OpTypeFunction %2 -%12 = OpTypePointer Function %4 -%14 = OpTypeInt 32 0 -%13 = OpConstant %14 0 -%9 = OpFunction %2 None %10 -%8 = OpLabel -%6 = OpVariable %7 Function -OpBranch %11 -%11 = OpLabel -%15 = OpAccessChain %12 %6 %13 -OpStore %15 %3 +%6 = OpTypeInt 32 0 +%7 = OpTypeRuntimeArray %6 +%8 = OpTypeStruct %7 +%9 = OpTypePointer Workgroup %8 +%11 = OpTypePointer Function %5 +%14 = OpTypeFunction %2 +%16 = OpTypePointer Function %4 +%17 = OpConstant %6 0 +%24 = OpTypeFunction %6 %9 %4 %6 +%26 = OpTypePointer Workgroup %7 +%27 = OpTypePointer Workgroup %6 +%30 = OpTypeBool +%32 = OpConstantNull %6 +%13 = OpFunction %2 None %14 +%12 = OpLabel +%10 = OpVariable %11 Function +OpBranch %15 +%15 = OpLabel +%18 = OpAccessChain %16 %10 %17 +OpStore %18 %3 OpReturn +OpFunctionEnd +%23 = OpFunction %6 None %24 +%20 = OpFunctionParameter %9 +%21 = OpFunctionParameter %4 +%22 = OpFunctionParameter %6 +%19 = OpLabel +OpBranch %25 +%25 = OpLabel +%28 = OpArrayLength %6 %20 0 +%29 = OpULessThan %30 %21 %28 +OpSelectionMerge %33 None +OpBranchConditional %29 %34 %33 +%34 = OpLabel +%31 = OpAccessChain %27 %20 %17 %21 +%35 = OpLoad %6 %31 +OpBranch %33 +%33 = OpLabel +%36 = OpPhi %6 %32 %25 %35 %34 +%37 = OpArrayLength %6 %20 0 +%38 = OpULessThan %30 %21 %37 +OpSelectionMerge %40 None +OpBranchConditional %38 %41 %40 +%41 = OpLabel +%39 = OpAccessChain %27 %20 %17 %21 +OpStore %39 %22 +OpBranch %40 +%40 = OpLabel +OpReturnValue %36 OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/pointers.wgsl b/tests/out/wgsl/pointers.wgsl index 15a5157ae5..cabe2eaedf 100644 --- a/tests/out/wgsl/pointers.wgsl +++ b/tests/out/wgsl/pointers.wgsl @@ -1,3 +1,8 @@ +[[block]] +struct DynamicArray { + array1: [[stride(4)]] array; +}; + fn f() { var v: vec2; @@ -6,3 +11,9 @@ fn f() { return; } +fn index_dynamic_array(p: ptr, i: i32, v1: u32) -> u32 { + let old: u32 = (*p).array1[i]; + (*p).array1[i] = v1; + return old; +} + diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 7d05d0fbfe..abccc15ebd 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -598,12 +598,6 @@ fn convert_spv_inverse_hyperbolic_trig_functions() { ); } -#[cfg(all(feature = "spv-in", feature = "spv-out"))] -//#[test] //TODO: https://github.com/gfx-rs/naga/issues/1432 -fn _convert_spv_pointer_access() { - convert_spv("pointer-access", true, Targets::SPIRV); -} - #[cfg(feature = "glsl-in")] #[allow(unused_variables)] #[test]