Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Performance problem with Haskell/OpenGL/GLFW
      (Jesper S?rnesj?)
   2. Re:  Performance problem with Haskell/OpenGL/GLFW
      (Jesper S?rnesj?)


----------------------------------------------------------------------

Message: 1
Date: Sun, 10 Mar 2013 16:46:58 +1100
From: Jesper S?rnesj? <sarne...@gmail.com>
Subject: Re: [Haskell-beginners] Performance problem with
        Haskell/OpenGL/GLFW
To: beginners@haskell.org
Message-ID:
        <calex+wgnlfgepmh4zrzqobuqh4qdvu6+4mo49o5ggybu8ur...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Mar 8, 2013 at 11:25 PM, Jesper S?rnesj? <sarne...@gmail.com> wrote:
> The program's CPU usage is quite high in general, and increases with
> the number of pixels redrawn per frame. It uses OpenGL 3.2, does most
> of its work on the GPU, and should do a constant amount of work per
> frame on the CPU, so this makes little sense.
>
> I've created a smaller program (still 91 lines, though), which renders
> a single triangle, but still reproduces this problem. If I make the
> triangle smaller (by editing vertexData), CPU usage goes down, and if
> I make it bigger, CPU usage goes up. [1]
>
> I've also created a C program which does the same thing (as far as
> possible), but which does not exhibit this problem. CPU usage is far
> lower, and stays constant regardless of the number of pixels redrawns
> per frame. [2]

I've figured out what the problem is: the Haskell program is using a
software implementation of OpenGL, so rendering *does* in fact happen
on the CPU.

This seems to happen because I request a renderer conforming to the
OpenGL 3.2 Core profile, while running on Mac OS X 10.8.2 [3]. If I
remove those lines from displayOptions, the program receives a
hardware-accelerated renderer. Of course, then I can't use features
from OpenGL 3.2, so that's hardly a solution.

It would appear that there is in fact some relevant difference between
the Haskell [1] and C [2] versions of my program, or possibly some way
in which the bindings from the GLFW-b package are different from the C
library.

I've updated my programs to check for hardware acceleration and also
print the GLFW and OpenGL versions. [4]

-- 
Jesper S?rnesj?
http://jesper.sarnesjo.org/

[1] https://gist.github.com/sarnesjo/5116084#file-test-hs
[2] https://gist.github.com/sarnesjo/5116084#file-test-c
[3] 
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_pixelformats/opengl_pixelformats.html
[4] https://gist.github.com/sarnesjo/5116084/revisions



------------------------------

Message: 2
Date: Sun, 10 Mar 2013 20:38:07 +1100
From: Jesper S?rnesj? <sarne...@gmail.com>
Subject: Re: [Haskell-beginners] Performance problem with
        Haskell/OpenGL/GLFW
To: beginners@haskell.org
Message-ID:
        <calex+wi0p2ag2fdiangrcafhbm43gz3n5zwzfcmfvgpfi80...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Mar 10, 2013 at 4:46 PM, Jesper S?rnesj? <sarne...@gmail.com> wrote:
> I've figured out what the problem is: the Haskell program is using a
> software implementation of OpenGL, so rendering *does* in fact happen
> on the CPU.
>
> It would appear that there is in fact some relevant difference between
> the Haskell and C versions of my program, or possibly some way
> in which the bindings from the GLFW-b package are different from the C
> library.

To remove any possibility of the problem being in GLFW-b or OpenGLRaw,
I created two new programs, one in Haskell [1] and one in C [2], that
don't import or include anything related to OpenGL, and that simply
create a context, check if it is hardware accelerated, and then exit.
That is all. And still, the Haskell program receives a software
renderer, while the C program receives a hardware one:

    $ ghc -O2 Test2.hs -lglfw -framework OpenGL -fforce-recomp && ./Test2
    [1 of 1] Compiling Main             ( Test2.hs, Test2.o )
    Linking Test2 ...
    software
    (2,7,7)
    (3,2,0)
    $ gcc -O2 test2.c -lglfw -framework OpenGL && ./a.out
    hardware
    2.7.7
    3.2.0

I haven't had the chance to run these programs on any OS other than
Mac OS X 10.8.2, so I don't know if this problem is Mac-specific.
Still, it's really weird that the system would differentiate between
Haskell and C programs in this way.

If anyone has any ideas about what's going on here, I'd very much like
to hear them.

-- 
Jesper S?rnesj?
http://jesper.sarnesjo.org/

[1] https://gist.github.com/sarnesjo/5116084#file-test2-hs
[2] https://gist.github.com/sarnesjo/5116084#file-test2-c



------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 57, Issue 9
****************************************

Reply via email to