vkd3d-shader/hlsl: Implement the firstbitlow() intrinsic.

This commit is contained in:
Petrichor Park
2024-08-13 11:34:23 -05:00
committed by Henri Verbeet
parent e6d840170d
commit e35604dbf0
Notes: Henri Verbeet 2025-09-22 11:46:20 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/965
9 changed files with 135 additions and 4 deletions

View File

@@ -343,6 +343,24 @@ static inline unsigned int vkd3d_log2i(unsigned int x)
#endif
}
static inline unsigned int vkd3d_ctz(uint32_t v)
{
#ifdef HAVE_BUILTIN_CTZ
return __builtin_ctz(v);
#else
unsigned int c = 31;
v &= -v;
c = (v & 0x0000ffff) ? c - 16 : c;
c = (v & 0x00ff00ff) ? c - 8 : c;
c = (v & 0x0f0f0f0f) ? c - 4 : c;
c = (v & 0x33333333) ? c - 2 : c;
c = (v & 0x55555555) ? c - 1 : c;
return c;
#endif
}
static inline void *vkd3d_memmem( const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)
{
const char *str = haystack;