From 7531c089fabd7aefd1ed92b10b5a489603cbc1f89f9eb5d7a349c0f9f6a9d3a6 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Mon, 22 Aug 2022 23:18:30 +0000
Subject: [PATCH 1/3] - Update to release 2022.3

OBS-URL: https://build.opensuse.org/package/show/X11:Wayland/spirv-tools?expand=0&rev=84
---
 baselibs.conf        |  4 ++--
 sdk-1.3.216.0.tar.gz |  3 ---
 spirv-tools.changes  | 15 +++++++++++++++
 spirv-tools.spec     |  9 ++++-----
 v2022.3.tar.gz       |  3 +++
 5 files changed, 24 insertions(+), 10 deletions(-)
 delete mode 100644 sdk-1.3.216.0.tar.gz
 create mode 100644 v2022.3.tar.gz

diff --git a/baselibs.conf b/baselibs.conf
index 56cb492..7111e2e 100644
--- a/baselibs.conf
+++ b/baselibs.conf
@@ -1,4 +1,4 @@
-libSPIRV-Tools-2022_3_sdk216
+libSPIRV-Tools-2022_3
 spirv-tools-devel
 	requires -spirv-tools-<targettype>
-	requires "libSPIRV-Tools-2022_3_sdk216-<targettype> = <version>"
+	requires "libSPIRV-Tools-2022_3-<targettype> = <version>"
diff --git a/sdk-1.3.216.0.tar.gz b/sdk-1.3.216.0.tar.gz
deleted file mode 100644
index 101540b..0000000
--- a/sdk-1.3.216.0.tar.gz
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:b82c5d4790ea4c27ff3a6152fc2fbbb11f6d89702f04d6c644512d851608d67b
-size 3019645
diff --git a/spirv-tools.changes b/spirv-tools.changes
index cf637a2..52e4cfe 100644
--- a/spirv-tools.changes
+++ b/spirv-tools.changes
@@ -1,3 +1,18 @@
+-------------------------------------------------------------------
+Mon Aug 22 23:12:02 UTC 2022 - Jan Engelhardt <jengelh@inai.de>
+
+- Update to release 2022.3~sdk224 (SDK-1.3.224.0)
+  * spirv-val: Add support for SPV_AMD_shader_early_and_late_fragment_tests
+  * Avoid replacing access chain with OOB access
+  * Avoid undefined divide-by-0
+  * Fixed crash unrolling loops with residual iterations
+  * Fix segfault in `SpirvTools::Disassemble` when printing
+  * Avoid undefined behaviour when getting debug opcode
+  * spirv-val: Add Vulkan decoration interface
+  * Implement SPV_NV_bindless_texture related changes
+- Update to release 2022.3
+  * spirv-val: Add SPV_KHR_ray_tracing instructions
+
 -------------------------------------------------------------------
 Wed Jun 15 16:51:34 UTC 2022 - Jan Engelhardt <jengelh@inai.de>
 
diff --git a/spirv-tools.spec b/spirv-tools.spec
index a2862e1..b848d32 100644
--- a/spirv-tools.spec
+++ b/spirv-tools.spec
@@ -17,18 +17,17 @@
 
 
 %define _lto_cflags %nil
-%define lname libSPIRV-Tools-2022_3_sdk216
+%define lname libSPIRV-Tools-2022_3
 
 Name:           spirv-tools
-Version:        2022.3~sdk216
+Version:        2022.3
 Release:        0
 Summary:        API and commands for processing SPIR-V modules
 License:        Apache-2.0
 Group:          Development/Libraries/C and C++
 URL:            https://github.com/KhronosGroup/SPIRV-Tools
 
-#Source:         https://github.com/KhronosGroup/SPIRV-Tools/archive/v%version.tar.gz
-Source:         https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/sdk-1.3.216.0.tar.gz
+Source:         https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/v%version.tar.gz
 Source9:        baselibs.conf
 Patch1:         ver.diff
 Patch2:         gcc48.diff
@@ -66,7 +65,7 @@ validator, and is used in the standalone tools whilst also enabling
 integration into other code bases directly.
 
 %prep
-%autosetup -p1 -n SPIRV-Tools-sdk-1.3.216.0
+%autosetup -p1 -n SPIRV-Tools-%version
 find . -type f -name CMakeLists.txt -exec \
 	perl -i -pe 's{\@PACKAGE_VERSION\@}{%version}' CMakeLists.txt {} +
 
diff --git a/v2022.3.tar.gz b/v2022.3.tar.gz
new file mode 100644
index 0000000..dc83748
--- /dev/null
+++ b/v2022.3.tar.gz
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:df6dc5ed5351f99aaaa6acc78111342d3400b27b99f18148d3be408570144a70
+size 3035130

From bcf2e90675c3161a666a6e5c010dc31c4557c5798fa0c4bb9146db996ee558d6 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Mon, 22 Aug 2022 23:32:48 +0000
Subject: [PATCH 2/3] - Add 0001-Fix-array-copy-propagation-4890.patch

OBS-URL: https://build.opensuse.org/package/show/X11:Wayland/spirv-tools?expand=0&rev=85
---
 0001-Fix-array-copy-propagation-4890.patch | 97 ++++++++++++++++++++++
 spirv-tools.changes                        |  1 +
 2 files changed, 98 insertions(+)
 create mode 100644 0001-Fix-array-copy-propagation-4890.patch

diff --git a/0001-Fix-array-copy-propagation-4890.patch b/0001-Fix-array-copy-propagation-4890.patch
new file mode 100644
index 0000000..db93d18
--- /dev/null
+++ b/0001-Fix-array-copy-propagation-4890.patch
@@ -0,0 +1,97 @@
+From 3a8a961cffb7699422a05dcbafdd721226b4547d Mon Sep 17 00:00:00 2001
+From: Cassandra Beckley <cbeckley@google.com>
+Date: Thu, 11 Aug 2022 09:59:37 -0700
+Subject: [PATCH] Fix array copy propagation (#4890)
+
+Array copy propagation was interpreting OpEntryPoint as a store
+---
+ source/opt/copy_prop_arrays.cpp   |  2 ++
+ source/opt/copy_prop_arrays.h     |  2 +-
+ test/opt/copy_prop_array_test.cpp | 45 +++++++++++++++++++++++++++++++
+ 3 files changed, 48 insertions(+), 1 deletion(-)
+
+diff --git a/source/opt/copy_prop_arrays.cpp b/source/opt/copy_prop_arrays.cpp
+index 321d4969..1c30138e 100644
+--- a/source/opt/copy_prop_arrays.cpp
++++ b/source/opt/copy_prop_arrays.cpp
+@@ -168,6 +168,8 @@ bool CopyPropagateArrays::HasNoStores(Instruction* ptr_inst) {
+       return false;
+     } else if (use->opcode() == SpvOpImageTexelPointer) {
+       return true;
++    } else if (use->opcode() == SpvOpEntryPoint) {
++      return true;
+     }
+     // Some other instruction.  Be conservative.
+     return false;
+diff --git a/source/opt/copy_prop_arrays.h b/source/opt/copy_prop_arrays.h
+index 46a508cf..07747c10 100644
+--- a/source/opt/copy_prop_arrays.h
++++ b/source/opt/copy_prop_arrays.h
+@@ -195,7 +195,7 @@ class CopyPropagateArrays : public MemPass {
+   // Return true if |type_id| is a pointer type whose pointee type is an array.
+   bool IsPointerToArrayType(uint32_t type_id);
+ 
+-  // Returns true of there are not stores using |ptr_inst| or something derived
++  // Returns true if there are not stores using |ptr_inst| or something derived
+   // from it.
+   bool HasNoStores(Instruction* ptr_inst);
+ 
+diff --git a/test/opt/copy_prop_array_test.cpp b/test/opt/copy_prop_array_test.cpp
+index a4599f0f..f322f4ad 100644
+--- a/test/opt/copy_prop_array_test.cpp
++++ b/test/opt/copy_prop_array_test.cpp
+@@ -1839,6 +1839,51 @@ OpFunctionEnd
+ 
+   SinglePassRunAndCheck<CopyPropagateArrays>(text, text, false);
+ }
++
++// Since Spir-V 1.4, resources that are used by a shader must be on the
++// OpEntryPoint instruction with the inputs and outputs. This test ensures that
++// this does not stop the pass from working.
++TEST_F(CopyPropArrayPassTest, EntryPointUser) {
++  const std::string before = R"(OpCapability Shader
++OpMemoryModel Logical GLSL450
++OpEntryPoint GLCompute %main "main" %g_rwTexture3d
++OpExecutionMode %main LocalSize 256 1 1
++OpSource HLSL 660
++OpName %type_3d_image "type.3d.image"
++OpName %g_rwTexture3d "g_rwTexture3d"
++OpName %main "main"
++OpDecorate %g_rwTexture3d DescriptorSet 0
++OpDecorate %g_rwTexture3d Binding 0
++%uint = OpTypeInt 32 0
++%uint_0 = OpConstant %uint 0
++%uint_1 = OpConstant %uint 1
++%uint_2 = OpConstant %uint 2
++%uint_3 = OpConstant %uint 3
++%v3uint = OpTypeVector %uint 3
++%10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
++%type_3d_image = OpTypeImage %uint 3D 2 0 0 2 R32ui
++%_ptr_UniformConstant_type_3d_image = OpTypePointer UniformConstant %type_3d_image
++%void = OpTypeVoid
++%13 = OpTypeFunction %void
++%_ptr_Function_type_3d_image = OpTypePointer Function %type_3d_image
++%_ptr_Image_uint = OpTypePointer Image %uint
++%g_rwTexture3d = OpVariable %_ptr_UniformConstant_type_3d_image UniformConstant
++%main = OpFunction %void None %13
++%16 = OpLabel
++%17 = OpVariable %_ptr_Function_type_3d_image Function
++%18 = OpLoad %type_3d_image %g_rwTexture3d
++OpStore %17 %18
++; CHECK: %19 = OpImageTexelPointer %_ptr_Image_uint %g_rwTexture3d %10 %uint_0
++%19 = OpImageTexelPointer %_ptr_Image_uint %17 %10 %uint_0
++%20 = OpAtomicIAdd %uint %19 %uint_1 %uint_0 %uint_1
++OpReturn
++OpFunctionEnd
++)";
++
++  SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
++  SetTargetEnv(SPV_ENV_UNIVERSAL_1_4);
++  SinglePassRunAndMatch<CopyPropagateArrays>(before, false);
++}
+ }  // namespace
+ }  // namespace opt
+ }  // namespace spvtools
+-- 
+2.37.2
+
diff --git a/spirv-tools.changes b/spirv-tools.changes
index 52e4cfe..e18276f 100644
--- a/spirv-tools.changes
+++ b/spirv-tools.changes
@@ -12,6 +12,7 @@ Mon Aug 22 23:12:02 UTC 2022 - Jan Engelhardt <jengelh@inai.de>
   * Implement SPV_NV_bindless_texture related changes
 - Update to release 2022.3
   * spirv-val: Add SPV_KHR_ray_tracing instructions
+- Add 0001-Fix-array-copy-propagation-4890.patch
 
 -------------------------------------------------------------------
 Wed Jun 15 16:51:34 UTC 2022 - Jan Engelhardt <jengelh@inai.de>

From b49384195f5f88ca862529b57e8bac2fccf63eb7556ea7fc56aa9dc2db98a3b3 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Tue, 23 Aug 2022 15:07:43 +0000
Subject: [PATCH 3/3] add patch

OBS-URL: https://build.opensuse.org/package/show/X11:Wayland/spirv-tools?expand=0&rev=86
---
 spirv-tools.spec | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spirv-tools.spec b/spirv-tools.spec
index b848d32..268dcd3 100644
--- a/spirv-tools.spec
+++ b/spirv-tools.spec
@@ -31,6 +31,7 @@ Source:         https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/v%
 Source9:        baselibs.conf
 Patch1:         ver.diff
 Patch2:         gcc48.diff
+Patch3:         0001-Fix-array-copy-propagation-4890.patch
 BuildRequires:  bison
 BuildRequires:  cmake >= 2.8.12
 BuildRequires:  gcc-c++