From a40e9e07b5a6e0617fd974137e8e71d74ebf77d8 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 13 Jul 2025 12:14:01 +0200 Subject: [PATCH] Metal Backend: define USE_BITSELECT and USE_SWIZZLE for Apple Intel --- OpenCL/inc_common.cl | 5 +++++ OpenCL/inc_vendor.h | 4 ++++ docs/changes.txt | 1 + 3 files changed, 10 insertions(+) diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index e0a9f28ed..1cd1e33cb 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -1115,7 +1115,12 @@ DECLSPEC u32 hc_swap32_S (const u32 v) asm volatile ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(r) : "r"(v)); #else #ifdef USE_SWIZZLE + #ifdef IS_METAL + uchar4 u = uchar4 ((v >> 0) & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF); + r = as_type(u.wzyx); + #else r = as_uint (as_uchar4 (v).s3210); + #endif #else r = ((v & 0xff000000) >> 24) | ((v & 0x00ff0000) >> 8) diff --git a/OpenCL/inc_vendor.h b/OpenCL/inc_vendor.h index f8ecb3533..53406cf6a 100644 --- a/OpenCL/inc_vendor.h +++ b/OpenCL/inc_vendor.h @@ -201,6 +201,10 @@ using namespace metal; #ifdef IS_METAL #define USE_ROTATE +#ifndef IS_APPLE_SILICON +#define USE_BITSELECT +#define USE_SWIZZLE +#endif // Metal support max VECT_SIZE = 4 #define s0 x diff --git a/docs/changes.txt b/docs/changes.txt index a12d42cf6..d57c7d172 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -177,6 +177,7 @@ - Metal Backend: allow use of devices with Metal if runtime version is >= 200 - Metal Backend: disable Metal devices only if at least one OpenCL device is active - Metal Backend: improved compute workloads calculation +- Metal Backend: define USE_BITSELECT and USE_SWIZZLE for Apple Intel - Modules: Check UnpackSize to raise false positive with hc_decompress_rar - User Options: added --metal-compiler-runtime option - User Options: limit --bitmap-max value to 31