Results 1 to 3 of 3

Thread: Patch: allow compilation of ClanSound without SSE2 code

  1. #1
    Join Date
    Mar 2008

    Default Patch: allow compilation of ClanSound without SSE2 code

    Hi All,

    I'm the packager of ClanLib for the Fedora Linux distribution. I recently received a bug report that a ClanLib using application would not compile on ppc. I've tracked this down to ClanSound not being compiled there as it only compiles on machines with SSE2 (iow only on Intel platforms).

    I've created a patch which allows the usage of ClanSound on non SSE2 platforms, and also fixes a bug in the remainder copy function for unpacking 8 bit mono samples:

    Some further Notes:

    1) It would be good to do the same for ClanGDI, I took a look and there are 3 clanGDI files using SSE2 "asm". one of them also hs plain C equivalents already implemented in the file, the other uses a remainder function, so can be fixed like clanSound was fixed, but the 3th needs someone who knows the code better to reimplement that one last bit in C code (under a #ifdef).

    2) The "asm" for the (unused) mix_many_to_one function seems wrong, it multiplies the accumulated output with the channel volume, and then adds the channel sample, rather then adding the channel sample multiplied by the channel volume to the accumulated channel output.

    3) While working on upgrading the Fedora packages to ClanLib-2.1.1 I also encountered a problem with the new dlopen of libGL code. It op[ens but:

    3a) There is no guarantee there is a, as that is a symlink meant to determine which libGL to link to when compiling apps. So this is packaged in libGL-devel, which is not installed on normal end user installations

    3b) Even when it is installed, dlopen-ing could result in not doing what you want for example in Fedora the libGL which comes with the binary nvidia drivers gets installed under /usr/lib/nvidia, and depending on which X driver is in use, /usr/lib/nvidia gets pre-pended to the library search path or not. But /usr/lib/nvidia does not contain a symlink, so even if it is pre-pended to the path the wrong libGL will get used, resulting in glxChooseVisualInfo always failing.

    The fix for both these issues is to dlopen, which is the official soname for libGL. I've a patch doing that here:

  2. #2
    ClanLib Developer
    Join Date
    May 2007


    Many thanks for the sound_sse.cpp patch.

    I will apply it directly to the ClanLib 2.1 SVN (next week).

    I will also apply a slightly modified version of the patch to ClanLib 2.2 (SVN) (that's released later this year, we are not sure when). ClanLib 2.2 contains SSE2 code also in clanCore, that is configurable via "--enable-sse2" in the configure script.

    Thanks for finding the "unpacking 8 bit mono samples" bug

    -		int value = input[0];
    +		int value = input[i];
    That would have been difficult to track down (with SSE2 enabled)

    The "(unused) mix_many_to_one" function. Since it is unused, i'll disable the function until our SSE2 expert fixes it.

    I did suspect there was a problem with the new dlopen of libGL code, after some people were still reporting problems using compiled programs on other machines.

    Again I will apply the patch to both ClanLib 2.1 SVN and ClanLib 2.2 SVN.

    I agree, ideally, clanGDI should be made to work without SSE2 code. Although it would be slower, it still would be of use for simple applications.
    I will add it the the ClanLib "todo.txt" list


  3. #3
    ClanLib Developer
    Join Date
    May 2007


    Patches applied.

    Also ClanLib's SSE2 expert has fixed the clanSound problems.

    (The patches will be in the ClanLib 2.1.2 release sometime this year)

    clanGDI (now known as clanSWRender in ClanLib 2.2) probably will never support non-sse2 CPU's. It will be difficult to maintain both formats due to the clanSWRender's architecture. Also Non-SSE2 CPU's (as far as I know) are not multicore. So all existing optimisations will detrimental.

    We did have a clanSDL target (now at svn:// ) but that was abandoned because SDL at the time was not powerful enough for various reasons.

    It should be easy to create a new display target, but since clanGL1 exists, it is not worth the effort.

Similar Threads

  1. Linux 32 bit compilation issue
    By trigger-happy in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 06-30-2010, 01:07 PM
  2. ANSI code page patch for batch installer
    By andlov in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 12-21-2009, 12:38 PM
  3. Replies: 5
    Last Post: 07-06-2009, 01:35 PM
  4. CL 0.8 Canvas patch, get-rid-of-warnings patch
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 09-30-2007, 11:08 PM
  5. Suggested API patch to remove commented out code
    By rombust in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-20-2007, 06:23 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts