Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC/Linux support #1

Closed
neobenedict opened this issue Aug 29, 2022 · 0 comments · Fixed by #3
Closed

GCC/Linux support #1

neobenedict opened this issue Aug 29, 2022 · 0 comments · Fixed by #3

Comments

@neobenedict
Copy link

neobenedict commented Aug 29, 2022

https://github.com/SergeyMakeev/Goofy/blob/master/GoofyTC/goofy_tc.h#L1453

blRangeY.m128i_u8[0] is not available outside MSVC.

Possible replacement (and I am no expert in using processor intrinsics):

alignas(16) unsigned char m128i_u8[16];
_mm_storeu_si128((__m128i*)m128i_u8, blRangeY);

const uint32_t block0a = etc1BrighnessRangeTocontrolByte[m128i_u8[0]] | ((baseColors.r0 << 3ull) & 0xFFFFFF);

Seems to work OK for me.

Some other things needed

#if defined(__GNUC__) || defined(__clang__)
#  define ALIGN(x) __attribute__ ((aligned(x)))
# define goofy_inline __attribute__((always_inline)) inline
#  define goofy_restrict __restrict
#elif defined(_MSC_VER)
#  define ALIGN(x) __declspec(align(x))
#  define goofy_restrict __restrict
#  define goofy_inline __forceinline
#else
#  error "Unknown compiler; can't define ALIGN"
#endif

    // constants
    ALIGN(16) static const uint32_t gConstEight[4] = { 0x08080808, 0x08080808, 0x08080808, 0x08080808 };
    ALIGN(16) static const uint32_t gConstSixteen[4] = { 0x10101010, 0x10101010, 0x10101010, 0x10101010 };
    ALIGN(16) static const uint32_t gConstMaxInt[4] = { 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f7f7f7f };

Possibly also x86intrin.h instead of immintrin.h

Also, the program completely fails if compressETC1 is not wrapped in #pragma optimize( "", off ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant